How can I generate a tsconfig.json file?

后端 未结 9 424
失恋的感觉
失恋的感觉 2020-12-04 10:48

How can I generate a tsconfig.json via the command line? I tried command tsc init, but this doesn\'t work.

相关标签:
9条回答
  • 2020-12-04 11:19

    Setup a ts project as following steps:

    • install typescript yarn global add typescript
    • create a package.json: run yarn init or setting defaults yarn init -yp
    • create a tsconfig.json: run tsc --init
    • (*optional) add tslint.json

    The project structure seems like:

    │  package.json
    │  tsconfig.json
    │  tslint.json
    │  yarn.lock
    │
    ├─dist
    │      index.js
    │
    └─src
           index.ts
    
    
    0 讨论(0)
  • 2020-12-04 11:19

    I recommend to uninstall typescript first with the command:

    npm uninstall -g typescript
    

    then use the chocolatey package in order to run:

    choco install typescript
    

    in PowerShell.

    0 讨论(0)
  • 2020-12-04 11:21

    It is supported since the release of TypeScript 1.6.

    The correct command is --init not init:

    $ tsc --init
    

    Try to run in your console the following to check the version:

    $ tsc -v
    

    If the version is older than 1.6 you will need to update:

    $ npm install -g typescript
    

    Remember that you need to install node.js to use npm.

    0 讨论(0)
提交回复
热议问题