1

I am writing TypeScript in a solution folder as a solution item. TypeScript will be processed by a task defined in gulp and placed at the proper position within the web project, so that 'ts' files are not included.

When trying to work with 'amd' and 'es6' features, Visual Studio IntelliSense doesn't understand those features unless specific flags are set like '--target' and '--module', the issue here is that I am not working within a project.

I was thinking to fix this to set specific TypeScript flags at global level.

So I started to look at the file 'Microsoft.TypeScript.Default.props' in folder 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript' and applied specific flag settings, but unfortunately this does not fix the issue.

Does anyone know how to apply TypeScript flags at global (default) level?

Kevin
  • 506
  • 6
  • 13

2 Answers2

2

You can use a tsconfig file to set these... as per this example from the TypeScript project. This is described in good detail in John Reilly's tsconfig.json article.

{
    "compilerOptions": {
        "module": "commonjs",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "out": "../../built/local/tsc.js",
        "sourceMap": true
    },
    "files": [
        "core.ts",
        "sys.ts",
        "types.ts",
        "scanner.ts",
        "parser.ts",
        "utilities.ts",
        "binder.ts",
        "checker.ts",
        "emitter.ts",
        "program.ts",
        "commandLineParser.ts",
        "tsc.ts",
        "diagnosticInformationMap.generated.ts"
    ]
}

The tsconfig file is designed to be a cross-IDE method of specifying this information - so it will only apply within an IDE that respects it - and it is part of this issue on GitHub.

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • 1
    This feature is part of TypeScript 1.5 and not yet released for Visual Studio 2013. See roadmap. Like John is telling in the article, "This change should ship with TypeScript 1.5 (hopefully) for those using Visual Studio." – Kevin Mar 11 '15 at 12:15
  • Sure - other IDEs are already using this, so it is a quick catch up for Visual Studio. – Fenton Mar 11 '15 at 14:41
  • 1
    One year on, VS2013 still doesn't honor tsconfig.json – masonk Feb 04 '16 at 20:24
  • 2
    @masonk VS2015 does, and so does Visual Studio Code. I think it would be a little unfair to expect every feature to be back-ported to older versions. – Fenton Feb 05 '16 at 08:11
1

After reviewing my architectural approach, I came to the conclusion that writing TypeScript or any other compilable languages outside a project brings in issues like working with a build automation system.

So I decided to create an empty project only for working with for example TypeScript, Sass or any other compilable language that I don't want in my main web project.

It keeps the solution clean and maintainable.

@SteveFenton, thanks for your answer and approach.

Kevin
  • 506
  • 6
  • 13