Repository navigation
NXT-20954: Added custom typecheck for Typescript 7 - #405
Open
daniel-stoian-lgp wants to merge 6 commits into
Open
daniel-stoian-lgp wants to merge 6 commits into
daniel-stoian-lgp wants to merge 6 commits into
Conversation
# Conflicts: # CHANGELOG.md # config/webpack.config.js
ion-andrusciac-lgp
approved these changes
Oct 19, 2026
| const pluginName = 'EnactTypeScriptCheckPlugin'; | ||
|
|
||
| // Diagnostics are not reported for test and setup files, matching the fork-ts-checker issue filters. | ||
| const excludeFile = /(^|[\\/])__tests__[\\/]|\.(spec|test)\.[^\\/]+$|[\\/]src[\\/]setup(Proxy|Tests)\.[^\\/]+$/; |
There was a problem hiding this comment.
src/setupTests.ts and src/setupProxy.* are not excluded when tsc prints a relative path.
|
|
||
| cancel () { | ||
| if (this.child) { | ||
| this.child.kill(); |
There was a problem hiding this comment.
A tsc process stopped on Windows is not treated as cancelled. (optional)
| }), | ||
| // TypeScript 7+ type checking via the tsc binary | ||
| tscPath && | ||
| new TypeScriptCheckPlugin({ |
There was a problem hiding this comment.
TypeScriptCheckPlugin is registered before ESLintPlugin and pushes its diagnostic during afterCompile. In enact serve, createCompiler keeps only errors[0], so an ESLint error from the same compilation is dropped from the terminal and the overlay when a type error is also present. enact pack still prints every error. Worth confirming this is acceptable, since on TypeScript 5/6 fork-ts-checker reports asynchronously and does not take that first slot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checklist
Issue Resolved / Feature Added
Follow-up to the TypeScript 6/7 support change (#404 ). That change lets TypeScript 7 apps build, but skips type checking for them entirely.
fork-ts-checker-webpack-pluginneeds the JS compiler API (createProgram), and TypeScript 7 doesn't ship it. As a result, type errors in TS 7 apps don't show up inenact pack/enact serve.This PR adds type checking for TypeScript 7 apps by running the
tscbinary that TS 7 ships.Resolution
New
config/TypeScriptCheckPlugin.js: a webpack plugin that runstsc --project tsconfig.json --noEmit --skipLibCheck --incremental --pretty falsewith Node. Build info goes tonode_modules/.cache/tsconfig.tsbuildinfo, the same file fork-ts-checker used.tscstarts each time webpack starts compiling (run/watchRun) and runs while webpack bundles.afterCompile), the plugin waits fortscand adds each diagnostic to the compilation as an error. Existing error output, exit code 1 on failure and the dev-server overlay all work without other changes.TSC_COMPILE_ON_ERROR=true, diagnostics are added as warnings instead, as with the existing checker plugin.__tests__,*.spec.*/*.test.*,src/setupProxy.*,src/setupTests.*) are skipped, matching fork-ts-checker's filters.tsccan't run, the build gets a warning instead of failing.tscrun still in progress is stopped when a watch or serve session ends.config/webpack.config.js:resolveLegacyTypeScript()becomesresolveTypeScript(). It returns{typescriptPath}when the app'stypescriptpackage hascreateProgram(TS 5/6, still handled by fork-ts-checker). Otherwise it returns{tscPath}from the package'sbinfield (TS 7, handled by the new plugin). The skip warning now only appears whentypescriptcan't be resolved at all.Additional Considerations
Test scenario
Setup:
cliand link it globally (npm linkinsidecli), soenactruns this branch.cd samples/tutorial-typescript && npm install(installstypescript@^7.0.2).src/views/MainPanel.tsx:const typeErrorProbe: number = 'not a number';
export {typeErrorProbe};
TypeScript 7 (new
TypeScriptCheckPlugin)enact pack.Failed to compile.withsrc/views/MainPanel.tsx(20,7)andTS2322: Type 'string' is not assignable to type 'number'.; exit code 1.enact pack -p.TSC_COMPILE_ON_ERROR=true enact pack(PowerShell:$env:TSC_COMPILE_ON_ERROR='true'; enact pack).TS2322is shown as a warning; exit code 0.enact serveand open the app in the browser.TS2322in the terminal and in the browser error overlay.const typeErrorProbe: number = 42;and save.Compiled successfully!and the overlay disappears.enact pack -p.TypeScript 6 regression (still uses
fork-ts-checker-webpack-plugin)npm install --no-save typescript@6, then runenact pack.> 20 | const typeErrorProbe ...); exit code 1.enact pack.Links
NXT-20954
Comments
Enact-DCO-1.0-Signed-off-by: Daniel Stoian (daniel.stoian@lgepartner.com)