Overriding interface property type declared in d.ts file
Hi everyone! I'm new to TypeScript and encountered a problem when working with a library that has a type declaration file (d.ts). Let's say I have an interface from the library:
```typescript
// node_modules/some-library/index.d.ts
export interface User {
id: number;
name: string;
email: string;
age: number;
}
```
I need to create my own version of this interface where the `id` field is a string instead of a number. I'm trying to extend the interface and override the property type, but TypeScript complains:
```typescript
import { User } from 'some-library';
// Attempt 1: Simply extend and override
interface MyUser extends User {
id: string; // Error: Type 'string' is not assignable to type 'number'
}
// Attempt 2: Create a new interface with the same name (declaration
No answers yet.
Log in to leave an answer