From 53ed427e0dbe1bb32cc7662044f2a40ef52c0b0d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Sun, 22 Feb 2015 17:59:24 -0800 Subject: [PATCH] Emit parameter initializers unless we are certain they don't have any side effects. --- src/compiler/emitter.ts | 106 +++++++++++++++++- .../reference/FunctionDeclaration10_es6.js | 1 - .../reference/FunctionDeclaration3_es6.js | 1 - .../reference/FunctionDeclaration6_es6.js | 1 - .../reference/FunctionDeclaration7_es6.js | 1 - tests/baselines/reference/callWithSpread.js | 8 -- .../collisionRestParameterFunction.js | 4 - ...llisionRestParameterFunctionExpressions.js | 4 - .../reference/declarationsAndAssignments.js | 1 - tests/baselines/reference/funcdecl.js | 3 - .../reference/functionImplementationErrors.js | 1 - ...onWithDefaultParameterWithNoStatements1.js | 5 + ...ithDefaultParameterWithNoStatements1.types | 5 + ...nWithDefaultParameterWithNoStatements10.js | 10 ++ ...thDefaultParameterWithNoStatements10.types | 11 ++ ...nWithDefaultParameterWithNoStatements11.js | 13 +++ ...thDefaultParameterWithNoStatements11.types | 16 +++ ...nWithDefaultParameterWithNoStatements12.js | 13 +++ ...thDefaultParameterWithNoStatements12.types | 16 +++ ...nWithDefaultParameterWithNoStatements13.js | 16 +++ ...thDefaultParameterWithNoStatements13.types | 16 +++ ...nWithDefaultParameterWithNoStatements14.js | 16 +++ ...thDefaultParameterWithNoStatements14.types | 18 +++ ...nWithDefaultParameterWithNoStatements15.js | 16 +++ ...thDefaultParameterWithNoStatements15.types | 16 +++ ...nWithDefaultParameterWithNoStatements16.js | 16 +++ ...thDefaultParameterWithNoStatements16.types | 16 +++ ...onWithDefaultParameterWithNoStatements2.js | 7 ++ ...ithDefaultParameterWithNoStatements2.types | 5 + ...onWithDefaultParameterWithNoStatements3.js | 10 ++ ...ithDefaultParameterWithNoStatements3.types | 9 ++ ...onWithDefaultParameterWithNoStatements4.js | 10 ++ ...ithDefaultParameterWithNoStatements4.types | 9 ++ ...onWithDefaultParameterWithNoStatements5.js | 10 ++ ...ithDefaultParameterWithNoStatements5.types | 9 ++ ...onWithDefaultParameterWithNoStatements6.js | 10 ++ ...ithDefaultParameterWithNoStatements6.types | 9 ++ ...onWithDefaultParameterWithNoStatements7.js | 10 ++ ...ithDefaultParameterWithNoStatements7.types | 9 ++ ...onWithDefaultParameterWithNoStatements8.js | 10 ++ ...ithDefaultParameterWithNoStatements8.types | 11 ++ ...faultParameterWithNoStatements9.errors.txt | 13 +++ ...onWithDefaultParameterWithNoStatements9.js | 10 ++ .../reference/optionalBindingParameters1.js | 1 - .../reference/optionalBindingParameters2.js | 1 - .../optionalBindingParametersInOverloads1.js | 4 - .../optionalBindingParametersInOverloads2.js | 4 - tests/baselines/reference/out-flag.js.map | 2 +- .../reference/out-flag.sourcemap.txt | 8 +- tests/baselines/reference/properties.js.map | 2 +- .../reference/properties.sourcemap.txt | 8 +- .../recursiveClassReferenceTest.js.map | 2 +- .../recursiveClassReferenceTest.sourcemap.txt | 4 +- .../restElementWithNullInitializer.js | 4 - .../restParameterAssignmentCompatibility.js | 4 - .../selfReferencesInFunctionParameters.js | 3 - .../sourceMap-FileWithComments.js.map | 2 +- .../sourceMap-FileWithComments.sourcemap.txt | 4 +- ...tionExpressionsInSubstitutionExpression.js | 4 - .../reference/varArgParamTypeCheck.js | 4 - tests/baselines/reference/vararg.js | 4 - ...onWithDefaultParameterWithNoStatements1.ts | 1 + ...nWithDefaultParameterWithNoStatements10.ts | 4 + ...nWithDefaultParameterWithNoStatements11.ts | 6 + ...nWithDefaultParameterWithNoStatements12.ts | 6 + ...nWithDefaultParameterWithNoStatements13.ts | 6 + ...nWithDefaultParameterWithNoStatements14.ts | 6 + ...nWithDefaultParameterWithNoStatements15.ts | 6 + ...nWithDefaultParameterWithNoStatements16.ts | 6 + ...onWithDefaultParameterWithNoStatements2.ts | 2 + ...onWithDefaultParameterWithNoStatements3.ts | 4 + ...onWithDefaultParameterWithNoStatements4.ts | 4 + ...onWithDefaultParameterWithNoStatements5.ts | 4 + ...onWithDefaultParameterWithNoStatements6.ts | 4 + ...onWithDefaultParameterWithNoStatements7.ts | 4 + ...onWithDefaultParameterWithNoStatements8.ts | 4 + ...onWithDefaultParameterWithNoStatements9.ts | 4 + 77 files changed, 562 insertions(+), 75 deletions(-) create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.js create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.types create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.errors.txt create mode 100644 tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.js create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements10.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements11.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements12.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements16.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements4.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements5.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements6.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements7.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts create mode 100644 tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ca6adc53169..f8b6e984a27 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -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((node).elements, hasPossibleSideEffects); + + case SyntaxKind.BindingElement: + return hasPossibleSideEffects((node).name) || + hasPossibleSideEffects((node).initializer); + + case SyntaxKind.Parameter: + return hasPossibleSideEffects((node).name) || + hasPossibleSideEffects((node).initializer); + + case SyntaxKind.PropertyAccessExpression: + return hasPossibleSideEffects((node).expression); + + case SyntaxKind.ArrayLiteralExpression: + return forEach((node).elements, hasPossibleSideEffects); + + case SyntaxKind.ElementAccessExpression: + return hasPossibleSideEffects((node).expression) || + hasPossibleSideEffects((node).argumentExpression); + + case SyntaxKind.ParenthesizedExpression: + return hasPossibleSideEffects((node).expression); + + case SyntaxKind.ObjectLiteralExpression: + return forEach((node).properties, hasPossibleSideEffects); + + case SyntaxKind.PropertyAssignment: + return hasPossibleSideEffects((node).name) || + hasPossibleSideEffects((node).initializer); + + case SyntaxKind.ComputedPropertyName: + return hasPossibleSideEffects((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)) { diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js index 51694533964..8d970027584 100644 --- a/tests/baselines/reference/FunctionDeclaration10_es6.js +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -4,5 +4,4 @@ function * foo(a = yield => yield) { //// [FunctionDeclaration10_es6.js] function foo(a) { - if (a === void 0) { a = function (yield) { return yield; }; } } diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.js b/tests/baselines/reference/FunctionDeclaration3_es6.js index e1df936dd21..712416df24e 100644 --- a/tests/baselines/reference/FunctionDeclaration3_es6.js +++ b/tests/baselines/reference/FunctionDeclaration3_es6.js @@ -4,5 +4,4 @@ function f(yield = yield) { //// [FunctionDeclaration3_es6.js] function f(yield) { - if (yield === void 0) { yield = yield; } } diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.js b/tests/baselines/reference/FunctionDeclaration6_es6.js index 07b3ff52212..28255ee22fb 100644 --- a/tests/baselines/reference/FunctionDeclaration6_es6.js +++ b/tests/baselines/reference/FunctionDeclaration6_es6.js @@ -4,5 +4,4 @@ function*foo(a = yield) { //// [FunctionDeclaration6_es6.js] function foo(a) { - if (a === void 0) { a = yield; } } diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.js b/tests/baselines/reference/FunctionDeclaration7_es6.js index 661e1668e0f..a65d714c984 100644 --- a/tests/baselines/reference/FunctionDeclaration7_es6.js +++ b/tests/baselines/reference/FunctionDeclaration7_es6.js @@ -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; } } } diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index d676c0f2a33..e9f7a7a3288 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -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; })(); diff --git a/tests/baselines/reference/collisionRestParameterFunction.js b/tests/baselines/reference/collisionRestParameterFunction.js index 8660e8f5db0..9ae266dad41 100644 --- a/tests/baselines/reference/collisionRestParameterFunction.js +++ b/tests/baselines/reference/collisionRestParameterFunction.js @@ -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) { } diff --git a/tests/baselines/reference/collisionRestParameterFunctionExpressions.js b/tests/baselines/reference/collisionRestParameterFunctionExpressions.js index 22709b087eb..f45619ddb71 100644 --- a/tests/baselines/reference/collisionRestParameterFunctionExpressions.js +++ b/tests/baselines/reference/collisionRestParameterFunctionExpressions.js @@ -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) { } diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index 032f4cb0e63..b82b0d237ef 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -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" }); diff --git a/tests/baselines/reference/funcdecl.js b/tests/baselines/reference/funcdecl.js index 348d25bd670..25dc7219a8a 100644 --- a/tests/baselines/reference/funcdecl.js +++ b/tests/baselines/reference/funcdecl.js @@ -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) { diff --git a/tests/baselines/reference/functionImplementationErrors.js b/tests/baselines/reference/functionImplementationErrors.js index 5eaf9027335..4a7ecd9104d 100644 --- a/tests/baselines/reference/functionImplementationErrors.js +++ b/tests/baselines/reference/functionImplementationErrors.js @@ -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 diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.js new file mode 100644 index 00000000000..e561ade57a6 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.js @@ -0,0 +1,5 @@ +//// [functionWithDefaultParameterWithNoStatements1.ts] +function foo(x = 0) { } + +//// [functionWithDefaultParameterWithNoStatements1.js] +function foo(x) { } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types new file mode 100644 index 00000000000..d5c114c9216 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts === +function foo(x = 0) { } +>foo : (x?: number) => void +>x : number + diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.js new file mode 100644 index 00000000000..c52c3c86446 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements10.ts] +function foo(a = [0]) { } + +function bar(a = [0]) { +} + +//// [functionWithDefaultParameterWithNoStatements10.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types new file mode 100644 index 00000000000..df28a085d85 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types @@ -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[] +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.js new file mode 100644 index 00000000000..54ec7781059 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.js @@ -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) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types new file mode 100644 index 00000000000..5e522855e4b --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types @@ -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[] +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.js new file mode 100644 index 00000000000..b0e5b6982d1 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.js @@ -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) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.types new file mode 100644 index 00000000000..c458b4d2850 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements12.types @@ -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[] +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.js new file mode 100644 index 00000000000..7fcbae72541 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.js @@ -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]; } +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types new file mode 100644 index 00000000000..eccf0a92856 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.js new file mode 100644 index 00000000000..084168435f0 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.js @@ -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]; } +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types new file mode 100644 index 00000000000..c155b335e9a --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.js new file mode 100644 index 00000000000..6c03ae90f93 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.js @@ -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); } +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types new file mode 100644 index 00000000000..a782b4bd15c --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.js new file mode 100644 index 00000000000..698be233d09 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.js @@ -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(); } +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.types new file mode 100644 index 00000000000..050c95ec1c8 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements16.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.js new file mode 100644 index 00000000000..a6360938937 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.js @@ -0,0 +1,7 @@ +//// [functionWithDefaultParameterWithNoStatements2.ts] +function foo(x = 0) { +} + +//// [functionWithDefaultParameterWithNoStatements2.js] +function foo(x) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types new file mode 100644 index 00000000000..9be77e7d82e --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts === +function foo(x = 0) { +>foo : (x?: number) => void +>x : number +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.js new file mode 100644 index 00000000000..591310560f1 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements3.ts] +function foo(a = "") { } + +function bar(a = "") { +} + +//// [functionWithDefaultParameterWithNoStatements3.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types new file mode 100644 index 00000000000..77895ae1cc9 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.js new file mode 100644 index 00000000000..cb0bae0c894 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements4.ts] +function foo(a = ``) { } + +function bar(a = ``) { +} + +//// [functionWithDefaultParameterWithNoStatements4.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.types new file mode 100644 index 00000000000..7071c956db2 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements4.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.js new file mode 100644 index 00000000000..d09e27f98fc --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements5.ts] +function foo(a = 0) { } + +function bar(a = 0) { +} + +//// [functionWithDefaultParameterWithNoStatements5.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types new file mode 100644 index 00000000000..b7d53b544fa --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.js new file mode 100644 index 00000000000..dd0212494e8 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements6.ts] +function foo(a = true) { } + +function bar(a = true) { +} + +//// [functionWithDefaultParameterWithNoStatements6.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types new file mode 100644 index 00000000000..b430bc70953 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.js new file mode 100644 index 00000000000..a01a214f98d --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements7.ts] +function foo(a = false) { } + +function bar(a = false) { +} + +//// [functionWithDefaultParameterWithNoStatements7.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types new file mode 100644 index 00000000000..baf83c870a9 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.js new file mode 100644 index 00000000000..eef4fd07ce6 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements8.ts] +function foo(a = undefined) { } + +function bar(a = undefined) { +} + +//// [functionWithDefaultParameterWithNoStatements8.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.types new file mode 100644 index 00000000000..e4480691c45 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements8.types @@ -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 +} diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.errors.txt b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.errors.txt new file mode 100644 index 00000000000..4e60ceda6b5 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.errors.txt @@ -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'. + } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.js b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.js new file mode 100644 index 00000000000..e9822275606 --- /dev/null +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements9.js @@ -0,0 +1,10 @@ +//// [functionWithDefaultParameterWithNoStatements9.ts] +function foo(a = console.log) { } + +function bar(a = console.log) { +} + +//// [functionWithDefaultParameterWithNoStatements9.js] +function foo(a) { } +function bar(a) { +} diff --git a/tests/baselines/reference/optionalBindingParameters1.js b/tests/baselines/reference/optionalBindingParameters1.js index 536cb1e567a..7d992b2ca3c 100644 --- a/tests/baselines/reference/optionalBindingParameters1.js +++ b/tests/baselines/reference/optionalBindingParameters1.js @@ -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, ""]); diff --git a/tests/baselines/reference/optionalBindingParameters2.js b/tests/baselines/reference/optionalBindingParameters2.js index 04e1138561a..1d85eba4824 100644 --- a/tests/baselines/reference/optionalBindingParameters2.js +++ b/tests/baselines/reference/optionalBindingParameters2.js @@ -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: "" }); diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.js b/tests/baselines/reference/optionalBindingParametersInOverloads1.js index 3658efa72c6..af83404c2c8 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.js +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.js @@ -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, ""]); diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.js b/tests/baselines/reference/optionalBindingParametersInOverloads2.js index 1ddfdae4f07..f32fb1bfbf4 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads2.js +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.js @@ -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: "" }); diff --git a/tests/baselines/reference/out-flag.js.map b/tests/baselines/reference/out-flag.js.map index 9247af9d5d4..795d564b2c0 100644 --- a/tests/baselines/reference/out-flag.js.map +++ b/tests/baselines/reference/out-flag.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/tests/baselines/reference/out-flag.sourcemap.txt b/tests/baselines/reference/out-flag.sourcemap.txt index c0289140552..b54f7f8d0a1 100644 --- a/tests/baselines/reference/out-flag.sourcemap.txt +++ b/tests/baselines/reference/out-flag.sourcemap.txt @@ -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->^^^^ diff --git a/tests/baselines/reference/properties.js.map b/tests/baselines/reference/properties.js.map index d47694825ec..e59b82653b6 100644 --- a/tests/baselines/reference/properties.js.map +++ b/tests/baselines/reference/properties.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/tests/baselines/reference/properties.sourcemap.txt b/tests/baselines/reference/properties.sourcemap.txt index 7ef028e33c0..ac124f60230 100644 --- a/tests/baselines/reference/properties.sourcemap.txt +++ b/tests/baselines/reference/properties.sourcemap.txt @@ -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 diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index a61032b3797..d5d1e9c52fb 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -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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"} \ No newline at end of file +{"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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"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 84ddc2befb3..0c040166870 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -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->^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/restElementWithNullInitializer.js b/tests/baselines/reference/restElementWithNullInitializer.js index 9f326602fb8..ea7b76f987c 100644 --- a/tests/baselines/reference/restElementWithNullInitializer.js +++ b/tests/baselines/reference/restElementWithNullInitializer.js @@ -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); } diff --git a/tests/baselines/reference/restParameterAssignmentCompatibility.js b/tests/baselines/reference/restParameterAssignmentCompatibility.js index 62c0204c749..cdfc257db41 100644 --- a/tests/baselines/reference/restParameterAssignmentCompatibility.js +++ b/tests/baselines/reference/restParameterAssignmentCompatibility.js @@ -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; })(); diff --git a/tests/baselines/reference/selfReferencesInFunctionParameters.js b/tests/baselines/reference/selfReferencesInFunctionParameters.js index c707fc0116b..8600888b44a 100644 --- a/tests/baselines/reference/selfReferencesInFunctionParameters.js +++ b/tests/baselines/reference/selfReferencesInFunctionParameters.js @@ -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) { diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js.map b/tests/baselines/reference/sourceMap-FileWithComments.js.map index 28d4566efc7..914d81cee83 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js.map +++ b/tests/baselines/reference/sourceMap-FileWithComments.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt index c0e46430688..74975cdc583 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt @@ -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->^^^^ diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js index a4dd1619642..1f5d65390a7 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js @@ -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"; }; diff --git a/tests/baselines/reference/varArgParamTypeCheck.js b/tests/baselines/reference/varArgParamTypeCheck.js index c2a33416436..5d8a60a564a 100644 --- a/tests/baselines/reference/varArgParamTypeCheck.js +++ b/tests/baselines/reference/varArgParamTypeCheck.js @@ -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) { } diff --git a/tests/baselines/reference/vararg.js b/tests/baselines/reference/vararg.js index 038afb90cbc..c0260cd8d86 100644 --- a/tests/baselines/reference/vararg.js +++ b/tests/baselines/reference/vararg.js @@ -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 = []; diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts new file mode 100644 index 00000000000..8dfc001ed4a --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts @@ -0,0 +1 @@ +function foo(x = 0) { } \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements10.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements10.ts new file mode 100644 index 00000000000..5e8fabd1cb2 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements10.ts @@ -0,0 +1,4 @@ +function foo(a = [0]) { } + +function bar(a = [0]) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements11.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements11.ts new file mode 100644 index 00000000000..ca696b35014 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements11.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = v[0]) { } + +function bar(a = v[0]) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements12.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements12.ts new file mode 100644 index 00000000000..6724f83bb3a --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements12.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = (v)) { } + +function bar(a = (v)) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts new file mode 100644 index 00000000000..97c6baad999 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements13.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = [1 + 1]) { } + +function bar(a = [1 + 1]) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts new file mode 100644 index 00000000000..7b86efe287b --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements14.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = v[1 + 1]) { } + +function bar(a = v[1 + 1]) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts new file mode 100644 index 00000000000..74fcd9e14b0 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements15.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = (1 + 1)) { } + +function bar(a = (1 + 1)) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements16.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements16.ts new file mode 100644 index 00000000000..2143232aae6 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements16.ts @@ -0,0 +1,6 @@ +var v: any[]; + +function foo(a = bar()) { } + +function bar(a = foo()) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts new file mode 100644 index 00000000000..e7945020386 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts @@ -0,0 +1,2 @@ +function foo(x = 0) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts new file mode 100644 index 00000000000..7b82a5b2e3c --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements3.ts @@ -0,0 +1,4 @@ +function foo(a = "") { } + +function bar(a = "") { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements4.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements4.ts new file mode 100644 index 00000000000..c86960030da --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements4.ts @@ -0,0 +1,4 @@ +function foo(a = ``) { } + +function bar(a = ``) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements5.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements5.ts new file mode 100644 index 00000000000..9ed5111ab33 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements5.ts @@ -0,0 +1,4 @@ +function foo(a = 0) { } + +function bar(a = 0) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements6.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements6.ts new file mode 100644 index 00000000000..5946619a2ce --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements6.ts @@ -0,0 +1,4 @@ +function foo(a = true) { } + +function bar(a = true) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements7.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements7.ts new file mode 100644 index 00000000000..4e97c631fd7 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements7.ts @@ -0,0 +1,4 @@ +function foo(a = false) { } + +function bar(a = false) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts new file mode 100644 index 00000000000..ae0689a7e29 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements8.ts @@ -0,0 +1,4 @@ +function foo(a = undefined) { } + +function bar(a = undefined) { +} \ No newline at end of file diff --git a/tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts new file mode 100644 index 00000000000..cd2b753c792 --- /dev/null +++ b/tests/cases/compiler/functionWithDefaultParameterWithNoStatements9.ts @@ -0,0 +1,4 @@ +function foo(a = console.log) { } + +function bar(a = console.log) { +} \ No newline at end of file