-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Compiler Options in MSBuild projects
Compiler options can be specified using MSBuild properties within an MSBuild project.
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
Compiler Option | MSBuild Property Name | Allowed Values |
---|---|---|
--declaration |
TypeScriptGeneratesDeclarations | boolean |
--module |
TypeScriptModuleKind |
AMD , CommonJs , UMD , or System
|
--target |
TypeScriptTarget |
ES3 , ES5 , or ES6
|
--charset |
TypeScriptCharset | |
--emitBOM |
TypeScriptEmitBOM | boolean |
--emitDecoratorMetadata |
TypeScriptEmitDecoratorMetadata | boolean |
--experimentalDecorators |
TypeScriptExperimentalDecorators | boolean |
--inlineSourceMap |
TypeScriptInlineSourceMap | boolean |
--inlineSources |
TypeScriptInlineSources | boolean |
--locale |
automatic | Automatically set to PreferredUILang value |
--mapRoot |
TypeScriptMapRoot | File path |
--newLine |
TypeScriptNewLine |
CRLF or LF
|
--noEmitOnError |
TypeScriptNoEmitOnError | boolean |
--noEmitHelpers |
TypeScriptNoEmitHelpers | boolean |
--noImplicitAny |
TypeScriptNoImplicitAny | boolean |
--noLib |
TypeScriptNoLib | boolean |
--noResolve |
TypeScriptNoResolve | boolean |
--out |
TypeScriptOutFile | File path |
--outDir |
TypeScriptOutDir | File path |
--preserveConstEnums |
TypeScriptPreserveConstEnums | boolean |
--removeComments |
TypeScriptRemoveComments | boolean |
--rootDir |
TypeScriptRootDir | File path |
--isolatedModules |
TypeScriptIsolatedModules | boolean |
--sourceMap |
TypeScriptSourceMap | File path |
--sourceRoot |
TypeScriptSourceRoot | File path |
--suppressImplicitAnyIndexErrors |
TypeScriptSuppressImplicitAnyIndexErrors | boolean |
--suppressExcessPropertyErrors |
TypeScriptSuppressExcessPropertyErrors | boolean |
--moduleResolution |
TypeScriptModuleResolution |
Classic or Node
|
--experimentalAsyncFunctions |
TypeScriptExperimentalAsyncFunctions | boolean |
--jsx |
TypeScriptJSXEmit |
React or Preserve
|
--reactNamespace [1]
|
TypeScriptReactNamespace | |
--skipDefaultLibCheck [1]
|
TypeScriptSkipDefaultLibCheck | boolean |
--allowUnusedLabels [1]
|
TypeScriptAllowUnusedLabels | boolean |
--noImplicitReturns [1]
|
TypeScriptNoImplicitReturns | boolean |
--noFallthroughCasesInSwitch [1]
|
TypeScriptNoFallthroughCasesInSwitch | boolean |
--allowUnreachableCode [1]
|
TypeScriptAllowUnreachableCode | boolean |
--forceConsistentCasingInFileNames [1]
|
TypeScriptForceConsistentCasingInFileNames | boolean |
--allowSyntheticDefaultImports [1]
|
TypeScriptAllowSyntheticDefaultImports | boolean |
--noImplicitUseStrict [1]
|
TypeScriptNoImplicitUseStrict | boolean |
--project |
Not supported in VS | |
--watch |
Not supported in VS | |
--diagnostics |
Not supported in VS | |
--listFiles |
Not supported in VS | |
--noEmit |
Not supported in VS | |
VS only option | TypeScriptAdditionalFlags | Any compiler option |
1 These settings are new in TypeScript 1.8
Look in your C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets
file.
The authoritative mappings between MSBuild XML tags and tsc
compiler options live in there.
The value of <TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>
property in the project file identifies the compiler version to use to build (1.7 in this example). This allows a project to build against the save versions of the compiler on different machines.
If TypeScriptToolsVersion
is not specified, the latest compiler version installed on the machine will be used to build.
Users using newer versions of TS, will see a prompt to upgrade their project on first load.
If you are using a different build tool to build your project (e.g. gulp, grunt ,etc..) and VS for the development and debugging experience, set <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
in your project. This should give you all the editing support, but not the build when you hit F5.
TypeScript Language Basics
- Basic Types
- Interfaces
- Classes
- Namespaces and Modules
- Functions
- Generics
- Compiler Options
- tsconfig.json
- Integrating with Build Tools
- Nightly Builds
TypeScript Language Advanced
- Mixins
- Declaration Merging
- Type Inference
- Type Compatibility
- JSX
- Writing Declaration Files
- Typings for NPM packages
News
TypeScript Contributors
- Contributing to TypeScript
- TypeScript Design Goals
- Coding Guidelines
- Spec conformance testing
- Useful Links for TypeScript Issue Management
- Writing Good Design Proposals
- Compiler Internals
Building Tools for TypeScript
- Architectural Overview
- Using the Compiler API
- Using the Language Service API
- Dev Mode in Visual Studio
- Debugging Language Service in VS Code
FAQs