News for hackers. Stuff that matters.
Re:TypeScript is terrible for library developers by danielvaughn on Tuesday August 23, 2022 @05:17PM (#32571636)
Case in point, over the weekend I tried creating an npm package for a custom hook. Since it's public-facing, I wanted to use TS so I could expose types for users.

Part of this hook is that users can pass in custom data. I tried to create a type that was basically "an object of any string key, with the type value". Gave up after like an hour of banging my head against my desk. Maybe I'm new to TS, but FFS it should not be that hard to do.

Re:TypeScript is terrible for library developers by jeremyjacob on Tuesday August 23, 2022 @05:31PM (#32571831)
Fortunately that's not too difficult:

  let x: {[key: string]: Type}
But maybe the documentation is lacking here?
Re:TypeScript is terrible for library developers by aylmao on Tuesday August 23, 2022 @05:56PM (#32572099)
For the record, this is equivalent to:

  let x: Record<string, Type>
Pun intended.