News for hackers. Stuff that matters.
Re:Adding type safety to object IDs in TypeScript by sagia on Tuesday January 30, 2024 @03:22PM (#39195232)
I wonder if a similar (but maybe more bloated) implementation using interfaces (and probably generics too?) will work in this case.
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.