Update for typescript 5.4+ - #950
snowystinger wants to merge 1 commit into
Conversation
* Fix lib/main.d.ts for TypeScript >= 5.4 with isolatedModules
src/main.ts imported Type, NodePath and builders and then declared
consts of the same names from the fork, so the emitted lib/main.d.ts
contained `import { Type } ...` followed by `declare const Type`.
TypeScript 5.4 rejects that combination under isolatedModules:
error TS2865: Import 'Type' conflicts with local value, so must be
declared with a type-only import when 'isolatedModules' is enabled.
Import the type meanings under different names and re-declare them next
to the consts, so the single `export { ... }` carries both meanings.
This uses only plain aliased imports, so no currently supported
TypeScript version loses support (checked against 3.9, 4.4, 4.9, 5.4 and
5.9). As a side effect, Type and NodePath imported from the package are
now usable as generic types, which they were not before.
Add script/consumer-typecheck, a minimal consumer of lib/main compiled by
run-tests.sh with both the pinned TypeScript and TypeScript 5.9 (installed
under the alias typescript5) with isolatedModules, so declaration-file
regressions like this one fail in CI. Without this fix that check reports
the three TS2865 errors above plus "Type 'NodePath' is not generic".
Fixes #948. Builds on #950.
* Type-check the consumer sample with TypeScript 4.4 as the supported floor
Add typescript@4.4.4 (the last release before inline `type` import
modifiers) alongside the pinned compiler and TypeScript 5.9, so
"supports TypeScript >= 4.4" is checked on every run rather than assumed.
The extra compilers move into script/consumer-typecheck's own
package.json, installed by run-tests.sh with `npm ci --prefix`. Keeping
them out of the root package matters: npm aliases of typescript all ship
a `tsc` bin, and the last one installed wins node_modules/.bin/tsc, which
`npm run build` uses. In the root that silently replaced the pinned
4.9.4 compiler with 4.4.4.
|
Thanks for tracking this down. Your diagnosis in #948 was exactly right, and it's now fixed on Two things kept me from merging this one as-is. #959 takes the aliasing route instead ( |
Closes #948