generated from garronej/ts-ci
-
Notifications
You must be signed in to change notification settings - Fork 6
/
PickOptionals.ts
51 lines (42 loc) 路 1.01 KB
/
PickOptionals.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { PickOptionals } from "../PickOptionals.ts";
import { assert } from "../assert.ts";
import type { Equals } from "../Equals.ts";
{
type A = {
a: number;
b?: number;
method1(param: string): number;
method2?(params: { a: string; b: number }): typeof params;
};
type Expected = {
b: number;
method2(params: { a: string; b: number }): typeof params;
};
type Got = PickOptionals<A>;
assert<Equals<Got, Expected>>();
}
{
type A = {
a: number | undefined;
b?: string;
};
type Expected = {
b: string;
};
type Got = PickOptionals<A>;
assert<Equals<Got, Expected>>();
}
{
interface A {
a: number;
b: string;
c?: unknown;
method1?: () => void;
}
//@ts-expect-error
type Got = PickOptionals<A>;
}
//@ts-expect-error
type X = PickOptionals<number>;