TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.86k stars 536 forks source link

Fix @tsconfig/bases implicit config logic so old TS versions won't get an incompatible config #2065

Closed cspotcode closed 1 year ago

cspotcode commented 1 year ago

breaking changes to newer @tsconfig/bases

The latest @tsconfig/bases use module node16, for example: https://github.com/tsconfig/bases/blob/main/bases/node14.json

node16/nodenext was added in TS 4.7

We still support as low as TS 4.4, because we match DefinitelyTyped's support window

Our implicit config logic already rejects tsconfigs that your TS version does not support, but it only falls back so far, returning the node14 config by default.

We need to go a step further, falling back to no implicit config if none of the @tsconfig/bases are compatible. Note that the user controls which version of @tsconfig/bases they install, so if their project has an older revision of a @tsconfig/bases installed, and it is compatible with their TS version, then they'll get it by default.

We also need to add logic to fallback when module and moduleResolution options are incompatible

Broken tests

When we fallback to no implicit tsconfig, other test cases break. They were relying on an implicit @tsconfig/node14 setting a relatively high target and module: node or similar.

To avoid this and still have reasonable test coverage: