microsoft / microsoft/TypeScript
Allow extending multiple interfaces with different, but compatible types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
interface Change {
uid: string;
type: string;
}
interface SomeChangeExtension {
type: 'some';
foo: number;
}
interface SomeChange extends Change, SomeChangeExtension { }
In this example, I was expecting SomeChange to have a type equivalent to:
interface SomeChange {
uid: string;
type: 'some';
foo: number;
}
But it would result in error:
Interface 'SomeChange' cannot simultaneously extend types 'Change' and 'SomeChangeExtension'.
Named property 'type' of types 'Change' and 'SomeChangeExtension' are not identical.
In this case, 'some' is compatible with string if the order of interfaces being extended is respected.
The reason why I want this to be allowed is that, I need to maintain multiple interfaces of the same kind of change during different stages: raw change, change, broadcast change. And having to duplicate part of the "extension" on every of them doesn't look good.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the interface example in the TypeScript compiler and inspect how multiple interface extensions check members with the same name. Done means compatible narrower properties such as 'some' and string are accepted while incompatible declarations remain errors; no specific files or tests are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100