I’m trying to setup a new project with React, and I’m thinking in replacing PropTypes with TypeScript.
But I want to know if I’m going to have integration issues.
For example:
react-redux) with TypeScript + Reactreact-bootstrapMy main concern is related to importing from TypeScript a non-TypeScript code.
Any clues or experience with this?
You can import Javascript libraries in your Typescript project. I do that all the time, unfortunately. Some libraries have community-typed types which you can install by running npm i @types/mypackage --dev.
Otherwise, you will have to create an empty TS module declaration for the package:
Adhering to convention, create a file named mypackage.d.ts somewhere in your src directory. (I usually place it in src/types/)
mypackage.d.ts should contain declare module "mypackage";
Now, whatever you import from the mypackage will have type any.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With