UNPKG

1.57 kBTypeScriptView Raw
1import { Key, VNode, VNodeData } from "./vnode.js";
2import { ArrayOrElement } from "./h.js";
3import { Props } from "./modules/props.js";
4export type JsxVNodeChild = VNode | string | number | boolean | undefined | null;
5export type JsxVNodeChildren = ArrayOrElement<JsxVNodeChild>;
6export type FunctionComponent = (props: {
7 [prop: string]: any;
8} | null, children?: VNode[]) => VNode;
9export declare function Fragment(data: {
10 key?: Key;
11} | null, ...children: JsxVNodeChildren[]): VNode;
12/**
13 * jsx/tsx compatible factory function
14 * see: https://www.typescriptlang.org/docs/handbook/jsx.html#factory-functions
15 */
16export declare function jsx(tag: string | FunctionComponent, data: VNodeData | null, ...children: JsxVNodeChildren[]): VNode;
17export declare namespace jsx {
18 type Element = VNode;
19 type IfEquals<X, Y, Output> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? Output : never;
20 type WritableKeys<T> = {
21 [P in keyof T]-?: IfEquals<{
22 [Q in P]: T[P];
23 }, {
24 -readonly [Q in P]: T[P];
25 }, P>;
26 }[keyof T];
27 type ElementProperties<T> = {
28 [Property in WritableKeys<T> as T[Property] extends string | number | null | undefined ? Property : never]?: T[Property];
29 };
30 type VNodeProps<T> = ElementProperties<T> & Props;
31 type HtmlElements = {
32 [Property in keyof HTMLElementTagNameMap]: VNodeData<VNodeProps<HTMLElementTagNameMap[Property]>>;
33 };
34 interface IntrinsicElements extends HtmlElements {
35 [elemName: string]: VNodeData;
36 }
37}