4 ms·
I come from a Java / Kotlin background and TS is totally fine.
by edem 3y ago
I come from a Java / Kotlin background and TS is totally fine.
- sk0g 3y agoSome quirks I've noticed are typed objects not performing any validations, like for building DTOs. Structural typing so the newtype pattern is not possible without some awkward hacks. A general "disconnect" between compile time and run time behaviour, so once you start casting your errors are relegated to property access/usage time, which makes — IMO excessive — test coverage paramount in catching bugs wherever you have conditional logic. I would have gone with C# or Kotlin if I had the luxury of choice, but I'll get that with a deliberate career move maybe.
- ncallaway 3y agoIf you’re taking in data from an external source that needs to be validated, I highly recommend a schema library like zod, that can produce a typescript type. That way you can define the type in a single place, have runtime validation for that type, but also be able to use the type in typescript at compile time.
- sk0g 3y agoCan you use something like Zod with the newtype pattern? I use DDD-style types for domain specific data over primitives.