-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 4.7 with new moduleResolution mode node16/nodenext does not resolve types #22397
Comments
Validated that hacking the package.json to be explicit about file appears to solve this issue in my local project. Ie. In From
To
|
I get the same problem, but the above fix doesn't work. Also this isn't a problem with cypress v9, just with cypress v10, at least for me. I've been using nodenext since typescript 4.5 as experimental and it has always worked fine with cypress up until now. |
I may have jumped the gun on my fix that worked - possibly a version mismatch which would validate @smmccabe saying this has been a regression. |
Interesting, I will dig into this one tomorrow. One thing we changed from 9.x to 10.x was adding the https://github.com/cypress-io/cypress/blob/develop/cli/package.json#L119-L143 Thanks for the info @smmccabe, I'll verify on my end if it's a regression just to be sure - if so, that narrows the surface area down quite a bit, which is good. |
You are correct, the exports need to also specify types, see microsoft/TypeScript#33079 and https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#package-json-exports-imports-and-self-referencing example: ".": {
"import": "./index.mjs",
"require": "./index.js",
"types": "./types/index.d.ts"
}, I hacked that in and it worked |
Nice job debugging this. Would you like to make a PR contributing a fix @smmccabe? |
already made one just before you posted that :P |
I think the blast radius of this issue might be larger than described here. I'm seeing the type issues mentioned above in TypeScript 4.5.2 in a Yarn PnP project. After "unplugging" and applying the fix from #22498, the issue goes away. |
Current behavior
Types are not correctly resolved when using typescript 4.7 with moduleResolution set to "node16".
https://www.typescriptlang.org/docs/handbook/module-resolution.html
error TS2688: Cannot find type definition file for 'cypress'.
Desired behavior
Types should be resolved.
Test code to reproduce
Cypress Version
10.1.0
Other
I believe this being due to new module resolution logic requiring explicit extension. Currently the
package.json
types
field just saystypes
(referring to the folder where historically it would've been inferred to useindex.d.ts
) but now needs to be explicit and configured astypes/index.d.ts
The text was updated successfully, but these errors were encountered: