Overview

Compiler options can be specified using MSBuild properties within an MSBuild project.

Example

  1. <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  2. <TypeScriptRemoveComments>false</TypeScriptRemoveComments>
  3. <TypeScriptSourceMap>true</TypeScriptSourceMap>
  4. </PropertyGroup>
  5. <PropertyGroup Condition="'$(Configuration)' == 'Release'">
  6. <TypeScriptRemoveComments>true</TypeScriptRemoveComments>
  7. <TypeScriptSourceMap>false</TypeScriptSourceMap>
  8. </PropertyGroup>
  9. <Import
  10. Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets"
  11. Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />

Mappings

Compiler OptionMSBuild Property NameAllowed Values
—allowJsNot supported in MSBuild
—allowSyntheticDefaultImportsTypeScriptAllowSyntheticDefaultImportsboolean
—allowUnreachableCodeTypeScriptAllowUnreachableCodeboolean
—allowUnusedLabelsTypeScriptAllowUnusedLabelsboolean
—alwaysStrictTypeScriptAlwaysStrictboolean
—baseUrlTypeScriptBaseUrlFile path
—charsetTypeScriptCharset
—declarationTypeScriptGeneratesDeclarationsboolean
—declarationDirTypeScriptDeclarationDirFile path
—diagnosticsNot supported in MSBuild
—disableSizeLimitNot supported in MSBuild
—emitBOMTypeScriptEmitBOMboolean
—emitDecoratorMetadataTypeScriptEmitDecoratorMetadataboolean
—emitDeclarationOnlyTypeScriptEmitDeclarationOnlyboolean
—esModuleInteropTypeScriptESModuleInteropboolean
—experimentalAsyncFunctionsTypeScriptExperimentalAsyncFunctionsboolean
—experimentalDecoratorsTypeScriptExperimentalDecoratorsboolean
—forceConsistentCasingInFileNamesTypeScriptForceConsistentCasingInFileNamesboolean
—helpNot supported in MSBuild
—importHelpersTypeScriptImportHelpersboolean
—inlineSourceMapTypeScriptInlineSourceMapboolean
—inlineSourcesTypeScriptInlineSourcesboolean
—initNot supported in MSBuild
—isolatedModulesTypeScriptIsolatedModulesboolean
—jsxTypeScriptJSXEmitreact, react-native, preserve
—jsxFactoryTypeScriptJSXFactoryqualified name
—libTypeScriptLibComma-separated list of strings
—listEmittedFilesNot supported in MSBuild
—listFilesNot supported in MSBuild
—localeautomaticAutomatically set to PreferredUILang value
—mapRootTypeScriptMapRootFile path
—maxNodeModuleJsDepthNot supported in MSBuild
—moduleTypeScriptModuleKindAMD, CommonJs, UMD, System or ES6
—moduleResolutionTypeScriptModuleResolutionClassic or Node
—newLineTypeScriptNewLineCRLF or LF
—noEmitNot supported in MSBuild
—noEmitHelpersTypeScriptNoEmitHelpersboolean
—noEmitOnErrorTypeScriptNoEmitOnErrorboolean
—noFallthroughCasesInSwitchTypeScriptNoFallthroughCasesInSwitchboolean
—noImplicitAnyTypeScriptNoImplicitAnyboolean
—noImplicitReturnsTypeScriptNoImplicitReturnsboolean
—noImplicitThisTypeScriptNoImplicitThisboolean
—noImplicitUseStrictTypeScriptNoImplicitUseStrictboolean
—noStrictGenericChecksTypeScriptNoStrictGenericChecksboolean
—noUnusedLocalsTypeScriptNoUnusedLocalsboolean
—noUnusedParametersTypeScriptNoUnusedParametersboolean
—noLibTypeScriptNoLibboolean
—noResolveTypeScriptNoResolveboolean
—outTypeScriptOutFileFile path
—outDirTypeScriptOutDirFile path
—outFileTypeScriptOutFileFile path
—pathsNot supported in MSBuild
—preserveConstEnumsTypeScriptPreserveConstEnumsboolean
—preserveSymlinksTypeScriptPreserveSymlinksboolean
—listEmittedFilesNot supported in MSBuild
—prettyNot supported in MSBuild
—reactNamespaceTypeScriptReactNamespacestring
—removeCommentsTypeScriptRemoveCommentsboolean
—rootDirTypeScriptRootDirFile path
—rootDirsNot supported in MSBuild
—skipLibCheckTypeScriptSkipLibCheckboolean
—skipDefaultLibCheckTypeScriptSkipDefaultLibCheckboolean
—sourceMapTypeScriptSourceMapFile path
—sourceRootTypeScriptSourceRootFile path
—strictTypeScriptStrictboolean
—strictFunctionTypesTypeScriptStrictFunctionTypesboolean
—strictNullChecksTypeScriptStrictNullChecksboolean
—strictPropertyInitializationTypeScriptStrictPropertyInitializationboolean
—stripInternalTypeScriptStripInternalboolean
—suppressExcessPropertyErrorsTypeScriptSuppressExcessPropertyErrorsboolean
—suppressImplicitAnyIndexErrorsTypeScriptSuppressImplicitAnyIndexErrorsboolean
—targetTypeScriptTargetES3, ES5, or ES6
—traceResolutionNot supported in MSBuild
—typesNot supported in MSBuild
—typeRootsNot supported in MSBuild
—useDefineForClassFieldsTypeScriptUseDefineForClassFieldsboolean
—watchNot supported in MSBuild
MSBuild only optionTypeScriptAdditionalFlagsAny compiler option

What is supported in my version of Visual Studio?

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.

ToolsVersion

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 same 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.

TypeScriptCompileBlocked

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.