Update tests
This commit is contained in:
parent
854a20f1fe
commit
5498a95245
4 changed files with 12 additions and 25 deletions
|
@ -95,22 +95,18 @@ function f10(shape: Shape) {
|
|||
|
||||
function f11(a: Shape[]) {
|
||||
let len = getProperty(a, "length"); // number
|
||||
let shape = getProperty(a, 1000); // Shape
|
||||
setProperty(a, 1000, getProperty(a, 1001));
|
||||
setProperty(a, "length", len);
|
||||
}
|
||||
|
||||
function f12(t: [Shape, boolean]) {
|
||||
let len = getProperty(t, "length");
|
||||
let s1 = getProperty(t, 0); // Shape
|
||||
let s2 = getProperty(t, "0"); // Shape
|
||||
let b1 = getProperty(t, 1); // boolean
|
||||
let b2 = getProperty(t, "1"); // boolean
|
||||
let x1 = getProperty(t, 2); // Shape | boolean
|
||||
}
|
||||
|
||||
function f13(foo: any, bar: any) {
|
||||
let x = getProperty(foo, "x"); // any
|
||||
let y = getProperty(foo, 100); // any
|
||||
let y = getProperty(foo, "100"); // any
|
||||
let z = getProperty(foo, bar); // any
|
||||
}
|
||||
|
||||
|
@ -181,20 +177,14 @@ function f40(c: C) {
|
|||
let z: Z = c["z"];
|
||||
}
|
||||
|
||||
function f50<T>(k: keyof T, s: string, n: number) {
|
||||
function f50<T>(k: keyof T, s: string) {
|
||||
const x1 = s as keyof T;
|
||||
const x2 = n as keyof T;
|
||||
const x3 = k as string;
|
||||
const x4 = k as number;
|
||||
const x5 = k as string | number;
|
||||
const x2 = k as string;
|
||||
}
|
||||
|
||||
function f51<T, K extends keyof T>(k: K, s: string, n: number) {
|
||||
function f51<T, K extends keyof T>(k: K, s: string) {
|
||||
const x1 = s as keyof T;
|
||||
const x2 = n as keyof T;
|
||||
const x3 = k as string;
|
||||
const x4 = k as number;
|
||||
const x5 = k as string | number;
|
||||
const x2 = k as string;
|
||||
}
|
||||
|
||||
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {
|
||||
|
|
|
@ -20,8 +20,9 @@ interface Point {
|
|||
// Constraint checking
|
||||
|
||||
type T00 = { [P in P]: string }; // Error
|
||||
type T01 = { [P in Date]: number }; // Error
|
||||
type T02 = Record<Date, number>; // Error
|
||||
type T01 = { [P in number]: string }; // Error
|
||||
type T02 = { [P in Date]: number }; // Error
|
||||
type T03 = Record<Date, number>; // Error
|
||||
|
||||
type T10 = Pick<Shape, "name">;
|
||||
type T11 = Pick<Shape, "foo">; // Error
|
||||
|
|
|
@ -27,13 +27,9 @@ type T37 = { [P in keyof symbol]: void };
|
|||
type T38 = { [P in keyof never]: void };
|
||||
|
||||
type T40 = { [P in string]: void };
|
||||
type T41 = { [P in number]: void };
|
||||
type T42 = { [P in string | number]: void };
|
||||
type T43 = { [P in "a" | "b" | 0 | 1]: void };
|
||||
type T43 = { [P in "a" | "b"]: void };
|
||||
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
|
||||
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
|
||||
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
|
||||
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
|
||||
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 };
|
||||
|
|
|
@ -28,7 +28,7 @@ type DeepReadonly<T> = {
|
|||
declare function assign<T>(obj: T, props: Partial<T>): void;
|
||||
declare function freeze<T>(obj: T): Readonly<T>;
|
||||
declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
|
||||
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
|
||||
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 Shape {
|
||||
|
|
Loading…
Reference in a new issue