News for hackers. Stuff that matters.
Re:TypeScript is terrible for library developers by overgard on Tuesday August 23, 2022 @04:13PM (#32570832)
I think allowing people to call functions in a vast variety of ways is a mistake. It's one of the things that frustrates me the most about the javascript ecosystem, it's hard to figure out the call signature for any given function because there's like 15 different ways to call it. I'd argue it's better to just have one well documented way. It's not even like there aren't patterns for it, ie passing an "options" object or something like that (although even then I think that can be an antipattern unless there truly needs to be a variety of options -- ie a db connection or something. Better just to have multiple functions with specific purposes instead of one mega function that does everything)
Re:TypeScript is terrible for library developers by cogman10 on Tuesday August 23, 2022 @04:54PM (#32571359)
Agree, 100%. Make your function definition `foo(foo: Foo)` not `foo<T extends comparable | int | Bar>(foo: T)` Flexibility is the enemy of a type system and library design in general.