paulirish / lite-youtube-embed

A faster youtube embed.
https://paulirish.github.io/lite-youtube-embed/
Other
5.84k stars 271 forks source link

Type declarations #148

Open bsastregx opened 1 year ago

bsastregx commented 1 year ago

Hi, Greetings!

Do you have a type declarations file? I am importing LiteYTEmbed on a typescript project and getting the following warning:

Could not find a declaration file for module 'lite-youtube-embed'. 
'd:/genexus/repos/gwds-lit/node_modules/lite-youtube-embed/src/lite-yt-embed.js' 
implicitly has an 'any' type.Try `npm i --save-dev @types/lite-youtube-embed` if it exists
or add a new declaration (.d.ts) file containing `declare module 'lite-youtube-embed';`ts(7016)
smac89 commented 2 days ago

Here you go:

declare module "lite-youtube-embed" {
   declare class LiteYTEmbed extends HTMLElement {
      async getYTPlayer(): Promise<YT.Player>;
   }
   declare global {
      interface HTMLElementTagNameMap {
         "lite-youtube": LiteYTEmbed;
      }
   }
}

YT.Player comes from @types/youtube

Put that in a declaration file somewhere, and you're golden.