Hacker News new | ask | show | jobs
Half my dev time fighting TS types
6 points by koolyy 445 days ago
I'm a swe at a yc startup that uses the T3 stack (next, trpc, prisma) and I'm spending ~half of my dev time fighting typescript types. Updates require type changes across multiple files - most of which are unrelated to the feature I'm adding.

Are we just using ts wrong? ts is newer to me - I was in laravel and dotnet before with very structured dto's and almost never had to touch types unless there was db changes.

I get that functional programming is meant for small single use functions that define only the type of the object that it needs, but in my opinion, thats lead to a mess of types across the codebase and I miss the structured dto's being defined in one place and thats the type that gets passed everywhere.

I'm not naive so I know I'm not the first dev to encounter these issues w ts so could someone tell me if we're just not using it correctly? I know we could define dto's in ts I'm just not sure if thats defeating the functional purpose. Does anyone else feel like they are spending way too much time wrestling types?

1 comments

What kind of "updates"? Library versions? Code changes? What kind of types are you having to change?

Yes, managing types does take more work up front than _not_ having types... but the overall result should be that you benefit from them significantly by having fewer runtime bugs, and an easier time maintaining and understanding the code.

Mainly just when adding new features. For example, updating a trpc endpoint to return an additional field often requires updating other unrelated prisma queries just to satisfy the return types.

I get types are necessary, it just seems to me that they should only ever be defined once and in one place rather than defining any type you need anywhere you need it.