Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
JavaScript is first class typescript. Name it {filename}.ts, use commonjs modules and go from there.
-
theuser48024yNot sure what you mean by generating Typescript from JavaScript using dead code elimination?
-
@aviophile remove parts on a lib/framework you don't use in you js bundle. Helps keep the files "small".
-
theuser48024y@aviophile Its been argued to be different from dead code removal, but in practice, probably not.
-
theuser48024y@react-guy The author argued that its kinda different on a technical level, but to me it sounds like he is simply naming his shiny invention. In any case, its at least easier to say than "dead code removal"
-
You can but it’s not as simple as mv index.js index.ts. You’d also need to add all the types you need like dom or node, react if you’re using it etc as well as still use webpack to treeshake. You can also invoke the ts compiler with webpack. Probably a ‘plugin’ for that.
As for converting to TS, best way to start is to set strict to false, that way your JS file is TS but everything is declared as any or (forgot the word) assumed to be of a certain type. Then you can be more specific when and where you need to be. Else there’s no point of using TS in an already JS project
Can you take this JavaScript file and make it TypeScript with tree shaking. Step one pass week to understand TypeScript and webpackShit compilers and try to importe it in a basic chrome windows ... What a mess
rant