Hacker News new | ask | show | jobs
by olmo23 90 days ago
If you're already passing over the sources to strip the types, why would you also not do tree-shaking and minifications?
1 comments

Why would I want to strip my types?
Because it's a waste of bandwidth if they're not enforced at runtime, the same reason why minification exists.
Both not minifying and including unenforced type hints consumes a little bandwidth though this can be largely offset by compression. This is an engineering trade off against the complexity of getting source maps working reliably for debugging and alerting. If I am shipping a video player or an internal company dashboard how much of my time is that bandwidth worth?
Maybe because TypeScript is not valid JavaScript (yet)? If you don't strip types, your code doesn't work.
It depends on the runtime: Node can run Typescript because it automatically strips types (which is so convenient during development).

But in browser, for now only the more limited JSDoc-style types can be shipped as-is indeed.

This feels like a ridiculous thread that captures everything wrong with modern Javascript ecosystem.

It's grown into a product of cults and attempted zingers rather than pragmatic or sensible technical discussions about what we should and shouldn't expect to be able to do with an individual programming language.

edit: to clarify, I assume there needs to be a basical level of comprehension of programming languages to debate the nuance of one, and if you can't think of a single reason as to why someone would want types removed, that's a possible indicator you don't have that necessary level yet, and I think the most effective way for you to learn that is to Google it. Sorry for coming across as rude if you genuinely don't know this stuff.

If you already know many reasons as to why types would be removed, then it seems disingenuous to ask that question, other than to make the point that you feel types shouldn't be stripped. If you think that, say it, and explain why you think they shouldn't be stripped.

The current state of Javascript is you _have_ to remove types; I was pointing out I can think of reasons why I sometimes wouldn't want to. (Admittedly in a glib manor; though on this site many prefer that to four paragraphs)
I agree entirely on all points. It'd save me time too:)
How goes that saying?... always assume ignorance or malice will getcha
Hear me out: javascript integrates types as comments (ignored by default) in its standard and engines start to use types as performance / optimization hints. If you mistype, your program runs, but you get worse performance and warnings in console. If you type correctly, your program runs more efficiently. We already have different levels of optimization in V8 or JSC, why can't they use type hints to refine predictions?