-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
40 lines (35 loc) · 1.05 KB
/
types.ts
File metadata and controls
40 lines (35 loc) · 1.05 KB
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
/**
* This type checks that the type true is passed to it.
* @internal
*/
export type Expect<T extends true> = T;
/**
* Return true if types are exactly equal and false otherwise.
* IsEqual<{foo: string}, {foo: string}> = true.
* IsEqual<{readonly foo: string}, {foo: string}> = false.
*/
export type IsEqual<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
? true
: false;
/**
* The function makes a copy of the object, converting the object's properties into data-test-attributes.
*/
export type Locator = (
testId: TestId<{}>,
properties?: Record<string, string | undefined>,
) => Record<string, string> | undefined;
/**
* Generate TestId by shape.
*/
export type TestId<T> = {
[K in keyof T]: IsEqual<T[K], unknown> extends true ? string : TestId<T[K]>;
};
/**
* Creates testId as string from path in typed components tree.
*/
export type CreateTestId = (<T = {}>() => TestId<T>) & (<T = {}>(prefix: string) => TestId<T>);
/**
* Proxy target.
* @internal
*/
export type Target = Record<string | symbol, unknown>;