Global Visual Studio 2013 TypeScript Flags

做~自己de王妃 提交于 2019-12-11 10:07:16

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/28959847/global-visual-studio-2013-typescript-flags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!