ضبط خيارات المترجم في مشاريع MSBuild في TypeScript

من موسوعة حسوب
اذهب إلى التنقل اذهب إلى البحث
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


مقدمة

يُمكن تحديد خيارات المترجم عبر استخدام خاصيات 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')" />

الاقترانات (Mappings)

الخيار اسم خاصية MSBuild القيم المسموح بها
--allowJs ‎غير مدعوم في MSBuild.
--allowSyntheticDefaultImports TypeScriptAllowSyntheticDefaultImports ‎قيمة منطقية
--allowUnreachableCode TypeScriptAllowUnreachableCode ‎قيمة منطقية
--allowUnusedLabels TypeScriptAllowUnusedLabels ‎قيمة منطقية
--alwaysStrict TypeScriptAlwaysStrict ‎قيمة منطقية
--baseUrl TypeScriptBaseUrl ‎مسار ملفّ
--charset TypeScriptCharset
--declaration TypeScriptGeneratesDeclarations ‎قيمة منطقية
--declarationDir TypeScriptDeclarationDir ‎مسار ملفّ
--diagnostics غير مدعوم
--disableSizeLimit غير مدعوم
--emitBOM TypeScriptEmitBOM قيمة منطقيّة
--emitDecoratorMetadata TypeScriptEmitDecoratorMetadata قيمة منطقيّة
--emitDeclarationOnly TypeScriptEmitDeclarationOnly قيمة منطقيّة
--emitBOM TypeScriptEmitBOM قيمة منطقيّة
--esModuleInterop TypeScriptESModuleInterop قيمة منطقيّة
--experimentalAsyncFunctions TypeScriptExperimentalAsyncFunctions قيمة منطقيّة
--experimentalDecorators TypeScriptExperimentalDecorators قيمة منطقيّة
--forceConsistentCasingInFileNames TypeScriptForceConsistentCasingInFileNames قيمة منطقيّة
--help غير مدعوم
--importHelpers TypeScriptImportHelpers قيمة منطقيّة
--inlineSourceMap TypeScriptInlineSourceMap قيمة منطقيّة
--inlineSources TypeScriptInlineSources قيمة منطقيّة
--init غير مدعوم
--isolatedModules TypeScriptIsolatedModules قيمة منطقيّة
--jsx TypeScriptJSXEmit React‎ أو ‎Preserve
--jsxFactory TypeScriptJSXFactory اسمٌ خاصّ.
--lib TypeScriptLib قائمة سلاسلَ نصيةٍ مُفصولةٍ بفاصلة (Comma).
--listEmittedFiles غير مدعوم
--listFiles غير مدعوم
--locale تلقائي تُضبَط قيمته افتراضيًّا إلى قيمة PreferredUILang.
--mapRoot TypeScriptMapRoot ‎مسار ملفّ
--maxNodeModuleJsDepth TypeScriptMapRoot ‎غير مدعوم
--module TypeScriptModuleKind ‎‎AMD‎، أو ‎CommonJs‎، أو ‎UMD‎، أو ‎System‎، أو ‎ES6‎.
--moduleResolution TypeScriptModuleResolution ‎‎Classic‎ أو ‎Node
--newLine TypeScriptNewLine ‎‎CRLF‎ أو ‎LF
--noEmit غير مدعوم
--noEmitHelpers TypeScriptNoEmitHelpers قيمة منطقيّة
--noEmitOnError TypeScriptNoEmitOnError قيمة منطقيّة
--noFallthroughCasesInSwitch TypeScriptNoFallthroughCasesInSwitch قيمة منطقيّة
--noImplicitAny TypeScriptNoImplicitAny قيمة منطقيّة
--noImplicitReturns TypeScriptNoImplicitReturns قيمة منطقيّة
--noImplicitThis TypeScriptNoImplicitThis قيمة منطقيّة
--noImplicitUseStrict TypeScriptNoImplicitUseStrict قيمة منطقيّة
--noStrictGenericChecks TypeScriptNoStrictGenericChecks قيمة منطقيّة
--noUnusedLocals TypeScriptNoUnusedLocals قيمة منطقيّة
--noUnusedParameters TypeScriptNoUnusedParameters قيمة منطقيّة
--noLib TypeScriptNoLib قيمة منطقيّة
--noResolve TypeScriptNoResolve قيمة منطقيّة
--out TypeScriptOutFile ‎مسار ملفّ
--outDir TypeScriptOutDir ‎مسار ملفّ
--outFile TypeScriptOutFile ‎مسار ملفّ
--paths غير مدعوم
--preserveConstEnums TypeScriptPreserveConstEnums قيمة منطقيّة
--preserveSymlinks TypeScriptPreserveSymlinks قيمة منطقيّة
--listEmittedFiles غير مدعوم
--pretty غير مدعوم
--reactNamespace TypeScriptReactNamespace سلسلة نصيّة‎
--removeComments TypeScriptRemoveComments قيمة منطقية‎
--rootDir TypeScriptRootDir مسار ملفّات‎
--rootDirs غير مدعوم
--skipLibCheck TypeScriptSkipLibCheck قيمة منطقيّة‎
--skipDefaultLibCheck TypeScriptSkipDefaultLibCheck قيمة منطقيّة‎
--sourceMap TypeScriptSourceMap مسار ملفّات ‎
--sourceRoot TypeScriptSourceRoot مسار ملفّات ‎
--strict TypeScriptStrict قيمة منطقيّة‎
--strictFunctionTypes TypeScriptStrictFunctionTypes قيمة منطقيّة
--strictNullChecks TypeScriptStrictNullChecks قيمة منطقيّة
--strictPropertyInitialization TypeScriptStrictPropertyInitialization قيمة منطقيّة
--stripInternal TypeScriptStripInternal قيمة منطقيّة
--suppressExcessPropertyErrors TypeScriptSuppressExcessPropertyErrors قيمة منطقيّة
--suppressImplicitAnyIndexErrors TypeScriptSuppressImplicitAnyIndexErrors قيمة منطقيّة
--target TypeScriptTarget ES3‎، أو ‎ES5‎، أو ‎ES6‎.
--traceResolution غير مدعوم
--types غير مدعوم
--typeRoots غير مدعوم
--watch غير مدعوم
‎خيار موجود في MSBuild فقط. TypeScriptAdditionalFlags أي خيار من خيارات المترجم.‎

