Skip to content

Commit

Permalink
In BundleTransformer.TypeScript added support of the TypeScript versi…
Browse files Browse the repository at this point in the history
…on 4.0.5
  • Loading branch information
Taritsyn committed Nov 2, 2020
1 parent 6caf7d3 commit a3f1165
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS1591;NU5125</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>BundleTransformer.TypeScript contains one translator-adapter - `TypeScriptTranslator` (supports the TypeScript (http://www.typescriptlang.org) version 4.0 RTM). This adapter makes translation of TypeScript code to JS code. Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is responsible for text output of translated TypeScript asset.
<Description>BundleTransformer.TypeScript contains one translator-adapter - `TypeScriptTranslator` (supports the TypeScript (http://www.typescriptlang.org) version 4.0.5). This adapter makes translation of TypeScript code to JS code. Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is responsible for text output of translated TypeScript asset.

BundleTransformer.TypeScript does not support external modules (CommonJS, AMD, SystemJS, UMD and ES6 modules).

As a JS engine is used the JavaScript Engine Switcher library (https://github.com/Taritsyn/JavaScriptEngineSwitcher). For correct working of this module, you need to install one of the following NuGet packages: JavaScriptEngineSwitcher.Msie (only in the Chakra “Edge” JsRT mode), JavaScriptEngineSwitcher.V8 or JavaScriptEngineSwitcher.ChakraCore.</Description>
<PackageIconUrl>https://raw.githubusercontent.com/Taritsyn/BundleTransformer/master/images/icons/128/BundleTransformer_TypeScript_Logo_128x128.png</PackageIconUrl>
<PackageTags>BundleTransformer;System.Web.Optimization;IBundleTransform;ASP.NET;JavaScript;JS;Bundling;TypeScript;Translation;Translator;Compilation;Compiler</PackageTags>
<PackageReleaseNotes>Added support of the TypeScript version 4.0 RTM (please note: The 4.0 RTM release is also called '4.0.2').</PackageReleaseNotes>
<PackageReleaseNotes>Added support of the TypeScript version 4.0.5.</PackageReleaseNotes>
</PropertyGroup>

<Import Project="../../build/common.props" />
Expand Down
125 changes: 83 additions & 42 deletions src/BundleTransformer.TypeScript/Resources/typescript-combined.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
var ts;
(function (ts) {
ts.versionMajorMinor = "4.0";
ts.version = "4.0.2";
ts.version = "4.0.5";
var NativeCollections;
(function (NativeCollections) {
function tryGetNativeMap() {
Expand Down Expand Up @@ -55293,13 +55293,10 @@ var ts;
function checkTupleType(node) {
var elementTypes = node.elements;
var seenOptionalElement = false;
var seenNamedElement = false;
var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember);
for (var i = 0; i < elementTypes.length; i++) {
var e = elementTypes[i];
if (e.kind === 191) {
seenNamedElement = true;
}
else if (seenNamedElement) {
if (e.kind !== 191 && hasNamedElement) {
grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
break;
}
Expand Down Expand Up @@ -69855,6 +69852,8 @@ var ts;
switch (node.kind) {
case 213:
return visitBinaryExpression(node);
case 332:
return visitCommaListExpression(node);
case 214:
return visitConditionalExpression(node);
case 216:
Expand Down Expand Up @@ -70046,20 +70045,6 @@ var ts;
}
return ts.visitEachChild(node, visitor, context);
}
function visitLogicalBinaryExpression(node) {
var resultLabel = defineLabel();
var resultLocal = declareLocal();
emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
if (node.operatorToken.kind === 55) {
emitBreakWhenFalse(resultLabel, resultLocal, node.left);
}
else {
emitBreakWhenTrue(resultLabel, resultLocal, node.left);
}
emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
markLabel(resultLabel);
return resultLocal;
}
function visitCommaExpression(node) {
var pendingExpressions = [];
visit(node.left);
Expand All @@ -70079,6 +70064,37 @@ var ts;
}
}
}
function visitCommaListExpression(node) {
var pendingExpressions = [];
for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
var elem = _a[_i];
if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27) {
pendingExpressions.push(visitCommaExpression(elem));
}
else {
if (containsYield(elem) && pendingExpressions.length > 0) {
emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
pendingExpressions = [];
}
pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression));
}
}
return factory.inlineExpressions(pendingExpressions);
}
function visitLogicalBinaryExpression(node) {
var resultLabel = defineLabel();
var resultLocal = declareLocal();
emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
if (node.operatorToken.kind === 55) {
emitBreakWhenFalse(resultLabel, resultLocal, node.left);
}
else {
emitBreakWhenTrue(resultLabel, resultLocal, node.left);
}
emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
markLabel(resultLabel);
return resultLocal;
}
function visitConditionalExpression(node) {
if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
var whenFalseLabel = defineLabel();
Expand Down Expand Up @@ -80481,6 +80497,7 @@ var ts;
getOptionsDiagnostics: getOptionsDiagnostics,
getGlobalDiagnostics: getGlobalDiagnostics,
getSemanticDiagnostics: getSemanticDiagnostics,
getCachedSemanticDiagnostics: getCachedSemanticDiagnostics,
getSuggestionDiagnostics: getSuggestionDiagnostics,
getDeclarationDiagnostics: getDeclarationDiagnostics,
getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
Expand Down Expand Up @@ -80995,6 +81012,11 @@ var ts;
function getSemanticDiagnostics(sourceFile, cancellationToken) {
return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
}
function getCachedSemanticDiagnostics(sourceFile) {
var _a;
return sourceFile
? (_a = cachedBindAndCheckDiagnosticsForFile.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path) : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
}
function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
}
Expand Down Expand Up @@ -83589,30 +83611,49 @@ var ts;
return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
}
function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
var restorePendingEmitOnHandlingNoEmitSuccess = false;
var savedAffectedFilesPendingEmit;
var savedAffectedFilesPendingEmitKind;
var savedAffectedFilesPendingEmitIndex;
if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
!targetSourceFile &&
!ts.outFile(state.compilerOptions) &&
!state.compilerOptions.noEmit &&
state.compilerOptions.noEmitOnError) {
restorePendingEmitOnHandlingNoEmitSuccess = true;
savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
}
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
if (result)
return result;
if (!targetSourceFile) {
var sourceMaps = [];
var emitSkipped = false;
var diagnostics = void 0;
var emittedFiles = [];
var affectedEmitResult = void 0;
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
}
return {
emitSkipped: emitSkipped,
diagnostics: diagnostics || ts.emptyArray,
emittedFiles: emittedFiles,
sourceMaps: sourceMaps
};
}
var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
if (result)
return result;
if (restorePendingEmitOnHandlingNoEmitSuccess) {
state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
}
if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
var sourceMaps = [];
var emitSkipped = false;
var diagnostics = void 0;
var emittedFiles = [];
var affectedEmitResult = void 0;
while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
}
return {
emitSkipped: emitSkipped,
diagnostics: diagnostics || ts.emptyArray,
emittedFiles: emittedFiles,
sourceMaps: sourceMaps
};
}
return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
}
Expand All @@ -83625,7 +83666,7 @@ var ts;
else if (affected === state.program) {
return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
}
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) {
addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
}
if (ignoreSourceFile && ignoreSourceFile(affected)) {
Expand Down
5 changes: 2 additions & 3 deletions src/BundleTransformer.TypeScript/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
===========
BundleTransformer.TypeScript contains one translator-adapter -
`TypeScriptTranslator` (supports the TypeScript (http://www.typescriptlang.org)
version 4.0 RTM). This adapter makes translation of TypeScript code to JS code.
version 4.0.5). This adapter makes translation of TypeScript code to JS code.
Also contains the `TypeScriptAssetHandler` debugging HTTP handler, which is
responsible for text output of translated TypeScript asset.

Expand All @@ -26,8 +26,7 @@
=============
RELEASE NOTES
=============
Added support of the TypeScript version 4.0 RTM (please note: The 4.0 RTM
release is also called '4.0.2').
Added support of the TypeScript version 4.0.5.

====================
POST-INSTALL ACTIONS
Expand Down

0 comments on commit a3f1165

Please sign in to comment.