Skip to content

NXT-20807: Updated cli to support typescript 6 and 7 - #404

Open
daniel-stoian-lgp wants to merge 1 commit into
developfrom
feature/NXT-20807
Open

daniel-stoian-lgp wants to merge 1 commit into
developfrom
feature/NXT-20807

Conversation

@daniel-stoian-lgp

Copy link
Copy Markdown
Contributor

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • I have run automated testing and it is passed
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

Apps that upgrade to typescript@7 fail to build with enact pack / enact serve:

Error: Cannot find module 'typescript' from 'node_modules'
    at module.exports (cli/config/webpack.config.js:633)

There are two causes:

  1. TS 7's package has no main field, only exports. The resolve package used to find the app's typescript doesn't read exports, so lookup fails.
  2. Even if lookup worked, TS 7 doesn't ship the JS compiler API (require('typescript').createProgram is undefined). fork-ts-checker-webpack-plugin needs that API.

Resolution

  • webpack.config.js: new resolveLegacyTypeScript() finds the app's typescript with Node's own resolver, so exports works. It turns on ForkTsCheckerWebpackPlugin only if the package has createProgram. Otherwise it warns and skips type checking, so the build still succeeds. Removes the now-unused resolve import.
  • pack.js: flattens the nested import('chalk') / import('strip-ansi') chain so a failed build exits with code 1, even if the failure happens before chalk loads.
  • package.json / npm-shrinkwrap.json: optional typescript peer range goes from ^5.4.0 to ^5.4.0 || ^6.0.0 || ^7.0.2. TS 6 still has the compiler API and works with the checker.

Effect on apps:
5.x / 6.x - Unchanged: fork-ts-checker-webpack-plugin runs
7.x - Skipped, with a warning
none / no tsconfig.json - Unchanged: no checking

Additional Considerations

Side effects / open questions:

  • TS 7 apps get no type checking during the build. They need a separate tsc --noEmit step. A follow-up could run the native tsc inside the build.

Links

NXT-20807

Comments

Enact-DCO-1.0-Signed-off-by: Daniel Stoian (daniel.stoian@lgepartner.com)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant