【问题标题】:Typescript compiler option alwaysStrict unavailable?Typescript 编译器选项 alwaysStrict 不可用?
【发布时间】:2017-01-30 09:58:20
【问题描述】:

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

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

我在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)

我错过了什么吗?

【问题讨论】:

    标签: typescript tsc


    【解决方案1】:

    alwaysStrict 标志是在 2.1 版中添加的,您可以在 What's new in TypeScript 中看到。

    如果您希望使用此标志,请更新您的 typescript 版本。

    【讨论】:

    • 自我注意:总是仔细检查你的包的版本...我解雇了npm -g install typescript,现在我升级到2.1.5并且选项在那里。
    猜你喜欢
    • 2018-10-20
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    • 2017-08-04
    • 1970-01-01
    • 2018-01-10
    相关资源
    最近更新 更多