Port node18 and nodenext changes#1070
Merged
andrewbranch merged 3 commits intomicrosoft:mainfrom Jun 5, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ports changes from upstream TypeScript pull requests to add support for Node18 alongside node16 and nodenext. Key changes include:
- Updated baselines and type declarations for ESM modules and dynamic imports.
- Inclusion of Node18 in module resolution and compiler options.
- Addition of a new helper method (GetEmitSyntaxForUsageLocation) and updated grammar checks in the checker.
Reviewed Changes
Copilot reviewed 379 out of 379 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testdata/baselines/reference/submodule/compiler/esmNoSynthesizedDefault* | Updated error, type, and symbol baselines reflecting new default export behavior for ESM modules |
| testdata/baselines/reference/submodule/compiler/esmModeDeclarationFileWithExportAssignment* | Adjustments to type and error baselines for export assignments under ESM contexts |
| testdata/baselines/reference/submodule/compiler/dynamicImportsDeclaration* | Revised dynamic import declarations to output default export unions consistently |
| internal/core/compileroptions.go | Revised module kind switch cases to include Node18 contexts for script target and module resolution |
| internal/compiler/program.go | Added GetEmitSyntaxForUsageLocation to support dynamic import syntax adjustments |
| internal/compiler/fileloader.go | Refactored usage of fileEmitMode to enhance clarity in dynamic import handling |
| internal/checker/*.go | Updated grammar checks and module kind comparisons to properly include Node18 ranges |
Comments suppressed due to low confidence (2)
internal/core/compileroptions.go:152
- Consider adding a clarifying comment that Node18 is intentionally included alongside Node16 in GetEmitScriptTarget and GetModuleResolutionKind to aid future maintainers.
case ModuleKindNode16, ModuleKindNodeNext:
internal/checker/checker.go:5009
- Review the updated condition to ensure that extending the module kind range to include Node18 accurately reflects the intended behavior for JSON import checks.
if !importClause.IsTypeOnly() && core.ModuleKindNode18 <= c.moduleKind && c.moduleKind <= core.ModuleKindNodeNext && c.isOnlyImportableAsDefault(moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node) {
andrewbranch
commented
Jun 5, 2025
| // return host.getEmitSyntaxForUsageLocation(ast.GetSourceFileOfNode(usage), usage) | ||
| // } | ||
| if ast.IsStringLiteralLike(usage) { | ||
| return c.program.GetEmitSyntaxForUsageLocation(ast.GetSourceFileOfNode(usage), usage) |
Member
Author
There was a problem hiding this comment.
This was not part of the PRs but interacted with diffs they changed; I missed it before. There's also another bit in resolveESModuleSymbol I'm going to port in a separate PR.
jakebailey
approved these changes
Jun 5, 2025
Member
|
Tests fail because |
Member
Author
|
I hate that test |
jakebailey
approved these changes
Jun 5, 2025
weswigham
approved these changes
Jun 5, 2025
This was referenced Jun 19, 2025
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.
Ports
--module node18TypeScript#60722require(esm)in--module nodenextTypeScript#60761