I've been experimenting with 1.8 upgrade. I've put this on a branch for our repository and checked out master. Unfortunately, the master branch no longer builds.
1>VSTSC : tsc.js(31087, 13) JavaScript runtime error : Unable to get property 'compilerOptions' of undefined or null reference
I've checked this error and it seems to be a bug in TS 1.7 when tsconfig.json is invalid JSON. Unfortunately, my tsconfig.json is very much valid JSON. I checked an online JSON validator, which gives it the green light, as does VS's intellisense and also the fact that the master branch built just fine before trying 1.8.
Here's the entirety of our tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"outDir": "bin-js",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true
},
"files": [
"../Dependencies/require.d.ts",
"../Dependencies/d3.d.ts",
"../Dependencies/d3.element.d.ts",
"../Dependencies/d3.event.d.ts",
"../Dependencies/history.d.ts",
"../Dependencies/jquery.d.ts",
"../Dependencies/jquery.promise.d.ts",
"../Dependencies/jquery.when.d.ts",
"../Dependencies/jquery.cookie.d.ts",
"../Dependencies/jquery.autosize.d.ts",
"../Dependencies/moment.d.ts",
"../Dependencies/moment-fixes.d.ts",
"../Dependencies/rangy-core.d.ts",
"../Dependencies/route-recognizer.d.ts",
"../Dependencies/underscore.d.ts",
"../Dependencies/jasmine.d.ts",
"../Dependencies/jasmineAddons.d.ts",
"../Framework/InterfaceExtensions.ts"
]
}
If I delete the files, the build passes, so they're clearly involved, but not only are they clearly valid JSON, but TS 1.7 accepted them quite happily prior to me trying out the 1.8 update.
@markboyall the tsconfig.json seems fine. the problem seems to be somewhere else. can you share a sample project that we can look at. feel free to email me directly at mhegazy at microsoft dot com
I'll try to create a reproduction locally today.
Same thing happening with me after upgrading to version TypeScript Tools 1.8.6, project was compiling fine before.
@tritao can you share more details.
@mhegazy
I have a pretty simple project with this tsconfig.json file:
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"sourceMap": true,
"jsx": "react"
},
"exclude": [
"node_modules",
"typings/main.d.ts",
"typings/main"
],
"files": [
"app/index.ts",
"app/components/App.tsx",
"app/components/Item.tsx",
"app/components/ItemList.tsx",
"typings/browser.d.ts"
]
}
and get this error when I try compiling:
VSTSC(0,0): error : Unable to get property 'compilerOptions' of undefined or null reference
These are the versions reported by VS:
Microsoft Visual Studio Community 2015
Installed Version: Community
Node.js Tools 1.1.40301.01
Adds support for developing and debugging Node.js apps in Visual Studio
TypeScript 1.7.6.0
TypeScript for Microsoft Visual Studio
Even though I installed version from https://github.com/Microsoft/TypeScript/releases/tag/v1.8.7 VS reports TypeScript 1.7.6.0, is this normal?
How can I help further narrow down the issue?
in your project file what is the "TypeScriptToolsVersion" property set to?
you will need to right-click unload project, then edit the file.
Looks like I had not properly installed the TypeScript VS 2015 update, now VS reports the correct version and the project is building again, sorry for the noise.
Just a note, the build will always use TypeScriptToolsVersion value if specified. if you do not care to keep the compiler "frozen" at a specific version, you can remove the value all together, and that means it will always be using the latest installed.
@mhegazy
I am running into the same issue. I have the 1.8 tools installed. I have tried updating the "TypeScriptToolsVersion" in my project file to 1.8 and removing the value. The error still does not go away. Any thoughts?
@brianj1084 can you share the build log?
@mhegazy I figured it out. We had a 'TscToolPath' property set in our csproj that was pointing to the 1.7 tools. I removed that property and everything worked.
Thanks for following up! Glad it got fixed
I am using VS 2015 Update 3 and TS (1.8.35). I tried everything mentioned in previous comments but still facing same issue.
Unable to get property 'compilerOptions' of undefined or null reference
Contents of my tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts",
"Scripts/TypeLite.Net4.d.ts"
]
}
I also tried to update and repair TypeScript tools with latest version but it didn't help.
I caught the issue in my case and found the solution. I was installing latest version of TS (1.8.6) but studio was still showing me TS (1.8.35) in Help > About Microsoft Visual Studio. The issue was related to VS component cache. I installed an extension (https://visualstudiogallery.msdn.microsoft.com/22b94661-70c7-4a93-9ca3-8b6dd45f47cd) to manually clear and rebuild component cache. After clearing the cache, I just loaded the project and it got compiled.
Most helpful comment
Just a note, the build will always use
TypeScriptToolsVersionvalue if specified. if you do not care to keep the compiler "frozen" at a specific version, you can remove the value all together, and that means it will always be using the latest installed.