Skip to content

Commit 04a4eba

Browse files
Merge pull request #4 from ammarahm-ed/add-typescript-support
Fix ItemTemplate events typings
2 parents f509a41 + 5eae0b8 commit 04a4eba

File tree

3 files changed

+1443
-59
lines changed

3 files changed

+1443
-59
lines changed

index.d.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { Style } from "@nativescript/core";
1+
import { Style, ViewBase } from "@nativescript/core";
22
import {
33
Document,
44
DOMEvent,
55
HTMLElementTagNameMap,
66
Node,
77
NSComponentsMap,
88
NSCustomComponentsMap,
9+
PseudoElementsMap
910
} from "dominative";
1011
import { JSX as SolidJSX } from "solid-js";
1112

@@ -28,7 +29,7 @@ import { JSX as SolidJSX } from "solid-js";
2829
* Read more about the render function here:
2930
* @link https://www.solidjs.com/docs/latest#render
3031
*/
31-
export function render(app: () => JSX.Element, root: Node):void;
32+
export function render(app: () => JSX.Element, root: Node): void;
3233

3334
export type Filter<
3435
Set,
@@ -39,6 +40,15 @@ export type MapNativeViewEvents<T, C> = {
3940
[K in T as `on:${K}`]: (event: DOMEvent<C>) => void;
4041
};
4142

43+
export type MapPseudoElementEvents<T, C> = {
44+
[K in T as `on:${K}`]: (event: {
45+
view?: ViewBase;
46+
index?: number;
47+
item?: any;
48+
data?: any
49+
}) => void;
50+
};
51+
4252
type NSComponentEventsMap = {
4353
[K in keyof NSComponentsMap]: MapNativeViewEvents<
4454
HTMLElementTagNameMap[K]["eventNames"],
@@ -49,6 +59,13 @@ type NSComponentEventsMap = {
4959
NSCustomComponentsMap[K]["eventNames"],
5060
NSCustomComponentsMap[K]
5161
>;
62+
} & {
63+
[K in keyof Pick<PseudoElementsMap, "ItemTemplate">]: MapPseudoElementEvents<
64+
"createView" | "itemLoading",
65+
PseudoElementsMap[K]
66+
>;
67+
} & {
68+
[K in keyof Omit<PseudoElementsMap, "ItemTemplate">]: {};
5269
};
5370

5471
export type IgnoredKeys =
@@ -196,7 +213,7 @@ declare global {
196213
interface CustomCaptureEvents {}
197214

198215
type JSXElementAttributes<K> = SolidJSX.CustomAttributes<
199-
NSComponentsMap[K]
216+
NSComponentsMap[K]
200217
> &
201218
Partial<
202219
DefineNSComponent<HTMLElementTagNameMap[K], NSComponentEventsMap[K]> &

0 commit comments

Comments
 (0)