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
I found this, which is similar, but I don't think the same thing. #50762
🕗 Version & Regression Information
I see this on VSCode's typescript version, 5.3.2. It only really affects JavaScript, because with TypeScript you will usually have a tsconfig.json - and setting moduleResolution to node16 fixes.
This is the behavior in every version I tried, and I reviewed the FAQ for entries about package.json (they don't exist)
You can also see this problem by opening np in vscode:
git clone https://github.com/sindresorhus/np
cd np
npm install
code .
Then opening source/cli-implementation.js.
🙁 Actual behavior
Cannot find module 'meow' or its corresponding type declarations.(2307) showing as an intellisense error in IDEs.
🙂 Expected behavior
No intellisense error in IDEs. I'm guessing typescript comes up with a default jsconfig.json - and for codebases with a "type": "module" package.json (like np), it should assume moduleResolution=node16 or some similar value that looks for types in package.json -> exports.types, not just package.json -> types.
No intellisense error in IDEs. I'm guessing typescript comes up with a default jsconfig.json - and for codebases with a "type": "module" package.json (like np), it should assume moduleResolution=node16 or some similar value that looks for types in package.json -> exports.types, not just package.json -> types.
The next version of TypeScript includes #56785, which will be the new default in VS Code and probably fix your issue. Though, it doesn't seem like the change has been made to VS Code yet.
Yeah, what @jakebailey said—the defaults for VS Code are changing soon, it’s expected behavior for the defaults today, and you can change them by making a jsconfig.json if you need to.
🔎 Search Terms
"package.json exports types"
I found this, which is similar, but I don't think the same thing. #50762
🕗 Version & Regression Information
I see this on VSCode's typescript version, 5.3.2. It only really affects JavaScript, because with TypeScript you will usually have a tsconfig.json - and setting
moduleResolution
tonode16
fixes.⏯ Playground Link
https://www.typescriptlang.org/play?ssl=1&ssc=1&pln=2&pc=1#code/JYWwDg9gTgLgBCAphA7nAZlCI4HImq4BQRoksCyKAkgHYyJS0CGANhljvlQPQBGAV2CsAJj2C0RiAB4A6AFYBnYkA
💻 Code
Note that the playground link starts working as expected if you set the tsconfig.json to moduleResolution=node16
You can also see this problem by opening
np
in vscode:Then opening
source/cli-implementation.js
.🙁 Actual behavior
Cannot find module 'meow' or its corresponding type declarations.(2307)
showing as an intellisense error in IDEs.🙂 Expected behavior
No intellisense error in IDEs. I'm guessing typescript comes up with a default
jsconfig.json
- and for codebases with a"type": "module"
package.json (likenp
), it should assumemoduleResolution=node16
or some similar value that looks for types inpackage.json
->exports.types
, not justpackage.json
->types
.Additional information about the issue
If you look at meow's package.json, it is correctly configured: https://github.com/sindresorhus/meow/blob/fd0bc62ce47781e11da506b8e38e8668eb78a584/package.json
Adding a
types
field at the root level also fixes, but the maintainer didn't want to add a workaround to a typescript bug: sindresorhus/meow#253The text was updated successfully, but these errors were encountered: