Update TypeScript to tsgo (7.0)#77177
Conversation
|
Did you see #76148? |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @caseymilne, @felixmanus. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in ed80c38. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24889782832
|
|
I had a branch locally for this, but I wanted to clean up other things first. I am glad I am not the only one thinking about this. |
I didn't, thanks for linking 🙂 One thing that stands out is that the errors reported now are very different from what you described a month ago in the issue. |
Yes, because the |
|
Reported one issue where I was able to isolate a minimal example: microsoft/typescript-go#3370 |
e210564 to
566976b
Compare
|
Size Change: 0 B Total Size: 7.76 MB ℹ️ View Unchanged
|
|
I updated the PR to the latest version from the The PR is now green. The only thing that doesn't work for me is the VSCode/Cursor integration. |
Works fine for me. You need to have this in "typescript.experimental.useTsgo": trueand then install the required extension - TypeScript (Native Preview) You will need to restart VS Code after that. |
Yes, this is what I was missing. I just enabled the setting and nothing else. Now it works perfectly 🙂 Do we want to use the |
sirreal
left a comment
There was a problem hiding this comment.
The code changes look good.
Regarding documentation and messaging, this has made tsgo very apparent. The other direction seems appealing to me, to treat the TS compiler used as an implementation detail and de-emphasize which binary actually handles the compilation.
Regarding whether we're comfortable with a beta release, in this case I'd say yes. The compiler is used for type checking and seems to do a good job at that. It's not used to compile outputs that are evaluated by JavaScript runtimes.
The speed advantage seems well worth it to me.
| * can cause unchecked errors in JS files to be included in the compiled types.) | ||
| * | ||
| * We do so by running `tsc --noEmit` on the $package/build-types/index.d.ts file. | ||
| * We do so by running `tsgo --noEmit` on the $package/build-types/index.d.ts file. |
There was a problem hiding this comment.
In informative messages and comments, perhaps we can reference "the TypeScript compiler" instead of a specific binary name.
There was a problem hiding this comment.
Yes, I agree with that. Let us abstract out the implementation detail.
|
Do we have some numbers on the actual gains? Asking out of curiousity and excitement :D |
|
The latest static CI type checking was 3m55s. On this branch it was 2m34s. That's a substantial improvement. The type check step seems to do much more than type checking, but if we look at these timestamps: That's something like 2m56s (before) vs 1m41s (after), an improvement in the ballpark of 40%. This is anecdotal of course, but it seems reasonable to believe that |
| * can cause unchecked errors in JS files to be included in the compiled types.) | ||
| * | ||
| * We do so by running `tsc --noEmit` on the $package/build-types/index.d.ts file. | ||
| * We do so by running `tsgo --noEmit` on the $package/build-types/index.d.ts file. |
There was a problem hiding this comment.
| * We do so by running `tsgo --noEmit` on the $package/build-types/index.d.ts file. | |
| * We do so by running TypeScript compiler on the $package/build-types/index.d.ts file. |
| } catch { | ||
| console.error( | ||
| `Cannot access this declaration file. You may need to run tsc again: ${ decFile }` | ||
| `Cannot access this declaration file. You may need to run tsgo again: ${ decFile }` |
There was a problem hiding this comment.
| `Cannot access this declaration file. You may need to run tsgo again: ${ decFile }` | |
| `Cannot access this declaration file. You may need to run the build again: ${ decFile }` |
| await exec( 'tsgo', [ '--build' ] ).catch( () => { | ||
| console.error( | ||
| '\n❌ TypeScript compilation failed. Try cleaning up first: `npm run clean:package-types`' | ||
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' |
There was a problem hiding this comment.
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' | |
| '\n❌ TypeScript compilation failed. Try cleaning up first: `npm run clean:package-types`' |
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' | ||
| ); | ||
| throw new Error( 'TypeScript compilation failed' ); | ||
| throw new Error( 'TypeScript compilation via tsgo failed' ); |
There was a problem hiding this comment.
| throw new Error( 'TypeScript compilation via tsgo failed' ); | |
| throw new Error( 'TypeScript compilation failed' ); |
| await exec( 'tsgo', [ '--build' ] ).catch( () => { | ||
| console.error( | ||
| '\n❌ TypeScript compilation failed. Try cleaning up first: `npm run clean:package-types`' | ||
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' |
There was a problem hiding this comment.
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' | |
| '\n❌ TypeScript compilation failed. Try cleaning up first: `npm run clean:package-types`' |
| '\n❌ TypeScript compilation via tsgo failed. Try cleaning up first: `npm run clean:package-types`' | ||
| ); | ||
| throw new Error( 'TypeScript compilation failed' ); | ||
| throw new Error( 'TypeScript compilation via tsgo failed' ); |
There was a problem hiding this comment.
| throw new Error( 'TypeScript compilation via tsgo failed' ); | |
| throw new Error( 'TypeScript compilation failed' ); |
|
|
||
| // Start TypeScript watch | ||
| const tscWatch = execAsync( 'tsc', [ | ||
| const tsgoWatch = execAsync( 'tsgo', [ |
There was a problem hiding this comment.
Let us rename it to tsWatch, which is runtime agnostic.
| const tsgoWatch = execAsync( 'tsgo', [ | |
| const tsWatch = execAsync( 'tsgo', [ |
| const cleanup = () => { | ||
| console.log( '\n\n👋 Stopping watch mode...' ); | ||
| tscWatch.kill(); | ||
| tsgoWatch.kill(); |
There was a problem hiding this comment.
| tsgoWatch.kill(); | |
| tsWatch.kill(); |
| "scripts": { | ||
| "build": "node ./bin/build.mjs", | ||
| "build:profile-types": "rimraf ./ts-traces && npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsc --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'tsc failed.'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx --yes @typescript/analyze-trace ts-traces > ts-traces/analysis.txt && node -p \"'\\n\\nDone! Build traces saved to ts-traces/ directory.\\nTrace analysis saved to ts-traces/analysis.txt.'\"", | ||
| "build:profile-types": "rimraf ./ts-traces && npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsgo --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'tsgo failed.'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx --yes @typescript/analyze-trace ts-traces > ts-traces/analysis.txt && node -p \"'\\n\\nDone! Build traces saved to ts-traces/ directory.\\nTrace analysis saved to ts-traces/analysis.txt.'\"", |
There was a problem hiding this comment.
| "build:profile-types": "rimraf ./ts-traces && npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsgo --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'tsgo failed.'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx --yes @typescript/analyze-trace ts-traces > ts-traces/analysis.txt && node -p \"'\\n\\nDone! Build traces saved to ts-traces/ directory.\\nTrace analysis saved to ts-traces/analysis.txt.'\"", | |
| "build:profile-types": "rimraf ./ts-traces && npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsgo --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'TypeScript build failed.'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx --yes @typescript/analyze-trace ts-traces > ts-traces/analysis.txt && node -p \"'\\n\\nDone! Build traces saved to ts-traces/ directory.\\nTrace analysis saved to ts-traces/analysis.txt.'\"", |
|
Haven't had a chance to review this yet, but wow, the type check speed reduction is a huge improvement! |
4c305c0 to
ed80c38
Compare
|
I added timing support to the
I ran it all just once, so I don't know how much variance there is.
I agree, this was autogenerated by Cursor and at the time I didn't pay much attention, it was an experiment. I removed all the changes that don't actually run the compiler. Now only these places change |
* Build: print timimg of TS build * Experiment: update TypeScript to tsgo (7.0) * Fix type errors * Add components changelog entry
Trying to update the Gutenberg repo to tsgo (
@typescript/native-previewpackage). After fixing errors, it works perfectly.