-
Notifications
You must be signed in to change notification settings - Fork 386
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
Typescript not finding types when using NodeNext #1363
Comments
What package it's related to? |
I have the same issue with the The provided patch fixes the issue for me. |
What version of typescript was used? I'm trying to reproduce, but everything works seems fine. You can check my repo and fork if needed |
Looks like |
@thekip Thank you for taking a look! I can reproduce on your example with an additional "strict": true With this configuration I'm getting an error: yarn test
yarn run v1.22.19
warning package.json: No license field
$ tsc
index.ts:1:22 - error TS7016: Could not find a declaration file for module '@lingui/core'. '~/lingui-nodenext-issue/node_modules/@lingui/core/build/cjs/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/lingui__core` if it exists or add a new declaration (.d.ts) file containing `declare module '@lingui/core';`
1 import { i18n } from '@lingui/core'
~~~~~~~~~~~~~~
Found 1 error in index.ts:1 |
i'm curious should I also generate typings in cjs format (with |
@thekip I needed to patch @lingui/core and @lingui/react for my project |
Yes, I did it for the both packages |
According to the linked discussion it seems separate type declaration files are needed. Although, it seems that the problem is mostly visible when the package has the default exports. I'm not sure at the moment whether the problem is visible with named exports only (like If I understand correctly, since To make TS happy there need to be 2 files I'm not sure how the current |
Thanks for the explanation. It seems current solution (with one declaration file) is working. I also have tried to produce declaration with different input settings (module: CommonJs and ESM) and it gave me exactly same typings. So currently I use one typings for both targets and it seems fine. |
Thank you taking care of this! I fear that to make TS perfectly happy there need to be two files even if their content is the same. The issue seems to happen because TS interprets the declaration file type based on It seems to work fine in this case when no default exports are present. However, there may be an underlying problem which is currently not visible. |
Describe the bug
Typescript fails to find index.d.ts when using NodeNext / esm modules module resolution.
Relevant thread: microsoft/TypeScript#50466
To Reproduce
Here is a patch that fixes it:
The text was updated successfully, but these errors were encountered: