Skip to content

Commit 7ad2661

Browse files
committed
Add tests
1 parent 565ab7a commit 7ad2661

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @strict: true
2+
3+
function f0<T extends { a: string, b: string }>(obj: Pick<T, Extract<keyof T, 'b'>>) {
4+
obj.b;
5+
}
6+
7+
function f1<T extends { a: string, b: string }>(obj: Pick<T, Exclude<keyof T, 'a'>>) {
8+
obj.b;
9+
}
10+
11+
function f2<T extends { a: string, b: string }, U extends { b: string, c: string }>(obj: Pick<T | U, keyof (T | U)>) {
12+
obj.b;
13+
}
14+
15+
function f3<T extends { a: string, b: string }, U extends { b: string, c: string }>(obj: Pick<T & U, keyof (T & U)>) {
16+
obj.a;
17+
obj.b;
18+
obj.c;
19+
}
20+
21+
function f4<T extends { a: string, b: string }>(obj: Record<Exclude<keyof T, 'b'> | 'c', string>) {
22+
obj.a;
23+
obj.c;
24+
}
25+
26+
// Repro from #28821
27+
28+
type TargetProps = {
29+
foo: string,
30+
bar: string
31+
};
32+
33+
const modifier = <T extends TargetProps>(targetProps: T) => {
34+
let {bar, ...rest} = targetProps;
35+
rest.foo;
36+
};

0 commit comments

Comments
 (0)