@oomfware/jsx 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * core JSX types, modeled after React's type definitions
3
+ */
4
+
5
+ // #region Component types
6
+
7
+ /** function component */
8
+ export type Component<P = {}> = (props: P) => JSXNode;
9
+
10
+ /** function component (alias for Component) */
11
+ export type FC<P = {}> = Component<P>;
12
+
13
+ // #endregion
14
+
15
+ // #region JSXElement
16
+
17
+ /**
18
+ * virtual element representing a JSX element
19
+ * @template P props type
20
+ * @template T element type (tag string or component)
21
+ */
22
+ export interface JSXElement<P = unknown, T extends string | Component<any> = string | Component<any>> {
23
+ type: T;
24
+ props: P;
25
+ }
26
+
27
+ // #endregion
28
+
29
+ // #region JSXNode (children)
30
+
31
+ /**
32
+ * valid JSX child types - anything that can appear as children
33
+ * modeled after React's ReactNode
34
+ */
35
+ export type JSXNode = JSXElement | string | number | bigint | boolean | null | undefined | Iterable<JSXNode>;
36
+
37
+ // #endregion