@@ -351,11 +351,12 @@ function buildEventHandlerType(
351
351
return nativeEventHandlerType ;
352
352
}
353
353
if ( element . kind === "component" ) {
354
- // I think we need to give an expression to the function call in order to reason correctly,
355
- // but that's not currently supported.
356
- // In the first place, the `@typescript-eslint/parser` currently
357
- // cannot correctly parse the import types of `*.svelte`.
358
- // return `(1 as any as ${elementName}['$on'])('${eventName}', $$expr)`;
354
+ // `@typescript-eslint/parser` currently cannot parse `*.svelte` import types correctly.
355
+ // So if we try to do a correct type parsing, it's argument type will be `any`.
356
+ // A workaround is to inject the type directly, as `CustomEvent<any>` is better than `any`.
357
+
358
+ // const componentEvents = `import('svelte').ComponentEvents<${elementName}>`;
359
+ // return `(e:'${eventName}' extends keyof ${componentEvents}?${componentEvents}['${eventName}']:CustomEvent<any>)=>void`;
359
360
360
361
return `(e:CustomEvent<any>)=>void` ;
361
362
}
@@ -374,7 +375,7 @@ function buildEventHandlerType(
374
375
/* */ /* */ /* */ `'${ attrName } ' extends infer ATTR` ,
375
376
/* */ /* */ /* */ `?(` ,
376
377
/* */ /* */ /* */ /* */ `ATTR extends keyof ${ importSvelteHTMLElements } [EVT]` ,
377
- /* */ /* */ /* */ /* */ /* */ `?${ importSvelteHTMLElements } [U ][ATTR]` ,
378
+ /* */ /* */ /* */ /* */ /* */ `?${ importSvelteHTMLElements } [EVT ][ATTR]` ,
378
379
/* */ /* */ /* */ /* */ /* */ `:${ nativeEventHandlerType } ` ,
379
380
/* */ /* */ /* */ `)` ,
380
381
/* */ /* */ /* */ `:${ nativeEventHandlerType } ` ,
0 commit comments