danvk / effective-typescript

Effective TypeScript 2nd Edition: 83 Specific Ways to Improve Your TypeScript
https://effectivetypescript.com
Other
1.53k stars 226 forks source link

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

Open danvk opened 2 years ago

danvk commented 2 years ago

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

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

danvk commented 2 years ago

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

Here I have overloaded BuiltIn CallableFunction

jedwards1211 commented 1 year ago

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 commented 1 year ago

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

jedwards1211 commented 1 year ago

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.