TypeScript/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.symbols
Anders Hejlsberg a4f9bf0fce
Create type aliases for unresolved type symbols (#45976)
* Create type aliases for unresolved type symbols

* Accept new baselines

* Update fourslash tests

* Unresolved import aliases create tagged unresolved symbols

* Add comments

* Accept new baselines

* Add fourslash tests
2021-09-23 13:21:27 -07:00

223 lines
7.9 KiB
Plaintext

=== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts ===
// String indexer types constrain the types of named properties in their containing type
interface MyNumber extends Number {
>MyNumber : Symbol(MyNumber, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 0, 0))
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
foo: number;
>foo : Symbol(MyNumber.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 2, 35))
}
class C {
>C : Symbol(C, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 4, 1))
[x: number]: string;
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 7, 5))
constructor() { } // ok
a: string; // ok
>a : Symbol(C.a, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 9, 21))
b: number; // ok
>b : Symbol(C.b, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 11, 14))
c: () => {} // ok
>c : Symbol(C.c, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 12, 14))
"d": string; // ok
>"d" : Symbol(C["d"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 13, 15))
"e": number; // ok
>"e" : Symbol(C["e"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 14, 16))
1.0: string; // ok
>1.0 : Symbol(C[1.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 15, 16))
2.0: number; // error
>2.0 : Symbol(C[2.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 16, 16))
"3.0": string; // ok
>"3.0" : Symbol(C["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 17, 16))
"4.0": number; // error
>"4.0" : Symbol(C["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 18, 18))
3.0: MyNumber // error
>3.0 : Symbol(C[3.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 19, 18))
>MyNumber : Symbol(MyNumber, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 0, 0))
get X() { // ok
>X : Symbol(C.X, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 20, 17), Decl(numericIndexerConstrainsPropertyDeclarations.ts, 24, 5))
return '';
}
set X(v) { } // ok
>X : Symbol(C.X, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 20, 17), Decl(numericIndexerConstrainsPropertyDeclarations.ts, 24, 5))
>v : Symbol(v, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 25, 10))
foo() {
>foo : Symbol(C.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 25, 16))
return '';
}
static sa: number; // ok
>sa : Symbol(C.sa, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 29, 5))
static sb: string; // ok
>sb : Symbol(C.sb, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 31, 22))
static foo() { } // ok
>foo : Symbol(C.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 32, 22))
static get X() { // ok
>X : Symbol(C.X, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 34, 20))
return 1;
}
}
interface I {
>I : Symbol(I, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 38, 1))
[x: number]: string;
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 41, 5))
a: string; // ok
>a : Symbol(I.a, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 41, 24))
b: number; // ok
>b : Symbol(I.b, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 43, 14))
c: () => {} // ok
>c : Symbol(I.c, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 44, 14))
"d": string; // ok
>"d" : Symbol(I["d"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 45, 15))
"e": number; // ok
>"e" : Symbol(I["e"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 46, 16))
1.0: string; // ok
>1.0 : Symbol(I[1.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 47, 16))
2.0: number; // error
>2.0 : Symbol(I[2.0], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 48, 16))
(): string; // ok
(x): number // ok
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 51, 5))
foo(): string; // ok
>foo : Symbol(I.foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 51, 15))
"3.0": string; // ok
>"3.0" : Symbol(I["3.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 52, 18))
"4.0": number; // error
>"4.0" : Symbol(I["4.0"], Decl(numericIndexerConstrainsPropertyDeclarations.ts, 53, 18))
f: MyNumber; // error
>f : Symbol(I.f, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 54, 18))
>MyNumber : Symbol(MyNumber, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 0, 0))
}
var a: {
>a : Symbol(a, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 58, 3))
[x: number]: string;
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 59, 5))
a: string; // ok
>a : Symbol(a, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 59, 24))
b: number; // ok
>b : Symbol(b, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 61, 14))
c: () => {} // ok
>c : Symbol(c, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 62, 14))
"d": string; // ok
>"d" : Symbol("d", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 63, 15))
"e": number; // ok
>"e" : Symbol("e", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 64, 16))
1.0: string; // ok
>1.0 : Symbol(1.0, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 65, 16))
2.0: number; // error
>2.0 : Symbol(2.0, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 66, 16))
(): string; // ok
(x): number // ok
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 69, 5))
foo(): string; // ok
>foo : Symbol(foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 69, 15))
"3.0": string; // ok
>"3.0" : Symbol("3.0", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 70, 18))
"4.0": number; // error
>"4.0" : Symbol("4.0", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 71, 18))
f: MyNumber; // error
>f : Symbol(f, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 72, 18))
>MyNumber : Symbol(MyNumber, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 0, 0))
}
// error
var b: { [x: number]: string; } = {
>b : Symbol(b, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 77, 3))
>x : Symbol(x, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 77, 10))
a: '',
>a : Symbol(a, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 77, 35))
b: 1,
>b : Symbol(b, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 78, 10))
c: () => { },
>c : Symbol(c, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 79, 9))
"d": '',
>"d" : Symbol("d", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 80, 17))
"e": 1,
>"e" : Symbol("e", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 81, 12))
1.0: '',
>1.0 : Symbol(1.0, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 82, 11))
2.0: 1,
>2.0 : Symbol(2.0, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 83, 12))
"3.0": '',
>"3.0" : Symbol("3.0", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 84, 11))
"4.0": 1,
>"4.0" : Symbol("4.0", Decl(numericIndexerConstrainsPropertyDeclarations.ts, 85, 14))
f: <Myn>null,
>f : Symbol(f, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 86, 13))
>Myn : Symbol(Myn)
get X() {
>X : Symbol(X, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 87, 17), Decl(numericIndexerConstrainsPropertyDeclarations.ts, 91, 6))
return '';
},
set X(v) { },
>X : Symbol(X, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 87, 17), Decl(numericIndexerConstrainsPropertyDeclarations.ts, 91, 6))
>v : Symbol(v, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 92, 10))
foo() {
>foo : Symbol(foo, Decl(numericIndexerConstrainsPropertyDeclarations.ts, 92, 17))
return '';
}
}