|
| 1 | +=== tests/cases/compiler/genericFunctionsAndConditionalInference.ts === |
| 2 | +interface Targets<A> { |
| 3 | +>Targets : Symbol(Targets, Decl(genericFunctionsAndConditionalInference.ts, 0, 0)) |
| 4 | +>A : Symbol(A, Decl(genericFunctionsAndConditionalInference.ts, 0, 18)) |
| 5 | + |
| 6 | + left: A |
| 7 | +>left : Symbol(Targets.left, Decl(genericFunctionsAndConditionalInference.ts, 0, 22)) |
| 8 | +>A : Symbol(A, Decl(genericFunctionsAndConditionalInference.ts, 0, 18)) |
| 9 | + |
| 10 | + right: A |
| 11 | +>right : Symbol(Targets.right, Decl(genericFunctionsAndConditionalInference.ts, 1, 11)) |
| 12 | +>A : Symbol(A, Decl(genericFunctionsAndConditionalInference.ts, 0, 18)) |
| 13 | +} |
| 14 | +type Target = keyof Targets<any> |
| 15 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 16 | +>Targets : Symbol(Targets, Decl(genericFunctionsAndConditionalInference.ts, 0, 0)) |
| 17 | + |
| 18 | +type Result<F extends Target, A> = Targets<A>[F] |
| 19 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 20 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 5, 12)) |
| 21 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 22 | +>A : Symbol(A, Decl(genericFunctionsAndConditionalInference.ts, 5, 29)) |
| 23 | +>Targets : Symbol(Targets, Decl(genericFunctionsAndConditionalInference.ts, 0, 0)) |
| 24 | +>A : Symbol(A, Decl(genericFunctionsAndConditionalInference.ts, 5, 29)) |
| 25 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 5, 12)) |
| 26 | + |
| 27 | +type LR<F extends Target, L, R> = [F] extends ["left"] ? L : R |
| 28 | +>LR : Symbol(LR, Decl(genericFunctionsAndConditionalInference.ts, 5, 48)) |
| 29 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 7, 8)) |
| 30 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 31 | +>L : Symbol(L, Decl(genericFunctionsAndConditionalInference.ts, 7, 25)) |
| 32 | +>R : Symbol(R, Decl(genericFunctionsAndConditionalInference.ts, 7, 28)) |
| 33 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 7, 8)) |
| 34 | +>L : Symbol(L, Decl(genericFunctionsAndConditionalInference.ts, 7, 25)) |
| 35 | +>R : Symbol(R, Decl(genericFunctionsAndConditionalInference.ts, 7, 28)) |
| 36 | + |
| 37 | +interface Ops<F extends Target> { |
| 38 | +>Ops : Symbol(Ops, Decl(genericFunctionsAndConditionalInference.ts, 7, 62)) |
| 39 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 40 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 41 | + |
| 42 | + _f: F |
| 43 | +>_f : Symbol(Ops._f, Decl(genericFunctionsAndConditionalInference.ts, 9, 33)) |
| 44 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 45 | + |
| 46 | + str: Result<F, string> |
| 47 | +>str : Symbol(Ops.str, Decl(genericFunctionsAndConditionalInference.ts, 10, 9)) |
| 48 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 49 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 50 | + |
| 51 | + num: Result<F, number> |
| 52 | +>num : Symbol(Ops.num, Decl(genericFunctionsAndConditionalInference.ts, 11, 26)) |
| 53 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 54 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 55 | + |
| 56 | + lr<I, O>(a: Result<F, I>, o: Result<F, O>): Result<F, LR<F, I, O>> |
| 57 | +>lr : Symbol(Ops.lr, Decl(genericFunctionsAndConditionalInference.ts, 12, 26)) |
| 58 | +>I : Symbol(I, Decl(genericFunctionsAndConditionalInference.ts, 13, 7)) |
| 59 | +>O : Symbol(O, Decl(genericFunctionsAndConditionalInference.ts, 13, 9)) |
| 60 | +>a : Symbol(a, Decl(genericFunctionsAndConditionalInference.ts, 13, 13)) |
| 61 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 62 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 63 | +>I : Symbol(I, Decl(genericFunctionsAndConditionalInference.ts, 13, 7)) |
| 64 | +>o : Symbol(o, Decl(genericFunctionsAndConditionalInference.ts, 13, 29)) |
| 65 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 66 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 67 | +>O : Symbol(O, Decl(genericFunctionsAndConditionalInference.ts, 13, 9)) |
| 68 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 69 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 70 | +>LR : Symbol(LR, Decl(genericFunctionsAndConditionalInference.ts, 5, 48)) |
| 71 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 72 | +>I : Symbol(I, Decl(genericFunctionsAndConditionalInference.ts, 13, 7)) |
| 73 | +>O : Symbol(O, Decl(genericFunctionsAndConditionalInference.ts, 13, 9)) |
| 74 | + |
| 75 | + dict: <P>(p: {[k in keyof P]: Result<F, P[k]>}) => Result<F, P> |
| 76 | +>dict : Symbol(Ops.dict, Decl(genericFunctionsAndConditionalInference.ts, 13, 70)) |
| 77 | +>P : Symbol(P, Decl(genericFunctionsAndConditionalInference.ts, 14, 11)) |
| 78 | +>p : Symbol(p, Decl(genericFunctionsAndConditionalInference.ts, 14, 14)) |
| 79 | +>k : Symbol(k, Decl(genericFunctionsAndConditionalInference.ts, 14, 19)) |
| 80 | +>P : Symbol(P, Decl(genericFunctionsAndConditionalInference.ts, 14, 11)) |
| 81 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 82 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 83 | +>P : Symbol(P, Decl(genericFunctionsAndConditionalInference.ts, 14, 11)) |
| 84 | +>k : Symbol(k, Decl(genericFunctionsAndConditionalInference.ts, 14, 19)) |
| 85 | +>Result : Symbol(Result, Decl(genericFunctionsAndConditionalInference.ts, 4, 32)) |
| 86 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 9, 14)) |
| 87 | +>P : Symbol(P, Decl(genericFunctionsAndConditionalInference.ts, 14, 11)) |
| 88 | +} |
| 89 | +const left: Ops<"left"> = {} as any |
| 90 | +>left : Symbol(left, Decl(genericFunctionsAndConditionalInference.ts, 16, 5)) |
| 91 | +>Ops : Symbol(Ops, Decl(genericFunctionsAndConditionalInference.ts, 7, 62)) |
| 92 | + |
| 93 | +const right: Ops<"right"> = {} as any |
| 94 | +>right : Symbol(right, Decl(genericFunctionsAndConditionalInference.ts, 17, 5)) |
| 95 | +>Ops : Symbol(Ops, Decl(genericFunctionsAndConditionalInference.ts, 7, 62)) |
| 96 | + |
| 97 | +const ok = <F extends Target>(at: Ops<F>) => ({lr: at.lr(at.str, at.num)}) |
| 98 | +>ok : Symbol(ok, Decl(genericFunctionsAndConditionalInference.ts, 19, 5)) |
| 99 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 19, 12)) |
| 100 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 101 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 19, 30)) |
| 102 | +>Ops : Symbol(Ops, Decl(genericFunctionsAndConditionalInference.ts, 7, 62)) |
| 103 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 19, 12)) |
| 104 | +>lr : Symbol(lr, Decl(genericFunctionsAndConditionalInference.ts, 19, 47)) |
| 105 | +>at.lr : Symbol(Ops.lr, Decl(genericFunctionsAndConditionalInference.ts, 12, 26)) |
| 106 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 19, 30)) |
| 107 | +>lr : Symbol(Ops.lr, Decl(genericFunctionsAndConditionalInference.ts, 12, 26)) |
| 108 | +>at.str : Symbol(Ops.str, Decl(genericFunctionsAndConditionalInference.ts, 10, 9)) |
| 109 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 19, 30)) |
| 110 | +>str : Symbol(Ops.str, Decl(genericFunctionsAndConditionalInference.ts, 10, 9)) |
| 111 | +>at.num : Symbol(Ops.num, Decl(genericFunctionsAndConditionalInference.ts, 11, 26)) |
| 112 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 19, 30)) |
| 113 | +>num : Symbol(Ops.num, Decl(genericFunctionsAndConditionalInference.ts, 11, 26)) |
| 114 | + |
| 115 | +const orphaned = <F extends Target>(at: Ops<F>) => at.dict(ok(at)) |
| 116 | +>orphaned : Symbol(orphaned, Decl(genericFunctionsAndConditionalInference.ts, 20, 5)) |
| 117 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 20, 18)) |
| 118 | +>Target : Symbol(Target, Decl(genericFunctionsAndConditionalInference.ts, 3, 1)) |
| 119 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 20, 36)) |
| 120 | +>Ops : Symbol(Ops, Decl(genericFunctionsAndConditionalInference.ts, 7, 62)) |
| 121 | +>F : Symbol(F, Decl(genericFunctionsAndConditionalInference.ts, 20, 18)) |
| 122 | +>at.dict : Symbol(Ops.dict, Decl(genericFunctionsAndConditionalInference.ts, 13, 70)) |
| 123 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 20, 36)) |
| 124 | +>dict : Symbol(Ops.dict, Decl(genericFunctionsAndConditionalInference.ts, 13, 70)) |
| 125 | +>ok : Symbol(ok, Decl(genericFunctionsAndConditionalInference.ts, 19, 5)) |
| 126 | +>at : Symbol(at, Decl(genericFunctionsAndConditionalInference.ts, 20, 36)) |
| 127 | + |
| 128 | +const leftOk = ok(left) |
| 129 | +>leftOk : Symbol(leftOk, Decl(genericFunctionsAndConditionalInference.ts, 22, 5)) |
| 130 | +>ok : Symbol(ok, Decl(genericFunctionsAndConditionalInference.ts, 19, 5)) |
| 131 | +>left : Symbol(left, Decl(genericFunctionsAndConditionalInference.ts, 16, 5)) |
| 132 | + |
| 133 | +const leftOrphaned = orphaned(left) |
| 134 | +>leftOrphaned : Symbol(leftOrphaned, Decl(genericFunctionsAndConditionalInference.ts, 23, 5)) |
| 135 | +>orphaned : Symbol(orphaned, Decl(genericFunctionsAndConditionalInference.ts, 20, 5)) |
| 136 | +>left : Symbol(left, Decl(genericFunctionsAndConditionalInference.ts, 16, 5)) |
| 137 | + |
| 138 | +const rightOk = ok(right) |
| 139 | +>rightOk : Symbol(rightOk, Decl(genericFunctionsAndConditionalInference.ts, 25, 5)) |
| 140 | +>ok : Symbol(ok, Decl(genericFunctionsAndConditionalInference.ts, 19, 5)) |
| 141 | +>right : Symbol(right, Decl(genericFunctionsAndConditionalInference.ts, 17, 5)) |
| 142 | + |
| 143 | +const rightOrphaned = orphaned(right) |
| 144 | +>rightOrphaned : Symbol(rightOrphaned, Decl(genericFunctionsAndConditionalInference.ts, 26, 5)) |
| 145 | +>orphaned : Symbol(orphaned, Decl(genericFunctionsAndConditionalInference.ts, 20, 5)) |
| 146 | +>right : Symbol(right, Decl(genericFunctionsAndConditionalInference.ts, 17, 5)) |
| 147 | + |
0 commit comments