diff --git a/src/writer/writer-ts-definitions.ts b/src/writer/writer-ts-definitions.ts index 34e4d40..33d3750 100644 --- a/src/writer/writer-ts-definitions.ts +++ b/src/writer/writer-ts-definitions.ts @@ -124,11 +124,8 @@ function genSlotDef(def: Pick) { .join("\n"); } -const mapEvent = (name: string) => { - if (["cut", "copy", "paste"].includes(name)) { - return "DocumentAndElementEventHandlersEventMap"; - } - +const mapEvent = () => { + // lib.dom.d.ts should map event types by name. return "WindowEventMap"; }; @@ -147,7 +144,7 @@ function genEventDef(def: Pick) { description = "/** " + event.description + " */\n"; } return `${description}${clampKey(event.name)}: ${ - event.type === "dispatched" ? createDispatchedEvent(event.detail) : `${mapEvent(event.name)}["${event.name}"]` + event.type === "dispatched" ? createDispatchedEvent(event.detail) : `${mapEvent()}["${event.name}"]` };\n`; }) .join(""); diff --git a/tests/__snapshots__/fixtures.test.ts.snap b/tests/__snapshots__/fixtures.test.ts.snap index 61245f1..ccc951a 100644 --- a/tests/__snapshots__/fixtures.test.ts.snap +++ b/tests/__snapshots__/fixtures.test.ts.snap @@ -1553,11 +1553,7 @@ export interface InputEventsProps {} export default class InputEvents extends SvelteComponentTyped< InputEventsProps, - { - input: WindowEventMap["input"]; - change: WindowEventMap["change"]; - paste: DocumentAndElementEventHandlersEventMap["paste"]; - }, + { input: WindowEventMap["input"]; change: WindowEventMap["change"]; paste: WindowEventMap["paste"] }, {} > {} " diff --git a/tests/fixtures/input-events/output.d.ts b/tests/fixtures/input-events/output.d.ts index 4bce624..76d075e 100644 --- a/tests/fixtures/input-events/output.d.ts +++ b/tests/fixtures/input-events/output.d.ts @@ -4,10 +4,6 @@ export interface InputEventsProps {} export default class InputEvents extends SvelteComponentTyped< InputEventsProps, - { - input: WindowEventMap["input"]; - change: WindowEventMap["change"]; - paste: DocumentAndElementEventHandlersEventMap["paste"]; - }, + { input: WindowEventMap["input"]; change: WindowEventMap["change"]; paste: WindowEventMap["paste"] }, {} > {}