Hacker News new | ask | show | jobs
by toastercat 1361 days ago
I overall like TypeScript. But one thing I have encountered in every TypeScript codebase I've worked on are types with a crazy amount of optional properties like this:

type Foo = { prop1?: number; prop2: string; prop3?: boolean };

I'm sure there is some value to having this than not having it at all, but I find it hilarious the amount of times I'm writing TypeScript that I can't even trust the types given to me. Of course this isn't a fault of TS itself, but I think what TS has inadvertently done is give programmer yet another outlet to express their bad habits.

1 comments

Sounds like a shitty function. Count your lucky stars it's at least statically typed! TS unfortunately can't solve people not understanding the benefits of a type system as it pertains to foundational design - they have to learn that on their own.
Amen!