What are `.d.ts` files in TypeScript and why are they needed?
Hi everyone! I just started learning TypeScript and came across files with the `.d.ts` extension. Honestly, I'm a bit confused. The official documentation says these are "declaration files," but I don't fully understand their purpose.
I have a project where I use the `lodash` library. I installed it via npm, but TypeScript complains that it can't find types for `lodash`. I had to separately install `@types/lodash`, and after that, `.d.ts` files appeared in the project.
I tried writing my own `.d.ts` file for a simple function:
```typescript
// utils.d.ts
declare function greet(name: string): string;
```
But when I tried to use this function in my code, TypeScript said the function doesn't exist. What am I doing wrong?
Please explain.