effective-typescript icon indicating copy to clipboard operation
effective-typescript copied to clipboard

In defense of interface: Using declaration merging to disable bad parts

Open danvk opened this issue 2 years ago • 4 comments

In defense of interface: Using declaration merging to disable bad parts

https://effectivetypescript.com/2021/06/03/interface/

danvk avatar Mar 01 '22 15:03 danvk

Comment by Serhii on 2021-07-07 09:13:

Here I have overloaded BuiltIn CallableFunction

danvk avatar Mar 01 '22 15:03 danvk

Declaration merging deserves all the hate it gets. I can’t declare a class named Plugin in one of my files because it conflicts with the DOM Plugin class? That’s user-antagonistic behavior. Local names in JS shadow global names, so it’s really annoying that TS behaves completely differently.

jedwards1211 avatar May 16 '23 03:05 jedwards1211

It’s just leftover cruft from TypeScript's pre-ESM days that needs to be eradicated.

jedwards1211 avatar May 16 '23 03:05 jedwards1211

Monkeypatching type definitions can be useful but there should be a way to explicitly declare overrides, instead of having to exploit an ill-conceived feature to do so.

jedwards1211 avatar May 16 '23 03:05 jedwards1211