ssleptsov / ninja-keys

Keyboard shortcuts interface for your website. Working with static HTML, Vanilla JS, Vue, React, Svelte.
https://ninja-keys-demo.vercel.app/
MIT License
1.65k stars 60 forks source link

[typescript] type error in react #18

Open StringKe opened 2 years ago

StringKe commented 2 years ago
CleanShot 2022-02-16 at 15 16 47@2x

declare global {
    namespace JSX {
        interface IntrinsicElements {
            'ninja-keys': NinjaKeys
        }
    }
}

I try to add definitions, but the IDE prompts me for indeed a lot of attributes, including those of HTML elements.

CleanShot 2022-02-16 at 15 17 49@2x
mikhael28 commented 2 years ago

+1 here, thinking about moving to kbar

wobsoriano commented 2 years ago
interface KBarMethods {
  open: (opts?: { parent: string }) => void;
  close: () => void;
  setParent: (parent: string) => void;
}

export interface KBarAction {
  id: string;
  title: string;
  hotkey?: string;
  handler?: Function;
  mdIcon?: string;
  icon?: string;
  parent?: string;
  keywords?: string;
  children?: string[];
  section?: string;
}

export interface KBarProps {
  hideBreadcrumbs?: boolean,
  ...
}

type KBar = Pick<HTMLElement, "addEventListener" | "removeEventListener"> &
  KBarMethods & KBarProps & { data: KBarAction[] };

declare global {
  namespace JSX {
    interface IntrinsicElements {
      ["ninja-keys"]: KBar;
    }
  }
}
williamleiby commented 2 years ago

+1

wobsoriano commented 2 years ago

My answer didnt help @williamleiby ?