forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
61 lines (52 loc) · 2.06 KB
/
Copy pathutils.ts
File metadata and controls
61 lines (52 loc) · 2.06 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// https://github.com/sindresorhus/type-fest/blob/main/source/require-exactly-one.d.ts
export type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> = {
[Key in KeysType]: Required<Pick<ObjectType, Key>> & Partial<Record<Exclude<KeysType, Key>, never>>;
}[KeysType] &
Omit<ObjectType, KeysType>;
export type VerificationStatus =
| 'expired'
| 'failed'
| 'loading'
| 'verified'
| 'verified_switch_tab'
| 'client_mismatch';
/**
* Zero-runtime polymorphic component definitions for React
*
* @link https://github.com/kripod/react-polymorphic-types
*/
type Merge<T, U> = Omit<T, keyof U> & U;
type PropsWithAs<P, T extends React.ElementType> = P & { as?: T };
export type PolymorphicPropsWithoutRef<P, T extends React.ElementType> = Merge<
T extends keyof JSX.IntrinsicElements
? React.PropsWithoutRef<JSX.IntrinsicElements[T]>
: React.ComponentPropsWithoutRef<T>,
PropsWithAs<P, T>
>;
export type PolymorphicPropsWithRef<P, T extends React.ElementType> = Merge<
T extends keyof JSX.IntrinsicElements ? React.PropsWithRef<JSX.IntrinsicElements[T]> : React.ComponentPropsWithRef<T>,
PropsWithAs<P, T>
>;
type PolymorphicExoticComponent<P = object, T extends React.ElementType = React.ElementType> = Merge<
React.ExoticComponent<P & { [key: string]: unknown }>,
{
/**
* **NOTE**: Exotic components are not callable.
*/
<InstanceT extends React.ElementType = T>(
props: PolymorphicPropsWithRef<P, InstanceT>,
): ReturnType<React.FunctionComponent>;
}
>;
export type PolymorphicForwardRefExoticComponent<P, T extends React.ElementType> = Merge<
React.ForwardRefExoticComponent<P & { [key: string]: unknown }>,
PolymorphicExoticComponent<P, T>
>;
export type PolymorphicMemoExoticComponent<P, T extends React.ElementType> = Merge<
React.MemoExoticComponent<React.ComponentType<any>>,
PolymorphicExoticComponent<P, T>
>;
export type PolymorphicLazyExoticComponent<P, T extends React.ElementType> = Merge<
React.LazyExoticComponent<React.ComponentType<any>>,
PolymorphicExoticComponent<P, T>
>;