4 ms·
On the one hand, I like this very much. On the other hand, if I open a project and I see many lines of complex types that don't do anything and I have to under
by tobyhinloopen 4y ago
On the one hand, I like this very much.
On the other hand, if I open a project and I see many lines of complex types that don't do anything and I have to understand these types to use them to fix some bug, I'm going to say words out loud that I cannot write here.
I've seen projects where there were many lines of complex types and, after updating some dependencies, there were many type errors even though the project ran fine and the tests were all green. Pisses me off every time.
So in the end, I rather just see `params` be `unknown` and create a function to extract typed values, like `getNumberParam(params, 'shopid')` that returns a number or throws some kind of error. That way, you can compile-time checks AND run-time checks.
- ly3xqhl8g9 4y agoAs always, it's a problem of balancing complexity vs. utility while striving to raise the level of abstraction. With regards to TypeScript, any, unknown, never are perfectly valid types and plenty useful, just need to be used appropriately.