354 lines
13 KiB
Plaintext
354 lines
13 KiB
Plaintext
=== tests/cases/conformance/types/mapped/mappedTypes2.ts ===
|
|
|
|
function verifyLibTypes<T, K extends keyof T, U>() {
|
|
>verifyLibTypes : Symbol(verifyLibTypes, Decl(mappedTypes2.ts, 0, 0))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 1, 26))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 1, 45))
|
|
|
|
var x1: Partial<T>;
|
|
>x1 : Symbol(x1, Decl(mappedTypes2.ts, 2, 7), Decl(mappedTypes2.ts, 3, 7))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
|
|
var x1: { [P in keyof T]?: T[P] };
|
|
>x1 : Symbol(x1, Decl(mappedTypes2.ts, 2, 7), Decl(mappedTypes2.ts, 3, 7))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 3, 15))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 3, 15))
|
|
|
|
var x2: Readonly<T>;
|
|
>x2 : Symbol(x2, Decl(mappedTypes2.ts, 4, 7), Decl(mappedTypes2.ts, 5, 7))
|
|
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
|
|
var x2: { readonly [P in keyof T]: T[P] };
|
|
>x2 : Symbol(x2, Decl(mappedTypes2.ts, 4, 7), Decl(mappedTypes2.ts, 5, 7))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 5, 24))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 5, 24))
|
|
|
|
var x3: Pick<T, K>;
|
|
>x3 : Symbol(x3, Decl(mappedTypes2.ts, 6, 7), Decl(mappedTypes2.ts, 7, 7))
|
|
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 1, 26))
|
|
|
|
var x3: { [P in K]: T[P] };
|
|
>x3 : Symbol(x3, Decl(mappedTypes2.ts, 6, 7), Decl(mappedTypes2.ts, 7, 7))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 7, 15))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 1, 26))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 1, 24))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 7, 15))
|
|
|
|
var x4: Record<K, U>;
|
|
>x4 : Symbol(x4, Decl(mappedTypes2.ts, 8, 7), Decl(mappedTypes2.ts, 9, 7))
|
|
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 1, 26))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 1, 45))
|
|
|
|
var x4: { [P in K]: U };
|
|
>x4 : Symbol(x4, Decl(mappedTypes2.ts, 8, 7), Decl(mappedTypes2.ts, 9, 7))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 9, 15))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 1, 26))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 1, 45))
|
|
}
|
|
|
|
type Proxy<T> = {
|
|
>Proxy : Symbol(Proxy, Decl(mappedTypes2.ts, 10, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 12, 11))
|
|
|
|
get(): T;
|
|
>get : Symbol(get, Decl(mappedTypes2.ts, 12, 17))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 12, 11))
|
|
|
|
set(value: T): void;
|
|
>set : Symbol(set, Decl(mappedTypes2.ts, 13, 13))
|
|
>value : Symbol(value, Decl(mappedTypes2.ts, 14, 8))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 12, 11))
|
|
}
|
|
|
|
type Proxify<T> = {
|
|
>Proxify : Symbol(Proxify, Decl(mappedTypes2.ts, 15, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 17, 13))
|
|
|
|
[P in keyof T]: Proxy<T[P]>;
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 18, 5))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 17, 13))
|
|
>Proxy : Symbol(Proxy, Decl(mappedTypes2.ts, 10, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 17, 13))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 18, 5))
|
|
}
|
|
|
|
type DeepReadonly<T> = {
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes2.ts, 19, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 21, 18))
|
|
|
|
readonly [P in keyof T]: DeepReadonly<T[P]>;
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 22, 14))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 21, 18))
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes2.ts, 19, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 21, 18))
|
|
>P : Symbol(P, Decl(mappedTypes2.ts, 22, 14))
|
|
|
|
};
|
|
|
|
declare function assign<T>(obj: T, props: Partial<T>): void;
|
|
>assign : Symbol(assign, Decl(mappedTypes2.ts, 23, 2))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 25, 24))
|
|
>obj : Symbol(obj, Decl(mappedTypes2.ts, 25, 27))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 25, 24))
|
|
>props : Symbol(props, Decl(mappedTypes2.ts, 25, 34))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 25, 24))
|
|
|
|
declare function freeze<T>(obj: T): Readonly<T>;
|
|
>freeze : Symbol(freeze, Decl(mappedTypes2.ts, 25, 60))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 26, 24))
|
|
>obj : Symbol(obj, Decl(mappedTypes2.ts, 26, 27))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 26, 24))
|
|
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 26, 24))
|
|
|
|
declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
|
>pick : Symbol(pick, Decl(mappedTypes2.ts, 26, 48))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 27, 22))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 27, 24))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 27, 22))
|
|
>obj : Symbol(obj, Decl(mappedTypes2.ts, 27, 44))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 27, 22))
|
|
>keys : Symbol(keys, Decl(mappedTypes2.ts, 27, 51))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 27, 24))
|
|
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 27, 22))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 27, 24))
|
|
|
|
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
|
>mapObject : Symbol(mapObject, Decl(mappedTypes2.ts, 27, 78))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
|
>obj : Symbol(obj, Decl(mappedTypes2.ts, 28, 51))
|
|
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
|
>f : Symbol(f, Decl(mappedTypes2.ts, 28, 69))
|
|
>x : Symbol(x, Decl(mappedTypes2.ts, 28, 74))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 28, 44))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
|
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
|
|
>K : Symbol(K, Decl(mappedTypes2.ts, 28, 27))
|
|
>U : Symbol(U, Decl(mappedTypes2.ts, 28, 47))
|
|
|
|
declare function proxify<T>(obj: T): Proxify<T>;
|
|
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 100))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 29, 25))
|
|
>obj : Symbol(obj, Decl(mappedTypes2.ts, 29, 28))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 29, 25))
|
|
>Proxify : Symbol(Proxify, Decl(mappedTypes2.ts, 15, 1))
|
|
>T : Symbol(T, Decl(mappedTypes2.ts, 29, 25))
|
|
|
|
interface Point {
|
|
>Point : Symbol(Point, Decl(mappedTypes2.ts, 29, 48))
|
|
|
|
x: number;
|
|
>x : Symbol(Point.x, Decl(mappedTypes2.ts, 31, 17))
|
|
|
|
y: number;
|
|
>y : Symbol(Point.y, Decl(mappedTypes2.ts, 32, 14))
|
|
}
|
|
|
|
interface Shape {
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
name: string;
|
|
>name : Symbol(Shape.name, Decl(mappedTypes2.ts, 36, 17))
|
|
|
|
width: number;
|
|
>width : Symbol(Shape.width, Decl(mappedTypes2.ts, 37, 17))
|
|
|
|
height: number;
|
|
>height : Symbol(Shape.height, Decl(mappedTypes2.ts, 38, 18))
|
|
|
|
location: Point;
|
|
>location : Symbol(Shape.location, Decl(mappedTypes2.ts, 39, 19))
|
|
>Point : Symbol(Point, Decl(mappedTypes2.ts, 29, 48))
|
|
}
|
|
|
|
interface PartialShape {
|
|
>PartialShape : Symbol(PartialShape, Decl(mappedTypes2.ts, 41, 1))
|
|
|
|
name?: string;
|
|
>name : Symbol(PartialShape.name, Decl(mappedTypes2.ts, 43, 24))
|
|
|
|
width?: number;
|
|
>width : Symbol(PartialShape.width, Decl(mappedTypes2.ts, 44, 18))
|
|
|
|
height?: number;
|
|
>height : Symbol(PartialShape.height, Decl(mappedTypes2.ts, 45, 19))
|
|
|
|
location?: Point;
|
|
>location : Symbol(PartialShape.location, Decl(mappedTypes2.ts, 46, 20))
|
|
>Point : Symbol(Point, Decl(mappedTypes2.ts, 29, 48))
|
|
}
|
|
|
|
interface ReadonlyShape {
|
|
>ReadonlyShape : Symbol(ReadonlyShape, Decl(mappedTypes2.ts, 48, 1))
|
|
|
|
readonly name: string;
|
|
>name : Symbol(ReadonlyShape.name, Decl(mappedTypes2.ts, 50, 25))
|
|
|
|
readonly width: number;
|
|
>width : Symbol(ReadonlyShape.width, Decl(mappedTypes2.ts, 51, 26))
|
|
|
|
readonly height: number;
|
|
>height : Symbol(ReadonlyShape.height, Decl(mappedTypes2.ts, 52, 27))
|
|
|
|
readonly location: Point;
|
|
>location : Symbol(ReadonlyShape.location, Decl(mappedTypes2.ts, 53, 28))
|
|
>Point : Symbol(Point, Decl(mappedTypes2.ts, 29, 48))
|
|
}
|
|
|
|
function f0(s1: Shape, s2: Shape) {
|
|
>f0 : Symbol(f0, Decl(mappedTypes2.ts, 55, 1))
|
|
>s1 : Symbol(s1, Decl(mappedTypes2.ts, 57, 12))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
>s2 : Symbol(s2, Decl(mappedTypes2.ts, 57, 22))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
assign(s1, { name: "circle" });
|
|
>assign : Symbol(assign, Decl(mappedTypes2.ts, 23, 2))
|
|
>s1 : Symbol(s1, Decl(mappedTypes2.ts, 57, 12))
|
|
>name : Symbol(name, Decl(mappedTypes2.ts, 58, 16))
|
|
|
|
assign(s2, { width: 10, height: 20 });
|
|
>assign : Symbol(assign, Decl(mappedTypes2.ts, 23, 2))
|
|
>s2 : Symbol(s2, Decl(mappedTypes2.ts, 57, 22))
|
|
>width : Symbol(width, Decl(mappedTypes2.ts, 59, 16))
|
|
>height : Symbol(height, Decl(mappedTypes2.ts, 59, 27))
|
|
}
|
|
|
|
function f1(shape: Shape) {
|
|
>f1 : Symbol(f1, Decl(mappedTypes2.ts, 60, 1))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 62, 12))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
var frozen: ReadonlyShape;
|
|
>frozen : Symbol(frozen, Decl(mappedTypes2.ts, 63, 7), Decl(mappedTypes2.ts, 64, 7), Decl(mappedTypes2.ts, 65, 7))
|
|
>ReadonlyShape : Symbol(ReadonlyShape, Decl(mappedTypes2.ts, 48, 1))
|
|
|
|
var frozen: Readonly<Shape>;
|
|
>frozen : Symbol(frozen, Decl(mappedTypes2.ts, 63, 7), Decl(mappedTypes2.ts, 64, 7), Decl(mappedTypes2.ts, 65, 7))
|
|
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
var frozen = freeze(shape);
|
|
>frozen : Symbol(frozen, Decl(mappedTypes2.ts, 63, 7), Decl(mappedTypes2.ts, 64, 7), Decl(mappedTypes2.ts, 65, 7))
|
|
>freeze : Symbol(freeze, Decl(mappedTypes2.ts, 25, 60))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 62, 12))
|
|
}
|
|
|
|
function f2(shape: Shape) {
|
|
>f2 : Symbol(f2, Decl(mappedTypes2.ts, 66, 1))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 68, 12))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
var partial: PartialShape;
|
|
>partial : Symbol(partial, Decl(mappedTypes2.ts, 69, 7), Decl(mappedTypes2.ts, 70, 7), Decl(mappedTypes2.ts, 71, 7))
|
|
>PartialShape : Symbol(PartialShape, Decl(mappedTypes2.ts, 41, 1))
|
|
|
|
var partial: Partial<Shape>;
|
|
>partial : Symbol(partial, Decl(mappedTypes2.ts, 69, 7), Decl(mappedTypes2.ts, 70, 7), Decl(mappedTypes2.ts, 71, 7))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
var partial: Partial<Shape> = {};
|
|
>partial : Symbol(partial, Decl(mappedTypes2.ts, 69, 7), Decl(mappedTypes2.ts, 70, 7), Decl(mappedTypes2.ts, 71, 7))
|
|
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
}
|
|
|
|
function f3(shape: Shape) {
|
|
>f3 : Symbol(f3, Decl(mappedTypes2.ts, 72, 1))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 74, 12))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
const x = pick(shape, "name", "location"); // { name: string, location: Point }
|
|
>x : Symbol(x, Decl(mappedTypes2.ts, 75, 9))
|
|
>pick : Symbol(pick, Decl(mappedTypes2.ts, 26, 48))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 74, 12))
|
|
}
|
|
|
|
function f4() {
|
|
>f4 : Symbol(f4, Decl(mappedTypes2.ts, 76, 1))
|
|
|
|
const rec = { foo: "hello", bar: "world", baz: "bye" };
|
|
>rec : Symbol(rec, Decl(mappedTypes2.ts, 79, 9))
|
|
>foo : Symbol(foo, Decl(mappedTypes2.ts, 79, 17))
|
|
>bar : Symbol(bar, Decl(mappedTypes2.ts, 79, 31))
|
|
>baz : Symbol(baz, Decl(mappedTypes2.ts, 79, 45))
|
|
|
|
const lengths = mapObject(rec, s => s.length); // { foo: number, bar: number, baz: number }
|
|
>lengths : Symbol(lengths, Decl(mappedTypes2.ts, 80, 9))
|
|
>mapObject : Symbol(mapObject, Decl(mappedTypes2.ts, 27, 78))
|
|
>rec : Symbol(rec, Decl(mappedTypes2.ts, 79, 9))
|
|
>s : Symbol(s, Decl(mappedTypes2.ts, 80, 34))
|
|
>s.length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
>s : Symbol(s, Decl(mappedTypes2.ts, 80, 34))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, --, --))
|
|
}
|
|
|
|
function f5(shape: Shape) {
|
|
>f5 : Symbol(f5, Decl(mappedTypes2.ts, 81, 1))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 83, 12))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
const p = proxify(shape);
|
|
>p : Symbol(p, Decl(mappedTypes2.ts, 84, 9))
|
|
>proxify : Symbol(proxify, Decl(mappedTypes2.ts, 28, 100))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 83, 12))
|
|
|
|
let name = p.name.get();
|
|
>name : Symbol(name, Decl(mappedTypes2.ts, 85, 7))
|
|
>p.name.get : Symbol(get, Decl(mappedTypes2.ts, 12, 17))
|
|
>p.name : Symbol(name)
|
|
>p : Symbol(p, Decl(mappedTypes2.ts, 84, 9))
|
|
>name : Symbol(name)
|
|
>get : Symbol(get, Decl(mappedTypes2.ts, 12, 17))
|
|
|
|
p.width.set(42);
|
|
>p.width.set : Symbol(set, Decl(mappedTypes2.ts, 13, 13))
|
|
>p.width : Symbol(width)
|
|
>p : Symbol(p, Decl(mappedTypes2.ts, 84, 9))
|
|
>width : Symbol(width)
|
|
>set : Symbol(set, Decl(mappedTypes2.ts, 13, 13))
|
|
}
|
|
|
|
function f6(shape: DeepReadonly<Shape>) {
|
|
>f6 : Symbol(f6, Decl(mappedTypes2.ts, 87, 1))
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 89, 12))
|
|
>DeepReadonly : Symbol(DeepReadonly, Decl(mappedTypes2.ts, 19, 1))
|
|
>Shape : Symbol(Shape, Decl(mappedTypes2.ts, 34, 1))
|
|
|
|
let name = shape.name; // string
|
|
>name : Symbol(name, Decl(mappedTypes2.ts, 90, 7))
|
|
>shape.name : Symbol(name)
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 89, 12))
|
|
>name : Symbol(name)
|
|
|
|
let location = shape.location; // DeepReadonly<Point>
|
|
>location : Symbol(location, Decl(mappedTypes2.ts, 91, 7))
|
|
>shape.location : Symbol(location)
|
|
>shape : Symbol(shape, Decl(mappedTypes2.ts, 89, 12))
|
|
>location : Symbol(location)
|
|
|
|
let x = location.x; // number
|
|
>x : Symbol(x, Decl(mappedTypes2.ts, 92, 7))
|
|
>location.x : Symbol(x)
|
|
>location : Symbol(location, Decl(mappedTypes2.ts, 91, 7))
|
|
>x : Symbol(x)
|
|
}
|