How to fix error TS7016: Could not find a declaration file for module ‘XYZ’. ‘file.js’ implicitly has an ‘any’ type

Photo by Jason Leung on Unsplash

If you’re using TypeScript you might have run into this error before. The second part of the error says:

Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare module 'XYZ';