How to include typescript types for a library that does not exist in npm @types

Viewed 951

Ok so im very new to Typescript and I can't seem to figure this one out. In my React app, I have many types dependencies like so

"@types/react": "^16.0.22". 

Everything works great.

However I need to bring in a library that does not have it's types in '@types' lib on npm.

I am trying to include library react-responsive-carousel component, which actually has a bundled 'index.d.ts' file in the main folder already. But does not have a corresponding npm @types version.

I am trying to use the component like so:

<Carousel centerMode={true} centerSlidePercentage={50}>

But the TS comiler keeps giving me errors because it's not reading the types.

Property 'centerMode' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & ...'.

So how do I tell my TS compiler (typescript@2.7) to look for the d.ts file in the main directory, and not the @types directory ??

Thanks for helping thisTS noob out :)

0 Answers
Related