TypeScript/tests/baselines/reference/staticIndexSignature2.types
Wenlu Wang 41dc625b0a
Add static index signature (#37797)
* 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
2021-03-26 15:30:09 -07:00

52 lines
711 B
Plaintext

=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts ===
class C {
>C : C
static readonly [s: string]: number;
>s : string
static readonly [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