【问题标题】:atom-typescript - Why are these Typescript config options not recognised?atom-typescript - 为什么无法识别这些 Typescript 配置选项?
【发布时间】:2016-08-12 01:20:00
【问题描述】:

为什么会出现以下屏幕截图中显示的错误?

Atom 说我的 tsconfig.json “项目文件包含无效选项”,用于 allowJs、buildOnSave 和 compileOnSave。

但应该允许这些设置:https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md

【问题讨论】:

    标签: typescript atom-editor


    【解决方案1】:

    compileOnSavebuildOnSave 不属于CompilerOptions。像这样:

    {
      "compileOnSave": true,
      "buildOnSave": false,
      "compilerOptions": {
        "module": "system",
        "noImplicitAny": true,
        "preserveConstEnums": true,
        "removeComments": true,
        "sourceMap": true,
        "target": "es5"
        },
        "exclude": [
        "node_modules",
        "wwwroot/lib",
        "typings/main",
        "typings/main.d.ts"
      ]
    }
    

    似乎不支持allowJs,但很快就会支持。这是GitHub上的一个分支,显示他们已经添加了,只是还没有合并。

    【讨论】:

    • 由于主要的 Typescript 编译器支持 allowJs,因此可以将其保留在 tsconfig.json 文件中。它只会在 Atom 中显示错误,但在编译时仍然可以正常工作。
    • 我刚刚进行了编辑。看起来allowJs很快就会被添加。
    【解决方案2】:

    看起来这些选项尚未添加到 Atom TypeScript 中。看看他们的界面,它缺少您遇到问题的属性。

    https://github.com/TypeStrong/atom-typescript/blob/e2fa67c4715189b71430f766ed9a92d9fb3255f9/lib/main/tsconfig/tsconfig.ts#L8-L35

    interface CompilerOptions {
        allowNonTsExtensions?: boolean;
        charset?: string;
        codepage?: number;
        declaration?: boolean;
        diagnostics?: boolean;
        emitBOM?: boolean;
        help?: boolean;
        locale?: string;
        mapRoot?: string;                                 // Optionally Specifies the location where debugger should locate map files after deployment
        module?: string;                                  //'amd'|'commonjs' (default)
        noEmitOnError?: boolean;
        noErrorTruncation?: boolean;
        noImplicitAny?: boolean;                          // Error on inferred `any` type
        noLib?: boolean;
        noLibCheck?: boolean;
        noResolve?: boolean;
        out?: string;
        outDir?: string;                                  // Redirect output structure to this directory
        preserveConstEnums?: boolean;
        removeComments?: boolean;                         // Do not emit comments in output
        sourceMap?: boolean;                              // Generates SourceMaps (.map files)
        sourceRoot?: string;                              // Optionally specifies the location where debugger should locate TypeScript source files after deployment
        suppressImplicitAnyIndexErrors?: boolean;
        target?: string;                                  // 'es3'|'es5' (default)|'es6'
        version?: boolean;
        watch?: boolean;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-17
      • 2020-05-28
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 2021-01-13
      • 2012-10-18
      • 2021-03-30
      相关资源
      最近更新 更多