Closed jeetiss closed 1 year ago
Thanks!
If I understand this correctly, older Typescript uses typedVersions
instead of exports
?
Where can I find the spec for typesVersions
? The docs here are terrible.
{ [semver-range]: { [what-can-this-be]: [array of paths to types] } }
Typescript uses typedVersions instead of exports?
Kind of, moduleResolution
changes typescript behavior, when moduleResolution: 'node'
it uses types
and typesVersions
fields, when moduleResolution: 'node16'
or moduleResolution: 'bundler'
it can use types from exports
.
Where can I find the spec for typesVersions?
I don't see any other source of truth, so I use https://arethetypeswrong.github.io/ for tests
Is the Masquerading
issue easily fixable? I'm not sure I understand that error message
Imports of all entrypoints under the node16 module resolution setting when the importing module is ESM (its extension is .mts or .mjs, or it has a .ts or .js extension and is in scope of a package.json that contains "type": "module") resolved to CJS types, but ESM implementations.
Because there is no "type": "module" setting here, the .js and .d.ts file will always be interpreted as a CommonJS module. But if the importing file is an ES module, the runtime will resolve to the .mjs file, which is unambiguously ESM. In this case, the module kind of the types misrepresents the runtime-resolved module. This tends to present the most issues for users when default exports are used. In the future, this tool may detect whether an export default might make this problem more severe and give a full explanation of why. In the meantime, you can read the explanation in https://github.com/microsoft/TypeScript/issues/50058#issuecomment-1404411380. The simple fix for the example above would be to add an index.d.mts file dedicated to typing the .mjs module, and remove the "types" condition.
wow, it wants separate files even though they're identical.
I tried a few variants but I couldn't satisfy it without breaking other things. I leave it as-is. Thanks
The types are broken in last version: https://arethetypeswrong.github.io/?p=%40adraffy%2Fens-normalize%401.9.1
this PR adds types back:
Test for types