-
Notifications
You must be signed in to change notification settings - Fork 11
🤖 feat: Replace tsc with tsgo for 7.7x faster type checking #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
- Add @typescript/native-preview (tsgo) for TypeScript type checking - Update tsconfig.json to be compatible with TypeScript 7: - Remove deprecated baseUrl option - Fix paths to use relative paths (./src/* instead of src/*) - Update typecheck.sh to use tsgo with fallback to tsc - Update Makefile dev target to use tsgo in watch mode - Add platform-specific optional dependencies for all platforms Performance improvement: - Before (tsc): 5.942s - After (tsgo): 0.776s - **7.7x faster type checking** tsgo is Microsoft's Go-based TypeScript compiler that provides the same type checking accuracy as tsc but with significantly better performance. It will be the default compiler in TypeScript 7. _Generated with `cmux`_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
The @typescript/native-preview package already includes platform-specific packages as its own optionalDependencies, so we don't need to list them explicitly in our package.json.
Remove scripts/typecheck.sh and move the tsgo/tsc fallback logic directly into the Makefile typecheck target. The script was only called from one place, so there's no need for the indirection.
ammario
approved these changes
Oct 15, 2025
ammar-agent
added a commit
that referenced
this pull request
Oct 15, 2025
Replaces tsc with tsgo for main process build, reducing compilation time from 3.489s to 0.178s. Includes comprehensive investigation of tsgo integration opportunities across the entire build toolchain. Key findings: - Main process compilation: 19.6x faster with tsgo - Type checking: Already optimized (7.7x faster, PR #260) - Renderer (Vite): Cannot use tsgo due to architectural constraints - Path aliases: tsc-alias still required (tsgo doesn't resolve them) See INVESTIGATION.md for complete analysis and benchmarks.
ammar-agent
added a commit
that referenced
this pull request
Oct 15, 2025
Replaces tsc with tsgo for main process build, reducing compilation time from 3.489s to 0.178s. Includes comprehensive investigation of tsgo integration opportunities across the entire build toolchain. Key findings: - Main process compilation: 19.6x faster with tsgo - Type checking: Already optimized (7.7x faster, PR #260) - Renderer (Vite): Cannot use tsgo due to architectural constraints - Path aliases: tsc-alias still required (tsgo doesn't resolve them) See INVESTIGATION.md for complete analysis and benchmarks.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 15, 2025
## Summary Replaces `tsc` with `tsgo` for main process compilation, achieving a **19.6x speedup** (3.489s → 0.178s). Completes investigation of tsgo integration opportunities across the entire build toolchain. ## Performance Impact **Main process build:** - Before: 3.489s with tsc - After: 0.178s with tsgo - **Speedup: 19.6x** **Type checking (already optimized in PR #260):** - Before: 5.942s with tsc - After: 0.776s with tsgo - **Speedup: 7.7x** **Full build:** - Before: ~26s total - After: ~22.5s total (~13% faster) ## Regression Risk⚠️ **Medium risk** - Changing the compiler from tsc to tsgo for production builds: 1. **TypeScript 7 preview**: `@typescript/native-preview` is pre-release software (v7.0.0-dev) 2. **Different code generator**: While type checking is identical, the emitted JavaScript may have subtle differences 3. **Platform-specific binaries**: Relies on Go-based native binaries for darwin/linux/win32 across x64/arm64 4. **Path alias resolution**: Still requires `tsc-alias` post-processing (tsgo doesn't resolve `@/` imports) **Mitigation:** - CI tests run on both macOS and Linux - Integration tests verify IPC communication paths - E2E tests verify full application behavior - Build is deterministic (no conditional branches) **Rollback plan:** If issues arise, revert to `tsc` by changing one line in Makefile (line 77). ## Changes - **Updated `Makefile` build-main target**: Uses tsgo directly, no fallback branches - **Updated `Makefile` typecheck target**: Removed tsc fallback (already had branch from PR #260) - **Added build reproducibility guidelines**: Documents why branches are avoided in build targets - **Requires tsgo**: Builds fail fast if tsgo missing (in devDependencies, always available) ## Investigation Findings Analyzed every component of the build toolchain to maximize tsgo usage: | Component | Current Tool | Can Use tsgo? | Status | |-----------|--------------|---------------|--------| | Main process build | tsc | ✅ Yes | ✅ Implemented | | Renderer build | Vite+esbuild | ❌ No | N/A (Vite architecture) | | Preload build | bun | ❌ No | N/A (already fast) | | Type checking | tsgo | ✅ Yes | ✅ Done (PR #260) | | Dev watch (main) | tsgo -w | ✅ Yes | ✅ Done (PR #260) | **Key findings:** 1. **Path alias resolution**: tsgo doesn't resolve `@/` imports, so `tsc-alias` still required (~0.7s overhead, acceptable) 2. **Vite can't use tsgo**: Different compilation model (esbuild + HMR + bundling) 3. **Main build time dominated by Vite**: ~21s for renderer vs ~0.2s for main process **Conclusion:** We've maximized tsgo usage. The remaining build time (~21s Vite renderer compilation) cannot be optimized with tsgo due to architectural constraints. ## Build Reproducibility Removed all conditional branches (if/else fallbacks) from build targets. Builds now fail fast with clear errors if dependencies are missing, rather than silently using different compilers. Added to Makefile header: > **AVOID CONDITIONAL BRANCHES (if/else) IN BUILD TARGETS AT ALL COSTS.** > Branches reduce reproducibility - builds should fail fast with clear errors if dependencies are missing, not silently fall back to different behavior. ## Testing - ✅ Full build succeeds: `make build` - ✅ Type checking works: `make typecheck` - ✅ No unresolved `@/` imports in compiled output - ✅ Dev watch works: `make dev` - ⏳ CI checks (static, integration, e2e) pending _Generated with `cmux`_
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.
Summary
Replace TypeScript's tsc with tsgo (TypeScript's new Go-based compiler) for significantly faster type checking in the build system.
Performance Improvement
Changes
Dependencies
@typescript/native-previewdevDependency (includes platform-specific binaries automatically)Configuration
tsconfig.jsonto be compatible with TypeScript 7:baseUrloptionpathsto use relative paths (./src/*instead ofsrc/*)Build System
scripts/typecheck.shto use tsgo with automatic fallback to tscMakefiledev target to use tsgo in watch mode for faster development feedbackAbout tsgo
tsgo is Microsoft's Go-based TypeScript compiler that will become the default in TypeScript 7. It provides:
The implementation uses bun runtime which correctly detects arm64 architecture, and includes fallback to tsc for compatibility.
Testing
Type checking verified locally:
$ time ./scripts/typecheck.sh [0] bun run node_modules/@typescript/native-preview/bin/tsgo.js --noEmit exited with code 0 [1] bun run node_modules/@typescript/native-preview/bin/tsgo.js --noEmit -p tsconfig.main.json exited with code 0 real 0m0.776s user 0m2.406s sys 0m0.638sGenerated with
cmux