230 lines
7.9 KiB
Plaintext
230 lines
7.9 KiB
Plaintext
=== tests/cases/conformance/types/mapped/mappedTypes4.ts ===
|
|
|
|
type Box<T> = {
|
|
>Box : Symbol(Box, Decl(mappedTypes4.ts, 0, 0))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 1, 9))
|
|
|
|
};
|
|
|
|
type Boxified<T> = {
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes4.ts, 2, 2))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 4, 14))
|
|
|
|
[P in keyof T]: Box<T[P]>;
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 5, 5))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 4, 14))
|
|
>Box : Symbol(Box, Decl(mappedTypes4.ts, 0, 0))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 4, 14))
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 5, 5))
|
|
|
|
};
|
|
|
|
function boxify<T>(obj: T): Boxified<T> {
|
|
>boxify : Symbol(boxify, Decl(mappedTypes4.ts, 6, 2))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 8, 16))
|
|
>obj : Symbol(obj, Decl(mappedTypes4.ts, 8, 19))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 8, 16))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes4.ts, 2, 2))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 8, 16))
|
|
|
|
if (typeof obj === "object") {
|
|
>obj : Symbol(obj, Decl(mappedTypes4.ts, 8, 19))
|
|
|
|
let result = {} as Boxified<T>;
|
|
>result : Symbol(result, Decl(mappedTypes4.ts, 10, 11))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes4.ts, 2, 2))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 8, 16))
|
|
|
|
for (let k in obj) {
|
|
>k : Symbol(k, Decl(mappedTypes4.ts, 11, 16))
|
|
>obj : Symbol(obj, Decl(mappedTypes4.ts, 8, 19))
|
|
|
|
result[k] = { value: obj[k] };
|
|
>result : Symbol(result, Decl(mappedTypes4.ts, 10, 11))
|
|
>k : Symbol(k, Decl(mappedTypes4.ts, 11, 16))
|
|
>value : Symbol(value, Decl(mappedTypes4.ts, 12, 25))
|
|
>obj : Symbol(obj, Decl(mappedTypes4.ts, 8, 19))
|
|
>k : Symbol(k, Decl(mappedTypes4.ts, 11, 16))
|
|
}
|
|
return result;
|
|
>result : Symbol(result, Decl(mappedTypes4.ts, 10, 11))
|
|
}
|
|
return <any>obj;
|
|
>obj : Symbol(obj, Decl(mappedTypes4.ts, 8, 19))
|
|
}
|
|
|
|
type A = { a: string };
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>a : Symbol(a, Decl(mappedTypes4.ts, 19, 10))
|
|
|
|
type B = { b: string };
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>b : Symbol(b, Decl(mappedTypes4.ts, 20, 10))
|
|
|
|
type C = { c: string };
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
>c : Symbol(c, Decl(mappedTypes4.ts, 21, 10))
|
|
|
|
function f1(x: A | B | C | undefined) {
|
|
>f1 : Symbol(f1, Decl(mappedTypes4.ts, 21, 23))
|
|
>x : Symbol(x, Decl(mappedTypes4.ts, 23, 12))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
return boxify(x);
|
|
>boxify : Symbol(boxify, Decl(mappedTypes4.ts, 6, 2))
|
|
>x : Symbol(x, Decl(mappedTypes4.ts, 23, 12))
|
|
}
|
|
|
|
type T00 = Partial<A | B | C>;
|
|
>T00 : Symbol(T00, Decl(mappedTypes4.ts, 25, 1))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
type T01 = Readonly<A | B | C | null | undefined>;
|
|
>T01 : Symbol(T01, Decl(mappedTypes4.ts, 27, 30))
|
|
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
type T02 = Boxified<A | B[] | C | string>
|
|
>T02 : Symbol(T02, Decl(mappedTypes4.ts, 28, 50))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes4.ts, 2, 2))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
type T03 = Readonly<string | number | boolean | null | undefined | void>;
|
|
>T03 : Symbol(T03, Decl(mappedTypes4.ts, 29, 41))
|
|
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
|
|
|
type T04 = Boxified<string | number | boolean | null | undefined | void>;
|
|
>T04 : Symbol(T04, Decl(mappedTypes4.ts, 30, 73))
|
|
>Boxified : Symbol(Boxified, Decl(mappedTypes4.ts, 2, 2))
|
|
|
|
type T05 = Partial<"hello" | "world" | 42>;
|
|
>T05 : Symbol(T05, Decl(mappedTypes4.ts, 31, 73))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
|
|
type BoxifiedWithSentinel<T, U> = {
|
|
>BoxifiedWithSentinel : Symbol(BoxifiedWithSentinel, Decl(mappedTypes4.ts, 32, 43))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 34, 26))
|
|
>U : Symbol(U, Decl(mappedTypes4.ts, 34, 28))
|
|
|
|
[P in keyof T]: Box<T[P]> | U;
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 35, 5))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 34, 26))
|
|
>Box : Symbol(Box, Decl(mappedTypes4.ts, 0, 0))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 34, 26))
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 35, 5))
|
|
>U : Symbol(U, Decl(mappedTypes4.ts, 34, 28))
|
|
}
|
|
|
|
type T10 = BoxifiedWithSentinel<A | B | C, null>;
|
|
>T10 : Symbol(T10, Decl(mappedTypes4.ts, 36, 1))
|
|
>BoxifiedWithSentinel : Symbol(BoxifiedWithSentinel, Decl(mappedTypes4.ts, 32, 43))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
type T11 = BoxifiedWithSentinel<A | B | C, undefined>;
|
|
>T11 : Symbol(T11, Decl(mappedTypes4.ts, 38, 49))
|
|
>BoxifiedWithSentinel : Symbol(BoxifiedWithSentinel, Decl(mappedTypes4.ts, 32, 43))
|
|
>A : Symbol(A, Decl(mappedTypes4.ts, 17, 1))
|
|
>B : Symbol(B, Decl(mappedTypes4.ts, 19, 23))
|
|
>C : Symbol(C, Decl(mappedTypes4.ts, 20, 23))
|
|
|
|
type T12 = BoxifiedWithSentinel<string, undefined>;
|
|
>T12 : Symbol(T12, Decl(mappedTypes4.ts, 39, 54))
|
|
>BoxifiedWithSentinel : Symbol(BoxifiedWithSentinel, Decl(mappedTypes4.ts, 32, 43))
|
|
|
|
type DeepReadonly<T> = {
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes4.ts, 40, 51))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 42, 18))
|
|
|
|
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 43, 14))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 42, 18))
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes4.ts, 40, 51))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 42, 18))
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 43, 14))
|
|
|
|
};
|
|
|
|
type Foo = {
|
|
>Foo : Symbol(Foo, Decl(mappedTypes4.ts, 44, 2))
|
|
|
|
x: number;
|
|
>x : Symbol(x, Decl(mappedTypes4.ts, 46, 12))
|
|
|
|
y: { a: string, b: number };
|
|
>y : Symbol(y, Decl(mappedTypes4.ts, 47, 14))
|
|
>a : Symbol(a, Decl(mappedTypes4.ts, 48, 8))
|
|
>b : Symbol(b, Decl(mappedTypes4.ts, 48, 19))
|
|
|
|
z: boolean;
|
|
>z : Symbol(z, Decl(mappedTypes4.ts, 48, 32))
|
|
|
|
};
|
|
|
|
type DeepReadonlyFoo = {
|
|
>DeepReadonlyFoo : Symbol(DeepReadonlyFoo, Decl(mappedTypes4.ts, 50, 2))
|
|
|
|
readonly x: number;
|
|
>x : Symbol(x, Decl(mappedTypes4.ts, 52, 24))
|
|
|
|
readonly y: { readonly a: string, readonly b: number };
|
|
>y : Symbol(y, Decl(mappedTypes4.ts, 53, 23))
|
|
>a : Symbol(a, Decl(mappedTypes4.ts, 54, 17))
|
|
>b : Symbol(b, Decl(mappedTypes4.ts, 54, 37))
|
|
|
|
readonly z: boolean;
|
|
>z : Symbol(z, Decl(mappedTypes4.ts, 54, 59))
|
|
|
|
};
|
|
|
|
var x1: DeepReadonly<Foo>;
|
|
>x1 : Symbol(x1, Decl(mappedTypes4.ts, 58, 3), Decl(mappedTypes4.ts, 59, 3))
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes4.ts, 40, 51))
|
|
>Foo : Symbol(Foo, Decl(mappedTypes4.ts, 44, 2))
|
|
|
|
var x1: DeepReadonlyFoo;
|
|
>x1 : Symbol(x1, Decl(mappedTypes4.ts, 58, 3), Decl(mappedTypes4.ts, 59, 3))
|
|
>DeepReadonlyFoo : Symbol(DeepReadonlyFoo, Decl(mappedTypes4.ts, 50, 2))
|
|
|
|
// Repro from #13232
|
|
|
|
type Z = { a: number };
|
|
>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24))
|
|
>a : Symbol(a, Decl(mappedTypes4.ts, 63, 10))
|
|
|
|
type Clone<T> = {
|
|
>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11))
|
|
|
|
[P in keyof (T & {})]: T[P];
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 65, 3))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11))
|
|
>T : Symbol(T, Decl(mappedTypes4.ts, 64, 11))
|
|
>P : Symbol(P, Decl(mappedTypes4.ts, 65, 3))
|
|
|
|
};
|
|
type M = Clone<Z>; // M should be { a: number }
|
|
>M : Symbol(M, Decl(mappedTypes4.ts, 66, 2))
|
|
>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23))
|
|
>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24))
|
|
|
|
var z1: Z;
|
|
>z1 : Symbol(z1, Decl(mappedTypes4.ts, 69, 3), Decl(mappedTypes4.ts, 70, 3))
|
|
>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24))
|
|
|
|
var z1: Clone<Z>;
|
|
>z1 : Symbol(z1, Decl(mappedTypes4.ts, 69, 3), Decl(mappedTypes4.ts, 70, 3))
|
|
>Clone : Symbol(Clone, Decl(mappedTypes4.ts, 63, 23))
|
|
>Z : Symbol(Z, Decl(mappedTypes4.ts, 59, 24))
|
|
|