V
V
Vlad Yanukovich2021-09-01 13:58:16
typescript
Vlad Yanukovich, 2021-09-01 13:58:16

What to do if there is no @types for react package?

Hello ladies and gentlemen.

Ripe question. I'll start with an example to make it clear what I'm talking about.

In a project using TS, for example, I use axios, install it via npm (npm install axios) and then install a dependency with @types to use axios with TS.

So the question is, is it possible to somehow use the same axios in a project with TS, if it did not have the ability to drop the dependency? (i.e. there would be no way to add the @types package).

There is just a situation: there is a package that seems to be necessary for me, everything is installed on react, but not for TS. He asks to add @types for the package, but as you understand it is not there)

Is it possible to get around this somehow?

PS I hope that those who read this will understand what I mean.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Demian Smith, 2021-09-01
@Vladislav6

In this case, you will need to create a *.d.ts file yourself and include it in tsconfig.json
More details here https://www.typescriptlang.org/docs/handbook/2/typ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question