Emit functions on a singline line if they were originally written on a single line.

This commit is contained in:
Cyrus Najmabadi
2015-02-06 20:03:24 -08:00
parent 11aa4d362b
commit 0fbbbffde6
541 changed files with 4412 additions and 9120 deletions
+22 -7
View File
@@ -3487,19 +3487,34 @@ module ts {
write(" {");
scopeEmitStart(node);
var outPos = writer.getTextPos();
increaseIndent();
emitDetachedComments(body.statements);
var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true);
emitFunctionBodyPreamble(node);
emitLinesStartingAt(body.statements, startIndex);
emitTempDeclarations(/*newLine*/ true);
writeLine();
emitLeadingCommentsOfPosition(body.statements.end);
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
var preambleEmitted = writer.getTextPos() !== outPos;
if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
for (var i = 0, n = body.statements.length; i < n; i++) {
write(" ");
emit(body.statements[i]);
}
emitTempDeclarations(/*newLine*/ false);
write(" ");
emitLeadingCommentsOfPosition(body.statements.end);
}
else {
increaseIndent();
emitLinesStartingAt(body.statements, startIndex);
emitTempDeclarations(/*newLine*/ true);
writeLine();
emitLeadingCommentsOfPosition(body.statements.end);
decreaseIndent();
}
emitToken(SyntaxKind.CloseBraceToken, body.statements.end);
scopeEmitEnd();
}
+1 -3
View File
@@ -30,9 +30,7 @@ var Board = (function () {
function Board() {
}
Board.prototype.allShipsSunk = function () {
return this.ships.every(function (val) {
return val.isSunk;
});
return this.ships.every(function (val) { return val.isSunk; });
};
return Board;
})();
@@ -19,9 +19,7 @@ module clodule {
var clodule = (function () {
function clodule() {
}
clodule.sfn = function (id) {
return 42;
};
clodule.sfn = function (id) { return 42; };
return clodule;
})();
var clodule;
@@ -28,16 +28,12 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
}; // unexpected error here bug 840246
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
var Point;
(function (Point) {
function Origin() {
return null;
}
function Origin() { return null; }
Point.Origin = Origin; //expected duplicate identifier error
})(Point || (Point = {}));
var A;
@@ -47,17 +43,13 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
}; // unexpected error here bug 840246
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
}
function Origin() { return ""; }
Point.Origin = Origin; //expected duplicate identifier error
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -28,16 +28,12 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
};
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
var Point;
(function (Point) {
function Origin() {
return "";
} // not an error, since not exported
function Origin() { return ""; } // not an error, since not exported
})(Point || (Point = {}));
var A;
(function (A) {
@@ -46,16 +42,12 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () {
return { x: 0, y: 0 };
};
Point.Origin = function () { return { x: 0, y: 0 }; };
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() {
return "";
} // not an error since not exported
function Origin() { return ""; } // not an error since not exported
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -2,6 +2,4 @@
function* foo() { yield }
//// [YieldExpression13_es6.js]
function foo() {
;
}
function foo() { ; }
@@ -2,6 +2,4 @@
var v = { get foo() { yield foo; } }
//// [YieldExpression17_es6.js]
var v = { get foo() {
;
} };
var v = { get foo() { ; } };
@@ -52,9 +52,7 @@ var C = (function () {
}
C.privateMethod = function () { };
Object.defineProperty(C, "privateGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -65,9 +63,7 @@ var C = (function () {
});
C.protectedMethod = function () { };
Object.defineProperty(C, "protectedGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -78,9 +74,7 @@ var C = (function () {
});
C.publicMethod = function () { };
Object.defineProperty(C, "publicGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -97,9 +91,7 @@ var D = (function () {
}
D.privateMethod = function () { };
Object.defineProperty(D, "privateGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -110,9 +102,7 @@ var D = (function () {
});
D.protectedMethod = function () { };
Object.defineProperty(D, "protectedGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -123,9 +113,7 @@ var D = (function () {
});
D.publicMethod = function () { };
Object.defineProperty(D, "publicGetter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -142,9 +130,7 @@ var E = (function () {
}
E.prototype.method = function () { };
Object.defineProperty(E.prototype, "getter", {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
+1 -3
View File
@@ -47,9 +47,7 @@ var D = (function () {
return D;
})();
var x = {
get a() {
return 1;
}
get a() { return 1; }
};
var y = {
set b(v) { }
+1 -3
View File
@@ -44,9 +44,7 @@ var D = (function () {
return D;
})();
var x = {
get a() {
return 1;
}
get a() { return 1; }
};
var y = {
set b(v) { }
@@ -11,14 +11,10 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () {
return 1;
},
get: function () { return 1; },
enumerable: true,
configurable: true
});
return C;
})();
var y = { get foo() {
return 3;
} };
var y = { get foo() { return 3; } };
@@ -18,38 +18,26 @@ var LanguageSpec_section_4_5_error_cases = (function () {
function LanguageSpec_section_4_5_error_cases() {
}
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterFirst", {
get: function () {
return "";
},
get: function () { return ""; },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterLast", {
get: function () {
return "";
},
get: function () { return ""; },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterFirst", {
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterLast", {
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
configurable: true
});
@@ -47,49 +47,37 @@ var LanguageSpec_section_4_5_inference = (function () {
function LanguageSpec_section_4_5_inference() {
}
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation_GetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter_SetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation_GetterFirst", {
get: function () {
return new B();
},
get: function () { return new B(); },
set: function (a) { },
enumerable: true,
configurable: true
@@ -84,6 +84,4 @@ var r16 = a + M;
var r17 = a + '';
var r18 = a + 123;
var r19 = a + { a: '' };
var r20 = a + (function (a) {
return a;
});
var r20 = a + (function (a) { return a; });
@@ -25,9 +25,7 @@ var r11 = null + (() => { });
//// [additionOperatorWithNullValueAndInvalidOperator.js]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
function foo() {
return undefined;
}
function foo() { return undefined; }
var a;
var b;
var c;
@@ -25,9 +25,7 @@ var r11 = undefined + (() => { });
//// [additionOperatorWithUndefinedValueAndInvalidOperands.js]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
function foo() {
return undefined;
}
function foo() { return undefined; }
var a;
var b;
var c;
@@ -21,9 +21,7 @@ export var a = function () {
//// [aliasUsedAsNameValue_0.js]
exports.id;
//// [aliasUsedAsNameValue_1.js]
function b(a) {
return null;
}
function b(a) { return null; }
exports.b = b;
//// [aliasUsedAsNameValue_2.js]
///<reference path='aliasUsedAsNameValue_0.ts' />
@@ -5,6 +5,4 @@ function foo() { return null; }
//// [ambientClassOverloadForFunction.js]
;
function foo() {
return null;
}
function foo() { return null; }
@@ -6,9 +6,7 @@ var r3 = <<T>(x: T) => T>f; // ambiguous, appears to the parser as a << operatio
//// [ambiguousGenericAssertion1.js]
function f(x) {
return null;
}
function f(x) { return null; }
var r = function (x) { return x; };
var r2 = f; // valid
var r3 = << T > (x), T;
@@ -12,15 +12,11 @@ var x2: string = foof2("s", null);
var y2: number = foof2("s", null);
//// [ambiguousOverload.js]
function foof(bar) {
return bar;
}
function foof(bar) { return bar; }
;
var x = foof("s", null);
var y = foof("s", null);
function foof2(bar) {
return bar;
}
function foof2(bar) { return bar; }
;
var x2 = foof2("s", null);
var y2 = foof2("s", null);
+1 -3
View File
@@ -28,6 +28,4 @@ var M;
M.C = C;
})(M || (M = {}));
var c = new M.C();
c.m(function (n) {
return "hello: " + n;
}, 18);
c.m(function (n) { return "hello: " + n; }, 18);
@@ -27,6 +27,4 @@ paired.reduce(function (b1, b2) {
}, []);
paired.reduce(function (b3, b4) { return b3.concat({}); }, []);
paired.map(function (c1) { return c1.count; });
paired.map(function (c2) {
return c2.count;
});
paired.map(function (c2) { return c2.count; });
@@ -95,12 +95,8 @@ var __extends = this.__extends || function (d, b) {
var C1 = (function () {
function C1() {
}
C1.prototype.IM1 = function () {
return null;
};
C1.prototype.C1M1 = function () {
return null;
};
C1.prototype.IM1 = function () { return null; };
C1.prototype.C1M1 = function () { return null; };
return C1;
})();
var C2 = (function (_super) {
@@ -108,17 +104,13 @@ var C2 = (function (_super) {
function C2() {
_super.apply(this, arguments);
}
C2.prototype.C2M1 = function () {
return null;
};
C2.prototype.C2M1 = function () { return null; };
return C2;
})(C1);
var C3 = (function () {
function C3() {
}
C3.prototype.CM3M1 = function () {
return 3;
};
C3.prototype.CM3M1 = function () { return 3; };
return C3;
})();
/*
@@ -138,9 +130,7 @@ var i1 = c1;
var c2 = new C2();
var c3 = new C3();
var o1 = { one: 1 };
var f1 = function () {
return new C1();
};
var f1 = function () { return new C1(); };
var arr_any = [];
var arr_i1 = [];
var arr_c1 = [];
@@ -69,12 +69,8 @@ var __extends = this.__extends || function (d, b) {
var C1 = (function () {
function C1() {
}
C1.prototype.IM1 = function () {
return null;
};
C1.prototype.C1M1 = function () {
return null;
};
C1.prototype.IM1 = function () { return null; };
C1.prototype.C1M1 = function () { return null; };
return C1;
})();
var C2 = (function (_super) {
@@ -82,17 +78,13 @@ var C2 = (function (_super) {
function C2() {
_super.apply(this, arguments);
}
C2.prototype.C2M1 = function () {
return null;
};
C2.prototype.C2M1 = function () { return null; };
return C2;
})(C1);
var C3 = (function () {
function C3() {
}
C3.prototype.CM3M1 = function () {
return 3;
};
C3.prototype.CM3M1 = function () { return 3; };
return C3;
})();
/*
@@ -112,9 +104,7 @@ var i1 = c1;
var c2 = new C2();
var c3 = new C3();
var o1 = { one: 1 };
var f1 = function () {
return new C1();
};
var f1 = function () { return new C1(); };
var arr_any = [];
var arr_i1 = [];
var arr_c1 = [];
@@ -128,9 +118,7 @@ arr_c3 = arr_c2_2; // should be an error - is
arr_c3 = arr_c1_2; // should be an error - is
arr_c3 = arr_i1_2; // should be an error - is
arr_any = f1; // should be an error - is
arr_any = function () {
return null;
}; // should be an error - is
arr_any = function () { return null; }; // should be an error - is
arr_any = o1; // should be an error - is
arr_any = a1; // should be ok - is
arr_any = c1; // should be an error - is
@@ -30,9 +30,7 @@ arr_any = c3; // should be an error - is
var C3 = (function () {
function C3() {
}
C3.prototype.CM3M1 = function () {
return 3;
};
C3.prototype.CM3M1 = function () { return 3; };
return C3;
})();
/*
@@ -49,7 +47,5 @@ Type 1 of any[]:
var c3 = new C3();
var o1 = { one: 1 };
var arr_any = [];
arr_any = function () {
return null;
}; // should be an error - is
arr_any = function () { return null; }; // should be an error - is
arr_any = c3; // should be an error - is
@@ -184,14 +184,10 @@ var M2;
// <Identifier>(ParamList) => { ... } is a generic arrow function
var generic1 = function (n) { return [n]; };
var generic1; // Incorrect error, Bug 829597
var generic2 = function (n) {
return [n];
};
var generic2 = function (n) { return [n]; };
var generic2;
// <Identifier> ((ParamList) => { ... } ) is a type assertion to an arrow function
var asserted1 = (function (n) { return [n]; });
var asserted1;
var asserted2 = (function (n) {
return n;
});
var asserted2 = (function (n) { return n; });
var asserted2;
@@ -91,16 +91,10 @@ function tryCatchFn() {
//// [arrowFunctionExpressions.js]
// ArrowFormalParameters => AssignmentExpression is equivalent to ArrowFormalParameters => { return AssignmentExpression; }
var a = function (p) { return p.length; };
var a = function (p) {
return p.length;
};
var a = function (p) { return p.length; };
// Identifier => Block is equivalent to(Identifier) => Block
var b = function (j) {
return 0;
};
var b = function (j) {
return 0;
};
var b = function (j) { return 0; };
var b = function (j) { return 0; };
// Identifier => AssignmentExpression is equivalent to(Identifier) => AssignmentExpression
var c;
var d = function (n) { return c = n; };
@@ -11,6 +11,4 @@ var C = (function () {
}
return C;
})();
var c = new C(function () {
return asdf;
}); // should error
var c = new C(function () { return asdf; }); // should error
@@ -79,24 +79,12 @@ var missingCurliesWithArrow;
(function (missingCurliesWithArrow) {
var withStatement;
(function (withStatement) {
var a = function () {
var k = 10;
};
var b = function () {
var k = 10;
};
var c = function (x) {
var k = 10;
};
var d = function (x, y) {
var k = 10;
};
var e = function (x, y) {
var k = 10;
};
var f = function () {
var k = 10;
};
var a = function () { var k = 10; };
var b = function () { var k = 10; };
var c = function (x) { var k = 10; };
var d = function (x, y) { var k = 10; };
var e = function (x, y) { var k = 10; };
var f = function () { var k = 10; };
})(withStatement || (withStatement = {}));
var withoutStatement;
(function (withoutStatement) {
@@ -91,12 +91,8 @@ var h;
x = h;
var i;
x = i;
x = { f: function () {
return 1;
} };
x = { f: function (x) {
return x;
} };
x = { f: function () { return 1; } };
x = { f: function (x) { return x; } };
function j(a) {
x = a;
}
@@ -12,6 +12,4 @@ fn(function (a, b) { return true; })
//// [assignLambdaToNominalSubtypeOfFunction.js]
function fn(cb) { }
fn(function (a, b) { return true; });
fn(function (a, b) {
return true;
});
fn(function (a, b) { return true; });
+1 -3
View File
@@ -13,8 +13,6 @@ module M {
//// [assignToFn.js]
var M;
(function (M) {
var x = { f: function (n) {
return true;
} };
var x = { f: function (n) { return true; } };
x.f = "hello";
})(M || (M = {}));
@@ -44,50 +44,28 @@ b2 = { a: 0 }; // error
b2 = { b: 0, a: 0 };
var b3;
b3 = {
f: function (n) {
return 0;
},
g: function (s) {
return 0;
},
f: function (n) { return 0; },
g: function (s) { return 0; },
m: 0
}; // ok
b3 = {
f: function (n) {
return 0;
},
g: function (s) {
return 0;
}
f: function (n) { return 0; },
g: function (s) { return 0; }
}; // error
b3 = {
f: function (n) {
return 0;
},
f: function (n) { return 0; },
m: 0
}; // error
b3 = {
f: function (n) {
return 0;
},
g: function (s) {
return 0;
},
f: function (n) { return 0; },
g: function (s) { return 0; },
m: 0,
n: 0,
k: function (a) {
return null;
}
k: function (a) { return null; }
}; // ok
b3 = {
f: function (n) {
return 0;
},
g: function (s) {
return 0;
},
f: function (n) { return 0; },
g: function (s) { return 0; },
n: 0,
k: function (a) {
return null;
}
k: function (a) { return null; }
}; // error
@@ -28,12 +28,8 @@ foo(x + y);
//// [assignmentCompatBug3.js]
function makePoint(x, y) {
return {
get x() {
return x;
},
get y() {
return y;
},
get x() { return x; },
get y() { return y; },
//x: "yo",
//y: "boo",
dist: function () {
@@ -19,6 +19,4 @@ foo2(["s", "t"]);
function foo3(x) { }
;
foo3(function (s) { });
foo3(function (n) {
return;
});
foo3(function (n) { return; });
@@ -22,9 +22,7 @@ var TokenType;
})(TokenType || (TokenType = {}));
;
var list = {};
function returnType() {
return null;
}
function returnType() { return null; }
function foo() {
var x = returnType();
var x = list['one'];
@@ -57,26 +57,18 @@ a = s;
a = a2;
t = function (x) { return 1; };
t = function () { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = function (x) { return 1; };
a = function () { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
var s2;
var a3;
// these are errors
t = s2;
t = a3;
t = function (x) { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = s2;
a = a3;
a = function (x) { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
@@ -64,38 +64,24 @@ a = s;
a = a2;
t = { f: function () { return 1; } };
t = { f: function (x) { return 1; } };
t = { f: function f() {
return 1;
} };
t = { f: function (x) {
return '';
} };
t = { f: function f() { return 1; } };
t = { f: function (x) { return ''; } };
a = { f: function () { return 1; } };
a = { f: function (x) { return 1; } };
a = { f: function (x) {
return '';
} };
a = { f: function (x) { return ''; } };
// errors
t = function () { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = function () { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
var s2;
var a3;
// these are errors
t = s2;
t = a3;
t = function (x) { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = s2;
a = a3;
a = function (x) { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
@@ -54,12 +54,8 @@ var a3;
t = s2;
t = a3;
t = function (x) { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = s2;
a = a3;
a = function (x) { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
@@ -56,25 +56,17 @@ a = s;
a = a2;
// errors
t = function () { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = function () { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
var s2;
var a3;
// these are errors
t = s2;
t = a3;
t = function (x) { return 1; };
t = function (x) {
return '';
};
t = function (x) { return ''; };
a = s2;
a = a3;
a = function (x) { return 1; };
a = function (x) {
return '';
};
a = function (x) { return ''; };
@@ -31,18 +31,10 @@ var d: new(x: number) => void;
d = C; // Error
//// [assignmentCompatWithOverloads.js]
function f1(x) {
return null;
}
function f2(x) {
return null;
}
function f3(x) {
return null;
}
function f4(x) {
return undefined;
}
function f1(x) { return null; }
function f2(x) { return null; }
function f3(x) { return null; }
function f4(x) { return undefined; }
var g;
g = f1; // OK
g = f2; // Error
@@ -19,9 +19,7 @@ var __test1__;
})(__test1__ || (__test1__ = {}));
var __test2__;
(function (__test2__) {
__test2__.obj = function f(a) {
return a;
};
__test2__.obj = function f(a) { return a; };
;
__test2__.__val__obj = __test2__.obj;
})(__test2__ || (__test2__ = {}));
@@ -84,17 +84,11 @@ var C = (function () {
function C() {
this = value;
}
C.prototype.foo = function () {
this = value;
};
C.sfoo = function () {
this = value;
};
C.prototype.foo = function () { this = value; };
C.sfoo = function () { this = value; };
return C;
})();
function foo() {
this = value;
}
function foo() { this = value; }
this = value;
// identifiers: module, class, enum, function
var M;
@@ -129,12 +123,8 @@ var Derived = (function (_super) {
_super.call(this);
_super.prototype. = value;
}
Derived.prototype.foo = function () {
_super.prototype. = value;
};
Derived.sfoo = function () {
_super. = value;
};
Derived.prototype.foo = function () { _super.prototype. = value; };
Derived.sfoo = function () { _super. = value; };
return Derived;
})(C);
// function expression
@@ -26,15 +26,9 @@ var e3 = t3[2]; // any
var e4 = t4[3]; // number
//// [bestCommonTypeOfTuple.js]
function f1(x) {
return "foo";
}
function f2(x) {
return 10;
}
function f3(x) {
return true;
}
function f1(x) { return "foo"; }
function f2(x) { return 10; }
function f3(x) { return true; }
var E1;
(function (E1) {
E1[E1["one"] = 0] = "one";
@@ -18,9 +18,5 @@ function f() {
return b();
return d();
}
function b() {
return null;
}
function d() {
return null;
}
function b() { return null; }
function d() { return null; }
@@ -41,15 +41,11 @@ var ResultIsNumber8 = ~~BOOLEAN;
//// [bitwiseNotOperatorWithBooleanType.js]
// ~ operator on boolean type
var BOOLEAN;
function foo() {
return true;
}
function foo() { return true; }
var A = (function () {
function A() {
}
A.foo = function () {
return false;
};
A.foo = function () { return false; };
return A;
})();
var M;
@@ -48,15 +48,11 @@ var ResultIsNumber13 = ~~~(NUMBER + NUMBER);
// ~ operator on number type
var NUMBER;
var NUMBER1 = [1, 2];
function foo() {
return 1;
}
function foo() { return 1; }
var A = (function () {
function A() {
}
A.foo = function () {
return 1;
};
A.foo = function () { return 1; };
return A;
})();
var M;
@@ -70,9 +66,7 @@ var ResultIsNumber2 = ~NUMBER1;
// number type literal
var ResultIsNumber3 = ~1;
var ResultIsNumber4 = ~{ x: 1, y: 2 };
var ResultIsNumber5 = ~{ x: 1, y: function (n) {
return n;
} };
var ResultIsNumber5 = ~{ x: 1, y: function (n) { return n; } };
// number type expressions
var ResultIsNumber6 = ~objA.a;
var ResultIsNumber7 = ~M.n;
@@ -47,15 +47,11 @@ var ResultIsNumber14 = ~~~(STRING + STRING);
// ~ operator on string type
var STRING;
var STRING1 = ["", "abc"];
function foo() {
return "abc";
}
function foo() { return "abc"; }
var A = (function () {
function A() {
}
A.foo = function () {
return "";
};
A.foo = function () { return ""; };
return A;
})();
var M;
@@ -69,9 +65,7 @@ var ResultIsNumber2 = ~STRING1;
// string type literal
var ResultIsNumber3 = ~"";
var ResultIsNumber4 = ~{ x: "", y: "" };
var ResultIsNumber5 = ~{ x: "", y: function (s) {
return s;
} };
var ResultIsNumber5 = ~{ x: "", y: function (s) { return s; } };
// string type expressions
var ResultIsNumber6 = ~objA.a;
var ResultIsNumber7 = ~M.n;
@@ -47,14 +47,10 @@ var r7b = i2.f<number, string, number>(1, '');
//// [callGenericFunctionWithIncorrectNumberOfTypeArguments.js]
// type parameter lists must exactly match type argument lists
// all of these invocations are errors
function f(x, y) {
return null;
}
function f(x, y) { return null; }
var r1 = f(1, '');
var r1b = f(1, '');
var f2 = function (x, y) {
return null;
};
var f2 = function (x, y) { return null; };
var r2 = f2(1, '');
var r2b = f2(1, '');
var f3;
@@ -38,13 +38,9 @@ var r7 = i2.f(1);
//// [callGenericFunctionWithZeroTypeArguments.js]
// valid invocations of generic functions with no explicit type arguments provided
function f(x) {
return null;
}
function f(x) { return null; }
var r = f(1);
var f2 = function (x) {
return null;
};
var f2 = function (x) { return null; };
var r2 = f2(1);
var f3;
var r3 = f3(1);
@@ -46,13 +46,9 @@ var r8 = a2<number>();
//// [callNonGenericFunctionWithTypeArguments.js]
// it is always illegal to provide type arguments to a non-generic function
// all invocations here are illegal
function f(x) {
return null;
}
function f(x) { return null; }
var r = f(1);
var f2 = function (x) {
return null;
};
var f2 = function (x) { return null; };
var r2 = f2(1);
var f3;
var r3 = f3(1);
+1 -3
View File
@@ -25,9 +25,7 @@ var Foo = (function () {
Foo.prototype.bar1 = function () { };
return Foo;
})();
function F1(a) {
return a;
}
function F1(a) { return a; }
var f1 = new Foo("hey");
f1.bar1();
Foo();
+2 -6
View File
@@ -33,12 +33,8 @@ var Foo = (function () {
Foo.prototype.bar1 = function () { };
return Foo;
})();
function F1(s) {
return s;
} // error
function F1(a) {
return a;
} // error
function F1(s) { return s; } // error
function F1(a) { return a; } // error
var f1 = new Foo("hey");
f1.bar1();
Foo();
@@ -202,9 +202,7 @@ function foo12() {
return i2;
}
var r12 = foo12();
function m1() {
return 1;
}
function m1() { return 1; }
var m1;
(function (m1) {
m1.y = 2;
@@ -21,14 +21,8 @@ var r5b = _.map<number, string>(c2, rf1);
//// [callbacksDontShareTypes.js]
var _;
var c2;
var rf1 = function (x) {
return x.toFixed();
};
var r1a = _.map(c2, function (x) {
return x.toFixed();
});
var rf1 = function (x) { return x.toFixed(); };
var r1a = _.map(c2, function (x) { return x.toFixed(); });
var r1b = _.map(c2, rf1); // this line should not cause the following 2 to have errors
var r5a = _.map(c2, function (x) {
return x.toFixed();
});
var r5a = _.map(c2, function (x) { return x.toFixed(); });
var r5b = _.map(c2, rf1);
+1 -3
View File
@@ -47,7 +47,5 @@ var p_cast = ({
add: function (dx, dy) {
return new Point(this.x + dx, this.y + dy);
},
mult: function (p) {
return p;
}
mult: function (p) { return p; }
});
@@ -14,6 +14,4 @@ var s3 = s2.each(x => { x.key /* Type is K, should be number */ });
//// [chainedSpecializationToObjectTypeLiteral.js]
var s;
var s2 = s.groupBy(function (s) { return s.length; });
var s3 = s2.each(function (x) {
x.key; /* Type is K, should be number */
});
var s3 = s2.each(function (x) { x.key; /* Type is K, should be number */ });
@@ -19,20 +19,14 @@ var C = (function () {
function C() {
this.x = 1;
}
C.prototype.foo = function (x) {
return x;
};
C.prototype.foo = function (x) { return x; };
return C;
})();
var D2 = (function () {
function D2() {
this.x = 3;
}
D2.prototype.foo = function (x) {
return x;
};
D2.prototype.other = function (x) {
return x;
};
D2.prototype.foo = function (x) { return x; };
D2.prototype.other = function (x) { return x; };
return D2;
})();
@@ -23,9 +23,7 @@ var __extends = this.__extends || function (d, b) {
var A = (function () {
function A() {
}
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C = (function () {
@@ -24,9 +24,7 @@ var __extends = this.__extends || function (d, b) {
var A = (function () {
function A() {
}
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C = (function () {
@@ -27,9 +27,7 @@ var A = (function () {
function A() {
this.x = 1;
}
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C = (function () {
@@ -28,9 +28,7 @@ var A = (function () {
function A() {
this.x = 1;
}
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C = (function () {
@@ -34,9 +34,7 @@ var A = (function () {
A.bar = function () {
return "";
};
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C = (function () {
+1 -3
View File
@@ -31,9 +31,7 @@ var A = (function (_super) {
function A() {
_super.apply(this, arguments);
}
A.prototype.foo = function () {
this.bar();
};
A.prototype.foo = function () { this.bar(); };
return A;
})(B);
var B = (function () {
@@ -28,18 +28,14 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { };
Object.defineProperty(C, "b", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
@@ -28,18 +28,14 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { };
Object.defineProperty(C, "b", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
@@ -27,18 +27,14 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "y", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
});
C.prototype.foo = function () { };
Object.defineProperty(C, "b", {
get: function () {
return null;
},
get: function () { return null; },
set: function (x) { },
enumerable: true,
configurable: true
@@ -28,9 +28,7 @@ var A = (function () {
A.bar = function () {
return "";
};
A.prototype.foo = function () {
return 1;
};
A.prototype.foo = function () { return 1; };
return A;
})();
var C2 = (function (_super) {
@@ -30,13 +30,9 @@ i = c;
var C = (function () {
function C() {
}
C.prototype.y = function (a) {
return null;
};
C.prototype.y = function (a) { return null; };
Object.defineProperty(C.prototype, "z", {
get: function () {
return 1;
},
get: function () { return 1; },
set: function (v) { },
enumerable: true,
configurable: true
@@ -32,13 +32,9 @@ i = c;
var C = (function () {
function C() {
}
C.prototype.y = function (a) {
return null;
};
C.prototype.y = function (a) { return null; };
Object.defineProperty(C.prototype, "z", {
get: function () {
return 1;
},
get: function () { return 1; },
set: function (v) { },
enumerable: true,
configurable: true
@@ -30,12 +30,8 @@ var C = (function () {
this.b = '';
this.d = function () { return ''; };
}
C.prototype.c = function () {
return '';
};
C.f = function () {
return '';
};
C.prototype.c = function () { return ''; };
C.f = function () { return ''; };
C.g = function () { return ''; };
return C;
})();
@@ -41,12 +41,8 @@ var C = (function () {
this.b = '';
this.d = function () { return ''; };
}
C.prototype.c = function () {
return '';
};
C.f = function () {
return '';
};
C.prototype.c = function () { return ''; };
C.f = function () { return ''; };
C.g = function () { return ''; };
return C;
})();
@@ -28,12 +28,8 @@ var C = (function () {
this.b = '';
this.d = function () { return ''; };
}
C.prototype.c = function () {
return '';
};
C.f = function () {
return '';
};
C.prototype.c = function () { return ''; };
C.f = function () { return ''; };
C.g = function () { return ''; };
return C;
})();
@@ -31,13 +31,9 @@ var C = (function () {
this.a = a;
this.b = b;
}
C.fn = function () {
return this;
};
C.fn = function () { return this; };
Object.defineProperty(C, "x", {
get: function () {
return 1;
},
get: function () { return 1; },
set: function (v) { },
enumerable: true,
configurable: true
@@ -20,9 +20,7 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () {
return 1;
},
get: function () { return 1; },
enumerable: true,
configurable: true
});
@@ -38,9 +38,7 @@ var Shape;
(function (Shape) {
var Utils;
(function (Utils) {
function convert() {
return null;
}
function convert() { return null; }
Utils.convert = convert;
})(Utils = Shape.Utils || (Shape.Utils = {}));
})(Shape || (Shape = {}));
@@ -12,7 +12,5 @@ var console;
function x() {
var _this = this;
var _this = 5;
(function (x) {
console.log(_this.x);
});
(function (x) { console.log(_this.x); });
}
@@ -144,9 +144,7 @@ var Foo1 = (function () {
})();
function f1(_this) {
var _this = this;
(function (x) {
console.log(_this.x);
});
(function (x) { console.log(_this.x); });
}
var Foo3 = (function () {
function Foo3(_this) {
@@ -167,7 +165,5 @@ var Foo3 = (function () {
})();
function f3(_this) {
var _this = this;
(function (x) {
console.log(_this.x);
});
(function (x) { console.log(_this.x); });
}
@@ -14,9 +14,7 @@ var C = (function () {
/**
* @type {number}
*/
get: function () {
return 1;
},
get: function () { return 1; },
enumerable: true,
configurable: true
});
@@ -19,9 +19,7 @@ var C = (function () {
/**
* Getter.
*/
get: function () {
return 1;
},
get: function () { return 1; },
/**
* Setter.
*/
@@ -68,9 +68,7 @@ var Derived = (function (_super) {
})(Base);
var BaseCollection = (function () {
function BaseCollection(f) {
(function (item) {
return [item.Components];
});
(function (item) { return [item.Components]; });
}
return BaseCollection;
})();
@@ -83,9 +81,7 @@ var Thing = (function () {
function Thing() {
}
Object.defineProperty(Thing.prototype, "Components", {
get: function () {
return null;
},
get: function () { return null; },
enumerable: true,
configurable: true
});
@@ -7,12 +7,8 @@ var z: number = h<number>(f);
var z: number = h(f);
//// [compositeGenericFunction.js]
function f(value) {
return value;
}
function f(value) { return value; }
;
function h(func) {
return null;
}
function h(func) { return null; }
var z = h(f);
var z = h(f);
@@ -6,8 +6,6 @@ var v = {
//// [computedPropertyNames1.js]
var v = {
get [0 + 1]() {
return 0;
},
get [0 + 1]() { return 0; },
set [0 + 1](v) { } //No error
};
@@ -21,27 +21,15 @@ var s;
var n;
var a;
var v = {
get [s]() {
return 0;
},
get [s]() { return 0; },
set [n](v) { },
get [s + s]() {
return 0;
},
get [s + s]() { return 0; },
set [s + n](v) { },
get [+s]() {
return 0;
},
get [+s]() { return 0; },
set [""](v) { },
get [0]() {
return 0;
},
get [0]() { return 0; },
set [a](v) { },
get [true]() {
return 0;
},
get [true]() { return 0; },
set [`hello bye`](v) { },
get [`hello ${a} bye`]() {
return 0;
}
get [`hello ${a} bye`]() { return 0; }
};
@@ -24,9 +24,7 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, s, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -36,9 +34,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C, s + s, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -48,9 +44,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C.prototype, +s, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -60,9 +54,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C.prototype, 0, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -72,9 +64,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C, true, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -84,9 +74,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C.prototype, `hello ${a} bye`, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -15,9 +15,7 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, b, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -27,9 +25,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C.prototype, [], {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -39,9 +35,7 @@ var C = (function () {
configurable: true
});
Object.defineProperty(C, undefined, {
get: function () {
return 0;
},
get: function () { return 0; },
enumerable: true,
configurable: true
});
@@ -8,9 +8,7 @@ class C<T> {
}
//// [computedPropertyNames32.js]
function foo() {
return '';
}
function foo() { return ''; }
var C = (function () {
function C() {
}
@@ -10,9 +10,7 @@ class C<T> {
}
//// [computedPropertyNames33.js]
function foo() {
return '';
}
function foo() { return ''; }
var C = (function () {
function C() {
}
@@ -10,9 +10,7 @@ class C<T> {
}
//// [computedPropertyNames34.js]
function foo() {
return '';
}
function foo() { return ''; }
var C = (function () {
function C() {
}
@@ -6,6 +6,4 @@ interface I<T> {
}
//// [computedPropertyNames35.js]
function foo() {
return '';
}
function foo() { return ''; }
@@ -26,9 +26,7 @@ var C = (function () {
}
Object.defineProperty(C.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -26,9 +26,7 @@ var C = (function () {
}
Object.defineProperty(C.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -26,9 +26,7 @@ var C = (function () {
}
Object.defineProperty(C.prototype, 1 << 6, {
// Computed properties
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -26,9 +26,7 @@ var C = (function () {
}
Object.defineProperty(C.prototype, 1 << 6, {
// Computed properties
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -25,11 +25,7 @@ var C = (function () {
function C() {
}
// Computed properties
C.prototype[""] = function () {
return new Foo;
};
C.prototype[""] = function () {
return new Foo2;
};
C.prototype[""] = function () { return new Foo; };
C.prototype[""] = function () { return new Foo2; };
return C;
})();
@@ -24,8 +24,6 @@ var C = (function () {
function C() {
}
// Computed properties
C[""] = function () {
return new Foo;
};
C[""] = function () { return new Foo; };
return C;
})();
@@ -41,9 +41,7 @@ var D = (function (_super) {
}
Object.defineProperty(D.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -32,9 +32,7 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -33,9 +33,7 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
get: function () {
return new Foo;
},
get: function () { return new Foo; },
enumerable: true,
configurable: true
});
@@ -11,8 +11,6 @@ var o: I = {
//// [computedPropertyNamesContextualType1.js]
var o = {
["" + 0](y) {
return y.length;
},
["" + 0](y) { return y.length; },
["" + 1]: y => { return y.length; }
};

Some files were not shown because too many files have changed in this diff Show More