|
|
|
@ -106,29 +106,37 @@ export namespace jsx {
|
|
|
|
|
/*
|
|
|
|
|
IfEquals/WritableKeys: https://stackoverflow.com/questions/52443276/how-to-exclude-getter-only-properties-from-type-in-typescript/52473108#52473108
|
|
|
|
|
*/
|
|
|
|
|
export type IfEquals<X, Y, Output> = (<T>() => T extends X
|
|
|
|
|
? 1
|
|
|
|
|
: 2) extends <T>() => T extends Y ? 1 : 2
|
|
|
|
|
export type IfEquals<X, Y, Output> = (<T>() => T extends X ? 1 : 2) extends <
|
|
|
|
|
T
|
|
|
|
|
>() => T extends Y ? 1 : 2
|
|
|
|
|
? Output
|
|
|
|
|
: never
|
|
|
|
|
: never;
|
|
|
|
|
|
|
|
|
|
export type WritableKeys<T> = {
|
|
|
|
|
[P in keyof T]-?: IfEquals<
|
|
|
|
|
{ [Q in P]: T[P] },
|
|
|
|
|
{ -readonly [Q in P]: T[P] },
|
|
|
|
|
P
|
|
|
|
|
>
|
|
|
|
|
}[keyof T]
|
|
|
|
|
>;
|
|
|
|
|
}[keyof T];
|
|
|
|
|
|
|
|
|
|
export type ElementProperties<T> = {
|
|
|
|
|
[Property in WritableKeys<T> as T[Property] extends string | number | null | undefined ? Property : never]?: T[Property]
|
|
|
|
|
}
|
|
|
|
|
[Property in WritableKeys<T> as T[Property] extends
|
|
|
|
|
| string
|
|
|
|
|
| number
|
|
|
|
|
| null
|
|
|
|
|
| undefined
|
|
|
|
|
? Property
|
|
|
|
|
: never]?: T[Property];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type VNodeProps<T> = ElementProperties<T> & Props
|
|
|
|
|
export type VNodeProps<T> = ElementProperties<T> & Props;
|
|
|
|
|
|
|
|
|
|
export type HtmlElements = {
|
|
|
|
|
[Property in keyof HTMLElementTagNameMap]: VNodeData<VNodeProps<HTMLElementTagNameMap[Property]>>
|
|
|
|
|
}
|
|
|
|
|
[Property in keyof HTMLElementTagNameMap]: VNodeData<
|
|
|
|
|
VNodeProps<HTMLElementTagNameMap[Property]>
|
|
|
|
|
>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface IntrinsicElements extends HtmlElements {
|
|
|
|
|
[elemName: string]: VNodeData;
|
|
|
|
|