-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal-next.d.ts
37 lines (30 loc) · 1.05 KB
/
global-next.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
import type { FC, JSX, PropsWithChildren } from 'react';
type GetEventHandlers<T extends keyof JSX.IntrinsicElements> = Extract<keyof JSX.IntrinsicElements[T], `on${string}`>;
declare global {
/**
* @note
* Provides the event type for a given element and handler:
* https://www.totaltypescript.com/event-types-in-react-and-typescript#solution-4-use-an-eventfrom-helper
*
* @example
* type MyEvent = EventFor<"input", "onChange">;
*/
type EventFor<
TElement extends keyof JSX.IntrinsicElements,
THandler extends GetEventHandlers<TElement>,
> = JSX.IntrinsicElements[TElement][THandler] extends ((e: infer TEvent) => any) | undefined ? TEvent : never;
namespace Next {
type PageSearchParams = Record<string, string | string[] | undefined>;
type ErrorPageBoundaryProps = {
error: Error & { digest?: string };
reset: () => void;
};
type GlobalErrorPageParams = ErrorPageBoundaryProps;
}
}
declare module 'react' {
interface CSSProperties {
[key: `--${string}`]: string | number;
}
}
export {};