R
R
Rafis Bagautdinov2019-05-20 21:22:32
typescript
Rafis Bagautdinov, 2019-05-20 21:22:32

Is it possible to use Typescript in React partially?

Hello. Now I write in React using Typescript. This is of course convenient, having once described the interface, you can use it everywhere and not peep, all properties are highlighted and types are checked.
However, it often feels like I am writing the code 2 times, first to describe it in the interface, then the properties or functions themselves. Especially when describing mapStateToPropswhen using Redux. There really is a feeling that you write the same thing 2 times.
It would be convenient if you could only write interfaces in the right places. And some places can be written without types at all. For example, inside one component, object properties will be highlighted by the IDE. And, for example, I would like to describe the data that comes from the server in interfaces, since the incoming data is not known.
How can such work be organized? I don't want to completely abandon typescript either. Also, I would not want to put a stub in the form of a type everywhere any. Ideally, I would like the files to be js, and only the files needed to be ts.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question