Skip to content

Comment on Adding type safety to object IDs in TypeScript

Comments

Stripe does this (prefix ids with object type). Its smart. Makes it much easier to work with the ids.

Agreed, I can look at any ID and know what type it is. Even with well named fields it helps a ton in the docs “oh, they pass an account in or a payment ID”. Even in my own DB if I reference the stripe ID I know what it is without even having to look at the column name.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.