-
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.
Signed-off-by: Joey Watts <jwatts43@bloomberg.net>
- Loading branch information
Joey Watts
committed
Jun 27, 2019
1 parent
1608291
commit 5bea122
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/classExpressionInLoop.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,13 @@ | ||
tests/cases/conformance/classes/classExpressions/classExpressionInLoop.ts(5,9): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
|
||
|
||
==== tests/cases/conformance/classes/classExpressions/classExpressionInLoop.ts (1 errors) ==== | ||
let arr = []; | ||
for (let i = 0; i < 5; ++i) | ||
arr.push(class C { | ||
static hello = () => i; | ||
[i] = i; | ||
~~~ | ||
!!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. | ||
}); | ||
|
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,26 @@ | ||
//// [classExpressionInLoop.ts] | ||
let arr = []; | ||
for (let i = 0; i < 5; ++i) | ||
arr.push(class C { | ||
static hello = () => i; | ||
[i] = i; | ||
}); | ||
|
||
|
||
//// [classExpressionInLoop.js] | ||
var _a, _b; | ||
var arr = []; | ||
var _loop_1 = function (i) { | ||
arr.push((_b = /** @class */ (function () { | ||
function C() { | ||
this[_a] = i; | ||
} | ||
return C; | ||
}()), | ||
_a = i, | ||
_b.hello = function () { return i; }, | ||
_b)); | ||
}; | ||
for (var i = 0; i < 5; ++i) { | ||
_loop_1(i); | ||
} |
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,26 @@ | ||
=== tests/cases/conformance/classes/classExpressions/classExpressionInLoop.ts === | ||
let arr = []; | ||
>arr : Symbol(arr, Decl(classExpressionInLoop.ts, 0, 3)) | ||
|
||
for (let i = 0; i < 5; ++i) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
|
||
arr.push(class C { | ||
>arr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) | ||
>arr : Symbol(arr, Decl(classExpressionInLoop.ts, 0, 3)) | ||
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) | ||
>C : Symbol(C, Decl(classExpressionInLoop.ts, 2, 13)) | ||
|
||
static hello = () => i; | ||
>hello : Symbol(C.hello, Decl(classExpressionInLoop.ts, 2, 22)) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
|
||
[i] = i; | ||
>[i] : Symbol(C[i], Decl(classExpressionInLoop.ts, 3, 31)) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
>i : Symbol(i, Decl(classExpressionInLoop.ts, 1, 8)) | ||
|
||
}); | ||
|
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,34 @@ | ||
=== tests/cases/conformance/classes/classExpressions/classExpressionInLoop.ts === | ||
let arr = []; | ||
>arr : any[] | ||
>[] : undefined[] | ||
|
||
for (let i = 0; i < 5; ++i) | ||
>i : number | ||
>0 : 0 | ||
>i < 5 : boolean | ||
>i : number | ||
>5 : 5 | ||
>++i : number | ||
>i : number | ||
|
||
arr.push(class C { | ||
>arr.push(class C { static hello = () => i; [i] = i; }) : number | ||
>arr.push : (...items: any[]) => number | ||
>arr : any[] | ||
>push : (...items: any[]) => number | ||
>class C { static hello = () => i; [i] = i; } : typeof C | ||
>C : typeof C | ||
|
||
static hello = () => i; | ||
>hello : () => number | ||
>() => i : () => number | ||
>i : number | ||
|
||
[i] = i; | ||
>[i] : number | ||
>i : number | ||
>i : number | ||
|
||
}); | ||
|
6 changes: 6 additions & 0 deletions
6
tests/cases/conformance/classes/classExpressions/classExpressionInLoop.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,6 @@ | ||
let arr = []; | ||
for (let i = 0; i < 5; ++i) | ||
arr.push(class C { | ||
static hello = () => i; | ||
[i] = i; | ||
}); |