-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
38 lines (31 loc) · 1.07 KB
/
types.d.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
/** enrich props with (optional) children. */
type PropsWithChildren<P = Record<never, never>> = {
children?: JSX.Element[];
} & P;
/** function components w/ (optional) children. */
type FC<P = Record<never, never>> = (
props: PropsWithChildren<P>
) => JSX.Element;
/** void function components w/o children. */
type VFC<P = Record<never, never>> = (props: P) => JSX.Element;
/** get keys of passed object/map */
type GetKeys<U> = U extends Record<infer K, unknown> ? K : never;
/** transform union to intersection */
type UnionToIntersection<U extends Record<never, never>> = {
[K in GetKeys<U>]: U extends Record<K, infer T> ? T : never;
};
/** jsx namespace. */
declare namespace JSX {
type Element = {
props: {
children?: JSX.Element[];
[key: string]: unknown;
};
tag: FC | VFC | string;
};
type IntrinsicElements = UnionToIntersection<
| { [H in keyof HTMLElementTagNameMap]: Partial<HTMLElementTagNameMap[H]> }
| { [S in keyof SVGElementTagNameMap]: Partial<SVGElementTagNameMap[S]> }
>;
type Node = JSX.Element | JSX.Element[];
}