vscode任务文件上的Typescript未知选项

时间:2016-11-28 13:39:19

标签: typescript visual-studio-code

我在vscode中使用了这个tasks.json文件:

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": ["-p", "."],
    "showOutput": "silent",
    "problemMatcher": "$tsc"
}

VsCode告诉我:

error TS5007: Cannot resolve referenced file: '.'.
error TS5023: Unknown option 'p'
Use the '--help' flag to see options.

这是项目结构:

│   .gitignore
│   package.json
│   tsconfig.json
│
├───.vscode
│       settings.json
│       tasks.json
└───src
    │   configuration.ts
    │   index.ts
    │   variables.ts
    │
    ├───api
    │       api.ts
    │       UsersApi.ts
    │
    └───model
            models.ts

我已经创建了一个公共存储库,以便您能够在那里查看。 Here you can see the files

1 个答案:

答案 0 :(得分:0)

看起来该任务正在提升tsc的早期版本。我相信在Typescript 1.5中添加了-p标志。

要检查此问题,请尝试使用以下tasks.json

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": ["--version"]
}

然后检查vscode中的输出窗口: shift cmd u

显示正在拾取的TypeScript版本。

要获得新版本的TS,您可以:

  • 更新全球安装的TypeScript版本:npm install -g typescript
  • 或者在npm install typescript
  • 中安装TypeScript "command": "./node_modules/typescript/bin/tsc"并使用tasks.json