-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compileNamespace: "ts"
does not correctly type imports
#1651
Comments
I personally think there is no big value of With that being said, I'm not fascinated by these changes myself, so contributions are very welcome. |
If you are fine with me switching the |
@renchap i think it's fine. |
Any progress with this? I ran into this today when scanning my code with type-coverage. I agree with the second solution suggested. |
Fixed by #1851 |
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: