136 lines
5 KiB
Plaintext
136 lines
5 KiB
Plaintext
=== tests/cases/conformance/types/mapped/mappedTypes3.ts ===
|
|
|
|
class Box<P> {
|
|
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
|
|
>P : Symbol(P, Decl(mappedTypes3.ts, 1, 10))
|
|
|
|
value: P;
|
|
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 1, 14))
|
|
>P : Symbol(P, Decl(mappedTypes3.ts, 1, 10))
|
|
}
|
|
|
|
type Boxified<T> = {
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 3, 1))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 5, 14))
|
|
|
|
[K in keyof T]: Box<T[K]>;
|
|
>K : Symbol(K, Decl(mappedTypes3.ts, 6, 5))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 5, 14))
|
|
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 5, 14))
|
|
>K : Symbol(K, Decl(mappedTypes3.ts, 6, 5))
|
|
}
|
|
|
|
declare function boxify<T>(obj: T): Boxified<T>;
|
|
>boxify : Symbol(boxify, Decl(mappedTypes3.ts, 7, 1))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 24))
|
|
>obj : Symbol(obj, Decl(mappedTypes3.ts, 9, 27))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 24))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 3, 1))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 9, 24))
|
|
|
|
declare function unboxify<T>(obj: Boxified<T>): T;
|
|
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 9, 48))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 10, 26))
|
|
>obj : Symbol(obj, Decl(mappedTypes3.ts, 10, 29))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 3, 1))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 10, 26))
|
|
>T : Symbol(T, Decl(mappedTypes3.ts, 10, 26))
|
|
|
|
interface Bacon {
|
|
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 10, 50))
|
|
|
|
isPerfect: boolean;
|
|
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 12, 17))
|
|
|
|
weight: number;
|
|
>weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 13, 23))
|
|
}
|
|
|
|
interface BoxifiedBacon {
|
|
>BoxifiedBacon : Symbol(BoxifiedBacon, Decl(mappedTypes3.ts, 15, 1))
|
|
|
|
isPerfect: Box<boolean>;
|
|
>isPerfect : Symbol(BoxifiedBacon.isPerfect, Decl(mappedTypes3.ts, 17, 25))
|
|
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
|
|
|
|
weight: Box<number>;
|
|
>weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 18, 28))
|
|
>Box : Symbol(Box, Decl(mappedTypes3.ts, 0, 0))
|
|
}
|
|
|
|
function f1(b: Bacon) {
|
|
>f1 : Symbol(f1, Decl(mappedTypes3.ts, 20, 1))
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 22, 12))
|
|
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 10, 50))
|
|
|
|
let bb = boxify(b);
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 23, 7))
|
|
>boxify : Symbol(boxify, Decl(mappedTypes3.ts, 7, 1))
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 22, 12))
|
|
|
|
let isPerfect = bb.isPerfect.value;
|
|
>isPerfect : Symbol(isPerfect, Decl(mappedTypes3.ts, 24, 7))
|
|
>bb.isPerfect.value : Symbol(Box.value, Decl(mappedTypes3.ts, 1, 14))
|
|
>bb.isPerfect : Symbol(isPerfect)
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 23, 7))
|
|
>isPerfect : Symbol(isPerfect)
|
|
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 1, 14))
|
|
|
|
let weight = bb.weight.value;
|
|
>weight : Symbol(weight, Decl(mappedTypes3.ts, 25, 7))
|
|
>bb.weight.value : Symbol(Box.value, Decl(mappedTypes3.ts, 1, 14))
|
|
>bb.weight : Symbol(weight)
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 23, 7))
|
|
>weight : Symbol(weight)
|
|
>value : Symbol(Box.value, Decl(mappedTypes3.ts, 1, 14))
|
|
}
|
|
|
|
function f2(bb: Boxified<Bacon>) {
|
|
>f2 : Symbol(f2, Decl(mappedTypes3.ts, 26, 1))
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 28, 12))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes3.ts, 3, 1))
|
|
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 10, 50))
|
|
|
|
let b = unboxify(bb); // Infer Bacon for T
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 29, 7))
|
|
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 9, 48))
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 28, 12))
|
|
|
|
let bool = b.isPerfect;
|
|
>bool : Symbol(bool, Decl(mappedTypes3.ts, 30, 7))
|
|
>b.isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 12, 17))
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 29, 7))
|
|
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 12, 17))
|
|
|
|
let weight = b.weight;
|
|
>weight : Symbol(weight, Decl(mappedTypes3.ts, 31, 7))
|
|
>b.weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 13, 23))
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 29, 7))
|
|
>weight : Symbol(Bacon.weight, Decl(mappedTypes3.ts, 13, 23))
|
|
}
|
|
|
|
function f3(bb: BoxifiedBacon) {
|
|
>f3 : Symbol(f3, Decl(mappedTypes3.ts, 32, 1))
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 34, 12))
|
|
>BoxifiedBacon : Symbol(BoxifiedBacon, Decl(mappedTypes3.ts, 15, 1))
|
|
|
|
let b = unboxify<Bacon>(bb); // Explicit type parameter required
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 35, 7))
|
|
>unboxify : Symbol(unboxify, Decl(mappedTypes3.ts, 9, 48))
|
|
>Bacon : Symbol(Bacon, Decl(mappedTypes3.ts, 10, 50))
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 34, 12))
|
|
|
|
let bool = b.isPerfect;
|
|
>bool : Symbol(bool, Decl(mappedTypes3.ts, 36, 7))
|
|
>b.isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 12, 17))
|
|
>b : Symbol(b, Decl(mappedTypes3.ts, 35, 7))
|
|
>isPerfect : Symbol(Bacon.isPerfect, Decl(mappedTypes3.ts, 12, 17))
|
|
|
|
let weight = bb.weight;
|
|
>weight : Symbol(weight, Decl(mappedTypes3.ts, 37, 7))
|
|
>bb.weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 18, 28))
|
|
>bb : Symbol(bb, Decl(mappedTypes3.ts, 34, 12))
|
|
>weight : Symbol(BoxifiedBacon.weight, Decl(mappedTypes3.ts, 18, 28))
|
|
}
|