generated from garronej/ts-ci
-
Notifications
You must be signed in to change notification settings - Fork 6
/
PickRequired.ts
53 lines (42 loc) · 1012 Bytes
/
PickRequired.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
52
53
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { PickRequired } from "../PickRequired.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 = {
a: number;
method1(param: string): number;
};
type Got = PickRequired<A>;
assert<Equals<Got, Expected>>();
}
{
type A = {
a: number | undefined;
b?: string;
};
type Expected = {
a: number | undefined;
};
type Got = PickRequired<A>;
assert<Equals<Got, Expected>>();
}
{
interface A {
a: number;
b: string;
c?: unknown;
method1?: () => void;
}
//@ts-expect-error
type Got = PickRequired<A>;
}
//@ts-expect-error
type X = PickRequired<number>;