micahblu
micahblu

Reputation: 5212

tsconfig.json is apparently being ignored?

I need help in understanding why my tsconfig.json is being ignored? The tsconfig.json has a target of es5 and yet I'm still getting this error?

I have directory with the following:

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"
    ]
}

when I run tsc test.ts I get:

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.

Upvotes: 4

Views: 1661

Answers (1)

Pengyy
Pengyy

Reputation: 38171

When you run tsc filename.ts to compile specified files, the tsconfig.json will be ignored. Please refer this issuse.

Instead of tsc filename, you can use tsc, this will always get tsconfig.json.

Upvotes: 5

Related Questions