-
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.
* Add static index * fix lint * make lint happy * adjust test cases * add more cases * fix changes * Add more case * accept baseline * fix error if extends others * Update vfsUtil.ts * use equal to empty array * static signature of interface is an error * Accept baseline * Check index constraints for static signature * Accpet baseline * Fix crash * fix crash * Accept baseline * Fix regression * Fix crash * always return new array
- Loading branch information
Showing
43 changed files
with
1,490 additions
and
70 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
6 changes: 3 additions & 3 deletions
6
tests/baselines/reference/parserIndexMemberDeclaration10.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts(2,4): error TS1071: 'static' modifier cannot appear on an index signature. | ||
tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts(2,11): error TS1030: 'static' modifier already seen. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript5/IndexMemberDeclarations/parserIndexMemberDeclaration10.ts (1 errors) ==== | ||
class C { | ||
static static [x: string]: string; | ||
~~~~~~ | ||
!!! error TS1071: 'static' modifier cannot appear on an index signature. | ||
~~~~~~ | ||
!!! error TS1030: 'static' modifier already seen. | ||
} |
9 changes: 0 additions & 9 deletions
9
tests/baselines/reference/parserIndexMemberDeclaration6.errors.txt
This file was deleted.
Oops, something went wrong.
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,9 +1,9 @@ | ||
tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,5): error TS1071: 'static' modifier cannot appear on an index signature. | ||
tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts(2,13): error TS1023: An index signature parameter type must be either 'string' or 'number'. | ||
|
||
|
||
==== tests/cases/conformance/parser/ecmascript6/Symbols/parserSymbolIndexer3.ts (1 errors) ==== | ||
class C { | ||
static [s: symbol]: string; | ||
~~~~~~ | ||
!!! error TS1071: 'static' modifier cannot appear on an index signature. | ||
~ | ||
!!! error TS1023: An index signature parameter type must be either 'string' or 'number'. | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/staticIndexSignature1.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,17 @@ | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts(10,1): error TS2322: Type '2' is not assignable to type '42'. | ||
|
||
|
||
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts (1 errors) ==== | ||
class C { | ||
static [s: string]: number; | ||
static [s: number]: 42 | ||
} | ||
|
||
C["foo"] = 1 | ||
C.bar = 2; | ||
const foo = C["foo"] | ||
C[42] = 42 | ||
C[2] = 2; | ||
~~~~ | ||
!!! error TS2322: Type '2' is not assignable to type '42'. | ||
const bar = C[42] |
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 @@ | ||
//// [staticIndexSignature1.ts] | ||
class C { | ||
static [s: string]: number; | ||
static [s: number]: 42 | ||
} | ||
|
||
C["foo"] = 1 | ||
C.bar = 2; | ||
const foo = C["foo"] | ||
C[42] = 42 | ||
C[2] = 2; | ||
const bar = C[42] | ||
|
||
//// [staticIndexSignature1.js] | ||
var C = /** @class */ (function () { | ||
function C() { | ||
} | ||
return C; | ||
}()); | ||
C["foo"] = 1; | ||
C.bar = 2; | ||
var foo = C["foo"]; | ||
C[42] = 42; | ||
C[2] = 2; | ||
var bar = C[42]; |
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,31 @@ | ||
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts === | ||
class C { | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
static [s: string]: number; | ||
>s : Symbol(s, Decl(staticIndexSignature1.ts, 1, 12)) | ||
|
||
static [s: number]: 42 | ||
>s : Symbol(s, Decl(staticIndexSignature1.ts, 2, 12)) | ||
} | ||
|
||
C["foo"] = 1 | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
C.bar = 2; | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
const foo = C["foo"] | ||
>foo : Symbol(foo, Decl(staticIndexSignature1.ts, 7, 5)) | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
C[42] = 42 | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
C[2] = 2; | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
||
const bar = C[42] | ||
>bar : Symbol(bar, Decl(staticIndexSignature1.ts, 10, 5)) | ||
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0)) | ||
|
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,51 @@ | ||
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts === | ||
class C { | ||
>C : C | ||
|
||
static [s: string]: number; | ||
>s : string | ||
|
||
static [s: number]: 42 | ||
>s : number | ||
} | ||
|
||
C["foo"] = 1 | ||
>C["foo"] = 1 : 1 | ||
>C["foo"] : number | ||
>C : typeof C | ||
>"foo" : "foo" | ||
>1 : 1 | ||
|
||
C.bar = 2; | ||
>C.bar = 2 : 2 | ||
>C.bar : number | ||
>C : typeof C | ||
>bar : number | ||
>2 : 2 | ||
|
||
const foo = C["foo"] | ||
>foo : number | ||
>C["foo"] : number | ||
>C : typeof C | ||
>"foo" : "foo" | ||
|
||
C[42] = 42 | ||
>C[42] = 42 : 42 | ||
>C[42] : 42 | ||
>C : typeof C | ||
>42 : 42 | ||
>42 : 42 | ||
|
||
C[2] = 2; | ||
>C[2] = 2 : 2 | ||
>C[2] : 42 | ||
>C : typeof C | ||
>2 : 2 | ||
>2 : 2 | ||
|
||
const bar = C[42] | ||
>bar : 42 | ||
>C[42] : 42 | ||
>C : typeof C | ||
>42 : 42 | ||
|
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/staticIndexSignature2.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,29 @@ | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(6,1): error TS2542: Index signature in type 'typeof C' only permits reading. | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(7,1): error TS2542: Index signature in type 'typeof C' only permits reading. | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(9,1): error TS2542: Index signature in type 'typeof C' only permits reading. | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2322: Type '2' is not assignable to type '42'. | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2542: Index signature in type 'typeof C' only permits reading. | ||
|
||
|
||
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts (5 errors) ==== | ||
class C { | ||
static readonly [s: string]: number; | ||
static readonly [s: number]: 42 | ||
} | ||
|
||
C["foo"] = 1 | ||
~~~~~~~~ | ||
!!! error TS2542: Index signature in type 'typeof C' only permits reading. | ||
C.bar = 2; | ||
~~~~~ | ||
!!! error TS2542: Index signature in type 'typeof C' only permits reading. | ||
const foo = C["foo"] | ||
C[42] = 42 | ||
~~~~~ | ||
!!! error TS2542: Index signature in type 'typeof C' only permits reading. | ||
C[2] = 2; | ||
~~~~ | ||
!!! error TS2322: Type '2' is not assignable to type '42'. | ||
~~~~ | ||
!!! error TS2542: Index signature in type 'typeof C' only permits reading. | ||
const bar = C[42] |
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 @@ | ||
//// [staticIndexSignature2.ts] | ||
class C { | ||
static readonly [s: string]: number; | ||
static readonly [s: number]: 42 | ||
} | ||
|
||
C["foo"] = 1 | ||
C.bar = 2; | ||
const foo = C["foo"] | ||
C[42] = 42 | ||
C[2] = 2; | ||
const bar = C[42] | ||
|
||
//// [staticIndexSignature2.js] | ||
var C = /** @class */ (function () { | ||
function C() { | ||
} | ||
return C; | ||
}()); | ||
C["foo"] = 1; | ||
C.bar = 2; | ||
var foo = C["foo"]; | ||
C[42] = 42; | ||
C[2] = 2; | ||
var bar = C[42]; |
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,31 @@ | ||
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts === | ||
class C { | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
static readonly [s: string]: number; | ||
>s : Symbol(s, Decl(staticIndexSignature2.ts, 1, 21)) | ||
|
||
static readonly [s: number]: 42 | ||
>s : Symbol(s, Decl(staticIndexSignature2.ts, 2, 21)) | ||
} | ||
|
||
C["foo"] = 1 | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
C.bar = 2; | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
const foo = C["foo"] | ||
>foo : Symbol(foo, Decl(staticIndexSignature2.ts, 7, 5)) | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
C[42] = 42 | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
C[2] = 2; | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
||
const bar = C[42] | ||
>bar : Symbol(bar, Decl(staticIndexSignature2.ts, 10, 5)) | ||
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0)) | ||
|
Oops, something went wrong.