非常教程

Typescript参考手册

项目配置 | Project Configuration

Compiler Options in MSBuild

概观

编译器选项可以使用 MSBuild 项目中的 MSBuild 属性指定。

示例

  <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

--allowJs

Not supported in MSBuild

--allowSyntheticDefaultImports

TypeScriptAllowSyntheticDefaultImports

boolean

--allowUnreachableCode

TypeScriptAllowUnreachableCode

boolean

--allowUnusedLabels

TypeScriptAllowUnusedLabels

boolean

--alwaysStrict

TypeScriptAlwaysStrict

boolean

--baseUrl

TypeScriptBaseUrl

File path

--charset

TypeScriptCharset

--declaration

TypeScriptGeneratesDeclarations

boolean

--declarationDir

TypeScriptDeclarationDir

File path

--diagnostics

Not supported in MSBuild

--disableSizeLimit

Not supported in MSBuild

--emitBOM

TypeScriptEmitBOM

boolean

--emitDecoratorMetadata

TypeScriptEmitDecoratorMetadata

boolean

--experimentalAsyncFunctions

TypeScriptExperimentalAsyncFunctions

boolean

--experimentalDecorators

TypeScriptExperimentalDecorators

boolean

--forceConsistentCasingInFileNames

TypeScriptForceConsistentCasingInFileNames

boolean

--help

Not supported in MSBuild

--importHelpers

TypeScriptImportHelpers

boolean

--inlineSourceMap

TypeScriptInlineSourceMap

boolean

--inlineSources

TypeScriptInlineSources

boolean

--init

Not supported in MSBuild

--isolatedModules

TypeScriptIsolatedModules

boolean

--jsx

TypeScriptJSXEmit

React or Preserve

--jsxFactory

TypeScriptJSXFactory

qualified name

--lib

TypeScriptLib

Comma-separated list of strings

--listEmittedFiles

Not supported in MSBuild

--listFiles

Not supported in MSBuild

--locale

automatic

Automatically set to PreferredUILang value

--mapRoot

TypeScriptMapRoot

File path

--maxNodeModuleJsDepth

Not supported in MSBuild

--module

TypeScriptModuleKind

AMD, CommonJs, UMD, System or ES6

--moduleResolution

TypeScriptModuleResolution

Classic or Node

--newLine

TypeScriptNewLine

CRLF or LF

--noEmit

Not supported in MSBuild

--noEmitHelpers

TypeScriptNoEmitHelpers

boolean

--noEmitOnError

TypeScriptNoEmitOnError

boolean

--noFallthroughCasesInSwitch

TypeScriptNoFallthroughCasesInSwitch

boolean

--noImplicitAny

TypeScriptNoImplicitAny

boolean

--noImplicitReturns

TypeScriptNoImplicitReturns

boolean

--noImplicitThis

TypeScriptNoImplicitThis

boolean

--noImplicitUseStrict

TypeScriptNoImplicitUseStrict

boolean

--noStrictGenericChecks

TypeScriptNoStrictGenericChecks

boolean

--noUnusedLocals

TypeScriptNoUnusedLocals

boolean

--noUnusedParameters

TypeScriptNoUnusedParameters

boolean

--noLib

TypeScriptNoLib

boolean

--noResolve

TypeScriptNoResolve

boolean

--out

TypeScriptOutFile

File path

--outDir

TypeScriptOutDir

File path

--outFile

TypeScriptOutFile

File path

--paths

Not supported in MSBuild

--preserveConstEnums

TypeScriptPreserveConstEnums

boolean

--preserveSymlinks

TypeScriptPreserveSymlinks

boolean

--listEmittedFiles

Not supported in MSBuild

--pretty

Not supported in MSBuild

--reactNamespace

TypeScriptReactNamespace

string

--removeComments

TypeScriptRemoveComments

boolean

--rootDir

TypeScriptRootDir

File path

--rootDirs

Not supported in MSBuild

--skipLibCheck

TypeScriptSkipLibCheck

boolean

--skipDefaultLibCheck

TypeScriptSkipDefaultLibCheck

boolean

--sourceMap

TypeScriptSourceMap

File path

--sourceRoot

TypeScriptSourceRoot

File path

--strictNullChecks

TypeScriptStrictNullChecks

boolean

--stripInternal

TypeScriptStripInternal

boolean

--suppressExcessPropertyErrors

TypeScriptSuppressExcessPropertyErrors

boolean

--suppressImplicitAnyIndexErrors

TypeScriptSuppressImplicitAnyIndexErrors

boolean

--target

TypeScriptTarget

ES3, ES5, or ES6

--traceResolution

Not supported in MSBuild

--types

Not supported in MSBuild

--typeRoots

Not supported in MSBuild

--watch

Not supported in MSBuild

MSBuild only option

TypeScriptAdditionalFlags

Any compiler option

我的 Visual Studio 版本支持什么?

查看你的C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets文件。MSBuild XML 标签和tsc编译器选项之间的权威映射存在于那里。

ToolsVersion(工具版本)

<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>项目文件中属性的值标识了要用来构建的编译器版本(本例中为1.7)。这允许项目在不同机器上针对编译器的保存版本进行构建。

如果TypeScriptToolsVersion未指定,则将使用机器上安装的最新编译器版本进行编译。

使用较新版本 TS 的用户会看到一个提示,在第一次加载时升级他们的项目。

TypeScript 编译封锁

如果您正在使用其他构建工具来构建项目(例如 gulp,grunt 等)和 VS 以获得开发和调试体验,请<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>在项目中进行设置。这应该会给你所有的编辑支持,但是当你点击 F5 时不会生成。

Typescript

TypeScript 是 JavaScript 的类型的超集,它可以编译成纯 JavaScript。编译出来的 JavaScript 可以运行在任何浏览器上。

主页 https://www.typescriptlang.org
源码 https://github.com/Microsoft/TypeScript
发布版本 2.6.0