@sigil-dev/types 0.9.18 → 0.9.19

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.
Files changed (2) hide show
  1. package/index.d.ts +16 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -76,15 +76,29 @@ interface SigilBindProps {
76
76
  bindChecked?: boolean;
77
77
  }
78
78
 
79
+ /**
80
+ * Sigil hands a handler the browser's own event, not a React synthetic one:
81
+ * `onClick={(e: MouseEvent) => …}`, with `currentTarget` typed as the element.
82
+ */
83
+ type NativeHandler<H> = H extends ((event: infer E) => unknown) | undefined
84
+ ? E extends React.SyntheticEvent<infer Target, infer Native>
85
+ ? ((event: Native & { currentTarget: Target }) => unknown) | undefined
86
+ : H
87
+ : H;
88
+
89
+ type NativeHandlers<T> = {
90
+ [K in keyof T]: K extends `on${string}` ? NativeHandler<T[K]> : T[K];
91
+ };
92
+
79
93
  type LowercaseHandlers<T> = {
80
94
  [K in keyof T as K extends `on${string}`
81
95
  ? Lowercase<K & string>
82
- : never]?: T[K];
96
+ : never]?: NativeHandler<T[K]>;
83
97
  };
84
98
 
85
99
  type SigilIntrinsicElements = {
86
100
  [K in keyof React.JSX.IntrinsicElements]: Omit<
87
- React.JSX.IntrinsicElements[K],
101
+ NativeHandlers<React.JSX.IntrinsicElements[K]>,
88
102
  "style" | "children"
89
103
  > &
90
104
  SigilBaseProps &
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "url": "git+https://git.cane1712.dev/sigil/sigil.git",
9
9
  "directory": "packages/types"
10
10
  },
11
- "version": "0.9.18",
11
+ "version": "0.9.19",
12
12
  "type": "module",
13
13
  "exports": {
14
14
  ".": "./index.d.ts"