|
| 1 | +//// [tests/cases/compiler/reverseMappedTupleContext.ts] //// |
| 2 | + |
| 3 | +=== reverseMappedTupleContext.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/55382 |
| 5 | + |
| 6 | +declare function test1<T>(arg: { |
| 7 | +>test1 : Symbol(test1, Decl(reverseMappedTupleContext.ts, 0, 0)) |
| 8 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 2, 23)) |
| 9 | +>arg : Symbol(arg, Decl(reverseMappedTupleContext.ts, 2, 26)) |
| 10 | + |
| 11 | + [K in keyof T]: T[K]; |
| 12 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 3, 3)) |
| 13 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 2, 23)) |
| 14 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 2, 23)) |
| 15 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 3, 3)) |
| 16 | + |
| 17 | +}): T; |
| 18 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 2, 23)) |
| 19 | + |
| 20 | +const result1 = test1(["foo", 42]); |
| 21 | +>result1 : Symbol(result1, Decl(reverseMappedTupleContext.ts, 5, 5)) |
| 22 | +>test1 : Symbol(test1, Decl(reverseMappedTupleContext.ts, 0, 0)) |
| 23 | + |
| 24 | +declare function test2<T extends readonly unknown[]>(arg: { |
| 25 | +>test2 : Symbol(test2, Decl(reverseMappedTupleContext.ts, 5, 35)) |
| 26 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 7, 23)) |
| 27 | +>arg : Symbol(arg, Decl(reverseMappedTupleContext.ts, 7, 53)) |
| 28 | + |
| 29 | + [K in keyof T]: T[K]; |
| 30 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 8, 3)) |
| 31 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 7, 23)) |
| 32 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 7, 23)) |
| 33 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 8, 3)) |
| 34 | + |
| 35 | +}): T; |
| 36 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 7, 23)) |
| 37 | + |
| 38 | +const result2 = test2(["foo", 42]); |
| 39 | +>result2 : Symbol(result2, Decl(reverseMappedTupleContext.ts, 10, 5)) |
| 40 | +>test2 : Symbol(test2, Decl(reverseMappedTupleContext.ts, 5, 35)) |
| 41 | + |
| 42 | +type Schema = Record<string, unknown> | readonly unknown[]; |
| 43 | +>Schema : Symbol(Schema, Decl(reverseMappedTupleContext.ts, 10, 35)) |
| 44 | +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) |
| 45 | + |
| 46 | +type Definition<T> = { |
| 47 | +>Definition : Symbol(Definition, Decl(reverseMappedTupleContext.ts, 12, 59)) |
| 48 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 13, 16)) |
| 49 | + |
| 50 | + [K in keyof T]: (() => T[K]) | Definition<T[K]>; |
| 51 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 14, 3)) |
| 52 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 13, 16)) |
| 53 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 13, 16)) |
| 54 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 14, 3)) |
| 55 | +>Definition : Symbol(Definition, Decl(reverseMappedTupleContext.ts, 12, 59)) |
| 56 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 13, 16)) |
| 57 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 14, 3)) |
| 58 | + |
| 59 | +}; |
| 60 | +declare function create<T extends Schema>(definition: Definition<T>): T; |
| 61 | +>create : Symbol(create, Decl(reverseMappedTupleContext.ts, 15, 2)) |
| 62 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 16, 24)) |
| 63 | +>Schema : Symbol(Schema, Decl(reverseMappedTupleContext.ts, 10, 35)) |
| 64 | +>definition : Symbol(definition, Decl(reverseMappedTupleContext.ts, 16, 42)) |
| 65 | +>Definition : Symbol(Definition, Decl(reverseMappedTupleContext.ts, 12, 59)) |
| 66 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 16, 24)) |
| 67 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 16, 24)) |
| 68 | + |
| 69 | +const created1 = create([() => 1, [() => ""]]); |
| 70 | +>created1 : Symbol(created1, Decl(reverseMappedTupleContext.ts, 17, 5)) |
| 71 | +>create : Symbol(create, Decl(reverseMappedTupleContext.ts, 15, 2)) |
| 72 | + |
| 73 | +const created2 = create({ |
| 74 | +>created2 : Symbol(created2, Decl(reverseMappedTupleContext.ts, 18, 5)) |
| 75 | +>create : Symbol(create, Decl(reverseMappedTupleContext.ts, 15, 2)) |
| 76 | + |
| 77 | + a: () => 1, |
| 78 | +>a : Symbol(a, Decl(reverseMappedTupleContext.ts, 18, 25)) |
| 79 | + |
| 80 | + b: [() => ""], |
| 81 | +>b : Symbol(b, Decl(reverseMappedTupleContext.ts, 19, 13)) |
| 82 | + |
| 83 | +}); |
| 84 | + |
| 85 | +interface CompilerOptions { |
| 86 | +>CompilerOptions : Symbol(CompilerOptions, Decl(reverseMappedTupleContext.ts, 21, 3)) |
| 87 | + |
| 88 | + allowUnreachableCode?: boolean; |
| 89 | +>allowUnreachableCode : Symbol(CompilerOptions.allowUnreachableCode, Decl(reverseMappedTupleContext.ts, 23, 27)) |
| 90 | + |
| 91 | + allowUnusedLabels?: boolean; |
| 92 | +>allowUnusedLabels : Symbol(CompilerOptions.allowUnusedLabels, Decl(reverseMappedTupleContext.ts, 24, 33)) |
| 93 | + |
| 94 | + alwaysStrict?: boolean; |
| 95 | +>alwaysStrict : Symbol(CompilerOptions.alwaysStrict, Decl(reverseMappedTupleContext.ts, 25, 30)) |
| 96 | +} |
| 97 | +type KeepLiteralStrings<T extends string[]> = { |
| 98 | +>KeepLiteralStrings : Symbol(KeepLiteralStrings, Decl(reverseMappedTupleContext.ts, 27, 1)) |
| 99 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 28, 24)) |
| 100 | + |
| 101 | + [K in keyof T]: T[K]; |
| 102 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 29, 3)) |
| 103 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 28, 24)) |
| 104 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 28, 24)) |
| 105 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 29, 3)) |
| 106 | + |
| 107 | +}; |
| 108 | +declare function test4<T extends Record<string, string[]>>(obj: { |
| 109 | +>test4 : Symbol(test4, Decl(reverseMappedTupleContext.ts, 30, 2)) |
| 110 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 31, 23)) |
| 111 | +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) |
| 112 | +>obj : Symbol(obj, Decl(reverseMappedTupleContext.ts, 31, 59)) |
| 113 | + |
| 114 | + [K in keyof T & keyof CompilerOptions]: { |
| 115 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 32, 3)) |
| 116 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 31, 23)) |
| 117 | +>CompilerOptions : Symbol(CompilerOptions, Decl(reverseMappedTupleContext.ts, 21, 3)) |
| 118 | + |
| 119 | + dependencies: KeepLiteralStrings<T[K]>; |
| 120 | +>dependencies : Symbol(dependencies, Decl(reverseMappedTupleContext.ts, 32, 43)) |
| 121 | +>KeepLiteralStrings : Symbol(KeepLiteralStrings, Decl(reverseMappedTupleContext.ts, 27, 1)) |
| 122 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 31, 23)) |
| 123 | +>K : Symbol(K, Decl(reverseMappedTupleContext.ts, 32, 3)) |
| 124 | + |
| 125 | + }; |
| 126 | +}): T; |
| 127 | +>T : Symbol(T, Decl(reverseMappedTupleContext.ts, 31, 23)) |
| 128 | + |
| 129 | +const result4 = test4({ |
| 130 | +>result4 : Symbol(result4, Decl(reverseMappedTupleContext.ts, 36, 5)) |
| 131 | +>test4 : Symbol(test4, Decl(reverseMappedTupleContext.ts, 30, 2)) |
| 132 | + |
| 133 | + alwaysStrict: { |
| 134 | +>alwaysStrict : Symbol(alwaysStrict, Decl(reverseMappedTupleContext.ts, 36, 23)) |
| 135 | + |
| 136 | + dependencies: ["foo", "bar"], |
| 137 | +>dependencies : Symbol(dependencies, Decl(reverseMappedTupleContext.ts, 37, 17)) |
| 138 | + |
| 139 | + }, |
| 140 | + allowUnusedLabels: { |
| 141 | +>allowUnusedLabels : Symbol(allowUnusedLabels, Decl(reverseMappedTupleContext.ts, 39, 4)) |
| 142 | + |
| 143 | + dependencies: ["baz", "qwe"], |
| 144 | +>dependencies : Symbol(dependencies, Decl(reverseMappedTupleContext.ts, 40, 22)) |
| 145 | + |
| 146 | + }, |
| 147 | +}); |
| 148 | + |
0 commit comments