4
Mb3leb
4y

I have the will of migration from Javascript to typescript but i don't know where and how.

Comments
  • 0
    Read source code from Microsoft, duh 🤓
  • 0
    @010001111 here we go again 😭
  • 1
    Download typescript (tsc), then initialize it in a directory (tsc --init). Create some typescript files for fun and run tsc
  • 2
    First, typescript is a superset of js so all js is valid typescript.

    So use any tutorial to get some typescript example running and start experimenting.
  • 0
    I would learn modern javascript instead... keep it simple
  • 1
    @Mb3leb The move to TypeScript is absolutely worth it!
    Just @ me, if you ned help. I have been using it for 4.5 years now and it saved me lots of headaches.
    JS is not terrible, but just more prone to typing problems during coding errors etc.

    As @Voxera basically said, you don't need to migrate everything at once. Just keep trying to learn step by step and apply what fits you best.
    The hardest part is getting to know what you want to build for and whether you need a bundler like Webpack.

    For web you will need a bundler if you go the modular way (import/export).
    For node you don't need one, but chosing the right ECMA target is key.

    I use Webpack for all Web builds using "ts-loader" and terser (minifying).
    If you build for NodeJS, using TSC is sufficient.

    To start, just type "npm i --save-dev typescript" in your project to have the TS transpiler.
    For NodeJS targets, you can use "ts-node" (in NPM) to directly run and debug TS code. A you can set up for example the VS Code debugger to use ts-node, so you can directly step through your code.

    Also if you dislike Node, you cam try out "Deno", it runs TS directly. I've yet to try it myself though...
Add Comment