|
| 1 | +=== tests/cases/compiler/selfReferencingTypeReferenceInference.ts === |
| 2 | +interface Box<T> { |
| 3 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 0, 14)) |
| 5 | + |
| 6 | + __: T |
| 7 | +>__ : Symbol(Box.__, Decl(selfReferencingTypeReferenceInference.ts, 0, 18)) |
| 8 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 0, 14)) |
| 9 | +} |
| 10 | + |
| 11 | +type Recursive<T> = |
| 12 | +>Recursive : Symbol(Recursive, Decl(selfReferencingTypeReferenceInference.ts, 2, 1)) |
| 13 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 4, 15)) |
| 14 | + |
| 15 | + | T |
| 16 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 4, 15)) |
| 17 | + |
| 18 | + | Box<Recursive<T>> |
| 19 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 20 | +>Recursive : Symbol(Recursive, Decl(selfReferencingTypeReferenceInference.ts, 2, 1)) |
| 21 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 4, 15)) |
| 22 | + |
| 23 | +type InferRecursive<T> = T extends Recursive<infer R> ? R : "never!" |
| 24 | +>InferRecursive : Symbol(InferRecursive, Decl(selfReferencingTypeReferenceInference.ts, 6, 23)) |
| 25 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 8, 20)) |
| 26 | +>T : Symbol(T, Decl(selfReferencingTypeReferenceInference.ts, 8, 20)) |
| 27 | +>Recursive : Symbol(Recursive, Decl(selfReferencingTypeReferenceInference.ts, 2, 1)) |
| 28 | +>R : Symbol(R, Decl(selfReferencingTypeReferenceInference.ts, 8, 50)) |
| 29 | +>R : Symbol(R, Decl(selfReferencingTypeReferenceInference.ts, 8, 50)) |
| 30 | + |
| 31 | +// the type we are testing with |
| 32 | +type t1 = Box<string | Box<number | boolean>> |
| 33 | +>t1 : Symbol(t1, Decl(selfReferencingTypeReferenceInference.ts, 8, 68)) |
| 34 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 35 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 36 | + |
| 37 | +type t2 = InferRecursive<t1> |
| 38 | +>t2 : Symbol(t2, Decl(selfReferencingTypeReferenceInference.ts, 11, 45)) |
| 39 | +>InferRecursive : Symbol(InferRecursive, Decl(selfReferencingTypeReferenceInference.ts, 6, 23)) |
| 40 | +>t1 : Symbol(t1, Decl(selfReferencingTypeReferenceInference.ts, 8, 68)) |
| 41 | + |
| 42 | +type t3 = InferRecursive<Box<string | Box<number | boolean>>> // write t1 explicitly |
| 43 | +>t3 : Symbol(t3, Decl(selfReferencingTypeReferenceInference.ts, 13, 28)) |
| 44 | +>InferRecursive : Symbol(InferRecursive, Decl(selfReferencingTypeReferenceInference.ts, 6, 23)) |
| 45 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 46 | +>Box : Symbol(Box, Decl(selfReferencingTypeReferenceInference.ts, 0, 0)) |
| 47 | + |
| 48 | + // Why is t2 and t3 different?? |
| 49 | + // They have same input type! |
0 commit comments