Skip to content

Support source phase imports - #63915

Open
Oleksandr Tarasiuk (a-tarasyuk) wants to merge 36 commits into
microsoft:mainfrom
a-tarasyuk:feat/61216
Open

Oleksandr Tarasiuk (a-tarasyuk) wants to merge 36 commits into
microsoft:mainfrom
a-tarasyuk:feat/61216

Conversation

@a-tarasyuk

@a-tarasyuk Oleksandr Tarasiuk (a-tarasyuk) commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #61216


This patch adds support for TC39 Source Phase Imports

Copilot AI balanced review requested due to automatic review settings August 20, 2026 13:37
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 20, 2026
@typescript-automation typescript-automation Bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds TC39 source-phase import support across parsing, resolution, checking, emit, APIs, and language services.

Changes:

  • Supports static import source and dynamic import.source().
  • Adds phase-aware resolution, WebAssembly typing, diagnostics, and emit behavior.
  • Adds compiler, parser, resolver, API, and fourslash coverage.

Reviewed changes

Copilot reviewed 161 out of 167 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tsc/internal/ast/* Adds source-phase syntax kinds and AST helpers.
tsc/internal/api/encoder/* Encodes and decodes the new phase modifier.
tsc/internal/checker/* Checks syntax and assigns source-module types.
tsc/internal/compiler/* Tracks phase-aware resolutions and Wasm inputs.
tsc/internal/core/compileroptions.go Defines supported module modes.
tsc/internal/diagnostics/* Adds source-import diagnostics.
tsc/internal/fourslash/tests/*sourcePhase* Tests completions, auto-imports, and organization.
tsc/internal/ls/* Integrates source imports with language services.
tsc/internal/module/* Implements phase-aware module resolution and caching.
tsc/internal/parser/* Parses static and dynamic source imports.
tsc/internal/scanner/* Recognizes source as a contextual keyword.
tsc/internal/testutil/tsbaseline/js_emit_baseline.go Includes Wasm files during declaration verification.
tsc/internal/transformers/moduletransforms/commonjsmodule.go Avoids rewriting import.source() as ordinary dynamic import.
tsc/internal/tspath/extension.go Adds the Wasm extension.
tools/scripts/tsc/ast.json Updates AST generation metadata.
packages/typescript/src/* Exposes the new syntax through the TypeScript API.
tsc/testdata/tests/cases/conformance/importSource/* Covers syntax, typing, resolution, emit, and errors.
tsc/testdata/baselines/reference/conformance/importSource* Records expected compiler output.
tsc/testdata/baselines/reference/conformance/importMetaPropertyInvalidInCall.errors.txt Updates import meta-property suggestions.
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Comment thread tsc/testdata/baselines/reference/conformance/importSource9.js Outdated
@a-tarasyuk
Oleksandr Tarasiuk (a-tarasyuk) force-pushed the feat/61216 branch 3 times, most recently from 90faa2c to c8df015 Compare August 21, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 169 out of 175 changed files in this pull request and generated 1 comment.

Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
Suppressed comments (1)

tsc/internal/fourslash/tests/organizeImports_sourcePhase_test.go:44

  • This second use has the same compile error: CodeActionKindSourceSortImports is undefined. Use the TypeScript-specific CodeActionKindSourceSortImportsTs constant so the fourslash test package builds.
		lsproto.CodeActionKindSourceSortImports,

Comment thread tsc/internal/fourslash/tests/organizeImports_sourcePhase_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 169 out of 175 changed files in this pull request and generated no new comments.

Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

It changes parser, checker, resolver, emitter, language-service, and public API contracts across a broad new language feature.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Language-service reference tracking currently conflates source-phase bindings with default imports.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file

Comment thread tsc/internal/checker/checker.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

API-provided Wasm resolutions can bypass source-phase handling because their extension is not recognized.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file

Comment thread tsc/internal/module/util.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Declaration-file detection incorrectly rejects valid Wasm exports from bare package names ending in .d.ts.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file
Previously missed (1)

In code that hasn't changed since last review

Medium severity Validate resolved target before rejecting declaration-file imports

tsc/​internal/​checker/​checker.go:14857

This tests the module specifier text rather than the resolved file. A valid bare package such as import source m from "foo.d.ts" can export a .wasm file, but IsDeclarationFileName("foo.d.ts") makes the import an error even though no declaration file was imported. Require the resolved target to be a declaration too before issuing this diagnostic.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Declaration-only package targets are accepted as source imports, and organize-imports uses the wrong comparer for source bindings.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file
Previously missed (1)

In code that hasn't changed since last review

Medium severity Use named-import comparer when sorting local bindings

tsc/​internal/​ls/​organizeimports.go:488

This sorts local bindings with the module-specifier comparer. In auto mode, module-specifier and named-import casing/order are detected independently, so source bindings can be ordered differently from the file's identifier convention. Pass the named-import comparer for these names instead (the explicit sort test does not expose this because both comparers are identical there).

Comment thread tsc/internal/checker/checker.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The cross-cutting parser, resolver, checker, language-service, and public-protocol changes warrant final human validation despite extensive coverage.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (1)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The change spans parser, checker, resolver, emit, language service, and public API behavior and warrants final human validation.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Files not reviewed (6)
  • tsc/internal/api/encoder/decoder_generated.go: Generated file
  • tsc/internal/api/encoder/encoder_generated.go: Generated file
  • tsc/internal/api/enum_values_generated.go: Generated file
  • tsc/internal/ast/ast_generated.go: Generated file
  • tsc/internal/ast/kind_generated.go: Generated file
  • tsc/internal/ast/kind_stringer_generated.go: Generated file

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Support source phase imports

2 participants