-
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.
Test Literal-typed computed property names in obj literals
- Loading branch information
Showing
14 changed files
with
501 additions
and
20 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
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
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
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
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
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
108 changes: 108 additions & 0 deletions
108
tests/baselines/reference/objectLiteralEnumPropertyNames.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,108 @@ | ||
//// [objectLiteralEnumPropertyNames.ts] | ||
// Fixes #16887 | ||
enum Strs { | ||
A = 'a', | ||
B = 'b' | ||
} | ||
type TestStrs = { [key in Strs]: string } | ||
const x: TestStrs = { | ||
[Strs.A]: 'xo', | ||
[Strs.B]: 'xe' | ||
} | ||
const ux = { | ||
[Strs.A]: 'xo', | ||
[Strs.B]: 'xe' | ||
} | ||
const y: TestStrs = { | ||
['a']: 'yo', | ||
['b']: 'ye' | ||
} | ||
const a = 'a'; | ||
const b = 'b'; | ||
const z: TestStrs = { | ||
[a]: 'zo', | ||
[b]: 'ze' | ||
} | ||
const uz = { | ||
[a]: 'zo', | ||
[b]: 'ze' | ||
} | ||
|
||
enum Nums { | ||
A, | ||
B | ||
} | ||
type TestNums = { 0: number, 1: number } | ||
const n: TestNums = { | ||
[Nums.A]: 1, | ||
[Nums.B]: 2 | ||
} | ||
const un = { | ||
[Nums.A]: 3, | ||
[Nums.B]: 4 | ||
} | ||
const an = 0; | ||
const bn = 1; | ||
const m: TestNums = { | ||
[an]: 5, | ||
[bn]: 6 | ||
} | ||
const um = { | ||
[an]: 7, | ||
[bn]: 8 | ||
} | ||
|
||
|
||
//// [objectLiteralEnumPropertyNames.js] | ||
// Fixes #16887 | ||
var Strs; | ||
(function (Strs) { | ||
Strs["A"] = "a"; | ||
Strs["B"] = "b"; | ||
})(Strs || (Strs = {})); | ||
var x = (_a = {}, | ||
_a[Strs.A] = 'xo', | ||
_a[Strs.B] = 'xe', | ||
_a); | ||
var ux = (_b = {}, | ||
_b[Strs.A] = 'xo', | ||
_b[Strs.B] = 'xe', | ||
_b); | ||
var y = (_c = {}, | ||
_c['a'] = 'yo', | ||
_c['b'] = 'ye', | ||
_c); | ||
var a = 'a'; | ||
var b = 'b'; | ||
var z = (_d = {}, | ||
_d[a] = 'zo', | ||
_d[b] = 'ze', | ||
_d); | ||
var uz = (_e = {}, | ||
_e[a] = 'zo', | ||
_e[b] = 'ze', | ||
_e); | ||
var Nums; | ||
(function (Nums) { | ||
Nums[Nums["A"] = 0] = "A"; | ||
Nums[Nums["B"] = 1] = "B"; | ||
})(Nums || (Nums = {})); | ||
var n = (_f = {}, | ||
_f[Nums.A] = 1, | ||
_f[Nums.B] = 2, | ||
_f); | ||
var un = (_g = {}, | ||
_g[Nums.A] = 3, | ||
_g[Nums.B] = 4, | ||
_g); | ||
var an = 0; | ||
var bn = 1; | ||
var m = (_h = {}, | ||
_h[an] = 5, | ||
_h[bn] = 6, | ||
_h); | ||
var um = (_j = {}, | ||
_j[an] = 7, | ||
_j[bn] = 8, | ||
_j); | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; |
144 changes: 144 additions & 0 deletions
144
tests/baselines/reference/objectLiteralEnumPropertyNames.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,144 @@ | ||
=== tests/cases/compiler/objectLiteralEnumPropertyNames.ts === | ||
// Fixes #16887 | ||
enum Strs { | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
|
||
A = 'a', | ||
>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) | ||
|
||
B = 'b' | ||
>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) | ||
} | ||
type TestStrs = { [key in Strs]: string } | ||
>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) | ||
>key : Symbol(key, Decl(objectLiteralEnumPropertyNames.ts, 5, 19)) | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
|
||
const x: TestStrs = { | ||
>x : Symbol(x, Decl(objectLiteralEnumPropertyNames.ts, 6, 5)) | ||
>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) | ||
|
||
[Strs.A]: 'xo', | ||
>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) | ||
|
||
[Strs.B]: 'xe' | ||
>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) | ||
} | ||
const ux = { | ||
>ux : Symbol(ux, Decl(objectLiteralEnumPropertyNames.ts, 10, 5)) | ||
|
||
[Strs.A]: 'xo', | ||
>Strs.A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
>A : Symbol(Strs.A, Decl(objectLiteralEnumPropertyNames.ts, 1, 11)) | ||
|
||
[Strs.B]: 'xe' | ||
>Strs.B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) | ||
>Strs : Symbol(Strs, Decl(objectLiteralEnumPropertyNames.ts, 0, 0)) | ||
>B : Symbol(Strs.B, Decl(objectLiteralEnumPropertyNames.ts, 2, 12)) | ||
} | ||
const y: TestStrs = { | ||
>y : Symbol(y, Decl(objectLiteralEnumPropertyNames.ts, 14, 5)) | ||
>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) | ||
|
||
['a']: 'yo', | ||
>'a' : Symbol(['a'], Decl(objectLiteralEnumPropertyNames.ts, 14, 21)) | ||
|
||
['b']: 'ye' | ||
>'b' : Symbol(['b'], Decl(objectLiteralEnumPropertyNames.ts, 15, 16)) | ||
} | ||
const a = 'a'; | ||
>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) | ||
|
||
const b = 'b'; | ||
>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) | ||
|
||
const z: TestStrs = { | ||
>z : Symbol(z, Decl(objectLiteralEnumPropertyNames.ts, 20, 5)) | ||
>TestStrs : Symbol(TestStrs, Decl(objectLiteralEnumPropertyNames.ts, 4, 1)) | ||
|
||
[a]: 'zo', | ||
>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) | ||
|
||
[b]: 'ze' | ||
>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) | ||
} | ||
const uz = { | ||
>uz : Symbol(uz, Decl(objectLiteralEnumPropertyNames.ts, 24, 5)) | ||
|
||
[a]: 'zo', | ||
>a : Symbol(a, Decl(objectLiteralEnumPropertyNames.ts, 18, 5)) | ||
|
||
[b]: 'ze' | ||
>b : Symbol(b, Decl(objectLiteralEnumPropertyNames.ts, 19, 5)) | ||
} | ||
|
||
enum Nums { | ||
>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) | ||
|
||
A, | ||
>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) | ||
|
||
B | ||
>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) | ||
} | ||
type TestNums = { 0: number, 1: number } | ||
>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) | ||
|
||
const n: TestNums = { | ||
>n : Symbol(n, Decl(objectLiteralEnumPropertyNames.ts, 34, 5)) | ||
>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) | ||
|
||
[Nums.A]: 1, | ||
>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) | ||
>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) | ||
>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) | ||
|
||
[Nums.B]: 2 | ||
>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) | ||
>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) | ||
>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) | ||
} | ||
const un = { | ||
>un : Symbol(un, Decl(objectLiteralEnumPropertyNames.ts, 38, 5)) | ||
|
||
[Nums.A]: 3, | ||
>Nums.A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) | ||
>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) | ||
>A : Symbol(Nums.A, Decl(objectLiteralEnumPropertyNames.ts, 29, 11)) | ||
|
||
[Nums.B]: 4 | ||
>Nums.B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) | ||
>Nums : Symbol(Nums, Decl(objectLiteralEnumPropertyNames.ts, 27, 1)) | ||
>B : Symbol(Nums.B, Decl(objectLiteralEnumPropertyNames.ts, 30, 6)) | ||
} | ||
const an = 0; | ||
>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) | ||
|
||
const bn = 1; | ||
>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) | ||
|
||
const m: TestNums = { | ||
>m : Symbol(m, Decl(objectLiteralEnumPropertyNames.ts, 44, 5)) | ||
>TestNums : Symbol(TestNums, Decl(objectLiteralEnumPropertyNames.ts, 32, 1)) | ||
|
||
[an]: 5, | ||
>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) | ||
|
||
[bn]: 6 | ||
>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) | ||
} | ||
const um = { | ||
>um : Symbol(um, Decl(objectLiteralEnumPropertyNames.ts, 48, 5)) | ||
|
||
[an]: 7, | ||
>an : Symbol(an, Decl(objectLiteralEnumPropertyNames.ts, 42, 5)) | ||
|
||
[bn]: 8 | ||
>bn : Symbol(bn, Decl(objectLiteralEnumPropertyNames.ts, 43, 5)) | ||
} | ||
|
Oops, something went wrong.