News for hackers. Stuff that matters.
Re:Adding type safety to object IDs in TypeScript by jeroenhd on Tuesday January 30, 2024 @05:16PM (#39196654)
Something like this, maybe?

https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgIlAvFA...

Alternatively, with generics: https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgA...

I don't think these are better, to be honest. The string types suffice and are easier to exchange with servers and other APIs.

There are no comments on this comment yet.