Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 12, 2026

Ports microsoft/TypeScript#63077, but instead of a checker-level deprecation (suppressible via ignoreDeprecations), we reject assert at parse time unconditionally.

Parser (internal/parser/parser.go)

  • Emit TS2880 when assert keyword is encountered in all three import attribute parse sites: tryParseImportAttributes, parseExportDeclaration, parseImportType
  • Syntax is still parsed for error recovery

Checker (internal/checker/checker.go)

  • Remove isImportAttributes branching in checkImportAttributes — always use "import attributes" diagnostics
  • Remove assert/with core.IfElse in getResolutionModeOverride — always use "import attributes" messages
  • Remove assert/with distinction in import value string literal check

Since grammarErrorOnNode is a no-op when parse diagnostics exist, files using assert naturally skip redundant checker grammar errors.

Baseline changes

  • importAssertionsDeprecated.errors.txt.diff deleted (output now matches TS)
  • New diffs for importAssertionsDeprecatedIgnored (we error unconditionally; TS suppresses via ignoreDeprecations) and import type node cases (TS only checks import/export declarations in the checker)

💡 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 <[email protected]>
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
Comment on lines +5 to +8
+/index.ts(2,23): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
+/index.ts(3,23): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
+/index.ts(5,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
+/index.ts(6,50): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
Copy link
Member

Choose a reason for hiding this comment

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

Uh oh, we forgot to deprecate assert on import().

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.

2 participants