Interfaces can be augmented. What does it mean: if you export an interface, someone who imports it can literally add members to it without modifying your code. Why? Mainly for globals like Window (interface of window): you import it, augment, and further have typesafe global in your whole app. And this is done without modifying library which exports Window for your.
As a consequence, much of TypeScript metaprogramming does not work with interfaces β because they can be augmented, there's little sense in keyof Window (result can be anything), or in trying to create mapped interfaces (only mapped types possible).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Interfaces can be augmented. What does it mean: if you export an interface, someone who imports it can literally add members to it without modifying your code. Why? Mainly for globals like
Window
(interface ofwindow
): you import it, augment, and further have typesafe global in your whole app. And this is done without modifying library which exportsWindow
for your.As a consequence, much of TypeScript metaprogramming does not work with interfaces β because they can be augmented, there's little sense in
keyof Window
(result can be anything), or in trying to create mapped interfaces (only mapped types possible).