6 ms·
One area I find DRY particularly annoying is when people overly abstract Typescript types. Instead of a plain interface with a few properties, you end up with a
by cloverich 2y ago
One area I find DRY particularly annoying is when people overly abstract Typescript types. Instead of a plain interface with a few properties, you end up with a bunch of mushed together props like { thing: boolean } & Pick<MyOtherObj, 'bar' | 'baz'} & Omit<BaseObj, 'stuff'> instead of a few duplicated but easily readable interfaces:
interface MyProps {
thing: boolean;
bar: string;
baz: string;
stuff: string;
}
- jddj 2y agoAm I crazy for almost exclusively just using type and sum types and no generics or interfaces and somehow being able to express everything I need to express? Kind of wondering what I'm missing now.
- Aeolun 2y agoHmm, you can do pretty nice things with generics to make some things impossible (or at least fail on compile), but I agree it’s hardly readable. In some cases you need that though.