|
| 1 | +=== tests/cases/compiler/inferenceAndHKTs.ts === |
| 2 | +// Repro from #53970 |
| 3 | + |
| 4 | +export interface TypeLambda { |
| 5 | +>TypeLambda : Symbol(TypeLambda, Decl(inferenceAndHKTs.ts, 0, 0)) |
| 6 | + |
| 7 | + readonly A: unknown; |
| 8 | +>A : Symbol(TypeLambda.A, Decl(inferenceAndHKTs.ts, 2, 29)) |
| 9 | +} |
| 10 | + |
| 11 | +export interface TypeClass<F extends TypeLambda> { |
| 12 | +>TypeClass : Symbol(TypeClass, Decl(inferenceAndHKTs.ts, 4, 1)) |
| 13 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 6, 27)) |
| 14 | +>TypeLambda : Symbol(TypeLambda, Decl(inferenceAndHKTs.ts, 0, 0)) |
| 15 | + |
| 16 | + readonly _F: F; |
| 17 | +>_F : Symbol(TypeClass._F, Decl(inferenceAndHKTs.ts, 6, 50)) |
| 18 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 6, 27)) |
| 19 | +} |
| 20 | + |
| 21 | +export type Apply<F extends TypeLambda, A> = F extends { readonly type: unknown } |
| 22 | +>Apply : Symbol(Apply, Decl(inferenceAndHKTs.ts, 8, 1)) |
| 23 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 10, 18)) |
| 24 | +>TypeLambda : Symbol(TypeLambda, Decl(inferenceAndHKTs.ts, 0, 0)) |
| 25 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 10, 39)) |
| 26 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 10, 18)) |
| 27 | +>type : Symbol(type, Decl(inferenceAndHKTs.ts, 10, 56)) |
| 28 | + |
| 29 | + ? (F & { readonly A: A })['type'] |
| 30 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 10, 18)) |
| 31 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 11, 12)) |
| 32 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 10, 39)) |
| 33 | + |
| 34 | + : { readonly F: F, readonly A: A }; |
| 35 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 12, 7)) |
| 36 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 10, 18)) |
| 37 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 12, 22)) |
| 38 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 10, 39)) |
| 39 | + |
| 40 | +export interface T<A> { |
| 41 | +>T : Symbol(T, Decl(inferenceAndHKTs.ts, 12, 39)) |
| 42 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 14, 19)) |
| 43 | + |
| 44 | + value: A; |
| 45 | +>value : Symbol(T.value, Decl(inferenceAndHKTs.ts, 14, 23)) |
| 46 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 14, 19)) |
| 47 | +} |
| 48 | + |
| 49 | +export interface TTypeLambda extends TypeLambda { |
| 50 | +>TTypeLambda : Symbol(TTypeLambda, Decl(inferenceAndHKTs.ts, 16, 1)) |
| 51 | +>TypeLambda : Symbol(TypeLambda, Decl(inferenceAndHKTs.ts, 0, 0)) |
| 52 | + |
| 53 | + readonly type: T<this["A"]>; |
| 54 | +>type : Symbol(TTypeLambda.type, Decl(inferenceAndHKTs.ts, 18, 49)) |
| 55 | +>T : Symbol(T, Decl(inferenceAndHKTs.ts, 12, 39)) |
| 56 | +} |
| 57 | + |
| 58 | +export declare const map: <F extends TypeLambda>(F: TypeClass<F>) => <A, B>(a: Apply<F, A>, f: (a: A) => B) => Apply<F, B>; |
| 59 | +>map : Symbol(map, Decl(inferenceAndHKTs.ts, 22, 20)) |
| 60 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 22, 27), Decl(inferenceAndHKTs.ts, 22, 49)) |
| 61 | +>TypeLambda : Symbol(TypeLambda, Decl(inferenceAndHKTs.ts, 0, 0)) |
| 62 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 22, 27), Decl(inferenceAndHKTs.ts, 22, 49)) |
| 63 | +>TypeClass : Symbol(TypeClass, Decl(inferenceAndHKTs.ts, 4, 1)) |
| 64 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 22, 27), Decl(inferenceAndHKTs.ts, 22, 49)) |
| 65 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 22, 70)) |
| 66 | +>B : Symbol(B, Decl(inferenceAndHKTs.ts, 22, 72)) |
| 67 | +>a : Symbol(a, Decl(inferenceAndHKTs.ts, 22, 76)) |
| 68 | +>Apply : Symbol(Apply, Decl(inferenceAndHKTs.ts, 8, 1)) |
| 69 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 22, 27), Decl(inferenceAndHKTs.ts, 22, 49)) |
| 70 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 22, 70)) |
| 71 | +>f : Symbol(f, Decl(inferenceAndHKTs.ts, 22, 91)) |
| 72 | +>a : Symbol(a, Decl(inferenceAndHKTs.ts, 22, 96)) |
| 73 | +>A : Symbol(A, Decl(inferenceAndHKTs.ts, 22, 70)) |
| 74 | +>B : Symbol(B, Decl(inferenceAndHKTs.ts, 22, 72)) |
| 75 | +>Apply : Symbol(Apply, Decl(inferenceAndHKTs.ts, 8, 1)) |
| 76 | +>F : Symbol(F, Decl(inferenceAndHKTs.ts, 22, 27), Decl(inferenceAndHKTs.ts, 22, 49)) |
| 77 | +>B : Symbol(B, Decl(inferenceAndHKTs.ts, 22, 72)) |
| 78 | + |
| 79 | +declare const typeClass: TypeClass<TTypeLambda>; |
| 80 | +>typeClass : Symbol(typeClass, Decl(inferenceAndHKTs.ts, 24, 13)) |
| 81 | +>TypeClass : Symbol(TypeClass, Decl(inferenceAndHKTs.ts, 4, 1)) |
| 82 | +>TTypeLambda : Symbol(TTypeLambda, Decl(inferenceAndHKTs.ts, 16, 1)) |
| 83 | + |
| 84 | +declare const a: T<number>; |
| 85 | +>a : Symbol(a, Decl(inferenceAndHKTs.ts, 26, 13)) |
| 86 | +>T : Symbol(T, Decl(inferenceAndHKTs.ts, 12, 39)) |
| 87 | + |
| 88 | +const x1 = map(typeClass); |
| 89 | +>x1 : Symbol(x1, Decl(inferenceAndHKTs.ts, 28, 5)) |
| 90 | +>map : Symbol(map, Decl(inferenceAndHKTs.ts, 22, 20)) |
| 91 | +>typeClass : Symbol(typeClass, Decl(inferenceAndHKTs.ts, 24, 13)) |
| 92 | + |
| 93 | +const x2 = map(typeClass)(a, (_) => _); // T<number> |
| 94 | +>x2 : Symbol(x2, Decl(inferenceAndHKTs.ts, 29, 5)) |
| 95 | +>map : Symbol(map, Decl(inferenceAndHKTs.ts, 22, 20)) |
| 96 | +>typeClass : Symbol(typeClass, Decl(inferenceAndHKTs.ts, 24, 13)) |
| 97 | +>a : Symbol(a, Decl(inferenceAndHKTs.ts, 26, 13)) |
| 98 | +>_ : Symbol(_, Decl(inferenceAndHKTs.ts, 29, 30)) |
| 99 | +>_ : Symbol(_, Decl(inferenceAndHKTs.ts, 29, 30)) |
| 100 | + |
0 commit comments