fix(types): Fix module/moduleResolution options for TypeScript 5.2 #3251
+9
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋 Hey, I work on the TypeScript team, and in 5.2 we’re planning to break your tsconfig, so I’m opening a PR to preemptively fix it. Specifically, we’re going to enforce that
module
andmoduleResolution
have to be set to the same value when either isnode16
ornodenext
.You’re currently using
moduleResolution: node16
in combination with bothmodule: commonjs
andmodule: esnext
in order to achieve dual module format emit with tsc. tsc isn’t really designed to work with those combinations, as explained in the afore-linked PR. Those limitations are why you were susceptible to issues like #2759 and need the eslint rule that enforces file extensions on import paths. Really, TypeScript should be doing that validation for you. (By the way, it looks like #2759 was never released, as the current release still has type resolution errors.)This PR makes a slight modification to your build scripts to ensure that tsc sees an accurate value for package.json
"type"
when compiling, which (with the right tsconfig settings) affects its type checking, module resolution, and emit to all be in sync. You might also be interested in tracking microsoft/TypeScript#54593 which, if we ever resolve, aims to make this kind of thing easier.Feel free to use this PR, edit it, or close it and do something different. Just wanted to give you a heads up and hopefully get you started down the right track.