1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
=== tests/cases/conformance/types/mapped/mappedTypes3.ts ===
class Box<P> {
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
>P : Symbol(P, Decl(mappedTypes3.ts, 0, 10))
value: P;
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 0, 14))
>P : Symbol(P, Decl(mappedTypes3.ts, 0, 10))
}
type Boxified<T> = {
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 2, 1))
>T : Symbol(T, Decl(mappedTypes3.ts, 4, 14))
[K in keyof T]: Box<T[K]>;
>K : Symbol(K, Decl(mappedTypes3.ts, 5, 5))
>T : Symbol(T, Decl(mappedTypes3.ts, 4, 14))
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
>T : Symbol(T, Decl(mappedTypes3.ts, 4, 14))
>K : Symbol(K, Decl(mappedTypes3.ts, 5, 5))
}
declare function boxify<T>(obj: T): Boxified<T>;
>boxify : Symbol(boxify, Decl(mappedTypes3.ts, 6, 1))
>T : Symbol(T, Decl(mappedTypes3.ts, 8, 24))
>obj : Symbol(obj, Decl(mappedTypes3.ts, 8, 27))
>T : Symbol(T, Decl(mappedTypes3.ts, 8, 24))
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 2, 1))
>T : Symbol(T, Decl(mappedTypes3.ts, 8, 24))
declare function unboxify<T>(obj: Boxified<T>): T;
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 8, 48))
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 26))
>obj : Symbol(obj, Decl(mappedTypes3.ts, 9, 29))
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 2, 1))
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 26))
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 26))
interface Bacon {
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 9, 50))
isPerfect: boolean;
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 11, 17))
weight: number;
>weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 12, 23))
}
interface BoxifiedBacon {
>BoxifiedBacon : Symbol(BoxifiedBacon, Decl(mappedTypes3.ts, 14, 1))
isPerfect: Box<boolean>;
>isPerfect : Symbol(BoxifiedBacon.isPerfect, Decl(mappedTypes3.ts, 16, 25))
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
weight: Box<number>;
>weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 17, 28))
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
}
function f1(b: Bacon) {
>f1 : Symbol(f1, Decl(mappedTypes3.ts, 19, 1))
>b : Symbol(b, Decl(mappedTypes3.ts, 21, 12))
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 9, 50))
let bb = boxify(b);
>bb : Symbol(bb, Decl(mappedTypes3.ts, 22, 7))
>boxify : Symbol(boxify, Decl(mappedTypes3.ts, 6, 1))
>b : Symbol(b, Decl(mappedTypes3.ts, 21, 12))
let isPerfect = bb.isPerfect.value;
>isPerfect : Symbol(isPerfect, Decl(mappedTypes3.ts, 23, 7))
>bb.isPerfect.value : Symbol(Box.value, Decl(mappedTypes3.ts, 0, 14))
>bb.isPerfect : Symbol(isPerfect, Decl(mappedTypes3.ts, 11, 17))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 22, 7))
>isPerfect : Symbol(isPerfect, Decl(mappedTypes3.ts, 11, 17))
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 0, 14))
let weight = bb.weight.value;
>weight : Symbol(weight, Decl(mappedTypes3.ts, 24, 7))
>bb.weight.value : Symbol(Box.value, Decl(mappedTypes3.ts, 0, 14))
>bb.weight : Symbol(weight, Decl(mappedTypes3.ts, 12, 23))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 22, 7))
>weight : Symbol(weight, Decl(mappedTypes3.ts, 12, 23))
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 0, 14))
}
function f2(bb: Boxified<Bacon>) {
>f2 : Symbol(f2, Decl(mappedTypes3.ts, 25, 1))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 27, 12))
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 2, 1))
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 9, 50))
let b = unboxify(bb); // Infer Bacon for T
>b : Symbol(b, Decl(mappedTypes3.ts, 28, 7))
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 8, 48))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 27, 12))
let bool = b.isPerfect;
>bool : Symbol(bool, Decl(mappedTypes3.ts, 29, 7))
>b.isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 11, 17))
>b : Symbol(b, Decl(mappedTypes3.ts, 28, 7))
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 11, 17))
let weight = b.weight;
>weight : Symbol(weight, Decl(mappedTypes3.ts, 30, 7))
>b.weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 12, 23))
>b : Symbol(b, Decl(mappedTypes3.ts, 28, 7))
>weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 12, 23))
}
function f3(bb: BoxifiedBacon) {
>f3 : Symbol(f3, Decl(mappedTypes3.ts, 31, 1))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 33, 12))
>BoxifiedBacon : Symbol(BoxifiedBacon, Decl(mappedTypes3.ts, 14, 1))
let b = unboxify<Bacon>(bb); // Explicit type parameter required
>b : Symbol(b, Decl(mappedTypes3.ts, 34, 7))
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 8, 48))
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 9, 50))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 33, 12))
let bool = b.isPerfect;
>bool : Symbol(bool, Decl(mappedTypes3.ts, 35, 7))
>b.isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 11, 17))
>b : Symbol(b, Decl(mappedTypes3.ts, 34, 7))
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 11, 17))
let weight = bb.weight;
>weight : Symbol(weight, Decl(mappedTypes3.ts, 36, 7))
>bb.weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 17, 28))
>bb : Symbol(bb, Decl(mappedTypes3.ts, 33, 12))
>weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 17, 28))
}
|