Skip to content

Port node18 and nodenext changes #1070

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

Merged
merged 3 commits into from
Jun 5, 2025
Merged

Conversation

andrewbranch
Copy link
Member

@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 17:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

// return host.getEmitSyntaxForUsageLocation(ast.GetSourceFileOfNode(usage), usage)
// }
if ast.IsStringLiteralLike(usage) {
return c.program.GetEmitSyntaxForUsageLocation(ast.GetSourceFileOfNode(usage), usage)
Copy link
Member Author

@andrewbranch andrewbranch Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Tests fail because GetEmitSyntaxForUsageLocation is missing from a mock, it seems.

@andrewbranch
Copy link
Member Author

I hate that test

@andrewbranch andrewbranch enabled auto-merge June 5, 2025 18:24
@andrewbranch andrewbranch requested a review from jakebailey June 5, 2025 18:26
@andrewbranch andrewbranch added this pull request to the merge queue Jun 5, 2025
Merged via the queue into microsoft:main with commit b0278c5 Jun 5, 2025
22 of 43 checks passed
@andrewbranch andrewbranch deleted the node18 branch June 5, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants