繁体   English   中英

tsconfig.json显然被忽略了吗?

[英]tsconfig.json is apparently being ignored?

我需要帮助了解为什么我的tsconfig.json被忽略了吗? tsconfig.json的目标是es5 ,但我仍然收到此错误?

我有以下目录:

  • test.ts
  • tsconfig.json

test.ts

let passcode = "roscoes"

class Employee {
    private _fullName: String

    get fullName(): String {
        return this._fullName
    }

    set fullName(newName: String) {
        if (passcode && passcode === "roscoes") {
            this._fullName = newName
        } else {
            console.log("Error: Not authorized ")
        }
    }
}
let employee = new Employee()
employee.fullName = "Johnny Appleseed"

if (employee.fullName) {
    console.log(employee.fullName)
}

console.log('testing')

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6"
    },
    "files": [
        "./**/*.ts"
    ]
}

当我运行tsc test.ts我得到:

test.ts(6,6): error TS1056: Accessors are only available when targeting ECMAScript 5 and
 higher.
test.ts(10,6): error TS1056: Accessors are only available when targeting ECMAScript 5 an
d higher.

当您运行tsc filename.ts编译指定文件时, tsconfig.json将被忽略。 请参考这个问题

可以使用tsc代替tsc filename ,这将始终获得tsconfig.json

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM