forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick PR microsoft#44129 into release-4.3
Component commits: 7a9854c Ensure static index signatures have an errorNode available 626b431 Merge branch 'master' into error-node-static-index-signatures a8327a0 Lookup static index signature declarations in the right symbol table, stop checking prototype props
- Loading branch information
1 parent
27d6e44
commit 5903f4d
Showing
6 changed files
with
79 additions
and
4 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
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/staticIndexSignature3.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,33 @@ | ||
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(12,5): error TS2413: Numeric index type '1' is not assignable to string index type 'boolean'. | ||
|
||
|
||
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts (1 errors) ==== | ||
class B { | ||
static readonly [s: string]: number; | ||
static readonly [s: number]: 42 | 233 | ||
} | ||
|
||
class D extends B { | ||
static readonly [s: string]: number | ||
} | ||
|
||
class ED extends D { | ||
static readonly [s: string]: boolean | ||
static readonly [s: number]: 1 | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2413: Numeric index type '1' is not assignable to string index type 'boolean'. | ||
} | ||
|
||
class DD extends D { | ||
static readonly [s: string]: 421 | ||
} | ||
|
||
const a = B["f"]; | ||
const b = B[42]; | ||
const c = D["f"] | ||
const d = D[42] | ||
const e = ED["f"] | ||
const f = ED[42] | ||
const g = DD["f"] | ||
const h = DD[42] | ||
|
12 changes: 12 additions & 0 deletions
12
tests/baselines/reference/staticIndexSignatureAndNormalIndexSignature.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,12 @@ | ||
//// [staticIndexSignatureAndNormalIndexSignature.ts] | ||
class Foo { | ||
[p: string]: any; | ||
static [p: string]: number; | ||
} | ||
|
||
//// [staticIndexSignatureAndNormalIndexSignature.js] | ||
var Foo = /** @class */ (function () { | ||
function Foo() { | ||
} | ||
return Foo; | ||
}()); |
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/staticIndexSignatureAndNormalIndexSignature.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,10 @@ | ||
=== tests/cases/compiler/staticIndexSignatureAndNormalIndexSignature.ts === | ||
class Foo { | ||
>Foo : Symbol(Foo, Decl(staticIndexSignatureAndNormalIndexSignature.ts, 0, 0)) | ||
|
||
[p: string]: any; | ||
>p : Symbol(p, Decl(staticIndexSignatureAndNormalIndexSignature.ts, 1, 5)) | ||
|
||
static [p: string]: number; | ||
>p : Symbol(p, Decl(staticIndexSignatureAndNormalIndexSignature.ts, 2, 12)) | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/staticIndexSignatureAndNormalIndexSignature.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,10 @@ | ||
=== tests/cases/compiler/staticIndexSignatureAndNormalIndexSignature.ts === | ||
class Foo { | ||
>Foo : Foo | ||
|
||
[p: string]: any; | ||
>p : string | ||
|
||
static [p: string]: number; | ||
>p : string | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/cases/compiler/staticIndexSignatureAndNormalIndexSignature.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,4 @@ | ||
class Foo { | ||
[p: string]: any; | ||
static [p: string]: number; | ||
} |