Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 13.7k
fix35982: allow BigIntLiteral to parse as PropertyName for literal object and indices#58608
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
Isabel Duan (iisaduan)
merged 17 commits into
microsoft:main
from
iisaduan:parse-bigint-indexJul 20, 2024
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
549c2f5
add BigIntLiteral to PropertyName
iisaduan dc4fa17
change error wording
iisaduan fadbf13
change error to be a grammar error, add index error
iisaduan 262c6b1
more specific index error
iisaduan 026f259
update baselines again?
iisaduan f2da07f
suggested changes
iisaduan 544d4a3
fix errors
iisaduan 42c9150
merge/change error number
iisaduan c5a891e
Merge branch 'main' into parse-bigint-index
iisaduan 49b1369
add tests
iisaduan 2b1bafa
add even more tests + fix crashes
iisaduan bcd6023
fix tests
iisaduan 2cb0357
changed error to use literal string
iisaduan 4a4ee7e
fix error
iisaduan 8aa6c0d
Merge branch 'main' of https://github.com/microsoft/TypeScript into p…
iisaduan 2c222c6
update baselines
iisaduan 46f1b44
fix error messages
iisaduan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
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
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
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 |
|---|---|---|
| @@ -1721,7 +1721,14 @@ export interface QualifiedName extends Node, FlowContainer { | ||
| export type EntityName = Identifier | QualifiedName; | ||
| export type PropertyName = Identifier | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; | ||
| export type PropertyName = | ||
| | Identifier | ||
| | StringLiteral | ||
| | NoSubstitutionTemplateLiteral | ||
| | NumericLiteral | ||
| | ComputedPropertyName | ||
| | PrivateIdentifier | ||
| | BigIntLiteral; | ||
iisaduan marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| export type MemberName = Identifier | PrivateIdentifier; | ||
| @@ -2340,7 +2347,8 @@ export interface LiteralTypeNode extends TypeNode { | ||
| export interface StringLiteral extends LiteralExpression, Declaration { | ||
| readonly kind: SyntaxKind.StringLiteral; | ||
| /** @internal */ readonly textSourceNode?: Identifier | StringLiteralLike | NumericLiteral | PrivateIdentifier | JsxNamespacedName; // Allows a StringLiteral to get its text from another node (used by transforms). | ||
| /** @internal */ | ||
| readonly textSourceNode?: Identifier | StringLiteralLike | NumericLiteral | PrivateIdentifier | JsxNamespacedName | BigIntLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). | ||
| /** | ||
| * Note: this is only set when synthesizing a node, not during parsing. | ||
| * | ||
| @@ -2350,7 +2358,7 @@ export interface StringLiteral extends LiteralExpression, Declaration { | ||
| } | ||
| export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; | ||
| export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName; | ||
| export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral | JsxNamespacedName | BigIntLiteral; | ||
| export interface TemplateLiteralTypeNode extends TypeNode { | ||
| kind: SyntaxKind.TemplateLiteralType; | ||
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
69 changes: 69 additions & 0 deletions
69 tests/baselines/reference/bigintArbirtraryIdentifier.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,69 @@ | ||
| badExport.ts(1,10): error TS2304: Cannot find name 'foo'. | ||
| badExport.ts(1,17): error TS1003: Identifier expected. | ||
| badExport.ts(1,20): error TS1128: Declaration or statement expected. | ||
| badExport2.ts(1,10): error TS1003: Identifier expected. | ||
| badExport2.ts(1,16): error TS2304: Cannot find name 'foo'. | ||
| badExport2.ts(1,20): error TS1128: Declaration or statement expected. | ||
| badImport.ts(1,10): error TS1003: Identifier expected. | ||
| badImport.ts(1,10): error TS1141: String literal expected. | ||
| badImport.ts(1,20): error TS1128: Declaration or statement expected. | ||
| badImport.ts(1,22): error TS1434: Unexpected keyword or identifier. | ||
| badImport.ts(1,22): error TS2304: Cannot find name 'from'. | ||
| badImport2.ts(1,17): error TS1003: Identifier expected. | ||
| badImport2.ts(1,17): error TS1141: String literal expected. | ||
| badImport2.ts(1,20): error TS1128: Declaration or statement expected. | ||
| badImport2.ts(1,22): error TS1434: Unexpected keyword or identifier. | ||
| badImport2.ts(1,22): error TS2304: Cannot find name 'from'. | ||
| ==== foo.ts (0 errors) ==== | ||
| const foo = 0n; | ||
| export { foo as "0n" }; | ||
| ==== correctUse.ts (0 errors) ==== | ||
| import { "0n" as foo } from "./foo"; | ||
| export { foo as "0n" }; | ||
| ==== badImport.ts (5 errors) ==== | ||
| import { 0n as foo } from "./foo"; | ||
| ~~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~~~~~~~~~ | ||
| !!! error TS1141: String literal expected. | ||
| ~ | ||
| !!! error TS1128: Declaration or statement expected. | ||
| ~~~~ | ||
| !!! error TS1434: Unexpected keyword or identifier. | ||
| ~~~~ | ||
| !!! error TS2304: Cannot find name 'from'. | ||
| ==== badImport2.ts (5 errors) ==== | ||
| import { foo as 0n } from "./foo"; | ||
| ~~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~~ | ||
| !!! error TS1141: String literal expected. | ||
| ~ | ||
| !!! error TS1128: Declaration or statement expected. | ||
| ~~~~ | ||
| !!! error TS1434: Unexpected keyword or identifier. | ||
| ~~~~ | ||
| !!! error TS2304: Cannot find name 'from'. | ||
| ==== badExport.ts (3 errors) ==== | ||
| export { foo as 0n }; | ||
| ~~~ | ||
| !!! error TS2304: Cannot find name 'foo'. | ||
| ~~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~ | ||
| !!! error TS1128: Declaration or statement expected. | ||
| ==== badExport2.ts (3 errors) ==== | ||
| export { 0n as foo }; | ||
| ~~ | ||
| !!! error TS1003: Identifier expected. | ||
| ~~~ | ||
| !!! error TS2304: Cannot find name 'foo'. | ||
| ~ | ||
| !!! error TS1128: Declaration or statement expected. |
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,44 @@ | ||
| //// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// | ||
| //// [foo.ts] | ||
| const foo = 0n; | ||
| export { foo as "0n" }; | ||
| //// [correctUse.ts] | ||
| import { "0n" as foo } from "./foo"; | ||
| export { foo as "0n" }; | ||
| //// [badImport.ts] | ||
| import { 0n as foo } from "./foo"; | ||
| //// [badImport2.ts] | ||
| import { foo as 0n } from "./foo"; | ||
| //// [badExport.ts] | ||
| export { foo as 0n }; | ||
| //// [badExport2.ts] | ||
| export { 0n as foo }; | ||
| //// [foo.js] | ||
| const foo = 0n; | ||
| export { foo as "0n" }; | ||
| //// [correctUse.js] | ||
| import { "0n" as foo } from "./foo"; | ||
| export { foo as "0n" }; | ||
| //// [badImport.js] | ||
| from; | ||
| "./foo"; | ||
| export {}; | ||
| //// [badImport2.js] | ||
| from; | ||
| "./foo"; | ||
| export {}; | ||
| //// [badExport.js] | ||
| export { foo as }; | ||
| 0n; | ||
| ; | ||
| //// [badExport2.js] | ||
| 0n; | ||
| ; | ||
| export {}; |
34 changes: 34 additions & 0 deletions
34 tests/baselines/reference/bigintArbirtraryIdentifier.symbols
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 @@ | ||
| //// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// | ||
| === foo.ts === | ||
| const foo = 0n; | ||
| >foo : Symbol(foo, Decl(foo.ts, 0, 5)) | ||
| export { foo as "0n" }; | ||
| >foo : Symbol(foo, Decl(foo.ts, 0, 5)) | ||
| >"0n" : Symbol("0n", Decl(foo.ts, 1, 8)) | ||
| === correctUse.ts === | ||
| import { "0n" as foo } from "./foo"; | ||
| >foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) | ||
| export { foo as "0n" }; | ||
| >foo : Symbol(foo, Decl(correctUse.ts, 0, 8)) | ||
| >"0n" : Symbol("0n", Decl(correctUse.ts, 1, 8)) | ||
| === badImport.ts === | ||
| import { 0n as foo } from "./foo"; | ||
| >foo : Symbol(foo) | ||
| === badImport2.ts === | ||
| import { foo as 0n } from "./foo"; | ||
| > : Symbol((Missing), Decl(badImport2.ts, 0, 8)) | ||
| === badExport.ts === | ||
| export { foo as 0n }; | ||
| > : Symbol((Missing), Decl(badExport.ts, 0, 8)) | ||
| === badExport2.ts === | ||
| export { 0n as foo }; | ||
| >foo : Symbol(foo) | ||
64 changes: 64 additions & 0 deletions
64 tests/baselines/reference/bigintArbirtraryIdentifier.types
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,64 @@ | ||
| //// [tests/cases/compiler/bigintArbirtraryIdentifier.ts] //// | ||
| === foo.ts === | ||
| const foo = 0n; | ||
| >foo : 0n | ||
| > : ^^ | ||
| >0n : 0n | ||
| > : ^^ | ||
| export { foo as "0n" }; | ||
| >foo : 0n | ||
| > : ^^ | ||
| >"0n" : 0n | ||
| > : ^^ | ||
| === correctUse.ts === | ||
| import { "0n" as foo } from "./foo"; | ||
| >foo : 0n | ||
| > : ^^ | ||
| export { foo as "0n" }; | ||
| >foo : 0n | ||
| > : ^^ | ||
| >"0n" : 0n | ||
| > : ^^ | ||
| === badImport.ts === | ||
| import { 0n as foo } from "./foo"; | ||
| >0n as foo : foo | ||
| > : ^^^ | ||
| >0n : 0n | ||
| > : ^^ | ||
| >from : any | ||
| > : ^^^ | ||
| >"./foo" : "./foo" | ||
| > : ^^^^^^^ | ||
| === badImport2.ts === | ||
| import { foo as 0n } from "./foo"; | ||
| >foo : any | ||
| > : ^^^ | ||
| > : any | ||
| > : ^^^ | ||
| >from : any | ||
| > : ^^^ | ||
| >"./foo" : "./foo" | ||
| > : ^^^^^^^ | ||
| === badExport.ts === | ||
| export { foo as 0n }; | ||
| >foo : any | ||
| > : ^^^ | ||
| > : any | ||
| > : ^^^ | ||
| >0n : 0n | ||
| > : ^^ | ||
| === badExport2.ts === | ||
| export { 0n as foo }; | ||
| >0n as foo : foo | ||
| > : ^^^ | ||
| >0n : 0n | ||
| > : ^^ | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.