Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for computed properties in instance initializers (#31517)
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 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
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/instanceMemberWithComputedPropertyName.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,22 @@ | ||
//// [instanceMemberWithComputedPropertyName.ts] | ||
// https://github.com/microsoft/TypeScript/issues/30953 | ||
const x = 1; | ||
class C { | ||
[x] = true; | ||
constructor() { | ||
const { a, b } = { a: 1, b: 2 }; | ||
} | ||
} | ||
|
||
//// [instanceMemberWithComputedPropertyName.js] | ||
var _a; | ||
// https://github.com/microsoft/TypeScript/issues/30953 | ||
var x = 1; | ||
var C = /** @class */ (function () { | ||
function C() { | ||
this[_a] = true; | ||
var _b = { a: 1, b: 2 }, a = _b.a, b = _b.b; | ||
} | ||
return C; | ||
}()); | ||
_a = x; |
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/instanceMemberWithComputedPropertyName.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,20 @@ | ||
=== tests/cases/conformance/classes/propertyMemberDeclarations/instanceMemberWithComputedPropertyName.ts === | ||
// https://github.com/microsoft/TypeScript/issues/30953 | ||
const x = 1; | ||
>x : Symbol(x, Decl(instanceMemberWithComputedPropertyName.ts, 1, 5)) | ||
|
||
class C { | ||
>C : Symbol(C, Decl(instanceMemberWithComputedPropertyName.ts, 1, 12)) | ||
|
||
[x] = true; | ||
>[x] : Symbol(C[x], Decl(instanceMemberWithComputedPropertyName.ts, 2, 9)) | ||
>x : Symbol(x, Decl(instanceMemberWithComputedPropertyName.ts, 1, 5)) | ||
|
||
constructor() { | ||
const { a, b } = { a: 1, b: 2 }; | ||
>a : Symbol(a, Decl(instanceMemberWithComputedPropertyName.ts, 5, 15)) | ||
>b : Symbol(b, Decl(instanceMemberWithComputedPropertyName.ts, 5, 18)) | ||
>a : Symbol(a, Decl(instanceMemberWithComputedPropertyName.ts, 5, 26)) | ||
>b : Symbol(b, Decl(instanceMemberWithComputedPropertyName.ts, 5, 32)) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/instanceMemberWithComputedPropertyName.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=== tests/cases/conformance/classes/propertyMemberDeclarations/instanceMemberWithComputedPropertyName.ts === | ||
// https://github.com/microsoft/TypeScript/issues/30953 | ||
const x = 1; | ||
>x : 1 | ||
>1 : 1 | ||
|
||
class C { | ||
>C : C | ||
|
||
[x] = true; | ||
>[x] : boolean | ||
>x : 1 | ||
>true : true | ||
|
||
constructor() { | ||
const { a, b } = { a: 1, b: 2 }; | ||
>a : number | ||
>b : number | ||
>{ a: 1, b: 2 } : { a: number; b: number; } | ||
>a : number | ||
>1 : 1 | ||
>b : number | ||
>2 : 2 | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
.../conformance/classes/propertyMemberDeclarations/instanceMemberWithComputedPropertyName.ts
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,8 @@ | ||
// https://github.com/microsoft/TypeScript/issues/30953 | ||
const x = 1; | ||
class C { | ||
[x] = true; | ||
constructor() { | ||
const { a, b } = { a: 1, b: 2 }; | ||
} | ||
} |