4 ms·
It's because when developers are handed an abstraction like static types, they will tend to go as far as possible to create overengineered solutions using that
by ferdowsi 5y ago
It's because when developers are handed an abstraction like static types, they will tend to go as far as possible to create overengineered solutions using that tool, creating complexity that becomes a problem in its own right.
TypeScript in particular has been adding features at far too fast a pace, creating wild amounts of complexity in the type system. This is from one popular type library. Type theorists may enjoy this. I personally would not if I am onboarding to a new codebase and trying to understand this at a glance.
export type CamelCasedPropertiesDeep<Value> = Value extends Function
? Value
: Value extends Array<infer U>
? Array<CamelCasedPropertiesDeep<U>>
: Value extends Set<infer U>
? Set<CamelCasedPropertiesDeep<U>> : {
[K in keyof Value as CamelCase<K>]: CamelCasedPropertiesDeep<Value[K]>;
};
- __float 5y agoWith a powerful type system, I think you tend to see examples of libraries that fall along a spectrum of how deep into the type system they're willing to go. This is an example of the farther end, but "ideally" as a user of the library, the actual complexity would be hidden, and it "just works" for you.