-
Notifications
You must be signed in to change notification settings - Fork 871
Reject import assert in parser and checker, remove checker assert/with distinction
#2775
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e99e2c5
Initial plan
Copilot 88f025b
Reject import assert in parser and remove checker assert-specific logic
Copilot 163ff23
Merge remote-tracking branch 'origin/main' into copilot/remove-checke…
jakebailey b5abc81
Add checker-level check for assert in dynamic import() calls
Copilot 3eb2e8c
Update comment: 'resolution mode assertions' -> 'resolution mode attr…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
29 changes: 29 additions & 0 deletions
29
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecated.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /a.ts(1,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /b.ts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /c.ts(1,51): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
|
|
||
| ==== /a.ts (1 errors) ==== | ||
| import json from "./package.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /b.ts (1 errors) ==== | ||
| import * as data from "./data.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /c.ts (1 errors) ==== | ||
| export { default as config } from "./config.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /package.json (0 errors) ==== | ||
| {} | ||
|
|
||
| ==== /data.json (0 errors) ==== | ||
| {} | ||
|
|
||
| ==== /config.json (0 errors) ==== | ||
| {} | ||
|
|
33 changes: 0 additions & 33 deletions
33
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecated.errors.txt.diff
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
testdata/baselines/reference/submodule/compiler/importAssertionsDeprecatedIgnored.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /a.ts(2,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /b.ts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /c.ts(1,51): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
|
|
||
| ==== /a.ts (1 errors) ==== | ||
| // With ignoreDeprecations: "6.0", import assertions should not produce a deprecation error. | ||
| import json from "./package.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /b.ts (1 errors) ==== | ||
| import * as data from "./data.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /c.ts (1 errors) ==== | ||
| export { default as config } from "./config.json" assert { type: "json" }; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| ==== /package.json (0 errors) ==== | ||
| {} | ||
|
|
||
| ==== /data.json (0 errors) ==== | ||
| {} | ||
|
|
||
| ==== /config.json (0 errors) ==== | ||
| {} | ||
|
|
34 changes: 34 additions & 0 deletions
34
.../baselines/reference/submodule/compiler/importAssertionsDeprecatedIgnored.errors.txt.diff
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- old.importAssertionsDeprecatedIgnored.errors.txt | ||
| +++ new.importAssertionsDeprecatedIgnored.errors.txt | ||
| @@= skipped -0, +0 lines =@@ | ||
| -<no content> | ||
| +/a.ts(2,35): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| +/b.ts(1,37): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| +/c.ts(1,51): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| + | ||
| + | ||
| +==== /a.ts (1 errors) ==== | ||
| + // With ignoreDeprecations: "6.0", import assertions should not produce a deprecation error. | ||
| + import json from "./package.json" assert { type: "json" }; | ||
| + ~~~~~~ | ||
| +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| + | ||
| +==== /b.ts (1 errors) ==== | ||
| + import * as data from "./data.json" assert { type: "json" }; | ||
| + ~~~~~~ | ||
| +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| + | ||
| +==== /c.ts (1 errors) ==== | ||
| + export { default as config } from "./config.json" assert { type: "json" }; | ||
| + ~~~~~~ | ||
| +!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| + | ||
| +==== /package.json (0 errors) ==== | ||
| + {} | ||
| + | ||
| +==== /data.json (0 errors) ==== | ||
| + {} | ||
| + | ||
| +==== /config.json (0 errors) ==== | ||
| + {} | ||
| + |
24 changes: 24 additions & 0 deletions
24
testdata/baselines/reference/submodule/compiler/importTypeAssertionDeprecation.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /main.ts(1,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(2,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
|
|
||
| ==== /types.d.ts (0 errors) ==== | ||
| export interface MyType { x: string } | ||
|
|
||
| ==== /main.ts (4 errors) ==== | ||
| 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; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| const a = import("./types", { assert: { "resolution-mode": "import" } }); | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| const b = import("./types", { assert: { "resolution-mode": "require" } }); | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,26 +3,21 @@ | |
| @@= skipped -0, +0 lines =@@ | ||
| -/main.ts(1,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| -/main.ts(2,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| -/main.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| -/main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| - | ||
| - | ||
| -==== /types.d.ts (0 errors) ==== | ||
| - export interface MyType { x: string } | ||
| - | ||
| -==== /main.ts (4 errors) ==== | ||
| - type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; | ||
| +/main.ts(1,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| +/main.ts(2,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| @@= skipped -8, +8 lines =@@ | ||
| ==== /main.ts (4 errors) ==== | ||
| 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; | ||
| + ~~~~~~ | ||
|
Comment on lines
+14
to
+16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strada seems to issue this error in a dumb place. Funny |
||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; | ||
| - ~ | ||
| -!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| - | ||
| - const a = import("./types", { assert: { "resolution-mode": "import" } }); | ||
| - ~~~~~~ | ||
| -!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| - const b = import("./types", { assert: { "resolution-mode": "require" } }); | ||
| - ~~~~~~ | ||
| -!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| - | ||
| +<no content> | ||
| + ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| const a = import("./types", { assert: { "resolution-mode": "import" } }); | ||
25 changes: 25 additions & 0 deletions
25
...a/baselines/reference/submodule/compiler/importTypeAssertionDeprecationIgnored.errors.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /main.ts(2,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(3,30): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| /main.ts(6,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
|
|
||
| ==== /types.d.ts (0 errors) ==== | ||
| export interface MyType { x: string } | ||
|
|
||
| ==== /main.ts (4 errors) ==== | ||
| // With ignoreDeprecations: "6.0", import type assertions should not produce a deprecation error. | ||
| 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; | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
||
| const a = import("./types", { assert: { "resolution-mode": "import" } }); | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
| const b = import("./types", { assert: { "resolution-mode": "require" } }); | ||
| ~~~~~~ | ||
| !!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. | ||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.