Reject import assert in parser and checker, remove checker assert/with distinction#2775
Open
Reject import assert in parser and checker, remove checker assert/with distinction#2775
import assert in parser and checker, remove checker assert/with distinction#2775Conversation
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 Feb 12, 2026
import assert in parser, remove checker assert/with distinction
jakebailey
reviewed
Feb 13, 2026
...bmodule/conformance/nodeModulesImportTypeModeDeclarationEmit1(module=node18).errors.txt.diff
Outdated
Show resolved
Hide resolved
0b493b3 to
163ff23
Compare
jakebailey
reviewed
Mar 4, 2026
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecation.errors.txt.diff
Outdated
Show resolved
Hide resolved
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
Reject Mar 4, 2026
import assert in parser, remove checker assert/with distinctionimport assert in parser and checker, remove checker assert/with distinction
jakebailey
reviewed
Mar 4, 2026
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; | ||
| + ~~~~~~ |
Member
There was a problem hiding this comment.
Strada seems to issue this error in a dumb place. Funny
Contributor
There was a problem hiding this comment.
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
assertis 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 anassertproperty. - 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>
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.
assertkeyword is used for import attributes (3 locations)assertvswithtokens (always use "import attributes" messages)assertproperty in object literal second argument of dynamicimport()calls💡 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.