experiment: @typescript/native-preview compiler for 5-6x faster local builds, 33% faster CI#4923
Closed
dreamorosi wants to merge 5 commits intomainfrom
Closed
experiment: @typescript/native-preview compiler for 5-6x faster local builds, 33% faster CI#4923dreamorosi wants to merge 5 commits intomainfrom
dreamorosi wants to merge 5 commits intomainfrom
Conversation
- Install @typescript/native-preview@7.0.0-dev.20260106.1 - Remove baseUrl from all tsconfig.json files (not supported by native compiler) - Update all build scripts to use npx @typescript/native-preview - Fix import in layers/bin/layers.ts to use relative path with .js extension - Native compiler provides 5-6x faster compilation (256ms vs 1,574ms clean builds) - Stricter type checking catches additional type errors - Maintains compatibility with existing build system and project references
The native TypeScript compiler has stricter type checking that catches additional type errors in the codebase. Reverting to regular tsc while keeping the baseUrl removal to test CI performance impact of configuration changes alone.
- Restore npx @typescript/native-preview usage in all build scripts - Fix decorator type errors with (originalMethod as any).apply() - Add proper return type annotation for BedrockFunctionResponse.build() - Import BedrockAgentFunctionResponse type - Native compiler now builds successfully with 5-6x performance improvement
svozza
reviewed
Jan 6, 2026
| let result: unknown; | ||
| try { | ||
| result = await originalMethod.apply(this, args); | ||
| result = await (originalMethod as any).apply(this, args); |
Contributor
There was a problem hiding this comment.
I'm presuming these are unavoidable with the extra strictness of the new compiler?
Contributor
Author
There was a problem hiding this comment.
I need to figure this out - I'm not keen on keeping the any, once we can drop support for legacy decorators (addressed in v3 discussion) the implementation here would change though.
dreamorosi
commented
Jan 6, 2026
|
Contributor
Author
|
Closing for now, see PR body for details |
Contributor
|
Great deep dive @dreamorosi. I fully agree with your conclusions. |
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.



Summary
TL;DR: Native TypeScript compiler delivers 5-6x faster local builds and 33% faster CI builds, but we won't adopt it due to its experimental status and requirement for less strongly-typed decorator implementations. We'll revisit in v3 or when it becomes stable.
Performance Results
Local Development:
CI Environment:
Technical Changes
@typescript/native-preview@7.0.0-dev.20260106.1baseUrlfrom alltsconfig.jsonfiles (not supported by native compiler)npx @typescript/native-previewlayers/bin/layers.tsto use relative path with.jsextension(originalMethod as any).apply()- reduces type safetyMethodology
Local Testing:
@aws-lambda-powertools/commonspackageCI Analysis:
Decision Rationale
While performance improvements are substantial, we're not adopting the native compiler because:
@typescript/native-previewis development/preview softwareas anycasts in decorator implementationsWe'll reconsider adoption when:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.