Skip to content

Commit

Permalink
Fix Event after @types/node changes
Browse files Browse the repository at this point in the history
After merging my [recent PR](DefinitelyTyped/DefinitelyTyped#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.
  • Loading branch information
thw0rted committed Oct 6, 2022
1 parent 24ee6b2 commit 465803b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions code/lib/api/src/modules/shortcuts.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit 465803b

Please sign in to comment.