I've recently installed a new package to use in React Native. As with other packages I was prompted in Visual Studio Code to:
[ts]
Could not find a declaration file for module 'react-native-material-
dropdown'. '/home/stumfi-mobile/123-app/node_modules/react-native-
material-dropdown/index.js' implicitly has an 'any' type. Try `npm
install @types/react-native-material-dropdown` if it exists or add a new
declaration (.d.ts) file containing `declare module 'react-native-
material-dropdown';`
Usually this is a trivial fix, as I just type:
npm install @types/react-native-material-dropdown
However today this failed. And I learned that npm has had some issues with tokens being compromised recently:
npm WARN notice Due to a recent security incident, all user tokenshave
been invalidated. Please see
https://status.npmjs.org/incidents/dn7c1fgrr7ng for more details. To
generate a new token, visit https://www.npmjs.com/settings/~/tokens or
run "npm login".
After investigating their links, I've decided I need to to this manually (and hopefully get to learn something). Where do I create this file (.d.ts) file containing `declare module 'react-native-material-dropdown'
Added folder types in src. And then the file anything.d.ts
/src/types/anything.d.ts
//anything.d.ts
declare module "react-native-material-dropdown";
This seems to work, a better answer with explanation is welcome.
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