2017-01-30 227 views
0

Compiler Options page on Typescript website列出了--alwaysStrict选项,它应该告诉编译器在输出中发出“use strict”语句。Typescript编译器选项alwaysStrict不可用?

请注意,我正在使用Visual Studio代码。

我添加了一些选项在我tsconfig.json

{ 
    "compilerOptions": { 
     "alwaysStrict": true, 
     //... blah blah ... 

,但我得到Unknown compiler option 'alwaysStrict'试图建立的时候。

所以,我跑tsc,看看该选项未被列出,这里是从CMD输出复制粘贴:

Version 2.0.9 
Syntax: tsc [options] [file ...] 

Examples: tsc hello.ts 
      tsc --outFile file.js file.ts 
      tsc @args.txt 

Options: 
--allowJs       Allow javascript files to be compiled. 
--allowSyntheticDefaultImports  Allow default imports from modules with no default export. This does not affect code emit, just typechecking. 
--allowUnreachableCode    Do not report errors on unreachable code. 
--allowUnusedLabels     Do not report errors on unused labels. 
--baseUrl       Base directory to resolve non-absolute module names. 
(blah blah, the rest of options alphabetically) 

我缺少的东西?

回答

2

这个alwaysStrict标志被添加到2.1版中,如您在What's new in TypeScript中所见。

如果您想使用此标志,请更新您的打字稿版本。

+0

注意自我:总是仔细检查你的软件包的版本......我解雇了'npm -g install typescript',现在我升级到'2.1.5',并且选项在那里。 – Alex