// @declaration: true
class Box
{
value: P;
}
type Boxified = {
[K in keyof T]: Box;
}
declare function boxify(obj: T): Boxified;
declare function unboxify(obj: Boxified): T;
interface Bacon {
isPerfect: boolean;
weight: number;
}
interface BoxifiedBacon {
isPerfect: Box;
weight: Box;
}
function f1(b: Bacon) {
let bb = boxify(b);
let isPerfect = bb.isPerfect.value;
let weight = bb.weight.value;
}
function f2(bb: Boxified) {
let b = unboxify(bb); // Infer Bacon for T
let bool = b.isPerfect;
let weight = b.weight;
}
function f3(bb: BoxifiedBacon) {
let b = unboxify(bb); // Explicit type parameter required
let bool = b.isPerfect;
let weight = bb.weight;
}