2 ms·
But if the types don't impact the runtime, then putting them directly in the source code that would be transmitted to the client adds cost to bandwidth without
by shadowgovt 5y ago
But if the types don't impact the runtime, then putting them directly in the source code that would be transmitted to the client adds cost to bandwidth without benefit.
Or you pass the code through a preprocessor to strip out the types and squash it before sending it to the client. At which point you have a pre-processor in your tool chain, and it might as well be a compiler from your favorite language (such as TypeScript).
I think this might be reinventing the wheel to insufficient benefit.
- jakelazaroff 5y agoServices like Netlify and Cloudflare already give you the option to minify your code when serving it. Removing the types as well is a pretty small step from there.
- kevingadd 5y agoHow is it reinventing the wheel if there are already millions of LOC out there that use it? This is a debugging/development feature. The pre-processor already exists, but if you can iterate rapidly without having to run it and without having to hassle with stuff like source maps, that's a huge workflow improvement. Even without these type annotations any production javascript of moderate size is already getting minified and compressed before deployment regardless of whether type hints are used. Right now when I'm authoring typescript in vscode, I get live error feedback from tsc and eslint in the editor, so in practice I only need to run tsc to "build" because I need to strip out all the typescript syntax. If that syntax became usable in a modern browser I could skip that build step during development and only run it for deploys to CI, staging and production.