Home > Net >  How to declare types for a third party library locally which has a hyphenated name?
How to declare types for a third party library locally which has a hyphenated name?

Time:11-23

My code uses the "react-social-sharing" library and I'm migrating from JavaScript to TypeScript. It doesn't appear to have any types associated with it so I tried declaring it locally, but I can't get it to import correctly.

I was following the steps outlined here: screenshot of error in my index.d.ts

CodePudding user response:

I think the proper way for declaring a module is like this:

declare module 'react-social-sharing' {
  export type Facebook = JSX.Element;
   ...
}
  • Related