5

I'm using Angular 2 in my web project, and as such need TypeScript to suport experimental decorators such as @View. This can be done in tsconfig.json with "experimentalDecorators": true but I see no such option in Visual Studio's project settings. (I created a TypeScript Project.) As such, I need Visual Studio to detect and use my tsconfig.json file.

I've read various places online that Visual Studio should pick up and use a tsconfig.json if it's present in the project's root directory. However this is not happening. I am using Visual Studio 2013 Update 4 -- and upgrading to Update 5 as I write this.

Does anyone know how to get Visual Studio 2013 (NOT Visual Studio Code, and NOT Visual Studio 2015) to use the tsconfig.json file? Maybe it needs to be in the solution's root instead of the project's root?

Failing that I can try adding a pre-build event to call tsc directly... but that seems sloppy.

Vern Jensen
  • 3,449
  • 6
  • 42
  • 59

2 Answers2

2

I also was looking for this. It appears that Visual Studio 2013-2015 not support tsconfig.json yet. Currently you need to edit your project file.

Edit: With Typescript 1.8 release Visual Studio 2015 seams to fully support .tsconfig. See http://www.typescriptlang.org/docs/release-notes/typescript-1.8.html

Andzej Maciusovic
  • 4,306
  • 1
  • 29
  • 40
  • Yes that's the 'solution' I've taken as well. – Vern Jensen Nov 20 '15 at 23:43
  • What is the equivalent `.csproj` property to emulate `exclude` from `tsconfig.json`? I need that to let VS ignore e.g. `node_modules` folder. – superjos Mar 31 '16 at 17:57
  • @superjos You don't need to use exclude with .csproj, just exclude this folder from your project (you should never want to commit folders like note_modules to source control). Here is full mappings list http://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html – Andzej Maciusovic Apr 01 '16 at 10:49
  • Thanks for suggestions. `node_modules` is already **excluded** from VS project (and of course is ignored by source control as well). But still, under a *regular* (whatever that means) project, is very common to find `node_modules` directory under the project root. – superjos Apr 01 '16 at 11:23
  • @superjos Probably I don't understand your problem. In my current project I have node_modules under web project and I note_modules source code is not compiled by VS. What problems do you currently have? – Andzej Maciusovic Apr 01 '16 at 11:54
  • I have similar setup as yours, plus TS compile disabled in .csproj. But for some reason VS2013 complains about loads of errors found in sources within `node_modules`. I was not able to let it *ignore* that folder. I ended up defining some `///` in `.csproj`. Not the best thing ever – superjos Apr 01 '16 at 12:20
  • @superjos I suspect some of you node_modules contain TS definition files and your compiler version is older than these definitions or these definitions are very old and you have newer TS compiler. I suggest try to create demo.ts file and include your references to files which vs2013 complains about, then run compand line `tsc demo.ts` and see if where is no errors. – Andzej Maciusovic Apr 04 '16 at 05:54
0

The following question: What are the TypeScript project build configuration options? points to a .targets file where the TypeScript configuration options are defined.

You could manually modify that .targets file to add support for experimentalDecorators, although that's not scalable because you'd have to do that to each developer's machine.

Community
  • 1
  • 1
mejdev
  • 3,509
  • 4
  • 24
  • 38