Skip to content

Commit 2d2709f

Browse files
committed
Fixed typo in visitCallExpression
1 parent 30433c2 commit 2d2709f

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/compiler/printer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const _super = (function (geti, seti) {
147147
let startLexicalEnvironment: () => void;
148148
let endLexicalEnvironment: () => Statement[];
149149
let getNodeEmitFlags: (node: Node) => NodeEmitFlags;
150+
let setNodeEmitFlags: (node: Node, flags: NodeEmitFlags) => void;
150151
let isExpressionSubstitutionEnabled: (node: Node) => boolean;
151152
let isEmitNotificationEnabled: (node: Node) => boolean;
152153
let expressionSubstitution: (node: Expression) => Expression;
@@ -209,6 +210,7 @@ const _super = (function (geti, seti) {
209210
startLexicalEnvironment = undefined;
210211
endLexicalEnvironment = undefined;
211212
getNodeEmitFlags = undefined;
213+
setNodeEmitFlags = undefined;
212214
isExpressionSubstitutionEnabled = undefined;
213215
isEmitNotificationEnabled = undefined;
214216
expressionSubstitution = undefined;
@@ -230,6 +232,7 @@ const _super = (function (geti, seti) {
230232
startLexicalEnvironment = context.startLexicalEnvironment;
231233
endLexicalEnvironment = context.endLexicalEnvironment;
232234
getNodeEmitFlags = context.getNodeEmitFlags;
235+
setNodeEmitFlags = context.setNodeEmitFlags;
233236
isExpressionSubstitutionEnabled = context.isExpressionSubstitutionEnabled;
234237
isEmitNotificationEnabled = context.isEmitNotificationEnabled;
235238
expressionSubstitution = context.expressionSubstitution;
@@ -1968,10 +1971,13 @@ const _super = (function (geti, seti) {
19681971
}
19691972

19701973
function tryEmitSubstitute(node: Node, substitution: (node: Node) => Node) {
1971-
const substitute = substitution ? substitution(node) : node;
1972-
if (substitute && substitute !== node) {
1973-
emitWorker(substitute);
1974-
return true;
1974+
if (substitution && (getNodeEmitFlags(node) & NodeEmitFlags.NoSubstitution) === 0) {
1975+
const substitute = substitution(node);
1976+
if (substitute !== node) {
1977+
setNodeEmitFlags(substitute, NodeEmitFlags.NoSubstitution);
1978+
emitWorker(substitute);
1979+
return true;
1980+
}
19751981
}
19761982

19771983
return false;

src/compiler/transformers/es6.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,11 +1036,11 @@ namespace ts {
10361036
// explicit initializer since downlevel codegen for destructuring will fail
10371037
// in the absence of initializer so all binding elements will say uninitialized
10381038
const name = node.name;
1039-
if (isBindingPattern(name) || node.initializer) {
1039+
if (isBindingPattern(name)) {
10401040
return visitVariableDeclaration(node);
10411041
}
10421042

1043-
if (shouldEmitExplicitInitializerForLetDeclaration(node)) {
1043+
if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
10441044
const clone = getMutableClone(node);
10451045
clone.initializer = createVoidZero();
10461046
return clone;
@@ -1416,7 +1416,7 @@ namespace ts {
14161416
// We are here either because SuperKeyword was used somewhere in the expression, or
14171417
// because we contain a SpreadElementExpression.
14181418

1419-
const { target, thisArg } = createCallBinding(node);
1419+
const { target, thisArg } = createCallBinding(node.expression);
14201420
if (node.transformFlags & TransformFlags.ContainsSpreadElementExpression) {
14211421
// [source]
14221422
// f(...a, b)

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,6 +2809,7 @@ namespace ts {
28092809
AdviseOnEmitNode = 1 << 7, // The node printer should invoke the onBeforeEmitNode and onAfterEmitNode callbacks when printing this node.
28102810
IsNotEmittedNode = 1 << 8, // Is a node that is not emitted but whose comments should be preserved if possible.
28112811
EmitCommentsOfNotEmittedParent = 1 << 9, // Emits comments of missing parent nodes.
2812+
NoSubstitution = 1 << 10, // Disables further substitution of an expression.
28122813
}
28132814

28142815
/** Additional context provided to `visitEachChild` */

0 commit comments

Comments
 (0)