From 465803bf6faf7a76356dcdf05c3b700c6df48399 Mon Sep 17 00:00:00 2001 From: James Bromwell <943160+thw0rted@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:07:36 +0200 Subject: [PATCH] Fix Event after `@types/node` changes After merging my [recent PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59905) for `@types/node`, I was alerted that a couple dependents of this package were failing to compile. I have identified a fix that I believe should preserve the original behavior of this code while resolving those errors. I don't know anything about Storybook, so if I'm wrong, or if there's a better fix for the issue, please feel free to do your own thing. For background: I don't think Storybook, or the packages with failing `dtslint` runs, `storybook-readme` and `storybook-addon-jsx`, directly depend on `@types/node`, but it's common for frontend packages to install build tooling that does depend on the package. This causes Node types to be introduced to the default `typeRoot`, so you wind up with Node types merged in with those in the DOM lib. (Storybook may be a bit of an odd duck, because it looks like in some cases, React declares its own empty DOM interfaces in `@types/react/globals.d.ts`.) At any rate, I hope the proposed fix works for you. --- code/lib/api/src/modules/shortcuts.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/code/lib/api/src/modules/shortcuts.ts b/code/lib/api/src/modules/shortcuts.ts index 626dede58ce9..c49b00b5813a 100644 --- a/code/lib/api/src/modules/shortcuts.ts +++ b/code/lib/api/src/modules/shortcuts.ts @@ -92,14 +92,12 @@ export const defaultShortcuts: Shortcuts = Object.freeze({ }); const addonsShortcuts: AddonShortcuts = {}; -export interface Event extends KeyboardEvent { - target: { +interface TaggedEventTarget extends EventTarget { tagName: string; - addEventListener(): void; - removeEventListener(): boolean; - dispatchEvent(event: Event): boolean; getAttribute(attr: string): string | null; - }; +} +export interface Event extends KeyboardEvent { + target: TaggedEventTarget; } function focusInInput(event: Event) {