Skip to content

Commit 5498a95

Browse files
committed
Update tests
1 parent 854a20f commit 5498a95

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,18 @@ function f10(shape: Shape) {
9595

9696
function f11(a: Shape[]) {
9797
let len = getProperty(a, "length"); // number
98-
let shape = getProperty(a, 1000); // Shape
99-
setProperty(a, 1000, getProperty(a, 1001));
98+
setProperty(a, "length", len);
10099
}
101100

102101
function f12(t: [Shape, boolean]) {
103102
let len = getProperty(t, "length");
104-
let s1 = getProperty(t, 0); // Shape
105103
let s2 = getProperty(t, "0"); // Shape
106-
let b1 = getProperty(t, 1); // boolean
107104
let b2 = getProperty(t, "1"); // boolean
108-
let x1 = getProperty(t, 2); // Shape | boolean
109105
}
110106

111107
function f13(foo: any, bar: any) {
112108
let x = getProperty(foo, "x"); // any
113-
let y = getProperty(foo, 100); // any
109+
let y = getProperty(foo, "100"); // any
114110
let z = getProperty(foo, bar); // any
115111
}
116112

@@ -181,20 +177,14 @@ function f40(c: C) {
181177
let z: Z = c["z"];
182178
}
183179

184-
function f50<T>(k: keyof T, s: string, n: number) {
180+
function f50<T>(k: keyof T, s: string) {
185181
const x1 = s as keyof T;
186-
const x2 = n as keyof T;
187-
const x3 = k as string;
188-
const x4 = k as number;
189-
const x5 = k as string | number;
182+
const x2 = k as string;
190183
}
191184

192-
function f51<T, K extends keyof T>(k: K, s: string, n: number) {
185+
function f51<T, K extends keyof T>(k: K, s: string) {
193186
const x1 = s as keyof T;
194-
const x2 = n as keyof T;
195-
const x3 = k as string;
196-
const x4 = k as number;
197-
const x5 = k as string | number;
187+
const x2 = k as string;
198188
}
199189

200190
function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number) {

tests/cases/conformance/types/mapped/mappedTypeErrors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ interface Point {
2020
// Constraint checking
2121

2222
type T00 = { [P in P]: string }; // Error
23-
type T01 = { [P in Date]: number }; // Error
24-
type T02 = Record<Date, number>; // Error
23+
type T01 = { [P in number]: string }; // Error
24+
type T02 = { [P in Date]: number }; // Error
25+
type T03 = Record<Date, number>; // Error
2526

2627
type T10 = Pick<Shape, "name">;
2728
type T11 = Pick<Shape, "foo">; // Error

tests/cases/conformance/types/mapped/mappedTypes1.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ type T37 = { [P in keyof symbol]: void };
2727
type T38 = { [P in keyof never]: void };
2828

2929
type T40 = { [P in string]: void };
30-
type T41 = { [P in number]: void };
31-
type T42 = { [P in string | number]: void };
32-
type T43 = { [P in "a" | "b" | 0 | 1]: void };
30+
type T43 = { [P in "a" | "b"]: void };
3331
type T44 = { [P in "a" | "b" | "0" | "1"]: void };
34-
type T45 = { [P in "a" | "b" | "0" | "1" | 0 | 1]: void };
35-
type T46 = { [P in number | "a" | "b" | 0 | 1]: void };
36-
type T47 = { [P in string | number | "a" | "b" | 0 | 1]: void };
32+
type T47 = { [P in string | "a" | "b" | "0" | "1"]: void };
3733

3834
declare function f1<T1>(): { [P in keyof T1]: void };
3935
declare function f2<T1 extends string>(): { [P in keyof T1]: void };

tests/cases/conformance/types/mapped/mappedTypes2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type DeepReadonly<T> = {
2828
declare function assign<T>(obj: T, props: Partial<T>): void;
2929
declare function freeze<T>(obj: T): Readonly<T>;
3030
declare function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
31-
declare function mapObject<K extends string | number, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
31+
declare function mapObject<K extends string, T, U>(obj: Record<K, T>, f: (x: T) => U): Record<K, U>;
3232
declare function proxify<T>(obj: T): Proxify<T>;
3333

3434
interface Shape {

0 commit comments

Comments
 (0)