Skip to content

Reject import assert in parser and checker, remove checker assert/with distinction#2775

Open
Copilot wants to merge 5 commits intomainfrom
copilot/remove-checker-checks
Open

Reject import assert in parser and checker, remove checker assert/with distinction#2775
Copilot wants to merge 5 commits intomainfrom
copilot/remove-checker-checks

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

  • Port TypeScript PR #63077 (Deprecate import assert in favor of import with) with Go-specific approach
  • Add parse error in parser when assert keyword is used for import attributes (3 locations)
  • Remove checker logic that distinguishes assert vs with tokens (always use "import attributes" messages)
  • Port TypeScript PR #63172 (Deprecate assert in dynamic import() calls) — checker-level check for assert property in object literal second argument of dynamic import() calls
  • Update comment wording: 'resolution mode assertions' → 'resolution mode attributes'
  • Build and run tests — all passing
  • Accept baseline changes

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Error at parse time when 'assert' keyword is used for import attributes
(in all 3 parse locations: tryParseImportAttributes, parseExportDeclaration,
parseImportType). Remove checker logic that distinguished between 'assert'
and 'with' tokens, always using 'import attributes' messages.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix parsing errors by rejecting input entirely Reject import assert in parser, remove checker assert/with distinction Feb 12, 2026
Copilot AI requested a review from jakebailey February 12, 2026 23:20
@jakebailey jakebailey force-pushed the copilot/remove-checker-checks branch from 0b493b3 to 163ff23 Compare March 4, 2026 19:13
For dynamic import() calls, 'assert' is a property name in an object
literal, not syntax-level, so it can't be caught at parse time. Add a
checker-level error using c.error() (not grammarErrorOnNode, which
would be suppressed by parse diagnostics from import type assert errors
in the same file).

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title Reject import assert in parser, remove checker assert/with distinction Reject import assert in parser and checker, remove checker assert/with distinction Mar 4, 2026
Copilot AI requested a review from jakebailey March 4, 2026 19:34
Comment on lines +14 to +16
type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType;
- ~
-!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
- type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType;
+ ~~~~~~
Copy link
Member

Choose a reason for hiding this comment

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

Strada seems to issue this error in a dumb place. Funny

@jakebailey jakebailey marked this pull request as ready for review March 4, 2026 19:53
Copy link
Contributor

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

Ports recent TypeScript changes to fully replace import ... assert { ... } with import attributes (with) by emitting TS2880 at parse-time and simplifying checker diagnostics to always use “import attributes” wording, plus updating baselines accordingly.

Changes:

  • Parser: emit TS2880 whenever assert is used at supported import-attribute parse sites, while still parsing for recovery.
  • Checker: remove assert/with diagnostic branching and add a dynamic import() options check for an assert property.
  • Update/delete baseline diffs to reflect the new unconditional error behavior.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/parser/parser.go Emits TS2880 when encountering assert at import-attributes parse entry points (including import types).
internal/checker/checker.go Simplifies diagnostics to “import attributes” only; adds dynamic import() options rejection for assert.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt.diff Baseline diff updates for import-type attribute/assert handling.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=nodenext).errors.txt Baseline output updates for nodenext variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt.diff Baseline diff updates for node20 variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node20).errors.txt Baseline output updates for node20 variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt.diff Baseline diff updates for node18 variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node18).errors.txt Baseline output updates for node18 variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt.diff Baseline diff updates for node16 variant.
testdata/baselines/reference/submodule/conformance/nodeModulesImportTypeModeDeclarationEmitErrors1(module=node16).errors.txt Baseline output updates for node16 variant.
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecationIgnored.errors.txt.diff New baseline diff capturing unconditional TS2880 errors even under ignoreDeprecations.
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecationIgnored.errors.txt New/updated baseline output for the above case.
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecation.errors.txt.diff Baseline diff updates for import-type assert cases.
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecation.errors.txt Updated baseline output for unconditional TS2880 behavior.
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecatedIgnored.errors.txt.diff New baseline diff capturing unconditional TS2880 errors even under ignoreDeprecations.
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecatedIgnored.errors.txt New/updated baseline output for the above case.
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecated.errors.txt.diff Deleted diff baseline (now matches TS).
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecated.errors.txt Updated baseline output for the non-ignored import assertion test.

…ibutes'

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI requested a review from jakebailey March 4, 2026 20:09
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