|
| 1 | +=== tests/cases/compiler/objectRestBindingContextualInference.ts === |
| 2 | +// slimmed-down repro from #52629 |
| 3 | + |
| 4 | +type ImageHolder<K extends string> = { |
| 5 | +>ImageHolder : Symbol(ImageHolder, Decl(objectRestBindingContextualInference.ts, 0, 0)) |
| 6 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 2, 17)) |
| 7 | + |
| 8 | + [P in K]: string; |
| 9 | +>P : Symbol(P, Decl(objectRestBindingContextualInference.ts, 3, 3)) |
| 10 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 2, 17)) |
| 11 | + |
| 12 | +}; |
| 13 | + |
| 14 | +type SetupImageRefs<K extends string> = { |
| 15 | +>SetupImageRefs : Symbol(SetupImageRefs, Decl(objectRestBindingContextualInference.ts, 4, 2)) |
| 16 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 6, 20)) |
| 17 | + |
| 18 | + [P in K]: File; |
| 19 | +>P : Symbol(P, Decl(objectRestBindingContextualInference.ts, 7, 3)) |
| 20 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 6, 20)) |
| 21 | +>File : Symbol(File, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) |
| 22 | + |
| 23 | +}; |
| 24 | + |
| 25 | +type SetupImages<K extends string> = SetupImageRefs<K> & { |
| 26 | +>SetupImages : Symbol(SetupImages, Decl(objectRestBindingContextualInference.ts, 8, 2)) |
| 27 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 10, 17)) |
| 28 | +>SetupImageRefs : Symbol(SetupImageRefs, Decl(objectRestBindingContextualInference.ts, 4, 2)) |
| 29 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 10, 17)) |
| 30 | + |
| 31 | + prepare: () => { type: K }; |
| 32 | +>prepare : Symbol(prepare, Decl(objectRestBindingContextualInference.ts, 10, 58)) |
| 33 | +>type : Symbol(type, Decl(objectRestBindingContextualInference.ts, 11, 18)) |
| 34 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 10, 17)) |
| 35 | + |
| 36 | +}; |
| 37 | + |
| 38 | +interface TestInterface { |
| 39 | +>TestInterface : Symbol(TestInterface, Decl(objectRestBindingContextualInference.ts, 12, 2)) |
| 40 | + |
| 41 | + name: string; |
| 42 | +>name : Symbol(TestInterface.name, Decl(objectRestBindingContextualInference.ts, 14, 25)) |
| 43 | + |
| 44 | + image: string; |
| 45 | +>image : Symbol(TestInterface.image, Decl(objectRestBindingContextualInference.ts, 15, 15)) |
| 46 | +} |
| 47 | + |
| 48 | +declare function setupImages<R extends ImageHolder<K>, K extends string>( |
| 49 | +>setupImages : Symbol(setupImages, Decl(objectRestBindingContextualInference.ts, 17, 1)) |
| 50 | +>R : Symbol(R, Decl(objectRestBindingContextualInference.ts, 19, 29)) |
| 51 | +>ImageHolder : Symbol(ImageHolder, Decl(objectRestBindingContextualInference.ts, 0, 0)) |
| 52 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 19, 54)) |
| 53 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 19, 54)) |
| 54 | + |
| 55 | + item: R, |
| 56 | +>item : Symbol(item, Decl(objectRestBindingContextualInference.ts, 19, 73)) |
| 57 | +>R : Symbol(R, Decl(objectRestBindingContextualInference.ts, 19, 29)) |
| 58 | + |
| 59 | + keys: K[] |
| 60 | +>keys : Symbol(keys, Decl(objectRestBindingContextualInference.ts, 20, 10)) |
| 61 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 19, 54)) |
| 62 | + |
| 63 | +): SetupImages<K>; |
| 64 | +>SetupImages : Symbol(SetupImages, Decl(objectRestBindingContextualInference.ts, 8, 2)) |
| 65 | +>K : Symbol(K, Decl(objectRestBindingContextualInference.ts, 19, 54)) |
| 66 | + |
| 67 | +declare const test: TestInterface; |
| 68 | +>test : Symbol(test, Decl(objectRestBindingContextualInference.ts, 24, 13)) |
| 69 | +>TestInterface : Symbol(TestInterface, Decl(objectRestBindingContextualInference.ts, 12, 2)) |
| 70 | + |
| 71 | +const { prepare, ...rest } = setupImages(test, ["image"]); |
| 72 | +>prepare : Symbol(prepare, Decl(objectRestBindingContextualInference.ts, 26, 7)) |
| 73 | +>rest : Symbol(rest, Decl(objectRestBindingContextualInference.ts, 26, 16)) |
| 74 | +>setupImages : Symbol(setupImages, Decl(objectRestBindingContextualInference.ts, 17, 1)) |
| 75 | +>test : Symbol(test, Decl(objectRestBindingContextualInference.ts, 24, 13)) |
| 76 | + |
0 commit comments