3

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

Comments
  • 6
    JavaScript is first class typescript. Name it {filename}.ts, use commonjs modules and go from there.
  • 0
    Not sure what you mean by generating Typescript from JavaScript using dead code elimination?
  • 0
    @theuser yep remove unused code and load code only when needed
  • 0
    Wtf is tree shaking lol. I am so terrible.
  • 0
    @aviophile remove parts on a lib/framework you don't use in you js bundle. Helps keep the files "small".
  • 0
    @aviophile Its been argued to be different from dead code removal, but in practice, probably not.
  • 0
    @theuser same goal, probably not the same means I suppose.
  • 0
    @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"
  • 0
    Code cleaning and async lib load then
  • 0
    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
Add Comment