3 ms·
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 user
by danielvaughn 4y ago
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.
- jeremyjacob 4y agoFortunately that's not too difficult: let x: {[key: string]: Type} But maybe the documentation is lacking here?
- aylmao 4y agoFor the record, this is equivalent to: let x: Record<string, Type> Pun intended.
- deleted 4y ago[deleted]