|
| 1 | +=== tests/cases/compiler/identicalGenericConditionalsWithInferRelated.ts === |
| 2 | +function f<X>(arg: X) { |
| 3 | +>f : Symbol(f, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 0)) |
| 4 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 11)) |
| 5 | +>arg : Symbol(arg, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 14)) |
| 6 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 11)) |
| 7 | + |
| 8 | + type Cond1 = X extends [infer A] ? A : never; |
| 9 | +>Cond1 : Symbol(Cond1, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 23)) |
| 10 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 11)) |
| 11 | +>A : Symbol(A, Decl(identicalGenericConditionalsWithInferRelated.ts, 1, 33)) |
| 12 | +>A : Symbol(A, Decl(identicalGenericConditionalsWithInferRelated.ts, 1, 33)) |
| 13 | + |
| 14 | + type Cond2 = X extends [infer A] ? A : never; |
| 15 | +>Cond2 : Symbol(Cond2, Decl(identicalGenericConditionalsWithInferRelated.ts, 1, 49)) |
| 16 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 11)) |
| 17 | +>A : Symbol(A, Decl(identicalGenericConditionalsWithInferRelated.ts, 2, 33)) |
| 18 | +>A : Symbol(A, Decl(identicalGenericConditionalsWithInferRelated.ts, 2, 33)) |
| 19 | + |
| 20 | + let x: Cond1 = null as any; |
| 21 | +>x : Symbol(x, Decl(identicalGenericConditionalsWithInferRelated.ts, 4, 7)) |
| 22 | +>Cond1 : Symbol(Cond1, Decl(identicalGenericConditionalsWithInferRelated.ts, 0, 23)) |
| 23 | + |
| 24 | + let y: Cond2 = null as any; |
| 25 | +>y : Symbol(y, Decl(identicalGenericConditionalsWithInferRelated.ts, 5, 7)) |
| 26 | +>Cond2 : Symbol(Cond2, Decl(identicalGenericConditionalsWithInferRelated.ts, 1, 49)) |
| 27 | + |
| 28 | + x = y; // is err, should be ok |
| 29 | +>x : Symbol(x, Decl(identicalGenericConditionalsWithInferRelated.ts, 4, 7)) |
| 30 | +>y : Symbol(y, Decl(identicalGenericConditionalsWithInferRelated.ts, 5, 7)) |
| 31 | + |
| 32 | + y = x; // is err, should be ok |
| 33 | +>y : Symbol(y, Decl(identicalGenericConditionalsWithInferRelated.ts, 5, 7)) |
| 34 | +>x : Symbol(x, Decl(identicalGenericConditionalsWithInferRelated.ts, 4, 7)) |
| 35 | +} |
| 36 | + |
| 37 | +// repro from https://github.com/microsoft/TypeScript/issues/26627 |
| 38 | +export type Constructor<T> = new (...args: any[]) => T |
| 39 | +>Constructor : Symbol(Constructor, Decl(identicalGenericConditionalsWithInferRelated.ts, 8, 1)) |
| 40 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 24)) |
| 41 | +>args : Symbol(args, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 34)) |
| 42 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 24)) |
| 43 | + |
| 44 | +export type MappedResult<T> = |
| 45 | +>MappedResult : Symbol(MappedResult, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 54)) |
| 46 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 12, 25)) |
| 47 | + |
| 48 | + T extends Boolean ? boolean : |
| 49 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 12, 25)) |
| 50 | +>Boolean : Symbol(Boolean, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) |
| 51 | + |
| 52 | + T extends Number ? number : |
| 53 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 12, 25)) |
| 54 | +>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) |
| 55 | + |
| 56 | + T extends String ? string : |
| 57 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 12, 25)) |
| 58 | +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) |
| 59 | + |
| 60 | + T |
| 61 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 12, 25)) |
| 62 | + |
| 63 | + |
| 64 | +interface X { |
| 65 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 16, 5)) |
| 66 | + |
| 67 | + decode<C extends Constructor<any>>(ctor: C): MappedResult<C extends Constructor<infer T> ? T : never> |
| 68 | +>decode : Symbol(X.decode, Decl(identicalGenericConditionalsWithInferRelated.ts, 19, 13)) |
| 69 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 11)) |
| 70 | +>Constructor : Symbol(Constructor, Decl(identicalGenericConditionalsWithInferRelated.ts, 8, 1)) |
| 71 | +>ctor : Symbol(ctor, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 39)) |
| 72 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 11)) |
| 73 | +>MappedResult : Symbol(MappedResult, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 54)) |
| 74 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 11)) |
| 75 | +>Constructor : Symbol(Constructor, Decl(identicalGenericConditionalsWithInferRelated.ts, 8, 1)) |
| 76 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 89)) |
| 77 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 20, 89)) |
| 78 | +} |
| 79 | + |
| 80 | +class Y implements X { |
| 81 | +>Y : Symbol(Y, Decl(identicalGenericConditionalsWithInferRelated.ts, 21, 1)) |
| 82 | +>X : Symbol(X, Decl(identicalGenericConditionalsWithInferRelated.ts, 16, 5)) |
| 83 | + |
| 84 | + decode<C extends Constructor<any>>(ctor: C): MappedResult<C extends Constructor<infer T> ? T : never> { |
| 85 | +>decode : Symbol(Y.decode, Decl(identicalGenericConditionalsWithInferRelated.ts, 23, 22)) |
| 86 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 11)) |
| 87 | +>Constructor : Symbol(Constructor, Decl(identicalGenericConditionalsWithInferRelated.ts, 8, 1)) |
| 88 | +>ctor : Symbol(ctor, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 39)) |
| 89 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 11)) |
| 90 | +>MappedResult : Symbol(MappedResult, Decl(identicalGenericConditionalsWithInferRelated.ts, 11, 54)) |
| 91 | +>C : Symbol(C, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 11)) |
| 92 | +>Constructor : Symbol(Constructor, Decl(identicalGenericConditionalsWithInferRelated.ts, 8, 1)) |
| 93 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 89)) |
| 94 | +>T : Symbol(T, Decl(identicalGenericConditionalsWithInferRelated.ts, 24, 89)) |
| 95 | + |
| 96 | + throw new Error() |
| 97 | +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) |
| 98 | + } |
| 99 | +} |
| 100 | + |
0 commit comments