Merge pull request #2109 from Microsoft/sideEffects

Emit downlevel parameter initializers unless we are certain they don't have any side effects.
This commit is contained in:
CyrusNajmabadi
2015-02-23 15:43:56 -08:00
96 changed files with 889 additions and 168 deletions
+45 -1
View File
@@ -3899,7 +3899,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) {
@@ -3979,15 +3981,57 @@ module ts {
}
function emitBlockFunctionBody(node: FunctionLikeDeclaration, body: Block) {
// If the body has no statements, and we know there's no code that would cause any
// prologue to be emitted, then just do a simple emit if the empty block.
if (body.statements.length === 0 && !anyParameterHasBindingPatternOrInitializer(node)) {
emitFunctionBodyWithNoStatements(node, body);
}
else {
emitFunctionBodyWithStatements(node, body);
}
}
function anyParameterHasBindingPatternOrInitializer(func: FunctionLikeDeclaration) {
return forEach(func.parameters, hasBindingPatternOrInitializer);
}
function hasBindingPatternOrInitializer(parameter: ParameterDeclaration) {
return parameter.initializer || isBindingPattern(parameter.name);
}
function emitFunctionBodyWithNoStatements(node: FunctionLikeDeclaration, body: Block) {
var singleLine = isSingleLineEmptyBlock(node.body);
write(" {");
if (singleLine) {
write(" ");
}
else {
increaseIndent();
writeLine();
}
emitLeadingCommentsOfPosition(body.statements.end);
if (!singleLine) {
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)) {
@@ -10,12 +10,16 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "X", {
set: function (v) { },
set: function (v) {
if (v === void 0) { v = 0; }
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "X", {
set: function (v2) { },
set: function (v2) {
if (v2 === void 0) { v2 = 0; }
},
enumerable: true,
configurable: true
});
@@ -57,9 +57,15 @@ b.b(1);
//// [callSignatureWithOptionalParameterAndInitializer.js]
// Optional parameters cannot also have initializer expressions, these are all errors
function foo(x) { }
var f = function foo(x) { };
var f2 = function (x, y) { };
function foo(x) {
if (x === void 0) { x = 1; }
}
var f = function foo(x) {
if (x === void 0) { x = 1; }
};
var f2 = function (x, y) {
if (y === void 0) { y = 1; }
};
foo(1);
foo();
f(1);
@@ -69,7 +75,9 @@ f2(1, 2);
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
@@ -86,9 +94,15 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function (x) { },
a: function foo(x, y) { },
b: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
a: function foo(x, y) {
if (y === void 0) { y = ''; }
},
b: function (x) {
if (x === void 0) { x = ''; }
}
};
b.foo();
b.foo(1);
@@ -59,9 +59,15 @@ b.b(1);
//// [callSignaturesWithParameterInitializers.js]
// Optional parameters allow initializers only in implementation signatures
function foo(x) { }
var f = function foo(x) { };
var f2 = function (x, y) { };
function foo(x) {
if (x === void 0) { x = 1; }
}
var f = function foo(x) {
if (x === void 0) { x = 1; }
};
var f2 = function (x, y) {
if (y === void 0) { y = 1; }
};
foo(1);
foo();
f(1);
@@ -71,7 +77,9 @@ f2(1, 2);
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
@@ -89,9 +97,15 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function (x) { },
a: function foo(x, y) { },
b: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
a: function foo(x, y) {
if (y === void 0) { y = 1; }
},
b: function (x) {
if (x === void 0) { x = 1; }
}
};
b.foo();
b.foo(1);
@@ -28,21 +28,29 @@ b.foo(1);
//// [callSignaturesWithParameterInitializers2.js]
// Optional parameters allow initializers only in implementation signatures
// All the below declarations are errors
function foo(x) { }
function foo(x) {
if (x === void 0) { x = 1; }
}
foo(1);
foo();
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
C.prototype.foo = function (x) {
if (x === void 0) { x = 1; }
};
return C;
})();
var c;
c.foo();
c.foo(1);
var b = {
foo: function (x) { },
foo: function (x) { }
foo: function (x) {
if (x === void 0) { x = 1; }
},
foo: function (x) {
if (x === void 0) { x = 1; }
}
};
b.foo();
b.foo(1);
@@ -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;
})();
@@ -23,7 +23,9 @@ module M {
var M;
(function (_M) {
_M.x = 3;
function fn(M, p) { }
function fn(M, p) {
if (p === void 0) { p = _M.x; }
}
})(M || (M = {}));
var M;
(function (_M_1) {
@@ -39,7 +39,9 @@ var M;
var c = (function () {
function c() {
}
c.prototype.fn = function (M, p) { };
c.prototype.fn = function (M, p) {
if (p === void 0) { p = _M.x; }
};
return c;
})();
})(M || (M = {}));
@@ -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) {
}
File diff suppressed because one or more lines are too long
@@ -2197,18 +2197,21 @@ sourceFile:contextualTyping.ts
2 > ^^^^
3 > ^
4 > ^
5 > ^^^^^
5 > ^^^^
6 > ^
1 >
>function
2 > c9t5
3 > (
4 > f: (n: number) => IFoo
5 > ) {}
5 > ) {
6 > }
1 >Emitted(87, 10) Source(146, 10) + SourceIndex(0)
2 >Emitted(87, 14) Source(146, 14) + SourceIndex(0)
3 >Emitted(87, 15) Source(146, 15) + SourceIndex(0)
4 >Emitted(87, 16) Source(146, 37) + SourceIndex(0)
5 >Emitted(87, 21) Source(146, 41) + SourceIndex(0)
5 >Emitted(87, 20) Source(146, 40) + SourceIndex(0)
6 >Emitted(87, 21) Source(146, 41) + SourceIndex(0)
---
>>>;
1 >
@@ -49,16 +49,24 @@ s = f2('');
s = f2();
n = f2();
// Contextually type the default arg with the type annotation
var f3 = function (a) { };
var f3 = function (a) {
if (a === void 0) { a = function (s) { return s; }; }
};
// Type check using the function's contextual type
var f4 = function (a) { };
var f4 = function (a) {
if (a === void 0) { a = ""; }
};
// Contextually type the default arg using the function's contextual type
var f5 = function (a) { };
var f5 = function (a) {
if (a === void 0) { a = function (s) { return s; }; }
};
var U;
(function (U) {
U.x;
})(U || (U = {}));
var f6 = function (t) { };
var f6 = function (t) {
if (t === void 0) { t = T; }
};
var f7 = function (t) {
if (t === void 0) { t = U; }
return t;
@@ -20,12 +20,18 @@ interface I {
var f: (a = 3) => number;
//// [defaultArgsInOverloads.js]
function fun(a) { }
function fun(a) {
if (a === void 0) { a = null; }
}
var C = (function () {
function C() {
}
C.prototype.fun = function (a) { };
C.fun = function (a) { };
C.prototype.fun = function (a) {
if (a === void 0) { a = null; }
};
C.fun = function (a) {
if (a === void 0) { a = null; }
};
return C;
})();
var f;
@@ -3,4 +3,6 @@ function foo(x: string = '');
function foo(x = '') { }
//// [defaultValueInFunctionOverload1.js]
function foo(x) { }
function foo(x) {
if (x === void 0) { x = ''; }
}
@@ -11,7 +11,9 @@ foo(() => { return false; });
var f1 = function () { };
var f2 = function (x, y) { };
var f3 = function (x, y) { };
var f4 = function (x, y, z) { };
var f4 = function (x, y, z) {
if (z === void 0) { z = 10; }
};
function foo(func) { }
foo(function () { return true; });
foo(function () { return false; });
@@ -5,7 +5,23 @@ function bar(y = 10) { }
function bar1(y = 10, ...rest) { }
//// [emitDefaultParametersFunction.js]
function foo(x, y) { }
function baz(x, y) { }
function bar(y) { }
function bar1(y) { }
function foo(x, y) {
if (y === void 0) { y = 10; }
}
function baz(x, y) {
if (y === void 0) { y = 5; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
}
function bar(y) {
if (y === void 0) { y = 10; }
}
function bar1(y) {
if (y === void 0) { y = 10; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
}
@@ -10,10 +10,45 @@ var z = (function (num: number, boo = false, ...rest) { })(10)
//// [emitDefaultParametersFunctionExpression.js]
var lambda1 = function (y) { };
var lambda2 = function (x, y) { };
var lambda3 = function (x, y) { };
var lambda4 = function (y) { };
var x = function (str) { };
var y = (function (num, boo) { })();
var z = (function (num, boo) { })(10);
var lambda1 = function (y) {
if (y === void 0) { y = "hello"; }
};
var lambda2 = function (x, y) {
if (y === void 0) { y = "hello"; }
};
var lambda3 = function (x, y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
};
var lambda4 = function (y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
var x = function (str) {
if (str === void 0) { str = "hello"; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
var y = (function (num, boo) {
if (num === void 0) { num = 10; }
if (boo === void 0) { boo = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
})();
var z = (function (num, boo) {
if (boo === void 0) { boo = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
})(10);
@@ -9,8 +9,24 @@ var obj2 = {
//// [emitDefaultParametersFunctionProperty.js]
var obj2 = {
func1: function (y) { },
func2: function (x) { },
func3: function (x, z, y) { },
func4: function (x, z, y) { },
func1: function (y) {
if (y === void 0) { y = 10; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
},
func2: function (x) {
if (x === void 0) { x = "hello"; }
},
func3: function (x, z, y) {
if (y === void 0) { y = "hello"; }
},
func4: function (x, z, y) {
if (y === void 0) { y = "hello"; }
var rest = [];
for (var _i = 3; _i < arguments.length; _i++) {
rest[_i - 3] = arguments[_i];
}
},
};
@@ -22,10 +22,26 @@ var C = (function () {
function C(t, z, x, y) {
if (y === void 0) { y = "hello"; }
}
C.prototype.foo = function (x, t) { };
C.prototype.foo1 = function (x, t) { };
C.prototype.bar = function (t) { };
C.prototype.boo = function (t) { };
C.prototype.foo = function (x, t) {
if (t === void 0) { t = false; }
};
C.prototype.foo1 = function (x, t) {
if (t === void 0) { t = false; }
var rest = [];
for (var _i = 2; _i < arguments.length; _i++) {
rest[_i - 2] = arguments[_i];
}
};
C.prototype.bar = function (t) {
if (t === void 0) { t = false; }
};
C.prototype.boo = function (t) {
if (t === void 0) { t = false; }
var rest = [];
for (var _i = 1; _i < arguments.length; _i++) {
rest[_i - 1] = arguments[_i];
}
};
return C;
})();
var D = (function () {
@@ -0,0 +1,7 @@
//// [functionWithDefaultParameterWithNoStatements1.ts]
function foo(x = 0) { }
//// [functionWithDefaultParameterWithNoStatements1.js]
function foo(x) {
if (x === void 0) { x = 0; }
}
@@ -0,0 +1,5 @@
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements1.ts ===
function foo(x = 0) { }
>foo : (x?: number) => void
>x : number
@@ -0,0 +1,13 @@
//// [functionWithDefaultParameterWithNoStatements10.ts]
function foo(a = [0]) { }
function bar(a = [0]) {
}
//// [functionWithDefaultParameterWithNoStatements10.js]
function foo(a) {
if (a === void 0) { a = [0]; }
}
function bar(a) {
if (a === void 0) { a = [0]; }
}
@@ -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,16 @@
//// [functionWithDefaultParameterWithNoStatements11.ts]
var v: any[];
function foo(a = v[0]) { }
function bar(a = v[0]) {
}
//// [functionWithDefaultParameterWithNoStatements11.js]
var v;
function foo(a) {
if (a === void 0) { a = v[0]; }
}
function bar(a) {
if (a === void 0) { a = v[0]; }
}
@@ -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,16 @@
//// [functionWithDefaultParameterWithNoStatements12.ts]
var v: any[];
function foo(a = (v)) { }
function bar(a = (v)) {
}
//// [functionWithDefaultParameterWithNoStatements12.js]
var v;
function foo(a) {
if (a === void 0) { a = (v); }
}
function bar(a) {
if (a === void 0) { a = (v); }
}
@@ -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,8 @@
//// [functionWithDefaultParameterWithNoStatements2.ts]
function foo(x = 0) {
}
//// [functionWithDefaultParameterWithNoStatements2.js]
function foo(x) {
if (x === void 0) { x = 0; }
}
@@ -0,0 +1,5 @@
=== tests/cases/compiler/functionWithDefaultParameterWithNoStatements2.ts ===
function foo(x = 0) {
>foo : (x?: number) => void
>x : number
}
@@ -0,0 +1,13 @@
//// [functionWithDefaultParameterWithNoStatements3.ts]
function foo(a = "") { }
function bar(a = "") {
}
//// [functionWithDefaultParameterWithNoStatements3.js]
function foo(a) {
if (a === void 0) { a = ""; }
}
function bar(a) {
if (a === void 0) { 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,13 @@
//// [functionWithDefaultParameterWithNoStatements4.ts]
function foo(a = ``) { }
function bar(a = ``) {
}
//// [functionWithDefaultParameterWithNoStatements4.js]
function foo(a) {
if (a === void 0) { a = ""; }
}
function bar(a) {
if (a === void 0) { 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,13 @@
//// [functionWithDefaultParameterWithNoStatements5.ts]
function foo(a = 0) { }
function bar(a = 0) {
}
//// [functionWithDefaultParameterWithNoStatements5.js]
function foo(a) {
if (a === void 0) { a = 0; }
}
function bar(a) {
if (a === void 0) { a = 0; }
}
@@ -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,13 @@
//// [functionWithDefaultParameterWithNoStatements6.ts]
function foo(a = true) { }
function bar(a = true) {
}
//// [functionWithDefaultParameterWithNoStatements6.js]
function foo(a) {
if (a === void 0) { a = true; }
}
function bar(a) {
if (a === void 0) { a = true; }
}
@@ -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,13 @@
//// [functionWithDefaultParameterWithNoStatements7.ts]
function foo(a = false) { }
function bar(a = false) {
}
//// [functionWithDefaultParameterWithNoStatements7.js]
function foo(a) {
if (a === void 0) { a = false; }
}
function bar(a) {
if (a === void 0) { a = false; }
}
@@ -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,13 @@
//// [functionWithDefaultParameterWithNoStatements8.ts]
function foo(a = undefined) { }
function bar(a = undefined) {
}
//// [functionWithDefaultParameterWithNoStatements8.js]
function foo(a) {
if (a === void 0) { a = undefined; }
}
function bar(a) {
if (a === void 0) { a = undefined; }
}
@@ -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,13 @@
//// [functionWithDefaultParameterWithNoStatements9.ts]
function foo(a = console.log) { }
function bar(a = console.log) {
}
//// [functionWithDefaultParameterWithNoStatements9.js]
function foo(a) {
if (a === void 0) { a = console.log; }
}
function bar(a) {
if (a === void 0) { a = console.log; }
}
@@ -1065,18 +1065,42 @@ var x120 = (function () {
}
return x120;
})();
function x121(parm) { }
function x122(parm) { }
function x123(parm) { }
function x124(parm) { }
function x125(parm) { }
function x126(parm) { }
function x127(parm) { }
function x128(parm) { }
function x129(parm) { }
function x130(parm) { }
function x131(parm) { }
function x132(parm) { }
function x121(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x122(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x123(parm) {
if (parm === void 0) { parm = function named() { return [d1, d2]; }; }
}
function x124(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x125(parm) {
if (parm === void 0) { parm = function () { return [d1, d2]; }; }
}
function x126(parm) {
if (parm === void 0) { parm = function named() { return [d1, d2]; }; }
}
function x127(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x128(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x129(parm) {
if (parm === void 0) { parm = [d1, d2]; }
}
function x130(parm) {
if (parm === void 0) { parm = { n: [d1, d2] }; }
}
function x131(parm) {
if (parm === void 0) { parm = function (n) { var n; return null; }; }
}
function x132(parm) {
if (parm === void 0) { parm = { func: function (n) { return [d1, d2]; } }; }
}
function x133() { return function () { return [d1, d2]; }; }
function x134() { return function () { return [d1, d2]; }; }
function x135() { return function named() { return [d1, d2]; }; }
@@ -19,8 +19,18 @@ function foo2(x) {
if (x === void 0) { x = undefined; }
return x;
} // ok
function foo3(x) { } // error
function foo4(x, y) { } // error
function foo5(x, y) { } // ok
function foo6(x, y, z) { } // error
function foo7(x, y) { } // should be ok
function foo3(x) {
if (x === void 0) { x = 1; }
} // error
function foo4(x, y) {
if (y === void 0) { y = x; }
} // error
function foo5(x, y) {
if (y === void 0) { y = x; }
} // ok
function foo6(x, y, z) {
if (z === void 0) { z = y; }
} // error
function foo7(x, y) {
if (y === void 0) { y = x; }
} // should be ok
@@ -21,10 +21,16 @@ function func2(a, b, c) { }
; // error at "a,b,c"
function func3() { }
; // error at "args"
function func4(z, w) { }
function func4(z, w) {
if (z === void 0) { z = null; }
if (w === void 0) { w = undefined; }
}
; // error at "z,w"
// these shouldn't be errors
function noError1(x, y) { }
function noError1(x, y) {
if (x === void 0) { x = 3; }
if (y === void 0) { y = 2; }
}
;
function noError2(x, y) { }
;
@@ -10,12 +10,21 @@ var a = (x?=0) => { return 1; };
var b = (x, y?:number = 2) => { x; };
//// [optionalArgsWithDefaultValues.js]
function foo(x, y, z) { }
function foo(x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
}
var CCC = (function () {
function CCC() {
}
CCC.prototype.foo = function (x, y, z) { };
CCC.foo2 = function (x, y, z) { };
CCC.prototype.foo = function (x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
};
CCC.foo2 = function (x, y, z) {
if (y === void 0) { y = false; }
if (z === void 0) { z = 0; }
};
return CCC;
})();
var a = function (x) {
@@ -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: "" });
@@ -242,7 +242,10 @@ c1o1.C1M4();
i1o1.C1M4();
F4();
L4();
function fnOpt1(id, children, expectedPath, isRoot) { }
function fnOpt1(id, children, expectedPath, isRoot) {
if (children === void 0) { children = []; }
if (expectedPath === void 0) { expectedPath = []; }
}
function fnOpt2(id, children, expectedPath, isRoot) { }
fnOpt1(1, [2, 3], [1], true);
fnOpt2(1, [2, 3], [1], true);
+1 -1
View File
@@ -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->^^^^
@@ -73,14 +73,23 @@ function outside() {
var b;
}
}
function defaultArgFunction(a, b) { }
function defaultArgArrow(a, b) { }
function defaultArgFunction(a, b) {
if (a === void 0) { a = function () { return b; }; }
if (b === void 0) { b = 1; }
}
function defaultArgArrow(a, b) {
if (a === void 0) { a = function () { return function () { return b; }; }; }
if (b === void 0) { b = 3; }
}
var C = (function () {
function C(a, b) {
if (a === void 0) { a = b; }
if (b === void 0) { b = 1; }
}
C.prototype.method = function (a, b) { };
C.prototype.method = function (a, b) {
if (a === void 0) { a = b; }
if (b === void 0) { b = 1; }
};
return C;
})();
// Function expressions
@@ -8,7 +8,9 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "Foo", {
set: function (a) { },
set: function (a) {
if (a === void 0) { a = 1; }
},
enumerable: true,
configurable: true
});
@@ -7,6 +7,12 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
if (bar === void 0) { bar = 0; }
var bar = [];
for (var _i = 0; _i < arguments.length; _i++) {
bar[_i - 0] = arguments[_i];
}
};
return C;
})();
@@ -7,6 +7,8 @@ class C {
var C = (function () {
function C() {
}
C.prototype.F = function (A) { };
C.prototype.F = function (A) {
if (A === void 0) { A = 0; }
};
return C;
})();
+1 -1
View File
@@ -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":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,QAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC,IAAaA,eAAeA;oBAA5BC,SAAaA,eAAeA;oBAQ5BC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExBF,6BAAGA,GAAVA,UAAWA,KAA6BA;wBAEvCG,MAAMA,CAACA,IAAIA,C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tCA;QAADA,CAACA,EAxBmBV,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"}
{"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":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAACA,IAAAA,OAAOA,CAUpBA;IAVaA,WAAAA,OAAOA;QAACC,IAAAA,KAAKA,CAU1BA;QAVqBA,WAAAA,QAAKA;YAACC,IAAAA,IAAIA,CAU/BA;YAV2BA,WAAAA,IAAIA,EAACA,CAACA;gBACjCC,IAAaA,eAAeA;oBAA5BC,SAAaA,eAAeA;oBAQ5BC,CAACA;oBANOD,+BAAKA,GAAZA,cAAiBE,MAAMA,CAACA,IAAIA,CAACA,CAACA,CAACA;oBAExB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AAA;YACFA,CAACA,EAxB6BD,SAASA,GAATA,mBAASA,KAATA,mBAASA,QAwBtCA;QAADA,CAACA,EAxBmBT,SAASA,GAATA,eAASA,KAATA,eAASA,QAwB5BA;IAADA,CAACA,EAxBaR,KAAKA,GAALA,YAAKA,KAALA,YAAKA,QAwBlBA;AAADA,CAACA,EAxBM,MAAM,KAAN,MAAM,QAwBZ"}
@@ -975,8 +975,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->^^^^^^^^^^^^^^^^
@@ -4,4 +4,10 @@ function f2(...x = []) { }
//// [restParamAsOptional.js]
function f() { }
function f2() { }
function f2() {
if (x === void 0) { x = []; }
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i - 0] = arguments[_i];
}
}
@@ -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;
})();
@@ -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->^^^^
@@ -1,2 +1,2 @@
//// [sourceMapValidationFunctionPropertyAssignment.js.map]
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAM,EAAE,CAAC"}
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,gBAAK,CAAC,EAAE,CAAC"}
@@ -15,27 +15,30 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
4 > ^^^
5 > ^^
6 > ^
7 > ^^^^^^^^^^^^^^^^^
8 > ^^
9 > ^
10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
7 > ^^^^^^^^^^^^^^^^
8 > ^
9 > ^^
10> ^
11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
2 >var
3 > x
4 > =
5 > {
6 > n
7 > () { }
8 > }
9 > ;
7 > () {
8 > }
9 > }
10> ;
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
5 >Emitted(1, 11) Source(1, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(1, 12) + SourceIndex(0)
7 >Emitted(1, 29) Source(1, 18) + SourceIndex(0)
8 >Emitted(1, 31) Source(1, 20) + SourceIndex(0)
9 >Emitted(1, 32) Source(1, 21) + SourceIndex(0)
7 >Emitted(1, 28) Source(1, 17) + SourceIndex(0)
8 >Emitted(1, 29) Source(1, 18) + SourceIndex(0)
9 >Emitted(1, 31) Source(1, 20) + SourceIndex(0)
10>Emitted(1, 32) Source(1, 21) + SourceIndex(0)
---
>>>//# sourceMappingURL=sourceMapValidationFunctionPropertyAssignment.js.map
@@ -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"; };
File diff suppressed because one or more lines are too long
@@ -2266,15 +2266,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn1_2_2
3 >
4 > public AisIn1_2_2() { }
4 > public AisIn1_2_2() {
5 > }
1->Emitted(114, 21) Source(79, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
2 >Emitted(114, 48) Source(79, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
3 >Emitted(114, 51) Source(79, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
4 >Emitted(114, 66) Source(79, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
4 >Emitted(114, 65) Source(79, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
5 >Emitted(114, 66) Source(79, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2353,15 +2356,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > BisIn1_2_2
3 >
4 > public BisIn1_2_2() { }
4 > public BisIn1_2_2() {
5 > }
1->Emitted(121, 21) Source(80, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
2 >Emitted(121, 48) Source(80, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
3 >Emitted(121, 51) Source(80, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
4 >Emitted(121, 66) Source(80, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
4 >Emitted(121, 65) Source(80, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
5 >Emitted(121, 66) Source(80, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassB)
---
>>> return ClassB;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2440,15 +2446,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > CisIn1_2_2
3 >
4 > public CisIn1_2_2() { }
4 > public CisIn1_2_2() {
5 > }
1->Emitted(128, 21) Source(81, 42) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
2 >Emitted(128, 48) Source(81, 52) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
3 >Emitted(128, 51) Source(81, 35) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
4 >Emitted(128, 66) Source(81, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
4 >Emitted(128, 65) Source(81, 57) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
5 >Emitted(128, 66) Source(81, 58) + SourceIndex(0) name (TopLevelModule1.SubModule2.SubSubModule2.ClassC)
---
>>> return ClassC;
1 >^^^^^^^^^^^^^^^^^^^^
@@ -2619,15 +2628,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn1
3 >
4 > public AisIn1() { }
4 > public AisIn1() {
5 > }
1->Emitted(137, 13) Source(90, 16) + SourceIndex(0) name (TopLevelModule1.ClassA)
2 >Emitted(137, 36) Source(90, 22) + SourceIndex(0) name (TopLevelModule1.ClassA)
3 >Emitted(137, 39) Source(90, 9) + SourceIndex(0) name (TopLevelModule1.ClassA)
4 >Emitted(137, 54) Source(90, 28) + SourceIndex(0) name (TopLevelModule1.ClassA)
4 >Emitted(137, 53) Source(90, 27) + SourceIndex(0) name (TopLevelModule1.ClassA)
5 >Emitted(137, 54) Source(90, 28) + SourceIndex(0) name (TopLevelModule1.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^
@@ -3043,15 +3055,18 @@ sourceFile:typeResolution.ts
1->^^^^^^^^^^^^^^^^
2 > ^^^^^^^^^^^^^^^^^^^^^^^^^
3 > ^^^
4 > ^^^^^^^^^^^^^^^
4 > ^^^^^^^^^^^^^^
5 > ^
1->
2 > AisIn2_3
3 >
4 > public AisIn2_3() { }
4 > public AisIn2_3() {
5 > }
1->Emitted(157, 17) Source(105, 20) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
2 >Emitted(157, 42) Source(105, 28) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
3 >Emitted(157, 45) Source(105, 13) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
4 >Emitted(157, 60) Source(105, 34) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
4 >Emitted(157, 59) Source(105, 33) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
5 >Emitted(157, 60) Source(105, 34) + SourceIndex(0) name (TopLevelModule2.SubModule3.ClassA)
---
>>> return ClassA;
1 >^^^^^^^^^^^^^^^^
@@ -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) {
}
-4
View File
@@ -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) {
}