Be more conservative on when we'll emit a function in a single line.

This commit is contained in:
Cyrus Najmabadi
2015-02-23 12:31:40 -08:00
parent 8d0dc91d64
commit f46cb896a8
52 changed files with 437 additions and 219 deletions
+21 -91
View File
@@ -3932,10 +3932,9 @@ module ts {
}
function emitBlockFunctionBody(node: FunctionLikeDeclaration, body: Block) {
// If the body has no statements, and we know there's no code that would have to
// run that could cause side effects, then just do a simple emit if the empty
// block.
if (body.statements.length === 0 && !hasPossibleSideEffectingParameterInitializers(node)) {
// If the body has no statements, and we know there's no code that would cause any
// prologue to be emitted, then just do a simple emit if the empty block.
if (body.statements.length === 0 && !anyParameterHasBindingPatternOrInitializer(node)) {
emitFunctionBodyWithNoStatements(node, body);
}
else {
@@ -3943,102 +3942,33 @@ module ts {
}
}
function hasPossibleSideEffectingParameterInitializers(func: FunctionLikeDeclaration) {
return forEach(func.parameters, hasPossibleSideEffects);
function anyParameterHasBindingPatternOrInitializer(func: FunctionLikeDeclaration) {
return forEach(func.parameters, hasBindingPatternOrInitializer);
}
function hasPossibleSideEffects(node: Node): boolean {
if (!node) {
return false;
}
switch (node.kind) {
// TODO(cyrusn): Increase the number of cases we support for determining if
// something is side effect free.
//
// NOTE(cyrusn): Some expressions may seem to be side effect free, but may
// actually have side effects. For example, a binary + expression may cause
// the toString method to be called on value, which may have side effects.
// These are the set of syntactic productions which we know could definitely
// have side effects:
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
return true;
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
// Property/Element access might end up causing an accessor to run. As
// such, we have to assume there will be side effects.
return true;
// These are the set of syntactic productions which we know definitely do not
// have side effects:
case SyntaxKind.StringLiteral:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.NumericLiteral:
case SyntaxKind.RegularExpressionLiteral:
case SyntaxKind.TrueKeyword:
case SyntaxKind.FalseKeyword:
case SyntaxKind.NullKeyword:
case SyntaxKind.Identifier:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return false;
// These constructs may or may not have side effects depending on their
// constituent children.
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
return forEach((<BindingPattern>node).elements, hasPossibleSideEffects);
case SyntaxKind.BindingElement:
return hasPossibleSideEffects((<BindingElement>node).name) ||
hasPossibleSideEffects((<BindingElement>node).initializer);
case SyntaxKind.Parameter:
return hasPossibleSideEffects((<ParameterDeclaration>node).name) ||
hasPossibleSideEffects((<ParameterDeclaration>node).initializer);
case SyntaxKind.ArrayLiteralExpression:
return forEach((<ArrayLiteralExpression>node).elements, hasPossibleSideEffects);
case SyntaxKind.ParenthesizedExpression:
return hasPossibleSideEffects((<ParenthesizedExpression>node).expression);
case SyntaxKind.ObjectLiteralExpression:
return forEach((<ObjectLiteralExpression>node).properties, hasPossibleSideEffects);
case SyntaxKind.PropertyAssignment:
return hasPossibleSideEffects((<PropertyAssignment>node).name) ||
hasPossibleSideEffects((<PropertyAssignment>node).initializer);
case SyntaxKind.ComputedPropertyName:
return hasPossibleSideEffects((<ComputedPropertyName>node).expression);
default:
// We are conservative. Unless we have proved something is side effect
// free, we assume it has possible side effects.
return true;
}
function hasBindingPatternOrInitializer(parameter: ParameterDeclaration) {
return parameter.initializer || isBindingPattern(parameter.name);
}
function emitFunctionBodyWithNoStatements(node: FunctionLikeDeclaration, body: Block) {
if (isSingleLineEmptyBlock(node.body)) {
write(" { }");
var singleLine = isSingleLineEmptyBlock(node.body);
write(" {");
if (singleLine) {
write(" ");
}
else {
write(" {");
writeLine();
increaseIndent();
emitLeadingCommentsOfPosition(body.statements.end);
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
writeLine();
}
emitLeadingCommentsOfPosition(body.statements.end);
if (!singleLine) {
decreaseIndent();
}
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
}
function emitFunctionBodyWithStatements(node: FunctionLikeDeclaration, body: Block) {
@@ -4,4 +4,5 @@ function * foo(a = yield => yield) {
//// [FunctionDeclaration10_es6.js]
function foo(a) {
if (a === void 0) { a = function (yield) { return yield; }; }
}
@@ -4,4 +4,5 @@ function f(yield = yield) {
//// [FunctionDeclaration3_es6.js]
function f(yield) {
if (yield === void 0) { yield = yield; }
}
@@ -4,4 +4,5 @@ function*foo(a = yield) {
//// [FunctionDeclaration6_es6.js]
function foo(a) {
if (a === void 0) { a = yield; }
}
@@ -9,5 +9,6 @@ function*bar() {
function bar() {
// 'yield' here is an identifier, and not a yield expression.
function foo(a) {
if (a === void 0) { a = yield; }
}
}
@@ -10,12 +10,16 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "X", {
set: function (v) { },
set: function (v) {
if (v === void 0) { v = 0; }
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "X", {
set: function (v2) { },
set: function (v2) {
if (v2 === void 0) { v2 = 0; }
},
enumerable: true,
configurable: true
});
@@ -57,9 +57,15 @@ b.b(1);
//// [callSignatureWithOptionalParameterAndInitializer.js]
// Optional parameters cannot also have initializer expressions, these are all errors
function foo(x) { }
var f = function foo(x) { };
var f2 = function (x, y) { };
function foo(x) {
if (x === void 0) { x = 1; }
}
var f = function foo(x) {
if (x === void 0) { x = 1; }
};
var f2 = function (x, y) {
if (y === void 0) { y = 1; }
};
foo(1);
foo();
f(1);
@@ -69,7 +75,9 @@ f2(1, 2);
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
@@ -86,9 +94,15 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function (x) { },
a: function foo(x, y) { },
b: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
a: function foo(x, y) {
if (y === void 0) { y = ''; }
},
b: function (x) {
if (x === void 0) { x = ''; }
}
};
b.foo();
b.foo(1);
@@ -59,9 +59,15 @@ b.b(1);
//// [callSignaturesWithParameterInitializers.js]
// Optional parameters allow initializers only in implementation signatures
function foo(x) { }
var f = function foo(x) { };
var f2 = function (x, y) { };
function foo(x) {
if (x === void 0) { x = 1; }
}
var f = function foo(x) {
if (x === void 0) { x = 1; }
};
var f2 = function (x, y) {
if (y === void 0) { y = 1; }
};
foo(1);
foo();
f(1);
@@ -71,7 +77,9 @@ f2(1, 2);
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
@@ -89,9 +97,15 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function (x) { },
a: function foo(x, y) { },
b: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
a: function foo(x, y) {
if (y === void 0) { y = 1; }
},
b: function (x) {
if (x === void 0) { x = 1; }
}
};
b.foo();
b.foo(1);
@@ -28,21 +28,29 @@ b.foo(1);
//// [callSignaturesWithParameterInitializers2.js]
// Optional parameters allow initializers only in implementation signatures
// All the below declarations are errors
function foo(x) { }
function foo(x) {
if (x === void 0) { x = 1; }
}
foo(1);
foo();
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
c.foo();
c.foo(1);
var b = {
foo: function (x) { },
foo: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
foo: function (x) {
if (x === void 0) { x = 1; }
}
};
b.foo();
b.foo(1);
@@ -23,7 +23,9 @@ module M {
var M;
(function (_M) {
_M.x = 3;
function fn(M, p) { }
function fn(M, p) {
if (p === void 0) { p = _M.x; }
}
})(M || (M = {}));
var M;
(function (_M) {
@@ -39,7 +39,9 @@ var M;
var c = (function () {
function c() {
}
c.prototype.fn = function (M, p) { };
c.prototype.fn = function (M, p) {
if (p === void 0) { p = _M.x; }
};
return c;
})();
})(M || (M = {}));
File diff suppressed because one or more lines are too long
@@ -2197,18 +2197,21 @@ sourceFile:contextualTyping.ts
2 > ^^^^
3 > ^
4 > ^
5 > ^^^^^
5 > ^^^^
6 > ^
1 >
>function
2 > c9t5
3 > (
4 > f: (n: number) => IFoo
5 > ) {}
5 > ) {
6 > }
1 >Emitted(87, 10) Source(146, 10) + SourceIndex(0)
2 >Emitted(87, 14) Source(146, 14) + SourceIndex(0)
3 >Emitted(87, 15) Source(146, 15) + SourceIndex(0)
4 >Emitted(87, 16) Source(146, 37) + SourceIndex(0)
5 >Emitted(87, 21) Source(146, 41) + SourceIndex(0)
5 >Emitted(87, 20) Source(146, 40) + SourceIndex(0)
6 >Emitted(87, 21) Source(146, 41) + SourceIndex(0)
---
>>>;
1 >
@@ -290,6 +290,7 @@ function f16() {
var _a = f15(), a = _a.a, b = _a.b, c = _a.c;
}
function f17(_a) {
var _b = _a.a, a = _b === void 0 ? "" : _b, _c = _a.b, b = _c === void 0 ? 0 : _c, _d = _a.c, c = _d === void 0 ? false : _d;
}
f17({});
f17({ a: "hello" });
@@ -49,16 +49,24 @@ s = f2('');
s = f2();
n = f2();
// Contextually type the default arg with the type annotation
var f3 = function (a) { };
var f3 = function (a) {
if (a === void 0) { a = function (s) { return s; }; }
};
// Type check using the function's contextual type
var f4 = function (a) { };
var f4 = function (a) {
if (a === void 0) { a = ""; }
};
// Contextually type the default arg using the function's contextual type
var f5 = function (a) { };
var f5 = function (a) {
if (a === void 0) { a = function (s) { return s; }; }
};
var U;
(function (U) {
U.x;
})(U || (U = {}));
var f6 = function (t) { };
var f6 = function (t) {
if (t === void 0) { t = T; }
};
var f7 = function (t) {
if (t === void 0) { t = U; }
return t;
@@ -20,12 +20,18 @@ interface I {
var f: (a = 3) => number;
//// [defaultArgsInOverloads.js]
function fun(a) { }
function fun(a) {
if (a === void 0) { a = null; }
}
var C = (function () {
function C() {
}
C.prototype.fun = function (a) { };
C.fun = function (a) { };
C.prototype.fun = function (a) {
if (a === void 0) { a = null; }
};
C.fun = function (a) {
if (a === void 0) { a = null; }
};
return C;
})();
var f;
@@ -3,4 +3,6 @@ function foo(x: string = '');
function foo(x = '') { }
//// [defaultValueInFunctionOverload1.js]
function foo(x) { }
function foo(x) {
if (x === void 0) { x = ''; }
}
@@ -11,7 +11,9 @@ foo(() => { return false; });
var f1 = function () { };
var f2 = function (x, y) { };
var f3 = function (x, y) { };
var f4 = function (x, y, z) { };
var f4 = function (x, y, z) {
if (z === void 0) { z = 10; }
};
function foo(func) { }
foo(function () { return true; });
foo(function () { return false; });
@@ -5,7 +5,23 @@ function bar(y = 10) { }
function bar1(y = 10, ...rest) { }
//// [emitDefaultParametersFunction.js]
function foo(x, y) { }
function baz(x, y) { }
function bar(y) { }
function bar1(y) { }
function foo(x, y) {
if (y === void 0) { y = 10; }
}
function baz(x, y) {
if (y === void 0) { y = 5; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
}
function bar(y) {
if (y === void 0) { y = 10; }
}
function bar1(y) {
if (y === void 0) { y = 10; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
}
@@ -10,10 +10,45 @@ var z = (function (num: number, boo = false, ...rest) { })(10)
//// [emitDefaultParametersFunctionExpression.js]
var lambda1 = function (y) { };
var lambda2 = function (x, y) { };
var lambda3 = function (x, y) { };
var lambda4 = function (y) { };
var x = function (str) { };
var y = (function (num, boo) { })();
var z = (function (num, boo) { })(10);
var lambda1 = function (y) {
if (y === void 0) { y = "hello"; }
};
var lambda2 = function (x, y) {
if (y === void 0) { y = "hello"; }
};
var lambda3 = function (x, y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
};
var lambda4 = function (y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
var x = function (str) {
if (str === void 0) { str = "hello"; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
var y = (function (num, boo) {
if (num === void 0) { num = 10; }
if (boo === void 0) { boo = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
})();
var z = (function (num, boo) {
if (boo === void 0) { boo = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
})(10);
@@ -9,8 +9,24 @@ var obj2 = {
//// [emitDefaultParametersFunctionProperty.js]
var obj2 = {
func1: function (y) { },
func2: function (x) { },
func3: function (x, z, y) { },
func4: function (x, z, y) { },
func1: function (y) {
if (y === void 0) { y = 10; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
},
func2: function (x) {
if (x === void 0) { x = "hello"; }
},
func3: function (x, z, y) {
if (y === void 0) { y = "hello"; }
},
func4: function (x, z, y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 3; _i < arguments.length; _i++) {
rest[_i - 3] = arguments[_i];
}
},
};
@@ -22,10 +22,26 @@ var C = (function () {
function C(t, z, x, y) {
if (y === void 0) { y = "hello"; }
}
C.prototype.foo = function (x, t) { };
C.prototype.foo1 = function (x, t) { };
C.prototype.bar = function (t) { };
C.prototype.boo = function (t) { };
C.prototype.foo = function (x, t) {
if (t === void 0) { t = false; }
};
C.prototype.foo1 = function (x, t) {
if (t === void 0) { t = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
};
C.prototype.bar = function (t) {
if (t === void 0) { t = false; }
};
C.prototype.boo = function (t) {
if (t === void 0) { t = false; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
return C;
})();
var D = (function () {
+3
View File
@@ -95,9 +95,12 @@ function withOptionalParams(a) {
}
var withOptionalParamsVar = withOptionalParams;
function withInitializedParams(a, b0, b, c) {
if (b === void 0) { b = 30; }
if (c === void 0) { c = "string value"; }
}
var withInitializedParamsVar = withInitializedParams;
function withOptionalInitializedParams(a, c) {
if (c === void 0) { c = "hello string"; }
}
var withOptionalInitializedParamsVar = withOptionalInitializedParams;
function withRestParams(a) {
@@ -113,6 +113,7 @@ function f6(n) {
}
// Function signature with initializer referencing other parameter to the right
function f7(n, m) {
if (n === void 0) { n = m; }
}
// FunctionExpression with non -void return type annotation with a throw, no return, and other code
// Should be error but isn't
@@ -2,4 +2,6 @@
function foo(x = 0) { }
//// [functionWithDefaultParameterWithNoStatements1.js]
function foo(x) { }
function foo(x) {
if (x === void 0) { x = 0; }
}
@@ -5,6 +5,9 @@ function bar(a = [0]) {
}
//// [functionWithDefaultParameterWithNoStatements10.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = [0]; }
}
function bar(a) {
if (a === void 0) { a = [0]; }
}
@@ -8,6 +8,9 @@ function bar(a = (v)) {
//// [functionWithDefaultParameterWithNoStatements12.js]
var v;
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = (v); }
}
function bar(a) {
if (a === void 0) { a = (v); }
}
@@ -4,4 +4,5 @@ function foo(x = 0) {
//// [functionWithDefaultParameterWithNoStatements2.js]
function foo(x) {
if (x === void 0) { x = 0; }
}
@@ -5,6 +5,9 @@ function bar(a = "") {
}
//// [functionWithDefaultParameterWithNoStatements3.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = ""; }
}
function bar(a) {
if (a === void 0) { a = ""; }
}
@@ -5,6 +5,9 @@ function bar(a = ``) {
}
//// [functionWithDefaultParameterWithNoStatements4.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = ""; }
}
function bar(a) {
if (a === void 0) { a = ""; }
}
@@ -5,6 +5,9 @@ function bar(a = 0) {
}
//// [functionWithDefaultParameterWithNoStatements5.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = 0; }
}
function bar(a) {
if (a === void 0) { a = 0; }
}
@@ -5,6 +5,9 @@ function bar(a = true) {
}
//// [functionWithDefaultParameterWithNoStatements6.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = true; }
}
function bar(a) {
if (a === void 0) { a = true; }
}
@@ -5,6 +5,9 @@ function bar(a = false) {
}
//// [functionWithDefaultParameterWithNoStatements7.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = false; }
}
function bar(a) {
if (a === void 0) { a = false; }
}
@@ -5,6 +5,9 @@ function bar(a = undefined) {
}
//// [functionWithDefaultParameterWithNoStatements8.js]
function foo(a) { }
function bar(a) {
function foo(a) {
if (a === void 0) { a = undefined; }
}
function bar(a) {
if (a === void 0) { a = undefined; }
}
@@ -1065,18 +1065,42 @@ var x120 = (function () {
}
return x120;
})();
function x121(parm) { }
function x122(parm) { }
function x123(parm) { }
function x124(parm) { }
function x125(parm) { }
function x126(parm) { }
function x127(parm) { }
function x128(parm) { }
function x129(parm) { }
function x130(parm) { }
function x131(parm) { }
function x132(parm) { }
function x121(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x122(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x123(parm) {
if (parm === void 0) { parm = function named() { return [d1, d2]; }; }
}
function x124(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x125(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x126(parm) {
if (parm === void 0) { parm = function named() { return [d1, d2]; }; }
}
function x127(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x128(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x129(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x130(parm) {
if (parm === void 0) { parm = { n: [d1, d2] }; }
}
function x131(parm) {
if (parm === void 0) { parm = function (n) { var n; return null; }; }
}
function x132(parm) {
if (parm === void 0) { parm = { func: function (n) { return [d1, d2]; } }; }
}
function x133() { return function () { return [d1, d2]; }; }
function x134() { return function () { return [d1, d2]; }; }
function x135() { return function named() { return [d1, d2]; }; }
@@ -19,8 +19,18 @@ function foo2(x) {
if (x === void 0) { x = undefined; }
return x;
} // ok
function foo3(x) { } // error
function foo4(x, y) { } // error
function foo5(x, y) { } // ok
function foo6(x, y, z) { } // error
function foo7(x, y) { } // should be ok
function foo3(x) {
if (x === void 0) { x = 1; }
} // error
function foo4(x, y) {
if (y === void 0) { y = x; }
} // error
function foo5(x, y) {
if (y === void 0) { y = x; }
} // ok
function foo6(x, y, z) {
if (z === void 0) { z = y; }
} // error
function foo7(x, y) {
if (y === void 0) { y = x; }
} // should be ok
@@ -21,10 +21,16 @@ function func2(a, b, c) { }
; // error at "a,b,c"
function func3() { }
; // error at "args"
function func4(z, w) { }
function func4(z, w) {
if (z === void 0) { z = null; }
if (w === void 0) { w = undefined; }
}
; // error at "z,w"
// these shouldn't be errors
function noError1(x, y) { }
function noError1(x, y) {
if (x === void 0) { x = 3; }
if (y === void 0) { y = 2; }
}
;
function noError2(x, y) { }
;
@@ -10,12 +10,21 @@ var a = (x?=0) => { return 1; };
var b = (x, y?:number = 2) => { x; };
//// [optionalArgsWithDefaultValues.js]
function foo(x, y, z) { }
function foo(x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
}
var CCC = (function () {
function CCC() {
}
CCC.prototype.foo = function (x, y, z) { };
CCC.foo2 = function (x, y, z) { };
CCC.prototype.foo = function (x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
};
CCC.foo2 = function (x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
};
return CCC;
})();
var a = function (x) {
@@ -10,6 +10,7 @@ foo([false, 0, ""]);
//// [optionalBindingParameters1.js]
function foo(_a) {
var x = _a[0], y = _a[1], z = _a[2];
}
foo(["", 0, false]);
foo([false, 0, ""]);
@@ -10,6 +10,7 @@ foo({ x: false, y: 0, z: "" });
//// [optionalBindingParameters2.js]
function foo(_a) {
var x = _a.x, y = _a.y, z = _a.z;
}
foo({ x: "", y: 0, z: false });
foo({ x: false, y: 0, z: "" });
@@ -242,7 +242,10 @@ c1o1.C1M4();
i1o1.C1M4();
F4();
L4();
function fnOpt1(id, children, expectedPath, isRoot) { }
function fnOpt1(id, children, expectedPath, isRoot) {
if (children === void 0) { children = []; }
if (expectedPath === void 0) { expectedPath = []; }
}
function fnOpt2(id, children, expectedPath, isRoot) { }
fnOpt1(1, [2, 3], [1], true);
fnOpt2(1, [2, 3], [1], true);
@@ -73,14 +73,23 @@ function outside() {
var b;
}
}
function defaultArgFunction(a, b) { }
function defaultArgArrow(a, b) { }
function defaultArgFunction(a, b) {
if (a === void 0) { a = function () { return b; }; }
if (b === void 0) { b = 1; }
}
function defaultArgArrow(a, b) {
if (a === void 0) { a = function () { return function () { return b; }; }; }
if (b === void 0) { b = 3; }
}
var C = (function () {
function C(a, b) {
if (a === void 0) { a = b; }
if (b === void 0) { b = 1; }
}
C.prototype.method = function (a, b) { };
C.prototype.method = function (a, b) {
if (a === void 0) { a = b; }
if (b === void 0) { b = 1; }
};
return C;
})();
// Function expressions
@@ -8,7 +8,9 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "Foo", {
set: function (a) { },
set: function (a) {
if (a === void 0) { a = 1; }
},
enumerable: true,
configurable: true
});
@@ -7,6 +7,12 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
if (bar === void 0) { bar = 0; }
var bar = [];
for (var _i = 0; _i < arguments.length; _i++) {
bar[_i - 0] = arguments[_i];
}
};
return C;
})();
@@ -7,6 +7,8 @@ class C {
var C = (function () {
function C() {
}
C.prototype.F = function (A) { };
C.prototype.F = function (A) {
if (A === void 0) { A = 0; }
};
return C;
})();
@@ -14,10 +14,14 @@ function foo4([...r] = []) {
//// [restElementWithNullInitializer.js]
function foo1(_a) {
var _b = _a === void 0 ? null : _a, r = _b.slice(0);
}
function foo2(_a) {
var _b = _a === void 0 ? undefined : _a, r = _b.slice(0);
}
function foo3(_a) {
var _b = _a === void 0 ? {} : _a, r = _b.slice(0);
}
function foo4(_a) {
var _b = _a === void 0 ? [] : _a, r = _b.slice(0);
}
@@ -4,4 +4,10 @@ function f2(...x = []) { }
//// [restParamAsOptional.js]
function f() { }
function f2() { }
function f2() {
if (x === void 0) { x = []; }
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
}
}
@@ -15,8 +15,11 @@ class C {
//// [selfReferencesInFunctionParameters.js]
function foo(x) {
if (x === void 0) { x = x; }
}
function bar(x0, x) {
if (x0 === void 0) { x0 = ""; }
if (x === void 0) { x = x; }
}
var C = (function () {
function C(x, y) {
@@ -1,2 +1,2 @@
//// [sourceMapValidationFunctionPropertyAssignment.js.map]
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAM,EAAE,CAAC"}
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAK,CAAC,EAAE,CAAC"}
@@ -15,27 +15,30 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^
8 > ^^
9 > ^
10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
7 > ^^^^^^^^^^^^^^^^
8 > ^
9 > ^^
10> ^
11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
2 >var
3 > x
4 > =
5 > {
6 > n
7 > () { }
8 > }
9 > ;
7 > () {
8 > }
9 > }
10> ;
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(1, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(1, 12) + SourceIndex(0)
7 >Emitted(1, 29) Source(1, 18) + SourceIndex(0)
8 >Emitted(1, 31) Source(1, 20) + SourceIndex(0)
9 >Emitted(1, 32) Source(1, 21) + SourceIndex(0)
7 >Emitted(1, 28) Source(1, 17) + SourceIndex(0)
8 >Emitted(1, 29) Source(1, 18) + SourceIndex(0)
9 >Emitted(1, 31) Source(1, 20) + SourceIndex(0)
10>Emitted(1, 32) Source(1, 21) + SourceIndex(0)
---
>>>//# sourceMappingURL=sourceMapValidationFunctionPropertyAssignment.js.map
File diff suppressed because one or more lines are too long
@@ -2266,15 +2266,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn1_2_2
3 >
4 > public AisIn1_2_2() { }
4 > public AisIn1_2_2() {
5 > }
1->Emitted(114, 21) Source(79, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
2 >Emitted(114, 48) Source(79, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
3 >Emitted(114, 51) Source(79, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
4 >Emitted(114, 66) Source(79, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
4 >Emitted(114, 65) Source(79, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
5 >Emitted(114, 66) Source(79, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2353,15 +2356,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > BisIn1_2_2
3 >
4 > public BisIn1_2_2() { }
4 > public BisIn1_2_2() {
5 > }
1->Emitted(121, 21) Source(80, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
2 >Emitted(121, 48) Source(80, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
3 >Emitted(121, 51) Source(80, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
4 >Emitted(121, 66) Source(80, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
4 >Emitted(121, 65) Source(80, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
5 >Emitted(121, 66) Source(80, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
---
>>> return ClassB;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2440,15 +2446,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > CisIn1_2_2
3 >
4 > public CisIn1_2_2() { }
4 > public CisIn1_2_2() {
5 > }
1->Emitted(128, 21) Source(81, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
2 >Emitted(128, 48) Source(81, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
3 >Emitted(128, 51) Source(81, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
4 >Emitted(128, 66) Source(81, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
4 >Emitted(128, 65) Source(81, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
5 >Emitted(128, 66) Source(81, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
---
>>> return ClassC;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2619,15 +2628,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn1
3 >
4 > public AisIn1() { }
4 > public AisIn1() {
5 > }
1->Emitted(137, 13) Source(90, 16) + SourceIndex(0) name (TopLevelModule1.ClassA)
2 >Emitted(137, 36) Source(90, 22) + SourceIndex(0) name (TopLevelModule1.ClassA)
3 >Emitted(137, 39) Source(90, 9) + SourceIndex(0) name (TopLevelModule1.ClassA)
4 >Emitted(137, 54) Source(90, 28) + SourceIndex(0) name (TopLevelModule1.ClassA)
4 >Emitted(137, 53) Source(90, 27) + SourceIndex(0) name (TopLevelModule1.ClassA)
5 >Emitted(137, 54) Source(90, 28) + SourceIndex(0) name (TopLevelModule1.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^
@@ -3043,15 +3055,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn2_3
3 >
4 > public AisIn2_3() { }
4 > public AisIn2_3() {
5 > }
1->Emitted(157, 17) Source(105, 20) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
2 >Emitted(157, 42) Source(105, 28) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
3 >Emitted(157, 45) Source(105, 13) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
4 >Emitted(157, 60) Source(105, 34) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
4 >Emitted(157, 59) Source(105, 33) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
5 >Emitted(157, 60) Source(105, 34) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^^^^^