3 ms·
> I really wish I saw what everyone else sees in TypeScript > It's surprisingly common for me to wrrite code that compiles but crashes at runtime Well, is it
by nawgz 6y ago
> I really wish I saw what everyone else sees in TypeScript
> It's surprisingly common for me to wrrite code that compiles but crashes at runtime
Well, is it also common for you to allow `any` in your code?
TypeScript is strongest when it can type-check your entire code. If your API endpoints return data that doesn't match your type (or at any other external data load point), TypeScript clearly can't help with that. I'm actually quite sure that if you have this kind of behavior in TypeScript, your other JS-targeting languages would fail too; you have just mis-typed something.
> Other, better
Yes, you're not biased
> JS-targeting languages manage to allow me to retain type-level features at runtime
What does this mean? They compile to put a magic key `_type` on an object?
> while also outputting leaner, faster, and safer code
I highly dispute your claims. You're building JS still, it's not going to be magically better - this just means you write bad TS. Show me some numbers or some code to make this claim.
> it feels like a huge push for the right reasons and in the worst possible direction
Given that you started your complaint with "no one documents their types", I am not so inclined to listen to your opinion. Types are the documentation. Interface names, key names, types, full autocorrect interacting with any objects, generic type support, reasonably smart type solver / caster, great error messages; these are all things TypeScript offers for learning a thin extension of JS.
> I'm not even going to touch how visually noisy and distracting I find the C#-style type syntax to be
Why not? I would love to hear more ridiculous complaints which only make sense thru your personal lens and have no justification or empirical evidence behind them