From 562f39ca55f62ae2829bdfa0c11b0c0389525435 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Tue, 21 Nov 2023 15:35:09 +0100 Subject: [PATCH] build: export event types in react wrapper --- src/react/vite.config.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/react/vite.config.ts b/src/react/vite.config.ts index a5074e8359..28b30b11f5 100644 --- a/src/react/vite.config.ts +++ b/src/react/vite.config.ts @@ -85,7 +85,7 @@ function generateReactWrappers(): PluginOption { createDir(targetDir); const reactTemplate = `/* autogenerated */ -import { createComponent } from '@lit/react'; +import { createComponent, type EventName } from '@lit/react'; import { ${declaration.name} as ${declaration.name}Element } from '@sbb-esta/lyne-components/${ module.path }'; @@ -98,7 +98,14 @@ export const ${declaration.name} = createComponent({ react,${ declaration.events ? ` - events: {${declaration.events!.map((e) => `\n 'on${e.name}': '${e.name}',`).join('')} + events: {${declaration + .events!.map( + (e) => + `\n 'on${e.name.charAt(0).toUpperCase() + e.name.slice(1)}': '${e.name}' as EventName<${ + e.type.text + }>,`, + ) + .join('')} }, ` : ''