generated from garronej/ts-ci
-
Notifications
You must be signed in to change notification settings - Fork 6
/
MethodNames.ts
60 lines (46 loc) 路 1.25 KB
/
MethodNames.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
54
55
56
57
58
59
60
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { MethodNames } from "../MethodNames.ts";
import { doExtends } from "../doExtends.ts";
import type { Any } from "ts-toolbelt DENOIFY: DEPENDENCY UNMET (DEV DEPENDENCY)";
{
type A = {
a: string;
b: number;
method1(): void;
method2?(params: { a: boolean; b: string }): number;
};
type Expected = "method1" | "method2";
type Got = MethodNames<A>;
doExtends<Any.Equals<Got, Expected>, 1>();
}
class Car {
public readonly foo: string;
constructor() {
this.foo = "caca";
}
}
{
type A = {
a: unknown;
b: unknown;
method1?(): void;
// eslint-disable-next-line @typescript-eslint/ban-types
method2: Function;
method3?: (args: { a: unknown }) => unknown;
Car: typeof Car;
};
type Expected = "method1" | "method3";
type Got = MethodNames<A>;
doExtends<Any.Equals<Got, Expected>, 1>();
}
{
interface A {
a: string;
b: string;
method1(arg: unknown): unknown;
method2?: (arg: unknown) => unknown;
}
type Expected = "method1" | "method2";
type Got = MethodNames<A>;
doExtends<Any.Equals<Got, Expected>, 1>();
}