You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript will ignore files with duplicate filenames in the same folder (for example, src/file.ts and src/file.js). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is .ts, .tsx, .d.ts, .js, .jsx). For more info see #955.
This makes Typescript ignore your .d.ts file and type the import as any.
You also get this error when using typescript-eslint and you open a Lingui-generated .d.ts file:
Parsing error: ESLint was configured to run on <tsconfigRootDir>/locales/fr/core.d.ts using parserOptions.project: $project/packages/core/tsconfig.json
However, that TSConfig does not include this file. Either:
Change ESLint's list of included files to not include this file
To Reproduce
In a typescript project, configure Lingui with compileNamespace: "ts", compile a catalog, then import it from a Typescript file.
The import wont be typed (any type).
Expected behavior
The catalog is correctly typed
Additional context
jsLingui version lingui --version: 4.0.0
Suggested fix
The correct behaviour here would be either:
generate an app.js and an app.d.ts. Then Typescript will correctly use the d.ts file to type imports from the messages catalog
generate only an app.ts file, which includes the types information. Those will be stripped off when transpiled, so it wont change the resulting file. It can look like this:
I personally think there is no big value of compileNamespace: "ts" because in most of the cases you would use dynamic import such as import('/locales/' + locale + '.po') which will not be typed any way. And even if typed it directly passed to the i18n functions, so you will not benefit from typings here.
With that being said, I'm not fascinated by these changes myself, so contributions are very welcome.
Describe the bug
Currently, when you configure
compileNamespace: "ts"
then Lingui will create both aapp.ts
andapp.d.ts
files.But Typescript does ignore files with the same base name and different extension, as described here: https://typescript-eslint.io/architecture/parser/#project
This makes Typescript ignore your
.d.ts
file and type the import asany
.You also get this error when using
typescript-eslint
and you open a Lingui-generated.d.ts
file:To Reproduce
In a typescript project, configure Lingui with
compileNamespace: "ts"
, compile a catalog, then import it from a Typescript file.The import wont be typed (
any
type).Expected behavior
The catalog is correctly typed
Additional context
lingui --version
: 4.0.0Suggested fix
The correct behaviour here would be either:
app.js
and anapp.d.ts
. Then Typescript will correctly use thed.ts
file to type imports from the messages catalogapp.ts
file, which includes the types information. Those will be stripped off when transpiled, so it wont change the resulting file. It can look like this:I personally think the second solution is much cleaner and idiomatic. You are asking for Typescript code to get generated after all :)
The text was updated successfully, but these errors were encountered: