Transforming TypeScript into JavaScript

前端 未结 11 1279
再見小時候
再見小時候 2020-12-08 02:01

I\'m wondering how is it possible to transform the TypeScript into JavaScript in a cross platform manner. I\'m aware about availability of node package manager for typescrip

11条回答
  •  再見小時候
    2020-12-08 02:58

    You probably don't wanna use ts-node, because it is slow, instead follow following steps for fast .ts files compilation (Make sure node is installed):

    1. npm i -D @types/node typescript nodemon

    2. npx tsconfig.json and select node from the list. You are free to modify it as per your needs.

    3. Create a file names src/index.ts in your project root.

    4. Then in your package.json, add the following 2 scripts:

      "scripts": { "watch": "tsc -w", "dev": "nodemon dist/index.js" },

    5. Then use:

      npm run watch

      npm run dev

    And, it will automatically look for changes in .ts files and you can see the compiled file output in the terminal as you go!

提交回复
热议问题