mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
[Transform]: fix emit __extends within system.registry (#7973)
* Fix 7912: emit extends-helper inside System.registry * Fix 7912: emit extends-helper inside System.registry * Address PR: move setEmitNodeFlag into updateSourceFile * Address PR: fix comment
This commit is contained in:
parent
1e49a57a8d
commit
a27b4d07ae
@ -10,6 +10,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const {
|
||||
getNodeEmitFlags,
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
hoistVariableDeclaration,
|
||||
@ -120,6 +121,8 @@ namespace ts {
|
||||
);
|
||||
|
||||
// Write the call to `System.register`
|
||||
// Clear the emit-helpers flag for later passes since we'll have already used it in the module body
|
||||
// So the helper will be emit at the correct position instead of at the top of the source-file
|
||||
return updateSourceFile(node, [
|
||||
createStatement(
|
||||
createCall(
|
||||
@ -129,7 +132,7 @@ namespace ts {
|
||||
: [dependencies, body]
|
||||
)
|
||||
)
|
||||
]);
|
||||
], /*nodeEmitFlags*/ ~NodeEmitFlags.EmitEmitHelpers & getNodeEmitFlags(node));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1374,9 +1377,10 @@ namespace ts {
|
||||
hoistBindingElement(node, /*isExported*/ false);
|
||||
}
|
||||
|
||||
function updateSourceFile(node: SourceFile, statements: Statement[]) {
|
||||
function updateSourceFile(node: SourceFile, statements: Statement[], nodeEmitFlags: NodeEmitFlags) {
|
||||
const updated = getMutableClone(node);
|
||||
updated.statements = createNodeArray(statements, node.statements);
|
||||
setNodeEmitFlags(updated, nodeEmitFlags);
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,14 +30,14 @@ System.register([], function (exports_1, context_1) {
|
||||
};
|
||||
});
|
||||
//// [bar.js]
|
||||
System.register(['./foo'], function(exports_1, context_1) {
|
||||
System.register(["./foo"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var foo_1, Bar;
|
||||
return {
|
||||
setters: [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user