Avatar ·

How to import a class into a type declaration file (.d.ts) in TypeScript?

Hello everyone! I've been writing TypeScript recently and encountered a problem. I have a library written in JavaScript, and I want to add a type declaration file (.d.ts) to it so that TypeScript understands the types. The library has a `User` class and several helper functions that use this class. For example, the `createUser(name)` function returns a new instance of `User`. I created a `my-library.d.ts` file and want to describe the types in it. Here is an example of my code: ```typescript // my-library.d.ts class User { name: string; constructor(name: string); greet(): string; } export function createUser(name: string): User; ``` But when I try to use `User` inside another `.d.ts` file (for example, `extra-types.d.ts`), I need to import the `User` class to reference it.