|
| 1 | +//// [tests/cases/compiler/stringIndexSignatureIndexedAccess.ts] //// |
| 2 | + |
| 3 | +=== stringIndexSignatureIndexedAccess.ts === |
| 4 | +type AsNumber<T> = T extends number ? T : never; |
| 5 | +>AsNumber : Symbol(AsNumber, Decl(stringIndexSignatureIndexedAccess.ts, 0, 0)) |
| 6 | +>T : Symbol(T, Decl(stringIndexSignatureIndexedAccess.ts, 0, 14)) |
| 7 | +>T : Symbol(T, Decl(stringIndexSignatureIndexedAccess.ts, 0, 14)) |
| 8 | +>T : Symbol(T, Decl(stringIndexSignatureIndexedAccess.ts, 0, 14)) |
| 9 | + |
| 10 | +interface Dict { |
| 11 | +>Dict : Symbol(Dict, Decl(stringIndexSignatureIndexedAccess.ts, 0, 48)) |
| 12 | + |
| 13 | + [key: string]: number; |
| 14 | +>key : Symbol(key, Decl(stringIndexSignatureIndexedAccess.ts, 3, 5)) |
| 15 | +} |
| 16 | + |
| 17 | +class ClassDict { |
| 18 | +>ClassDict : Symbol(ClassDict, Decl(stringIndexSignatureIndexedAccess.ts, 4, 1)) |
| 19 | + |
| 20 | + [key: string]: number; |
| 21 | +>key : Symbol(key, Decl(stringIndexSignatureIndexedAccess.ts, 7, 5)) |
| 22 | +} |
| 23 | + |
| 24 | +interface GenericDict<T> { |
| 25 | +>GenericDict : Symbol(GenericDict, Decl(stringIndexSignatureIndexedAccess.ts, 8, 1)) |
| 26 | +>T : Symbol(T, Decl(stringIndexSignatureIndexedAccess.ts, 10, 22)) |
| 27 | + |
| 28 | + [key: string]: T; |
| 29 | +>key : Symbol(key, Decl(stringIndexSignatureIndexedAccess.ts, 11, 5)) |
| 30 | +>T : Symbol(T, Decl(stringIndexSignatureIndexedAccess.ts, 10, 22)) |
| 31 | +} |
| 32 | + |
| 33 | +declare function takesDict<K extends string>(x: AsNumber<Dict[K]>): void; |
| 34 | +>takesDict : Symbol(takesDict, Decl(stringIndexSignatureIndexedAccess.ts, 12, 1)) |
| 35 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 14, 27)) |
| 36 | +>x : Symbol(x, Decl(stringIndexSignatureIndexedAccess.ts, 14, 45)) |
| 37 | +>AsNumber : Symbol(AsNumber, Decl(stringIndexSignatureIndexedAccess.ts, 0, 0)) |
| 38 | +>Dict : Symbol(Dict, Decl(stringIndexSignatureIndexedAccess.ts, 0, 48)) |
| 39 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 14, 27)) |
| 40 | + |
| 41 | +declare function takesClass<K extends string>(x: AsNumber<ClassDict[K]>): void; |
| 42 | +>takesClass : Symbol(takesClass, Decl(stringIndexSignatureIndexedAccess.ts, 14, 73)) |
| 43 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 15, 28)) |
| 44 | +>x : Symbol(x, Decl(stringIndexSignatureIndexedAccess.ts, 15, 46)) |
| 45 | +>AsNumber : Symbol(AsNumber, Decl(stringIndexSignatureIndexedAccess.ts, 0, 0)) |
| 46 | +>ClassDict : Symbol(ClassDict, Decl(stringIndexSignatureIndexedAccess.ts, 4, 1)) |
| 47 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 15, 28)) |
| 48 | + |
| 49 | +declare function takesGeneric<K extends string>(x: AsNumber<GenericDict<number>[K]>): void; |
| 50 | +>takesGeneric : Symbol(takesGeneric, Decl(stringIndexSignatureIndexedAccess.ts, 15, 79)) |
| 51 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 16, 30)) |
| 52 | +>x : Symbol(x, Decl(stringIndexSignatureIndexedAccess.ts, 16, 48)) |
| 53 | +>AsNumber : Symbol(AsNumber, Decl(stringIndexSignatureIndexedAccess.ts, 0, 0)) |
| 54 | +>GenericDict : Symbol(GenericDict, Decl(stringIndexSignatureIndexedAccess.ts, 8, 1)) |
| 55 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 16, 30)) |
| 56 | + |
| 57 | +function test<K extends string>(dict: Dict[K], cls: ClassDict[K], generic: GenericDict<number>[K]) { |
| 58 | +>test : Symbol(test, Decl(stringIndexSignatureIndexedAccess.ts, 16, 91)) |
| 59 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 18, 14)) |
| 60 | +>dict : Symbol(dict, Decl(stringIndexSignatureIndexedAccess.ts, 18, 32)) |
| 61 | +>Dict : Symbol(Dict, Decl(stringIndexSignatureIndexedAccess.ts, 0, 48)) |
| 62 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 18, 14)) |
| 63 | +>cls : Symbol(cls, Decl(stringIndexSignatureIndexedAccess.ts, 18, 46)) |
| 64 | +>ClassDict : Symbol(ClassDict, Decl(stringIndexSignatureIndexedAccess.ts, 4, 1)) |
| 65 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 18, 14)) |
| 66 | +>generic : Symbol(generic, Decl(stringIndexSignatureIndexedAccess.ts, 18, 65)) |
| 67 | +>GenericDict : Symbol(GenericDict, Decl(stringIndexSignatureIndexedAccess.ts, 8, 1)) |
| 68 | +>K : Symbol(K, Decl(stringIndexSignatureIndexedAccess.ts, 18, 14)) |
| 69 | + |
| 70 | + takesDict(dict); |
| 71 | +>takesDict : Symbol(takesDict, Decl(stringIndexSignatureIndexedAccess.ts, 12, 1)) |
| 72 | +>dict : Symbol(dict, Decl(stringIndexSignatureIndexedAccess.ts, 18, 32)) |
| 73 | + |
| 74 | + takesClass(cls); |
| 75 | +>takesClass : Symbol(takesClass, Decl(stringIndexSignatureIndexedAccess.ts, 14, 73)) |
| 76 | +>cls : Symbol(cls, Decl(stringIndexSignatureIndexedAccess.ts, 18, 46)) |
| 77 | + |
| 78 | + takesGeneric(generic); |
| 79 | +>takesGeneric : Symbol(takesGeneric, Decl(stringIndexSignatureIndexedAccess.ts, 15, 79)) |
| 80 | +>generic : Symbol(generic, Decl(stringIndexSignatureIndexedAccess.ts, 18, 65)) |
| 81 | +} |
| 82 | + |
0 commit comments