Update tests

This commit is contained in:
Anders Hejlsberg
2016-11-22 14:28:21 -08:00
parent d7dd0289d5
commit 66f8a406dd
2 changed files with 16 additions and 9 deletions

View File

@@ -34,7 +34,9 @@ type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
declare function f1<T1>(): { [P in keyof T1]: void };
declare function f2<T1 extends string>(): { [P in keyof T1]: void };
declare function f3<T1 extends number>(): { [P in keyof T1]: void };
declare function f4<T1 extends Number>(): { [P in keyof T1]: void };
let x1 = f1();
let x2 = f2();
let x3 = f3();
let x3 = f3();
let x4 = f4();

View File

@@ -31,25 +31,30 @@ declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
declare function proxify<T>(obj: T): Proxify<T>;
interface Point {
x: number;
y: number;
}
interface Shape {
name: string;
width: number;
height: number;
visible: boolean;
location: Point;
}
interface PartialShape {
name?: string;
width?: number;
height?: number;
visible?: boolean;
location?: Point;
}
interface ReadonlyShape {
readonly name: string;
readonly width: number;
readonly height: number;
readonly visible: boolean;
readonly location: Point;
}
function f0(s1: Shape, s2: Shape) {
@@ -70,7 +75,7 @@ function f2(shape: Shape) {
}
function f3(shape: Shape) {
const x = pick(shape, "name", "visible"); // { name: string, visible: boolean }
const x = pick(shape, "name", "location"); // { name: string, location: Point }
}
function f4() {
@@ -81,11 +86,11 @@ function f4() {
function f5(shape: Shape) {
const p = proxify(shape);
let name = p.name.get();
p.visible.set(false);
p.width.set(42);
}
function f6(shape: DeepReadonly<Shape>) {
let name = shape.name; // DeepReadonly<string>
let length = name.length; // DeepReadonly<number>
let toString = length.toString; // DeepReadonly<(radix?: number) => string>
let name = shape.name; // string
let location = shape.location; // DeepReadonly<Point>
let x = location.x; // number
}