microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.93k stars 12.47k forks source link

Allow ability to do an in-place override (_not_ extend) of interface properties #26011

Open ffxsam opened 6 years ago

ffxsam commented 6 years ago

Search Terms

override interface override interface replace

Suggestion

It would be nice to be able to override (not extend) third party libraries' interfaces to change the types/signatures of the interface properties.

Use Cases

Sometimes they make mistakes or define interfaces in ways that force me to constantly use as to typecast. I'd rather short-circuit it in one place so it works across my project.

Examples

Reference: https://stackoverflow.com/questions/51562792/how-to-override-a-typescript-interface-without-extending

Checklist

My suggestion meets these guidelines: (Honestly I'm in no position to make these judgment calls, as I don't know the inner workings of this library - why ask these quesitons?)

aleclarson commented 2 years ago

I think a core problem here is: in the case of multiple overrides of the same property, how would the type-checker decide which override takes precedence?