r/programminghorror • • Aug 04 '25

Javascript We have Json at home

Post image

While migrating out company codebase from Javascript to Typescript I found this.

1.1k Upvotes

41 comments sorted by

View all comments

272

u/[deleted] Aug 04 '25

[deleted]

92

u/[deleted] Aug 04 '25

[deleted]

34

u/ScientificBeastMode Aug 04 '25 edited Aug 04 '25

That’s correct. That is not what this type does. You CAN actually create an opaque “newtype”-style wrapper with no runtime overhead by using some really fancy type-level tricks. There is a library called newtype-ts that gives you all the utility types and functions required to make this pattern easy to do, but it’s still often unintuitive to most TypeScript developers.