mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Emit parameter initializers unless we are certain they don't have any side effects.
This commit is contained in:
+105
-1
@@ -3850,7 +3850,9 @@ module ts {
|
||||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
if (isSingleLineEmptyBlock(node.body) || !node.body) {
|
||||
if (!node.body) {
|
||||
// There can be no body when there are parse errors. Just emit an empty block
|
||||
// in that case.
|
||||
write(" { }");
|
||||
}
|
||||
else if (node.body.kind === SyntaxKind.Block) {
|
||||
@@ -3930,15 +3932,117 @@ 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)) {
|
||||
emitFunctionBodyWithNoStatements(node, body);
|
||||
}
|
||||
else {
|
||||
emitFunctionBodyWithStatements(node, body);
|
||||
}
|
||||
}
|
||||
|
||||
function hasPossibleSideEffectingParameterInitializers(func: FunctionLikeDeclaration) {
|
||||
return forEach(func.parameters, hasPossibleSideEffects);
|
||||
}
|
||||
|
||||
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.
|
||||
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;
|
||||
|
||||
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.PropertyAccessExpression:
|
||||
return hasPossibleSideEffects((<PropertyAccessExpression>node).expression);
|
||||
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return forEach((<ArrayLiteralExpression>node).elements, hasPossibleSideEffects);
|
||||
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return hasPossibleSideEffects((<ElementAccessExpression>node).expression) ||
|
||||
hasPossibleSideEffects((<ElementAccessExpression>node).argumentExpression);
|
||||
|
||||
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 emitFunctionBodyWithNoStatements(node: FunctionLikeDeclaration, body: Block) {
|
||||
if (isSingleLineEmptyBlock(node.body)) {
|
||||
write(" { }");
|
||||
}
|
||||
else {
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitLeadingCommentsOfPosition(body.statements.end);
|
||||
decreaseIndent();
|
||||
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
|
||||
}
|
||||
}
|
||||
|
||||
function emitFunctionBodyWithStatements(node: FunctionLikeDeclaration, body: Block) {
|
||||
write(" {");
|
||||
scopeEmitStart(node);
|
||||
|
||||
var outPos = writer.getTextPos();
|
||||
|
||||
increaseIndent();
|
||||
emitDetachedComments(body.statements);
|
||||
var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true);
|
||||
emitFunctionBodyPreamble(node);
|
||||
decreaseIndent();
|
||||
|
||||
var preambleEmitted = writer.getTextPos() !== outPos;
|
||||
|
||||
if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
|
||||
|
||||
@@ -4,5 +4,4 @@ function * foo(a = yield => yield) {
|
||||
|
||||
//// [FunctionDeclaration10_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = function (yield) { return yield; }; }
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@ function f(yield = yield) {
|
||||
|
||||
//// [FunctionDeclaration3_es6.js]
|
||||
function f(yield) {
|
||||
if (yield === void 0) { yield = yield; }
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@ function*foo(a = yield) {
|
||||
|
||||
//// [FunctionDeclaration6_es6.js]
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,5 @@ function*bar() {
|
||||
function bar() {
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = yield; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,6 @@ var __extends = this.__extends || function (d, b) {
|
||||
d.prototype = new __();
|
||||
};
|
||||
function foo(x, y) {
|
||||
var z = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
z[_i - 2] = arguments[_i];
|
||||
}
|
||||
}
|
||||
var a;
|
||||
var z;
|
||||
@@ -93,10 +89,6 @@ var C = (function () {
|
||||
this.foo.apply(this, [x, y].concat(z));
|
||||
}
|
||||
C.prototype.foo = function (x, y) {
|
||||
var z = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
z[_i - 2] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -56,10 +56,6 @@ function f3NoError() {
|
||||
var _i = 10; // no error
|
||||
}
|
||||
function f4(_i) {
|
||||
var rest = [];
|
||||
for (var _a = 1; _a < arguments.length; _a++) {
|
||||
rest[_a - 1] = arguments[_a];
|
||||
}
|
||||
}
|
||||
function f4NoError(_i) {
|
||||
}
|
||||
|
||||
@@ -47,10 +47,6 @@ function foo() {
|
||||
var _i = 10; // no error
|
||||
}
|
||||
function f4(_i) {
|
||||
var rest = [];
|
||||
for (var _a = 1; _a < arguments.length; _a++) {
|
||||
rest[_a - 1] = arguments[_a];
|
||||
}
|
||||
}
|
||||
function f4NoError(_i) {
|
||||
}
|
||||
|
||||
@@ -290,7 +290,6 @@ 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" });
|
||||
|
||||
@@ -95,12 +95,9 @@ 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,7 +113,6 @@ 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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements1.ts]
|
||||
function foo(x = 0) { }
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements1.js]
|
||||
function foo(x) { }
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts ===
|
||||
function foo(x = 0) { }
|
||||
>foo : (x?: number) => void
|
||||
>x : number
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements10.ts]
|
||||
function foo(a = [0]) { }
|
||||
|
||||
function bar(a = [0]) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements10.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements10.ts ===
|
||||
function foo(a = [0]) { }
|
||||
>foo : (a?: number[]) => void
|
||||
>a : number[]
|
||||
>[0] : number[]
|
||||
|
||||
function bar(a = [0]) {
|
||||
>bar : (a?: number[]) => void
|
||||
>a : number[]
|
||||
>[0] : number[]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements11.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = v[0]) { }
|
||||
|
||||
function bar(a = v[0]) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements11.js]
|
||||
var v;
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements11.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = v[0]) { }
|
||||
>foo : (a?: any) => void
|
||||
>a : any
|
||||
>v[0] : any
|
||||
>v : any[]
|
||||
|
||||
function bar(a = v[0]) {
|
||||
>bar : (a?: any) => void
|
||||
>a : any
|
||||
>v[0] : any
|
||||
>v : any[]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements12.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = (v)) { }
|
||||
|
||||
function bar(a = (v)) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements12.js]
|
||||
var v;
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements12.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = (v)) { }
|
||||
>foo : (a?: any[]) => void
|
||||
>a : any[]
|
||||
>(v) : any[]
|
||||
>v : any[]
|
||||
|
||||
function bar(a = (v)) {
|
||||
>bar : (a?: any[]) => void
|
||||
>a : any[]
|
||||
>(v) : any[]
|
||||
>v : any[]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements13.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = [1 + 1]) { }
|
||||
|
||||
function bar(a = [1 + 1]) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements13.js]
|
||||
var v;
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = [1 + 1]; }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = [1 + 1]; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = [1 + 1]) { }
|
||||
>foo : (a?: number[]) => void
|
||||
>a : number[]
|
||||
>[1 + 1] : number[]
|
||||
>1 + 1 : number
|
||||
|
||||
function bar(a = [1 + 1]) {
|
||||
>bar : (a?: number[]) => void
|
||||
>a : number[]
|
||||
>[1 + 1] : number[]
|
||||
>1 + 1 : number
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements14.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = v[1 + 1]) { }
|
||||
|
||||
function bar(a = v[1 + 1]) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements14.js]
|
||||
var v;
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = v[1 + 1]; }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = v[1 + 1]; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = v[1 + 1]) { }
|
||||
>foo : (a?: any) => void
|
||||
>a : any
|
||||
>v[1 + 1] : any
|
||||
>v : any[]
|
||||
>1 + 1 : number
|
||||
|
||||
function bar(a = v[1 + 1]) {
|
||||
>bar : (a?: any) => void
|
||||
>a : any
|
||||
>v[1 + 1] : any
|
||||
>v : any[]
|
||||
>1 + 1 : number
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements15.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = (1 + 1)) { }
|
||||
|
||||
function bar(a = (1 + 1)) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements15.js]
|
||||
var v;
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = (1 + 1); }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = (1 + 1); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = (1 + 1)) { }
|
||||
>foo : (a?: number) => void
|
||||
>a : number
|
||||
>(1 + 1) : number
|
||||
>1 + 1 : number
|
||||
|
||||
function bar(a = (1 + 1)) {
|
||||
>bar : (a?: number) => void
|
||||
>a : number
|
||||
>(1 + 1) : number
|
||||
>1 + 1 : number
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements16.ts]
|
||||
var v: any[];
|
||||
|
||||
function foo(a = bar()) { }
|
||||
|
||||
function bar(a = foo()) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements16.js]
|
||||
var v;
|
||||
function foo(a) {
|
||||
if (a === void 0) { a = bar(); }
|
||||
}
|
||||
function bar(a) {
|
||||
if (a === void 0) { a = foo(); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements16.ts ===
|
||||
var v: any[];
|
||||
>v : any[]
|
||||
|
||||
function foo(a = bar()) { }
|
||||
>foo : (a?: void) => void
|
||||
>a : void
|
||||
>bar() : void
|
||||
>bar : (a?: void) => void
|
||||
|
||||
function bar(a = foo()) {
|
||||
>bar : (a?: void) => void
|
||||
>a : void
|
||||
>foo() : void
|
||||
>foo : (a?: void) => void
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements2.ts]
|
||||
function foo(x = 0) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements2.js]
|
||||
function foo(x) {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts ===
|
||||
function foo(x = 0) {
|
||||
>foo : (x?: number) => void
|
||||
>x : number
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements3.ts]
|
||||
function foo(a = "") { }
|
||||
|
||||
function bar(a = "") {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements3.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts ===
|
||||
function foo(a = "") { }
|
||||
>foo : (a?: string) => void
|
||||
>a : string
|
||||
|
||||
function bar(a = "") {
|
||||
>bar : (a?: string) => void
|
||||
>a : string
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements4.ts]
|
||||
function foo(a = ``) { }
|
||||
|
||||
function bar(a = ``) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements4.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements4.ts ===
|
||||
function foo(a = ``) { }
|
||||
>foo : (a?: string) => void
|
||||
>a : string
|
||||
|
||||
function bar(a = ``) {
|
||||
>bar : (a?: string) => void
|
||||
>a : string
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements5.ts]
|
||||
function foo(a = 0) { }
|
||||
|
||||
function bar(a = 0) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements5.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements5.ts ===
|
||||
function foo(a = 0) { }
|
||||
>foo : (a?: number) => void
|
||||
>a : number
|
||||
|
||||
function bar(a = 0) {
|
||||
>bar : (a?: number) => void
|
||||
>a : number
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements6.ts]
|
||||
function foo(a = true) { }
|
||||
|
||||
function bar(a = true) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements6.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements6.ts ===
|
||||
function foo(a = true) { }
|
||||
>foo : (a?: boolean) => void
|
||||
>a : boolean
|
||||
|
||||
function bar(a = true) {
|
||||
>bar : (a?: boolean) => void
|
||||
>a : boolean
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements7.ts]
|
||||
function foo(a = false) { }
|
||||
|
||||
function bar(a = false) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements7.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements7.ts ===
|
||||
function foo(a = false) { }
|
||||
>foo : (a?: boolean) => void
|
||||
>a : boolean
|
||||
|
||||
function bar(a = false) {
|
||||
>bar : (a?: boolean) => void
|
||||
>a : boolean
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements8.ts]
|
||||
function foo(a = undefined) { }
|
||||
|
||||
function bar(a = undefined) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements8.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts ===
|
||||
function foo(a = undefined) { }
|
||||
>foo : (a?: any) => void
|
||||
>a : any
|
||||
>undefined : undefined
|
||||
|
||||
function bar(a = undefined) {
|
||||
>bar : (a?: any) => void
|
||||
>a : any
|
||||
>undefined : undefined
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts(1,18): error TS2304: Cannot find name 'console'.
|
||||
tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts(3,18): error TS2304: Cannot find name 'console'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts (2 errors) ====
|
||||
function foo(a = console.log) { }
|
||||
~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'console'.
|
||||
|
||||
function bar(a = console.log) {
|
||||
~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'console'.
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [functionWithDefaultParameterWithNoStatements9.ts]
|
||||
function foo(a = console.log) { }
|
||||
|
||||
function bar(a = console.log) {
|
||||
}
|
||||
|
||||
//// [functionWithDefaultParameterWithNoStatements9.js]
|
||||
function foo(a) { }
|
||||
function bar(a) {
|
||||
}
|
||||
@@ -10,7 +10,6 @@ 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,7 +10,6 @@ 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: "" });
|
||||
|
||||
@@ -11,10 +11,6 @@ foo([false, 0, ""]);
|
||||
|
||||
//// [optionalBindingParametersInOverloads1.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo(["", 0, false]);
|
||||
foo([false, 0, ""]);
|
||||
|
||||
@@ -11,10 +11,6 @@ foo({ x: false, y: 0, z: "" });
|
||||
|
||||
//// [optionalBindingParametersInOverloads2.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo({ x: "", y: 0, z: false });
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [out-flag.js.map]
|
||||
{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count","MyClass.SetCount"],"mappings":"AAAA,eAAe;AAGf,AADA,oBAAoB;IACd,OAAO;IAAbA,SAAMA,OAAOA;IAYbC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;QAEzBG,EAAEA;IACNA,CAACA;IACLH,cAACA;AAADA,CAACA,AAZD,IAYC"}
|
||||
{"version":3,"file":"out-flag.js","sourceRoot":"","sources":["out-flag.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count"],"mappings":"AAAA,eAAe;AAGf,AADA,oBAAoB;IACd,OAAO;IAAbA,SAAMA,OAAOA;IAYbC,CAACA;IAVGD,uBAAuBA;IAChBA,uBAAKA,GAAZA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IAEMF,0BAAQA,GAAfA,UAAgBA,KAAaA;QAEzBA,EAAEA;IACNA,CAACA;IACLA,cAACA;AAADA,CAACA,AAZD,IAYC"}
|
||||
@@ -150,8 +150,8 @@ sourceFile:out-flag.ts
|
||||
> {
|
||||
>
|
||||
2 > //
|
||||
1 >Emitted(11, 9) Source(14, 9) + SourceIndex(0) name (MyClass.SetCount)
|
||||
2 >Emitted(11, 11) Source(14, 11) + SourceIndex(0) name (MyClass.SetCount)
|
||||
1 >Emitted(11, 9) Source(14, 9) + SourceIndex(0) name (MyClass)
|
||||
2 >Emitted(11, 11) Source(14, 11) + SourceIndex(0) name (MyClass)
|
||||
---
|
||||
>>> };
|
||||
1 >^^^^
|
||||
@@ -160,8 +160,8 @@ sourceFile:out-flag.ts
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(12, 5) Source(15, 5) + SourceIndex(0) name (MyClass.SetCount)
|
||||
2 >Emitted(12, 6) Source(15, 6) + SourceIndex(0) name (MyClass.SetCount)
|
||||
1 >Emitted(12, 5) Source(15, 5) + SourceIndex(0) name (MyClass)
|
||||
2 >Emitted(12, 6) Source(15, 6) + SourceIndex(0) name (MyClass)
|
||||
---
|
||||
>>> return MyClass;
|
||||
1->^^^^
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [properties.js.map]
|
||||
{"version":3,"file":"properties.js","sourceRoot":"","sources":["properties.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count"],"mappings":"AACA,IAAM,OAAO;IAAbA,SAAMA,OAAOA;IAWbC,CAACA;IATGD,sBAAWA,0BAAKA;aAAhBA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;aAEDF,UAAiBA,KAAaA;YAE1BE,EAAEA;QACNA,CAACA;;;OALAF;IAMLA,cAACA;AAADA,CAACA,AAXD,IAWC"}
|
||||
{"version":3,"file":"properties.js","sourceRoot":"","sources":["properties.ts"],"names":["MyClass","MyClass.constructor","MyClass.Count"],"mappings":"AACA,IAAM,OAAO;IAAbA,SAAMA,OAAOA;IAWbC,CAACA;IATGD,sBAAWA,0BAAKA;aAAhBA;YAEIE,MAAMA,CAACA,EAAEA,CAACA;QACdA,CAACA;aAEDF,UAAiBA,KAAaA;YAE1BA,EAAEA;QACNA,CAACA;;;OALAA;IAMLA,cAACA;AAADA,CAACA,AAXD,IAWC"}
|
||||
@@ -118,8 +118,8 @@ sourceFile:properties.ts
|
||||
> {
|
||||
>
|
||||
2 > //
|
||||
1 >Emitted(9, 13) Source(11, 9) + SourceIndex(0) name (MyClass.Count)
|
||||
2 >Emitted(9, 15) Source(11, 11) + SourceIndex(0) name (MyClass.Count)
|
||||
1 >Emitted(9, 13) Source(11, 9) + SourceIndex(0) name (MyClass)
|
||||
2 >Emitted(9, 15) Source(11, 11) + SourceIndex(0) name (MyClass)
|
||||
---
|
||||
>>> },
|
||||
1 >^^^^^^^^
|
||||
@@ -128,8 +128,8 @@ sourceFile:properties.ts
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(10, 9) Source(12, 5) + SourceIndex(0) name (MyClass.Count)
|
||||
2 >Emitted(10, 10) Source(12, 6) + SourceIndex(0) name (MyClass.Count)
|
||||
1 >Emitted(10, 9) Source(12, 5) + SourceIndex(0) name (MyClass)
|
||||
2 >Emitted(10, 10) Source(12, 6) + SourceIndex(0) name (MyClass)
|
||||
---
|
||||
>>> enumerable: true,
|
||||
>>> configurable: true
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [recursiveClassReferenceTest.js.map]
|
||||
{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","Sample.Thing.Widgets.FindWidget.destroy","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"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"}
|
||||
{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":["Sample","Sample.Actions","Sample.Actions.Thing","Sample.Actions.Thing.Find","Sample.Actions.Thing.Find.StartFindAction","Sample.Actions.Thing.Find.StartFindAction.constructor","Sample.Actions.Thing.Find.StartFindAction.getId","Sample.Actions.Thing.Find.StartFindAction.run","Sample.Thing","Sample.Thing.Widgets","Sample.Thing.Widgets.FindWidget","Sample.Thing.Widgets.FindWidget.constructor","Sample.Thing.Widgets.FindWidget.gar","Sample.Thing.Widgets.FindWidget.getDomNode","AbstractMode","AbstractMode.constructor","AbstractMode.getInitialState","Sample.Thing.Languages","Sample.Thing.Languages.PlainText","Sample.Thing.Languages.PlainText.State","Sample.Thing.Languages.PlainText.State.constructor","Sample.Thing.Languages.PlainText.State.clone","Sample.Thing.Languages.PlainText.State.equals","Sample.Thing.Languages.PlainText.State.getMode","Sample.Thing.Languages.PlainText.Mode","Sample.Thing.Languages.PlainText.Mode.constructor","Sample.Thing.Languages.PlainText.Mode.getInitialState"],"mappings":"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"}
|
||||
@@ -976,8 +976,8 @@ sourceFile:recursiveClassReferenceTest.ts
|
||||
>
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(51, 17) Source(61, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy)
|
||||
2 >Emitted(51, 18) Source(61, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget.destroy)
|
||||
1 >Emitted(51, 17) Source(61, 3) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget)
|
||||
2 >Emitted(51, 18) Source(61, 4) + SourceIndex(0) name (Sample.Thing.Widgets.FindWidget)
|
||||
---
|
||||
>>> return FindWidget;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -14,14 +14,10 @@ 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);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,6 @@ var T = (function () {
|
||||
function T() {
|
||||
}
|
||||
T.prototype.m = function () {
|
||||
var p3 = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
p3[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return T;
|
||||
})();
|
||||
|
||||
@@ -15,11 +15,8 @@ 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 @@
|
||||
//// [sourceMap-FileWithComments.js.map]
|
||||
{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":["Shapes","Shapes.Point","Shapes.Point.constructor","Shapes.Point.getDist","Shapes.foo"],"mappings":"AAOA,AADA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAGXA,AADAA,QAAQA;QACKA,KAAKA;QACdC,cAAcA;QACdA,SAFSA,KAAKA,CAEKA,CAASA,EAASA,CAASA;YAA3BC,MAACA,GAADA,CAACA,CAAQA;YAASA,MAACA,GAADA,CAACA,CAAQA;QAAIA,CAACA;QAEnDD,kBAAkBA;QAClBA,uBAAOA,GAAPA,cAAYE,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;QAElEF,gBAAgBA;QACTA,YAAMA,GAAGA,IAAIA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA,CAACA;QACpCA,YAACA;IAADA,CAACA,AATDD,IASCA;IATYA,YAAKA,GAALA,KASZA,CAAAA;IAGDA,AADAA,+BAA+BA;QAC3BA,CAACA,GAAGA,EAAEA,CAACA;IAEXA,SAAgBA,GAAGA;IACnBI,CAACA;IADeJ,UAAGA,GAAHA,GACfA,CAAAA;IAKDA,AAHAA;;MAEEA;QACEA,CAACA,GAAGA,EAAEA,CAACA;AACfA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAGD,AADA,qBAAqB;IACjB,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
||||
{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":["Shapes","Shapes.Point","Shapes.Point.constructor","Shapes.Point.getDist"],"mappings":"AAOA,AADA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAGXA,AADAA,QAAQA;QACKA,KAAKA;QACdC,cAAcA;QACdA,SAFSA,KAAKA,CAEKA,CAASA,EAASA,CAASA;YAA3BC,MAACA,GAADA,CAACA,CAAQA;YAASA,MAACA,GAADA,CAACA,CAAQA;QAAIA,CAACA;QAEnDD,kBAAkBA;QAClBA,uBAAOA,GAAPA,cAAYE,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;QAElEF,gBAAgBA;QACTA,YAAMA,GAAGA,IAAIA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAACA,CAACA;QACpCA,YAACA;IAADA,CAACA,AATDD,IASCA;IATYA,YAAKA,GAALA,KASZA,CAAAA;IAGDA,AADAA,+BAA+BA;QAC3BA,CAACA,GAAGA,EAAEA,CAACA;IAEXA,SAAgBA,GAAGA;IACnBA,CAACA;IADeA,UAAGA,GAAHA,GACfA,CAAAA;IAKDA,AAHAA;;MAEEA;QACEA,CAACA,GAAGA,EAAEA,CAACA;AACfA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAGD,AADA,qBAAqB;IACjB,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
||||
@@ -450,8 +450,8 @@ sourceFile:sourceMap-FileWithComments.ts
|
||||
1 >() {
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(21, 5) Source(26, 5) + SourceIndex(0) name (Shapes.foo)
|
||||
2 >Emitted(21, 6) Source(26, 6) + SourceIndex(0) name (Shapes.foo)
|
||||
1 >Emitted(21, 5) Source(26, 5) + SourceIndex(0) name (Shapes)
|
||||
2 >Emitted(21, 6) Source(26, 6) + SourceIndex(0) name (Shapes)
|
||||
---
|
||||
>>> Shapes.foo = foo;
|
||||
1->^^^^
|
||||
|
||||
-4
@@ -8,9 +8,5 @@ foo `${function (x: number) { x = "bad"; } }`;
|
||||
|
||||
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo "" + function (x) { x = "bad"; };
|
||||
|
||||
@@ -23,10 +23,6 @@ sequence(
|
||||
|
||||
//// [varArgParamTypeCheck.js]
|
||||
function sequence() {
|
||||
var sequences = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
sequences[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function callback(clb) {
|
||||
}
|
||||
|
||||
@@ -57,10 +57,6 @@ var M;
|
||||
return result;
|
||||
};
|
||||
C.prototype.fnope = function (x) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.fonly = function () {
|
||||
var rest = [];
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
function foo(x = 0) { }
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = [0]) { }
|
||||
|
||||
function bar(a = [0]) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = v[0]) { }
|
||||
|
||||
function bar(a = v[0]) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = (v)) { }
|
||||
|
||||
function bar(a = (v)) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = [1 + 1]) { }
|
||||
|
||||
function bar(a = [1 + 1]) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = v[1 + 1]) { }
|
||||
|
||||
function bar(a = v[1 + 1]) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = (1 + 1)) { }
|
||||
|
||||
function bar(a = (1 + 1)) {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
var v: any[];
|
||||
|
||||
function foo(a = bar()) { }
|
||||
|
||||
function bar(a = foo()) {
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
function foo(x = 0) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = "") { }
|
||||
|
||||
function bar(a = "") {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = ``) { }
|
||||
|
||||
function bar(a = ``) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = 0) { }
|
||||
|
||||
function bar(a = 0) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = true) { }
|
||||
|
||||
function bar(a = true) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = false) { }
|
||||
|
||||
function bar(a = false) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = undefined) { }
|
||||
|
||||
function bar(a = undefined) {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function foo(a = console.log) { }
|
||||
|
||||
function bar(a = console.log) {
|
||||
}
|
||||
Reference in New Issue
Block a user