ما هي الخيارات المدعومة في نسخة Visual Studio الخاصة بي؟

انظر ملفّ ‎C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets‎. الاقترانات المعتمدة بين وسوم XML في MSBuild وخيارات المترجم ‎tsc‎ موجودة في هذا الملفّ.

ToolsVersion

تُحدِّد قيمة الخاصية ‎<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>‎ في ملف المشروع نسخةَ المترجم التي ستُستَخدَم لبناء المشروع (1.7 في هذا المثال). هذا يسمح لمشروعٍ بالبناء باستخدام نفس نسخة المترجم على أجهزة ومنصات مختلفة.

إذا لم تُحدَّد النسخة عبر ‎TypeScriptToolsVersion‎، فسيُستخدَم أحدث إصدار من المترجم المثبت على الجهاز لبناء المشروع.

سيُلاحظ مستخدمو النسخ الأحدث من TypeScript محثًّا (prompt) يحثّ على ترقية المشروع في أول تحميل.

TypeScriptCompileBlocked

إن كنت تستعمل أداة بناء مختلفة لبناء مشروعك (مثل gulp، أوgrunt أو ما شابه)، مع Visual Studio للتطوير والتنقيح (debugging)، فاضبط الوسم ‎<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>‎ في مشروعك. سيمنحك هذا كل الدعم الذي تحتاج إليه عند التحرير دون بناء المشروع عند الضغط على مفتاح F5.

مصادر