|
| 1 | +//// [tests/cases/conformance/types/typeRelationships/typeInference/noInferSubstitutionTypes1.ts] //// |
| 2 | + |
| 3 | +=== noInferSubstitutionTypes1.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/59826 |
| 5 | + |
| 6 | +declare function g<A>(a: A, b: A extends string ? `rel:${NoInfer<A>}` : never): A; |
| 7 | +>g : Symbol(g, Decl(noInferSubstitutionTypes1.ts, 0, 0)) |
| 8 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 2, 19)) |
| 9 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 2, 22)) |
| 10 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 2, 19)) |
| 11 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 2, 27)) |
| 12 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 2, 19)) |
| 13 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 14 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 2, 19)) |
| 15 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 2, 19)) |
| 16 | + |
| 17 | +const result1 = g("5", "rel:7"); // error |
| 18 | +>result1 : Symbol(result1, Decl(noInferSubstitutionTypes1.ts, 3, 5)) |
| 19 | +>g : Symbol(g, Decl(noInferSubstitutionTypes1.ts, 0, 0)) |
| 20 | + |
| 21 | +declare function g2<A>(a: A, b: A extends string ? NoInfer<`rel:${A}`> : never): A; |
| 22 | +>g2 : Symbol(g2, Decl(noInferSubstitutionTypes1.ts, 3, 32)) |
| 23 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 5, 20)) |
| 24 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 5, 23)) |
| 25 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 5, 20)) |
| 26 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 5, 28)) |
| 27 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 5, 20)) |
| 28 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 29 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 5, 20)) |
| 30 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 5, 20)) |
| 31 | + |
| 32 | +const result2 = g2("5", "rel:7"); // error |
| 33 | +>result2 : Symbol(result2, Decl(noInferSubstitutionTypes1.ts, 6, 5)) |
| 34 | +>g2 : Symbol(g2, Decl(noInferSubstitutionTypes1.ts, 3, 32)) |
| 35 | + |
| 36 | +declare function g3<A>(a: A, b: NoInfer<A extends string ? `rel:${A}` : never>): A; |
| 37 | +>g3 : Symbol(g3, Decl(noInferSubstitutionTypes1.ts, 6, 33)) |
| 38 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 8, 20)) |
| 39 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 8, 23)) |
| 40 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 8, 20)) |
| 41 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 8, 28)) |
| 42 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 43 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 8, 20)) |
| 44 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 8, 20)) |
| 45 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 8, 20)) |
| 46 | + |
| 47 | +const result3 = g3("5", "rel:7"); // error |
| 48 | +>result3 : Symbol(result3, Decl(noInferSubstitutionTypes1.ts, 9, 5)) |
| 49 | +>g3 : Symbol(g3, Decl(noInferSubstitutionTypes1.ts, 6, 33)) |
| 50 | + |
| 51 | +declare function h<const A>(a: A, b: A extends string ? NoInfer<A> : never): A; |
| 52 | +>h : Symbol(h, Decl(noInferSubstitutionTypes1.ts, 9, 33)) |
| 53 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 11, 19)) |
| 54 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 11, 28)) |
| 55 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 11, 19)) |
| 56 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 11, 33)) |
| 57 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 11, 19)) |
| 58 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 59 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 11, 19)) |
| 60 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 11, 19)) |
| 61 | + |
| 62 | +const result4 = h("foo", "bar"); // error |
| 63 | +>result4 : Symbol(result4, Decl(noInferSubstitutionTypes1.ts, 12, 5)) |
| 64 | +>h : Symbol(h, Decl(noInferSubstitutionTypes1.ts, 9, 33)) |
| 65 | + |
| 66 | +declare function h2<const A>(a: A, b: NoInfer<A> extends string ? NoInfer<A> : never): A; |
| 67 | +>h2 : Symbol(h2, Decl(noInferSubstitutionTypes1.ts, 12, 32)) |
| 68 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 14, 20)) |
| 69 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 14, 29)) |
| 70 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 14, 20)) |
| 71 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 14, 34)) |
| 72 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 73 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 14, 20)) |
| 74 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 75 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 14, 20)) |
| 76 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 14, 20)) |
| 77 | + |
| 78 | +const result5 = h2("foo", "bar"); // error |
| 79 | +>result5 : Symbol(result5, Decl(noInferSubstitutionTypes1.ts, 15, 5)) |
| 80 | +>h2 : Symbol(h2, Decl(noInferSubstitutionTypes1.ts, 12, 32)) |
| 81 | + |
| 82 | +declare function h3<const A>(a: A, b: NoInfer<A> extends string ? A : never): A; |
| 83 | +>h3 : Symbol(h3, Decl(noInferSubstitutionTypes1.ts, 15, 33)) |
| 84 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 17, 20)) |
| 85 | +>a : Symbol(a, Decl(noInferSubstitutionTypes1.ts, 17, 29)) |
| 86 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 17, 20)) |
| 87 | +>b : Symbol(b, Decl(noInferSubstitutionTypes1.ts, 17, 34)) |
| 88 | +>NoInfer : Symbol(NoInfer, Decl(lib.es5.d.ts, --, --)) |
| 89 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 17, 20)) |
| 90 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 17, 20)) |
| 91 | +>A : Symbol(A, Decl(noInferSubstitutionTypes1.ts, 17, 20)) |
| 92 | + |
| 93 | +const result6 = h3("foo", "bar"); // no error |
| 94 | +>result6 : Symbol(result6, Decl(noInferSubstitutionTypes1.ts, 18, 5)) |
| 95 | +>h3 : Symbol(h3, Decl(noInferSubstitutionTypes1.ts, 15, 33)) |
| 96 | + |
| 97 | +const result7 = h3("foo", 42); // error |
| 98 | +>result7 : Symbol(result7, Decl(noInferSubstitutionTypes1.ts, 19, 5)) |
| 99 | +>h3 : Symbol(h3, Decl(noInferSubstitutionTypes1.ts, 15, 33)) |
| 100 | + |
0 commit comments