Typescript: TypeError when reading tsconfig.json

Created on 26 Jan 2016  路  5Comments  路  Source: microsoft/TypeScript

  • start tsc in watch mode
  • change the tsconfig.json to be invalid JSON

You get:

C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31084
            var jsonOptions = json["compilerOptions"];
                                  ^
TypeError: Cannot read property 'compilerOptions' of undefined
    at getCompilerOptions (C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31084:35)
    at Object.parseJsonConfigFileContent (C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31074:22)
    at parseConfigFile (C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31351:40)
    at performCompilation (C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31362:45)
    at recompile [as _onTimeout] (C:\Users\dirkb\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:31454:13)
    at Timer.listOnTimeout (timers.js:92:15)
Bug Fixed

Most helpful comment

In case anyone is still having this problem, in @JPVenson's case it is likely caused by the trailing comma after "noLib" in "compilerOptions".

All 5 comments

Which version of tsc are you using? Doesn't repro with compiler currently in master.

This repros in 1.7, it has since been fixed by https://github.com/Microsoft/TypeScript/pull/5589.

I've run into the same issue with 1.7.5 today as well.

I Agree Bug is still happen in 1.7.5

capture

tsconfig.json:

{
    "compilerOptions": {
        "target": "ES5",
        "module": "amd",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
    },
    "atom": {
        "formatOnSave": true
    }
}

In case anyone is still having this problem, in @JPVenson's case it is likely caused by the trailing comma after "noLib" in "compilerOptions".

Was this page helpful?
0 / 5 - 0 ratings