-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(25758): Computed properties no throws if there is a duplicate (#…
- Loading branch information
1 parent
1ed06e6
commit 9e1f0ad
Showing
16 changed files
with
675 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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
14 changes: 7 additions & 7 deletions
14
...ctLiteralProperty_computedName.errors.txt → ...tLiteralProperty_computedName1.errors.txt
This file contains 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 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
50 changes: 25 additions & 25 deletions
50
...bjectLiteralProperty_computedName.symbols → ...jectLiteralProperty_computedName1.symbols
This file contains 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 |
---|---|---|
@@ -1,74 +1,74 @@ | ||
=== tests/cases/compiler/duplicateObjectLiteralProperty_computedName.ts === | ||
=== tests/cases/compiler/duplicateObjectLiteralProperty_computedName1.ts === | ||
const t1 = { | ||
>t1 : Symbol(t1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 5)) | ||
>t1 : Symbol(t1, Decl(duplicateObjectLiteralProperty_computedName1.ts, 0, 5)) | ||
|
||
1: 1, | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9)) | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName1.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 1, 9)) | ||
|
||
[1]: 0 // duplicate | ||
>[1] : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9)) | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 1, 9)) | ||
>[1] : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName1.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 1, 9)) | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName1.ts, 0, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 1, 9)) | ||
} | ||
|
||
const t2 = { | ||
>t2 : Symbol(t2, Decl(duplicateObjectLiteralProperty_computedName.ts, 5, 5)) | ||
>t2 : Symbol(t2, Decl(duplicateObjectLiteralProperty_computedName1.ts, 5, 5)) | ||
|
||
1: 1, | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName.ts, 5, 12)) | ||
>1 : Symbol(1, Decl(duplicateObjectLiteralProperty_computedName1.ts, 5, 12)) | ||
|
||
[+1]: 0 // duplicate | ||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName.ts, 6, 9)) | ||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName1.ts, 6, 9)) | ||
} | ||
|
||
const t3 = { | ||
>t3 : Symbol(t3, Decl(duplicateObjectLiteralProperty_computedName.ts, 10, 5)) | ||
>t3 : Symbol(t3, Decl(duplicateObjectLiteralProperty_computedName1.ts, 10, 5)) | ||
|
||
"1": 1, | ||
>"1" : Symbol("1", Decl(duplicateObjectLiteralProperty_computedName.ts, 10, 12)) | ||
>"1" : Symbol("1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 10, 12)) | ||
|
||
[+1]: 0 // duplicate | ||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName.ts, 11, 11)) | ||
>[+1] : Symbol([+1], Decl(duplicateObjectLiteralProperty_computedName1.ts, 11, 11)) | ||
} | ||
|
||
const t4 = { | ||
>t4 : Symbol(t4, Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 5)) | ||
>t4 : Symbol(t4, Decl(duplicateObjectLiteralProperty_computedName1.ts, 15, 5)) | ||
|
||
"+1": 1, | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 16, 12)) | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 16, 12)) | ||
|
||
[+1]: 0 // two different keys, "+1", "1" | ||
>[+1] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 16, 12)) | ||
>[+1] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 16, 12)) | ||
} | ||
|
||
const t5 = { | ||
>t5 : Symbol(t5, Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 5)) | ||
>t5 : Symbol(t5, Decl(duplicateObjectLiteralProperty_computedName1.ts, 20, 5)) | ||
|
||
"+1": 1, | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12)) | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 21, 12)) | ||
|
||
["+1"]: 0 // duplicate | ||
>["+1"] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12)) | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 21, 12)) | ||
>["+1"] : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 21, 12)) | ||
>"+1" : Symbol("+1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 21, 12)) | ||
} | ||
|
||
const t6 = { | ||
>t6 : Symbol(t6, Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 5)) | ||
>t6 : Symbol(t6, Decl(duplicateObjectLiteralProperty_computedName1.ts, 25, 5)) | ||
|
||
"-1": 1, | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 26, 12)) | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 26, 12)) | ||
|
||
[-1]: 0 // duplicate | ||
>[-1] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 26, 12)) | ||
>[-1] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 25, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 26, 12)) | ||
} | ||
|
||
const t7 = { | ||
>t7 : Symbol(t7, Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 5)) | ||
>t7 : Symbol(t7, Decl(duplicateObjectLiteralProperty_computedName1.ts, 30, 5)) | ||
|
||
"-1": 1, | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12)) | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 31, 12)) | ||
|
||
["-1"]: 0 // duplicate | ||
>["-1"] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12)) | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName.ts, 31, 12)) | ||
>["-1"] : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 31, 12)) | ||
>"-1" : Symbol("-1", Decl(duplicateObjectLiteralProperty_computedName1.ts, 30, 12), Decl(duplicateObjectLiteralProperty_computedName1.ts, 31, 12)) | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
...eObjectLiteralProperty_computedName.types → ...ObjectLiteralProperty_computedName1.types
This file contains 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
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/duplicateObjectLiteralProperty_computedName2.errors.txt
This file contains 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,40 @@ | ||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts(8,5): error TS1117: An object literal cannot have multiple properties with the same name. | ||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts(13,5): error TS1117: An object literal cannot have multiple properties with the same name. | ||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts(18,5): error TS1117: An object literal cannot have multiple properties with the same name. | ||
tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts(23,5): error TS1117: An object literal cannot have multiple properties with the same name. | ||
|
||
|
||
==== tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts (4 errors) ==== | ||
const n = 1; | ||
const s = "s"; | ||
enum E1 { A = "ENUM_KEY" } | ||
enum E2 { B } | ||
|
||
const t1 = { | ||
[n]: 1, | ||
[n]: 1, // duplicate | ||
~~~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
} | ||
|
||
const t2 = { | ||
[s]: 1, | ||
[s]: 1, // duplicate | ||
~~~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
} | ||
|
||
const t3 = { | ||
[E1.A]: 1, | ||
[E1.A]: 1, // duplicate | ||
~~~~~~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
} | ||
|
||
const t4 = { | ||
[E2.B]: 1, | ||
[E2.B]: 1, // duplicate | ||
~~~~~~ | ||
!!! error TS1117: An object literal cannot have multiple properties with the same name. | ||
} | ||
|
55 changes: 55 additions & 0 deletions
55
tests/baselines/reference/duplicateObjectLiteralProperty_computedName2.js
This file contains 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,55 @@ | ||
//// [duplicateObjectLiteralProperty_computedName2.ts] | ||
const n = 1; | ||
const s = "s"; | ||
enum E1 { A = "ENUM_KEY" } | ||
enum E2 { B } | ||
|
||
const t1 = { | ||
[n]: 1, | ||
[n]: 1, // duplicate | ||
} | ||
|
||
const t2 = { | ||
[s]: 1, | ||
[s]: 1, // duplicate | ||
} | ||
|
||
const t3 = { | ||
[E1.A]: 1, | ||
[E1.A]: 1, // duplicate | ||
} | ||
|
||
const t4 = { | ||
[E2.B]: 1, | ||
[E2.B]: 1, // duplicate | ||
} | ||
|
||
|
||
//// [duplicateObjectLiteralProperty_computedName2.js] | ||
var _a, _b, _c, _d; | ||
var n = 1; | ||
var s = "s"; | ||
var E1; | ||
(function (E1) { | ||
E1["A"] = "ENUM_KEY"; | ||
})(E1 || (E1 = {})); | ||
var E2; | ||
(function (E2) { | ||
E2[E2["B"] = 0] = "B"; | ||
})(E2 || (E2 = {})); | ||
var t1 = (_a = {}, | ||
_a[n] = 1, | ||
_a[n] = 1, | ||
_a); | ||
var t2 = (_b = {}, | ||
_b[s] = 1, | ||
_b[s] = 1, | ||
_b); | ||
var t3 = (_c = {}, | ||
_c[E1.A] = 1, | ||
_c[E1.A] = 1, | ||
_c); | ||
var t4 = (_d = {}, | ||
_d[E2.B] = 1, | ||
_d[E2.B] = 1, | ||
_d); |
71 changes: 71 additions & 0 deletions
71
tests/baselines/reference/duplicateObjectLiteralProperty_computedName2.symbols
This file contains 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,71 @@ | ||
=== tests/cases/compiler/duplicateObjectLiteralProperty_computedName2.ts === | ||
const n = 1; | ||
>n : Symbol(n, Decl(duplicateObjectLiteralProperty_computedName2.ts, 0, 5)) | ||
|
||
const s = "s"; | ||
>s : Symbol(s, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 5)) | ||
|
||
enum E1 { A = "ENUM_KEY" } | ||
>E1 : Symbol(E1, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 14)) | ||
>A : Symbol(E1.A, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 9)) | ||
|
||
enum E2 { B } | ||
>E2 : Symbol(E2, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 26)) | ||
>B : Symbol(E2.B, Decl(duplicateObjectLiteralProperty_computedName2.ts, 3, 9)) | ||
|
||
const t1 = { | ||
>t1 : Symbol(t1, Decl(duplicateObjectLiteralProperty_computedName2.ts, 5, 5)) | ||
|
||
[n]: 1, | ||
>[n] : Symbol([n], Decl(duplicateObjectLiteralProperty_computedName2.ts, 5, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 6, 11)) | ||
>n : Symbol(n, Decl(duplicateObjectLiteralProperty_computedName2.ts, 0, 5)) | ||
|
||
[n]: 1, // duplicate | ||
>[n] : Symbol([n], Decl(duplicateObjectLiteralProperty_computedName2.ts, 5, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 6, 11)) | ||
>n : Symbol(n, Decl(duplicateObjectLiteralProperty_computedName2.ts, 0, 5)) | ||
} | ||
|
||
const t2 = { | ||
>t2 : Symbol(t2, Decl(duplicateObjectLiteralProperty_computedName2.ts, 10, 5)) | ||
|
||
[s]: 1, | ||
>[s] : Symbol([s], Decl(duplicateObjectLiteralProperty_computedName2.ts, 10, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 11, 11)) | ||
>s : Symbol(s, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 5)) | ||
|
||
[s]: 1, // duplicate | ||
>[s] : Symbol([s], Decl(duplicateObjectLiteralProperty_computedName2.ts, 10, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 11, 11)) | ||
>s : Symbol(s, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 5)) | ||
} | ||
|
||
const t3 = { | ||
>t3 : Symbol(t3, Decl(duplicateObjectLiteralProperty_computedName2.ts, 15, 5)) | ||
|
||
[E1.A]: 1, | ||
>[E1.A] : Symbol([E1.A], Decl(duplicateObjectLiteralProperty_computedName2.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 16, 14)) | ||
>E1.A : Symbol(E1.A, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 9)) | ||
>E1 : Symbol(E1, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 14)) | ||
>A : Symbol(E1.A, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 9)) | ||
|
||
[E1.A]: 1, // duplicate | ||
>[E1.A] : Symbol([E1.A], Decl(duplicateObjectLiteralProperty_computedName2.ts, 15, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 16, 14)) | ||
>E1.A : Symbol(E1.A, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 9)) | ||
>E1 : Symbol(E1, Decl(duplicateObjectLiteralProperty_computedName2.ts, 1, 14)) | ||
>A : Symbol(E1.A, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 9)) | ||
} | ||
|
||
const t4 = { | ||
>t4 : Symbol(t4, Decl(duplicateObjectLiteralProperty_computedName2.ts, 20, 5)) | ||
|
||
[E2.B]: 1, | ||
>[E2.B] : Symbol([E2.B], Decl(duplicateObjectLiteralProperty_computedName2.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 21, 14)) | ||
>E2.B : Symbol(E2.B, Decl(duplicateObjectLiteralProperty_computedName2.ts, 3, 9)) | ||
>E2 : Symbol(E2, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 26)) | ||
>B : Symbol(E2.B, Decl(duplicateObjectLiteralProperty_computedName2.ts, 3, 9)) | ||
|
||
[E2.B]: 1, // duplicate | ||
>[E2.B] : Symbol([E2.B], Decl(duplicateObjectLiteralProperty_computedName2.ts, 20, 12), Decl(duplicateObjectLiteralProperty_computedName2.ts, 21, 14)) | ||
>E2.B : Symbol(E2.B, Decl(duplicateObjectLiteralProperty_computedName2.ts, 3, 9)) | ||
>E2 : Symbol(E2, Decl(duplicateObjectLiteralProperty_computedName2.ts, 2, 26)) | ||
>B : Symbol(E2.B, Decl(duplicateObjectLiteralProperty_computedName2.ts, 3, 9)) | ||
} | ||
|
Oops, something went wrong.