generated from garronej/ts-ci
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Parameters.ts
56 lines (45 loc) 路 1.34 KB
/
Parameters.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
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { Parameters } from "../Parameters.ts";
import { doExtends } from "../doExtends.ts";
import type { Any } from "ts-toolbelt DENOIFY: DEPENDENCY UNMET (DEV DEPENDENCY)";
{
const myFunction = (arg1: unknown, arg2: string, extraParams: { a: number; b: number }) => {
return {
arg1,
arg2,
extraParams,
};
};
type Expected = [arg1: unknown, arg2: string, extraParams: { a: number; b: number }];
type Got = Parameters<typeof myFunction>;
doExtends<Any.Equals<Got, Expected>, 1>();
}
{
type A = {
a: number;
method: (arg1: number, arg2?: string) => void;
};
type Expected = [arg1: number, arg2?: string | undefined]; // [number] | [number, string | undefined]
type Got = Parameters<A["method"]>;
doExtends<Any.Equals<Got, Expected>, 1>();
}
{
//@ts-expect-error
type X = Parameters<string>;
}
{
type Expected = [searchString: string, position?: number | undefined];
type Got = Parameters<string["indexOf"]>;
doExtends<Any.Equals<Got, Expected>, 1>();
}
{
class A {
a: string;
constructor(a: string) {
this.a = a;
}
}
//@ts-expect-error
type Got = Parameters<A>;
}