If the state will be a string then we need to set the typed string and if the state is an array string we need to type like this way string. All element default value is any which is not recommended to use, otherwise, we will face some error in the frontend if the data pass wrong data. There is a file called tsconfig.json in each project's root folder that contains instructions for TypeScript. It loads the tsconfig.json file and uses its settings to build the project when it finds it.
As I am using react. I think TypeScript and React are a perfect fit. I am enjoying combining both technologies together to get a huge productivity boost when writing my applications!
There are some pros and cons to typescript which is:
We will get an instant error if we set any wrong property so that we can fix it instantly.
Readable, easily understandable code
Better support for JSX
Sometimes we need to use NPM packages, if the package does not have any typescript version then we can not use it.
Top comments (0)