Error "Could not find a declaration file for module" in TypeScript: solution
Hello! I'm new to TypeScript and trying to add the `lodash` library to my project. I installed it via npm, but when importing I get an error:
```
Could not find a declaration file for module 'lodash'. '/node_modules/lodash/lodash.js' implicitly has an 'any' type.
```
Here's my code:
```typescript
import _ from 'lodash';
const arr = [1, 2, 3];
const shuffled = _.shuffle(arr);
console.log(shuffled);
```
The project was created with `tsc --init`, the tsconfig.json configuration is standard. I checked — the `lodash` library is definitely installed in `node_modules`, but TypeScript is complaining. I tried adding `"noImplicitAny": false` to tsconfig, but that didn't help — the error remains.
Please tell me how to properly fix this problem? I've heard about declaration files (.d.ts), but I don't understand how
No answers yet.
Log in to leave an answer