mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #1974 from Microsoft/multiLineEmitting
Preserve single line blocks when emitting.
This commit is contained in:
+75
-50
@@ -2713,7 +2713,21 @@ module ts {
|
||||
emit(node.whenFalse);
|
||||
}
|
||||
|
||||
function isSingleLineBlock(node: Node) {
|
||||
if (node && node.kind === SyntaxKind.Block) {
|
||||
var block = <Block>node;
|
||||
return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block);
|
||||
}
|
||||
}
|
||||
|
||||
function emitBlock(node: Block) {
|
||||
if (isSingleLineBlock(node)) {
|
||||
emitToken(SyntaxKind.OpenBraceToken, node.pos);
|
||||
write(" ");
|
||||
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
|
||||
return;
|
||||
}
|
||||
|
||||
emitToken(SyntaxKind.OpenBraceToken, node.pos);
|
||||
increaseIndent();
|
||||
scopeEmitStart(node.parent);
|
||||
@@ -2886,6 +2900,11 @@ module ts {
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
}
|
||||
|
||||
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, node1.end) ===
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
}
|
||||
|
||||
function emitCaseOrDefaultClause(node: CaseOrDefaultClause) {
|
||||
if (node.kind === SyntaxKind.CaseClause) {
|
||||
write("case ");
|
||||
@@ -3385,73 +3404,79 @@ module ts {
|
||||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
write(" {");
|
||||
scopeEmitStart(node);
|
||||
|
||||
if (!node.body) {
|
||||
writeLine();
|
||||
write("}");
|
||||
if (isSingleLineBlock(node.body)) {
|
||||
write(" { }");
|
||||
}
|
||||
else {
|
||||
increaseIndent();
|
||||
write(" {");
|
||||
scopeEmitStart(node);
|
||||
|
||||
emitDetachedComments(node.body.kind === SyntaxKind.Block ? (<Block>node.body).statements : node.body);
|
||||
|
||||
var startIndex = 0;
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
startIndex = emitDirectivePrologues((<Block>node.body).statements, /*startWithNewLine*/ true);
|
||||
}
|
||||
var outPos = writer.getTextPos();
|
||||
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitDefaultValueAssignments(node);
|
||||
emitRestParameter(node);
|
||||
if (node.body.kind !== SyntaxKind.Block && outPos === writer.getTextPos()) {
|
||||
decreaseIndent();
|
||||
write(" ");
|
||||
emitStart(node.body);
|
||||
write("return ");
|
||||
|
||||
// Don't emit comments on this body. We'll have already taken care of it above
|
||||
// when we called emitDetachedComments.
|
||||
emitNode(node.body, /*disableComments:*/ true);
|
||||
emitEnd(node.body);
|
||||
write(";");
|
||||
emitTempDeclarations(/*newLine*/ false);
|
||||
write(" ");
|
||||
emitStart(node.body);
|
||||
if (!node.body) {
|
||||
writeLine();
|
||||
write("}");
|
||||
emitEnd(node.body);
|
||||
}
|
||||
else {
|
||||
increaseIndent();
|
||||
|
||||
emitDetachedComments(node.body.kind === SyntaxKind.Block ? (<Block>node.body).statements : node.body);
|
||||
|
||||
var startIndex = 0;
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
emitLinesStartingAt((<Block>node.body).statements, startIndex);
|
||||
startIndex = emitDirectivePrologues((<Block>node.body).statements, /*startWithNewLine*/ true);
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
emitLeadingComments(node.body);
|
||||
var outPos = writer.getTextPos();
|
||||
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitDefaultValueAssignments(node);
|
||||
emitRestParameter(node);
|
||||
if (node.body.kind !== SyntaxKind.Block && outPos === writer.getTextPos()) {
|
||||
decreaseIndent();
|
||||
write(" ");
|
||||
emitStart(node.body);
|
||||
write("return ");
|
||||
emit(node.body, /*disableComments:*/ true);
|
||||
|
||||
// Don't emit comments on this body. We'll have already taken care of it above
|
||||
// when we called emitDetachedComments.
|
||||
emitNode(node.body, /*disableComments:*/ true);
|
||||
emitEnd(node.body);
|
||||
write(";");
|
||||
emitTrailingComments(node.body);
|
||||
}
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
writeLine();
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
emitLeadingCommentsOfPosition((<Block>node.body).statements.end);
|
||||
decreaseIndent();
|
||||
emitToken(SyntaxKind.CloseBraceToken, (<Block>node.body).statements.end);
|
||||
}
|
||||
else {
|
||||
decreaseIndent();
|
||||
emitTempDeclarations(/*newLine*/ false);
|
||||
write(" ");
|
||||
emitStart(node.body);
|
||||
write("}");
|
||||
emitEnd(node.body);
|
||||
}
|
||||
else {
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
emitLinesStartingAt((<Block>node.body).statements, startIndex);
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
emitLeadingComments(node.body);
|
||||
write("return ");
|
||||
emit(node.body, /*disableComments:*/ true);
|
||||
write(";");
|
||||
emitTrailingComments(node.body);
|
||||
}
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
writeLine();
|
||||
if (node.body.kind === SyntaxKind.Block) {
|
||||
emitLeadingCommentsOfPosition((<Block>node.body).statements.end);
|
||||
decreaseIndent();
|
||||
emitToken(SyntaxKind.CloseBraceToken, (<Block>node.body).statements.end);
|
||||
}
|
||||
else {
|
||||
decreaseIndent();
|
||||
emitStart(node.body);
|
||||
write("}");
|
||||
emitEnd(node.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scopeEmitEnd();
|
||||
}
|
||||
|
||||
scopeEmitEnd();
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
writeLine();
|
||||
emitStart(node);
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = (public x: string) => { };
|
||||
|
||||
//// [ArrowFunctionExpression1.js]
|
||||
var v = function (x) {
|
||||
};
|
||||
var v = function (x) { };
|
||||
|
||||
+1
-2
@@ -58,8 +58,7 @@ var clodule1 = (function () {
|
||||
})();
|
||||
var clodule1;
|
||||
(function (clodule1) {
|
||||
function f(x) {
|
||||
}
|
||||
function f(x) { }
|
||||
})(clodule1 || (clodule1 = {}));
|
||||
var clodule2 = (function () {
|
||||
function clodule2() {
|
||||
|
||||
+1
-2
@@ -19,8 +19,7 @@ module clodule {
|
||||
var clodule = (function () {
|
||||
function clodule() {
|
||||
}
|
||||
clodule.fn = function (id) {
|
||||
};
|
||||
clodule.fn = function (id) { };
|
||||
return clodule;
|
||||
})();
|
||||
var clodule;
|
||||
|
||||
+1
-2
@@ -19,8 +19,7 @@ module clodule {
|
||||
var clodule = (function () {
|
||||
function clodule() {
|
||||
}
|
||||
clodule.fn = function (id) {
|
||||
};
|
||||
clodule.fn = function (id) { };
|
||||
return clodule;
|
||||
})();
|
||||
var clodule;
|
||||
|
||||
@@ -8,7 +8,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -8,7 +8,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
};
|
||||
C.prototype.bar = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -8,7 +8,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[1] = function () {
|
||||
};
|
||||
C.prototype[1] = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -8,7 +8,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype["bar"] = function () {
|
||||
};
|
||||
C.prototype["bar"] = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = function * yield() { }
|
||||
|
||||
//// [FunctionDeclaration12_es6.js]
|
||||
var v = , yield = function () {
|
||||
};
|
||||
var v = , yield = function () { };
|
||||
|
||||
@@ -3,5 +3,4 @@ function foo();
|
||||
function bar() { }
|
||||
|
||||
//// [FunctionDeclaration4.js]
|
||||
function bar() {
|
||||
}
|
||||
function bar() { }
|
||||
|
||||
@@ -6,6 +6,5 @@
|
||||
|
||||
//// [FunctionDeclaration6.js]
|
||||
{
|
||||
function bar() {
|
||||
}
|
||||
function bar() { }
|
||||
}
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = function * () { }
|
||||
|
||||
//// [FunctionExpression1_es6.js]
|
||||
var v = function () {
|
||||
};
|
||||
var v = function () { };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = function * foo() { }
|
||||
|
||||
//// [FunctionExpression2_es6.js]
|
||||
var v = function foo() {
|
||||
};
|
||||
var v = function foo() { };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = { *foo() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments1_es6.js]
|
||||
var v = { foo: function () {
|
||||
} };
|
||||
var v = { foo: function () { } };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = { *() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments2_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
var v = { : function () { } };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = { *{ } }
|
||||
|
||||
//// [FunctionPropertyAssignments3_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
var v = { : function () { } };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = { *[foo()]() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments5_es6.js]
|
||||
var v = { [foo()]: function () {
|
||||
} };
|
||||
var v = { [foo()]: function () { } };
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
var v = { *<T>() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments6_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
var v = { : function () { } };
|
||||
|
||||
@@ -8,8 +8,7 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "Foo", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[foo] = function () {
|
||||
};
|
||||
C.prototype[foo] = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype. = function () {
|
||||
};
|
||||
C.prototype. = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
};
|
||||
C.prototype.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.m = function () {
|
||||
};
|
||||
C.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.m = function () {
|
||||
};
|
||||
C.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -7,7 +7,6 @@ class C {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
};
|
||||
C.prototype.m = function () { };
|
||||
return C;
|
||||
})();
|
||||
|
||||
@@ -50,8 +50,7 @@ class E {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.privateMethod = function () {
|
||||
};
|
||||
C.privateMethod = function () { };
|
||||
Object.defineProperty(C, "privateGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -60,13 +59,11 @@ var C = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "privateSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C.protectedMethod = function () {
|
||||
};
|
||||
C.protectedMethod = function () { };
|
||||
Object.defineProperty(C, "protectedGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -75,13 +72,11 @@ var C = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "protectedSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C.publicMethod = function () {
|
||||
};
|
||||
C.publicMethod = function () { };
|
||||
Object.defineProperty(C, "publicGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -90,8 +85,7 @@ var C = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "publicSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -101,8 +95,7 @@ var C = (function () {
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
D.privateMethod = function () {
|
||||
};
|
||||
D.privateMethod = function () { };
|
||||
Object.defineProperty(D, "privateGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -111,13 +104,11 @@ var D = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(D, "privateSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
D.protectedMethod = function () {
|
||||
};
|
||||
D.protectedMethod = function () { };
|
||||
Object.defineProperty(D, "protectedGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -126,13 +117,11 @@ var D = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(D, "protectedSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
D.publicMethod = function () {
|
||||
};
|
||||
D.publicMethod = function () { };
|
||||
Object.defineProperty(D, "publicGetter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -141,8 +130,7 @@ var D = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(D, "publicSetter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -152,8 +140,7 @@ var D = (function () {
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
E.prototype.method = function () {
|
||||
};
|
||||
E.prototype.method = function () { };
|
||||
Object.defineProperty(E.prototype, "getter", {
|
||||
get: function () {
|
||||
return 0;
|
||||
@@ -162,8 +149,7 @@ var E = (function () {
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(E.prototype, "setter", {
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -10,14 +10,12 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "X", {
|
||||
set: function (v) {
|
||||
},
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "X", {
|
||||
set: function (v2) {
|
||||
},
|
||||
set: function (v2) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -52,6 +52,5 @@ var x = {
|
||||
}
|
||||
};
|
||||
var y = {
|
||||
set b(v) {
|
||||
}
|
||||
set b(v) { }
|
||||
};
|
||||
|
||||
@@ -49,6 +49,5 @@ var x = {
|
||||
}
|
||||
};
|
||||
var y = {
|
||||
set b(v) {
|
||||
}
|
||||
set b(v) { }
|
||||
};
|
||||
|
||||
@@ -10,16 +10,12 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "X", {
|
||||
set: function (v) {
|
||||
if (v === void 0) { v = 0; }
|
||||
},
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "X", {
|
||||
set: function (v2) {
|
||||
if (v2 === void 0) { v2 = 0; }
|
||||
},
|
||||
set: function (v2) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -10,22 +10,12 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "X", {
|
||||
set: function () {
|
||||
var v = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v[_i - 0] = arguments[_i];
|
||||
}
|
||||
},
|
||||
set: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C, "X", {
|
||||
set: function () {
|
||||
var v2 = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
v2[_i - 0] = arguments[_i];
|
||||
}
|
||||
},
|
||||
set: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -21,8 +21,7 @@ var LanguageSpec_section_4_5_error_cases = (function () {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -30,8 +29,7 @@ var LanguageSpec_section_4_5_error_cases = (function () {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -50,8 +50,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -59,8 +58,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -68,8 +66,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -77,8 +74,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -86,8 +82,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -95,8 +90,7 @@ var LanguageSpec_section_4_5_inference = (function () {
|
||||
get: function () {
|
||||
return new B();
|
||||
},
|
||||
set: function (a) {
|
||||
},
|
||||
set: function (a) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
@@ -40,13 +40,11 @@ var r19 = a + { a: '' };
|
||||
var r20 = a + ((a: string) => { return a });
|
||||
|
||||
//// [additionOperatorWithAnyAndEveryType.js]
|
||||
function foo() {
|
||||
}
|
||||
function foo() { }
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.foo = function () {
|
||||
};
|
||||
C.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
var E;
|
||||
|
||||
@@ -41,13 +41,11 @@ var r19 = E.a + C.foo();
|
||||
var r20 = E.a + M;
|
||||
|
||||
//// [additionOperatorWithInvalidOperands.js]
|
||||
function foo() {
|
||||
}
|
||||
function foo() { }
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.foo = function () {
|
||||
};
|
||||
C.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
var E;
|
||||
|
||||
@@ -44,5 +44,4 @@ var r7 = null + d;
|
||||
var r8 = null + true;
|
||||
var r9 = null + { a: '' };
|
||||
var r10 = null + foo();
|
||||
var r11 = null + (function () {
|
||||
});
|
||||
var r11 = null + (function () { });
|
||||
|
||||
@@ -74,7 +74,6 @@ function foo(t, u) {
|
||||
var r16 = t + undefined;
|
||||
var r17 = t + t;
|
||||
var r18 = t + u;
|
||||
var r19 = t + (function () {
|
||||
});
|
||||
var r19 = t + (function () { });
|
||||
var r20 = t + [];
|
||||
}
|
||||
|
||||
@@ -44,5 +44,4 @@ var r7 = undefined + d;
|
||||
var r8 = undefined + true;
|
||||
var r9 = undefined + { a: '' };
|
||||
var r10 = undefined + foo();
|
||||
var r11 = undefined + (function () {
|
||||
});
|
||||
var r11 = undefined + (function () { });
|
||||
|
||||
@@ -118,8 +118,7 @@ var E;
|
||||
E[E["A"] = 0] = "A";
|
||||
})(E || (E = {}));
|
||||
var r3 = foo3(a); // any
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
var f;
|
||||
(function (f) {
|
||||
f.bar = 1;
|
||||
|
||||
@@ -146,8 +146,7 @@ var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
})(E || (E = {}));
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
var f;
|
||||
(function (f) {
|
||||
f.bar = 1;
|
||||
|
||||
@@ -10,6 +10,5 @@ module myMod {
|
||||
var myMod;
|
||||
(function (myMod) {
|
||||
var myFn;
|
||||
function myFn() {
|
||||
}
|
||||
function myFn() { }
|
||||
})(myMod || (myMod = {}));
|
||||
|
||||
@@ -13,8 +13,7 @@ class C {
|
||||
}
|
||||
|
||||
//// [anyIdenticalToItself.js]
|
||||
function foo(x, y) {
|
||||
}
|
||||
function foo(x, y) { }
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
|
||||
@@ -44,10 +44,8 @@ var Elephant = (function () {
|
||||
}
|
||||
return Elephant;
|
||||
})();
|
||||
function foo(animals) {
|
||||
}
|
||||
function bar(animals) {
|
||||
}
|
||||
function foo(animals) { }
|
||||
function bar(animals) { }
|
||||
foo([
|
||||
new Giraffe(),
|
||||
new Elephant()
|
||||
|
||||
@@ -5,10 +5,5 @@ panic([], 'one', 'two');
|
||||
|
||||
|
||||
//// [arrayLiteralInNonVarArgParameter.js]
|
||||
function panic(val) {
|
||||
var opt = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
opt[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function panic(val) { }
|
||||
panic([], 'one', 'two');
|
||||
|
||||
@@ -28,8 +28,7 @@ var r7 = r6(''); // any not string
|
||||
|
||||
//// [arrayOfFunctionTypes3.js]
|
||||
// valid uses of arrays of function types
|
||||
var x = [function () { return 1; }, function () {
|
||||
}];
|
||||
var x = [function () { return 1; }, function () { }];
|
||||
var r2 = x[0]();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
|
||||
@@ -7,7 +7,6 @@ class X {
|
||||
var X = (function () {
|
||||
function X() {
|
||||
}
|
||||
X.prototype.f = function (a) {
|
||||
};
|
||||
X.prototype.f = function (a) { };
|
||||
return X;
|
||||
})();
|
||||
|
||||
@@ -138,8 +138,7 @@ function someOtherFn() {
|
||||
// Arrow function used in nested function in function
|
||||
function outerFn() {
|
||||
function innerFn() {
|
||||
var arrowFn = function () {
|
||||
};
|
||||
var arrowFn = function () { };
|
||||
var p = arrowFn();
|
||||
var p;
|
||||
}
|
||||
|
||||
@@ -69,16 +69,11 @@ module okay {
|
||||
//// [arrowFunctionsMissingTokens.js]
|
||||
var missingArrowsWithCurly;
|
||||
(function (missingArrowsWithCurly) {
|
||||
var a = function () {
|
||||
};
|
||||
var b = function () {
|
||||
};
|
||||
var c = function (x) {
|
||||
};
|
||||
var d = function (x, y) {
|
||||
};
|
||||
var e = function (x, y) {
|
||||
};
|
||||
var a = function () { };
|
||||
var b = function () { };
|
||||
var c = function (x) { };
|
||||
var d = function (x, y) { };
|
||||
var e = function (x, y) { };
|
||||
})(missingArrowsWithCurly || (missingArrowsWithCurly = {}));
|
||||
var missingCurliesWithArrow;
|
||||
(function (missingCurliesWithArrow) {
|
||||
@@ -127,14 +122,9 @@ var ce_nEst_pas_une_arrow_function;
|
||||
})(ce_nEst_pas_une_arrow_function || (ce_nEst_pas_une_arrow_function = {}));
|
||||
var okay;
|
||||
(function (okay) {
|
||||
var a = function () {
|
||||
};
|
||||
var b = function () {
|
||||
};
|
||||
var c = function (x) {
|
||||
};
|
||||
var d = function (x, y) {
|
||||
};
|
||||
var e = function (x, y) {
|
||||
};
|
||||
var a = function () { };
|
||||
var b = function () { };
|
||||
var c = function (x) { };
|
||||
var d = function (x, y) { };
|
||||
var e = function (x, y) { };
|
||||
})(okay || (okay = {}));
|
||||
|
||||
@@ -10,8 +10,7 @@ fn(function (a, b) { return true; })
|
||||
|
||||
|
||||
//// [assignLambdaToNominalSubtypeOfFunction.js]
|
||||
function fn(cb) {
|
||||
}
|
||||
function fn(cb) { }
|
||||
fn(function (a, b) { return true; });
|
||||
fn(function (a, b) {
|
||||
return true;
|
||||
|
||||
@@ -53,8 +53,7 @@ var C = (function () {
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
function foo(test) {
|
||||
}
|
||||
function foo(test) { }
|
||||
var x;
|
||||
var y;
|
||||
foo(x);
|
||||
|
||||
@@ -12,17 +12,13 @@ foo3((n) => { return; });
|
||||
|
||||
|
||||
//// [assignmentCompatBug5.js]
|
||||
function foo1(x) {
|
||||
}
|
||||
function foo1(x) { }
|
||||
foo1({ b: 5 });
|
||||
function foo2(x) {
|
||||
}
|
||||
function foo2(x) { }
|
||||
foo2(["s", "t"]);
|
||||
function foo3(x) {
|
||||
}
|
||||
function foo3(x) { }
|
||||
;
|
||||
foo3(function (s) {
|
||||
});
|
||||
foo3(function (s) { });
|
||||
foo3(function (n) {
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -20,10 +20,8 @@ Biz(new Foo());
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
Foo.prototype.Boz = function () {
|
||||
};
|
||||
Foo.prototype.Boz = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
function Biz(map) {
|
||||
}
|
||||
function Biz(map) { }
|
||||
Biz(new Foo());
|
||||
|
||||
@@ -13,6 +13,5 @@ var Foo = (function () {
|
||||
return Foo;
|
||||
})();
|
||||
;
|
||||
function bar(x) {
|
||||
}
|
||||
function bar(x) { }
|
||||
bar(Foo); // Error, but should be allowed
|
||||
|
||||
+3
-6
@@ -39,17 +39,14 @@ x = [''];
|
||||
x = 4;
|
||||
x = {};
|
||||
// Should work
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
;
|
||||
x = f;
|
||||
function fn(c) {
|
||||
}
|
||||
function fn(c) { }
|
||||
// Should Fail
|
||||
fn('');
|
||||
fn(['']);
|
||||
fn(4);
|
||||
fn({});
|
||||
// Should work
|
||||
fn(function (a) {
|
||||
});
|
||||
fn(function (a) { });
|
||||
|
||||
+3
-6
@@ -39,17 +39,14 @@ x = [''];
|
||||
x = 4;
|
||||
x = {};
|
||||
// Should work
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
;
|
||||
x = f;
|
||||
function fn(c) {
|
||||
}
|
||||
function fn(c) { }
|
||||
// Should Fail
|
||||
fn('');
|
||||
fn(['']);
|
||||
fn(4);
|
||||
fn({});
|
||||
// Should work
|
||||
fn(function (a) {
|
||||
});
|
||||
fn(function (a) { });
|
||||
|
||||
@@ -138,11 +138,9 @@ var Derived = (function (_super) {
|
||||
return Derived;
|
||||
})(C);
|
||||
// function expression
|
||||
function bar() {
|
||||
}
|
||||
function bar() { }
|
||||
value;
|
||||
(function () {
|
||||
});
|
||||
(function () { });
|
||||
value;
|
||||
// function calls
|
||||
foo() = value;
|
||||
@@ -159,6 +157,5 @@ foo() = value;
|
||||
(/d+/) = value;
|
||||
({}) = value;
|
||||
([]) = value;
|
||||
(function baz() {
|
||||
}) = value;
|
||||
(function baz() { }) = value;
|
||||
(foo()) = value;
|
||||
|
||||
@@ -13,7 +13,6 @@ g(1, "")
|
||||
var f = function (x, y) {
|
||||
x = y;
|
||||
};
|
||||
var g = function (x, y) {
|
||||
};
|
||||
var g = function (x, y) { };
|
||||
g = f;
|
||||
g(1, "");
|
||||
|
||||
@@ -11,8 +11,7 @@ module foo {
|
||||
}
|
||||
|
||||
//// [assignmentToFunction.js]
|
||||
function fn() {
|
||||
}
|
||||
function fn() { }
|
||||
fn = function () { return 3; };
|
||||
var foo;
|
||||
(function (foo) {
|
||||
|
||||
@@ -37,24 +37,20 @@ var goodObj = {
|
||||
}
|
||||
}; // Ok, because toString is a subtype of Object's toString
|
||||
var errFun = {}; // Error for no call signature
|
||||
function foo() {
|
||||
}
|
||||
function foo() { }
|
||||
var foo;
|
||||
(function (foo) {
|
||||
foo.boom = 0;
|
||||
})(foo || (foo = {}));
|
||||
var goodFundule = foo; // ok
|
||||
function bar() {
|
||||
}
|
||||
function bar() { }
|
||||
var bar;
|
||||
(function (bar) {
|
||||
function apply(thisArg, argArray) {
|
||||
}
|
||||
function apply(thisArg, argArray) { }
|
||||
bar.apply = apply;
|
||||
})(bar || (bar = {}));
|
||||
var goodFundule2 = bar; // ok
|
||||
function bad() {
|
||||
}
|
||||
function bad() { }
|
||||
var bad;
|
||||
(function (bad) {
|
||||
bad.apply = 0;
|
||||
|
||||
@@ -103,8 +103,7 @@ M2.M3 = { x: 3 }; // OK
|
||||
M2.M3 = { x: '' }; // Error
|
||||
(M2).M3 = { x: '' }; // Error
|
||||
(M2.M3) = { x: '' }; // Error
|
||||
function fn() {
|
||||
}
|
||||
function fn() { }
|
||||
fn = function () { return 3; }; // Bug 823548: Should be error (fn is not a reference)
|
||||
(fn) = function () { return 3; }; // Should be error
|
||||
function fn2(x, y) {
|
||||
|
||||
@@ -36,8 +36,7 @@ var E;
|
||||
(function (E) {
|
||||
})(E || (E = {}));
|
||||
E = null;
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
f = null;
|
||||
var x = 1;
|
||||
x = null;
|
||||
|
||||
@@ -53,8 +53,7 @@ var E;
|
||||
})(E || (E = {}));
|
||||
E = null; // Error
|
||||
0 /* A */ = null; // OK per spec, Error per implementation (509581)
|
||||
function fn() {
|
||||
}
|
||||
function fn() { }
|
||||
fn = null; // Should be error
|
||||
var v;
|
||||
v = null; // OK
|
||||
|
||||
@@ -23,7 +23,6 @@ var v2: {
|
||||
|
||||
//// [augmentedTypeAssignmentCompatIndexSignature.js]
|
||||
var o = {};
|
||||
var f = function () {
|
||||
};
|
||||
var f = function () { };
|
||||
var v1 = o; // Should be allowed
|
||||
var v2 = f; // Should be allowed
|
||||
|
||||
@@ -15,5 +15,4 @@ var b = (() => { })[0]; // Should be Bar
|
||||
|
||||
//// [augmentedTypeBracketAccessIndexSignature.js]
|
||||
var a = {}[0]; // Should be Foo
|
||||
var b = (function () {
|
||||
})[0]; // Should be Bar
|
||||
var b = (function () { })[0]; // Should be Bar
|
||||
|
||||
@@ -15,8 +15,7 @@ var r4 = f['data']; // Should be number
|
||||
|
||||
//// [augmentedTypeBracketNamedPropertyAccess.js]
|
||||
var o = {};
|
||||
var f = function () {
|
||||
};
|
||||
var f = function () { };
|
||||
var r1 = o['data']; // Should be number
|
||||
var r2 = o['functionData']; // Should be any (no property found)
|
||||
var r3 = f['functionData']; // Should be string
|
||||
|
||||
@@ -12,8 +12,7 @@ enum c4 { One } // error
|
||||
var c1 = (function () {
|
||||
function c1() {
|
||||
}
|
||||
c1.prototype.foo = function () {
|
||||
};
|
||||
c1.prototype.foo = function () { };
|
||||
return c1;
|
||||
})();
|
||||
var c1 = 1; // error
|
||||
@@ -21,8 +20,7 @@ var c1 = 1; // error
|
||||
var c4 = (function () {
|
||||
function c4() {
|
||||
}
|
||||
c4.prototype.foo = function () {
|
||||
};
|
||||
c4.prototype.foo = function () { };
|
||||
return c4;
|
||||
})();
|
||||
var c4;
|
||||
|
||||
@@ -9,11 +9,8 @@ var c2 = () => { }
|
||||
var c2 = (function () {
|
||||
function c2() {
|
||||
}
|
||||
c2.prototype.foo = function () {
|
||||
};
|
||||
c2.prototype.foo = function () { };
|
||||
return c2;
|
||||
})(); // error
|
||||
function c2() {
|
||||
} // error
|
||||
var c2 = function () {
|
||||
};
|
||||
function c2() { } // error
|
||||
var c2 = function () { };
|
||||
|
||||
@@ -18,15 +18,13 @@ class c5c { public foo() { } }
|
||||
var c5 = (function () {
|
||||
function c5() {
|
||||
}
|
||||
c5.prototype.foo = function () {
|
||||
};
|
||||
c5.prototype.foo = function () { };
|
||||
return c5;
|
||||
})();
|
||||
var c5a = (function () {
|
||||
function c5a() {
|
||||
}
|
||||
c5a.prototype.foo = function () {
|
||||
};
|
||||
c5a.prototype.foo = function () { };
|
||||
return c5a;
|
||||
})();
|
||||
var c5a;
|
||||
@@ -36,8 +34,7 @@ var c5a;
|
||||
var c5b = (function () {
|
||||
function c5b() {
|
||||
}
|
||||
c5b.prototype.foo = function () {
|
||||
};
|
||||
c5b.prototype.foo = function () { };
|
||||
return c5b;
|
||||
})();
|
||||
var c5b;
|
||||
@@ -48,8 +45,7 @@ var c5b;
|
||||
var c5c = (function () {
|
||||
function c5c() {
|
||||
}
|
||||
c5c.prototype.foo = function () {
|
||||
};
|
||||
c5c.prototype.foo = function () { };
|
||||
return c5c;
|
||||
})();
|
||||
//import c5c = require('');
|
||||
|
||||
@@ -9,14 +9,12 @@ class c3 { public bar() { } } // error
|
||||
var c3 = (function () {
|
||||
function c3() {
|
||||
}
|
||||
c3.prototype.foo = function () {
|
||||
};
|
||||
c3.prototype.foo = function () { };
|
||||
return c3;
|
||||
})(); // error
|
||||
var c3 = (function () {
|
||||
function c3() {
|
||||
}
|
||||
c3.prototype.bar = function () {
|
||||
};
|
||||
c3.prototype.bar = function () { };
|
||||
return c3;
|
||||
})(); // error
|
||||
|
||||
@@ -47,14 +47,12 @@ var e2;
|
||||
(function (e2) {
|
||||
e2[e2["One"] = 0] = "One";
|
||||
})(e2 || (e2 = {})); // error
|
||||
function e2() {
|
||||
} // error
|
||||
function e2() { } // error
|
||||
var e3;
|
||||
(function (e3) {
|
||||
e3[e3["One"] = 0] = "One";
|
||||
})(e3 || (e3 = {})); // error
|
||||
var e3 = function () {
|
||||
}; // error
|
||||
var e3 = function () { }; // error
|
||||
// enum then class
|
||||
var e4;
|
||||
(function (e4) {
|
||||
@@ -63,8 +61,7 @@ var e4;
|
||||
var e4 = (function () {
|
||||
function e4() {
|
||||
}
|
||||
e4.prototype.foo = function () {
|
||||
};
|
||||
e4.prototype.foo = function () { };
|
||||
return e4;
|
||||
})(); // error
|
||||
// enum then enum
|
||||
|
||||
@@ -9,8 +9,7 @@ define(["require", "exports"], function (require, exports) {
|
||||
var c5 = (function () {
|
||||
function c5() {
|
||||
}
|
||||
c5.prototype.foo = function () {
|
||||
};
|
||||
c5.prototype.foo = function () { };
|
||||
return c5;
|
||||
})();
|
||||
});
|
||||
|
||||
@@ -40,59 +40,46 @@ module y5c { export interface I { foo(): void } } // should be an error
|
||||
|
||||
//// [augmentedTypesFunction.js]
|
||||
// function then var
|
||||
function y1() {
|
||||
} // error
|
||||
function y1() { } // error
|
||||
var y1 = 1; // error
|
||||
// function then function
|
||||
function y2() {
|
||||
} // error
|
||||
function y2() {
|
||||
} // error
|
||||
function y2a() {
|
||||
} // error
|
||||
var y2a = function () {
|
||||
}; // error
|
||||
function y2() { } // error
|
||||
function y2() { } // error
|
||||
function y2a() { } // error
|
||||
var y2a = function () { }; // error
|
||||
// function then class
|
||||
function y3() {
|
||||
} // error
|
||||
function y3() { } // error
|
||||
var y3 = (function () {
|
||||
function y3() {
|
||||
}
|
||||
return y3;
|
||||
})(); // error
|
||||
function y3a() {
|
||||
} // error
|
||||
function y3a() { } // error
|
||||
var y3a = (function () {
|
||||
function y3a() {
|
||||
}
|
||||
y3a.prototype.foo = function () {
|
||||
};
|
||||
y3a.prototype.foo = function () { };
|
||||
return y3a;
|
||||
})(); // error
|
||||
// function then enum
|
||||
function y4() {
|
||||
} // error
|
||||
function y4() { } // error
|
||||
var y4;
|
||||
(function (y4) {
|
||||
y4[y4["One"] = 0] = "One";
|
||||
})(y4 || (y4 = {})); // error
|
||||
// function then internal module
|
||||
function y5() {
|
||||
}
|
||||
function y5a() {
|
||||
}
|
||||
function y5() { }
|
||||
function y5a() { }
|
||||
var y5a;
|
||||
(function (y5a) {
|
||||
var y = 2;
|
||||
})(y5a || (y5a = {})); // should be an error
|
||||
function y5b() {
|
||||
}
|
||||
function y5b() { }
|
||||
var y5b;
|
||||
(function (y5b) {
|
||||
y5b.y = 3;
|
||||
})(y5b || (y5b = {})); // should be an error
|
||||
function y5c() {
|
||||
}
|
||||
function y5c() { }
|
||||
// function then import, messes with other errors
|
||||
//function y6() { }
|
||||
//import y6 = require('');
|
||||
|
||||
@@ -115,51 +115,43 @@ var m1d;
|
||||
var I = (function () {
|
||||
function I() {
|
||||
}
|
||||
I.prototype.foo = function () {
|
||||
};
|
||||
I.prototype.foo = function () { };
|
||||
return I;
|
||||
})();
|
||||
m1d.I = I;
|
||||
})(m1d || (m1d = {}));
|
||||
var m1d = 1; // error
|
||||
function m2() {
|
||||
}
|
||||
function m2() { }
|
||||
; // ok since the module is not instantiated
|
||||
var m2a;
|
||||
(function (m2a) {
|
||||
var y = 2;
|
||||
})(m2a || (m2a = {}));
|
||||
function m2a() {
|
||||
}
|
||||
function m2a() { }
|
||||
; // error since the module is instantiated
|
||||
var m2b;
|
||||
(function (m2b) {
|
||||
m2b.y = 2;
|
||||
})(m2b || (m2b = {}));
|
||||
function m2b() {
|
||||
}
|
||||
function m2b() { }
|
||||
; // error since the module is instantiated
|
||||
// should be errors to have function first
|
||||
function m2c() {
|
||||
}
|
||||
function m2c() { }
|
||||
;
|
||||
var m2c;
|
||||
(function (m2c) {
|
||||
m2c.y = 2;
|
||||
})(m2c || (m2c = {}));
|
||||
function m2f() {
|
||||
}
|
||||
function m2f() { }
|
||||
;
|
||||
function m2g() {
|
||||
}
|
||||
function m2g() { }
|
||||
;
|
||||
var m2g;
|
||||
(function (m2g) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
m2g.C = C;
|
||||
@@ -176,15 +168,13 @@ var m3a;
|
||||
var m3a = (function () {
|
||||
function m3a() {
|
||||
}
|
||||
m3a.prototype.foo = function () {
|
||||
};
|
||||
m3a.prototype.foo = function () { };
|
||||
return m3a;
|
||||
})(); // error, class isn't ambient or declared before the module
|
||||
var m3b = (function () {
|
||||
function m3b() {
|
||||
}
|
||||
m3b.prototype.foo = function () {
|
||||
};
|
||||
m3b.prototype.foo = function () { };
|
||||
return m3b;
|
||||
})();
|
||||
var m3b;
|
||||
@@ -194,8 +184,7 @@ var m3b;
|
||||
var m3c = (function () {
|
||||
function m3c() {
|
||||
}
|
||||
m3c.prototype.foo = function () {
|
||||
};
|
||||
m3c.prototype.foo = function () { };
|
||||
return m3c;
|
||||
})();
|
||||
var m3c;
|
||||
@@ -215,8 +204,7 @@ var m3g;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
m3g.C = C;
|
||||
@@ -249,8 +237,7 @@ var m4d;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
})(m4d || (m4d = {}));
|
||||
|
||||
@@ -29,25 +29,21 @@ module m2g { export class C { foo() { } } }
|
||||
|
||||
|
||||
//// [augmentedTypesModules2.js]
|
||||
function m2() {
|
||||
}
|
||||
function m2() { }
|
||||
; // ok since the module is not instantiated
|
||||
var m2a;
|
||||
(function (m2a) {
|
||||
var y = 2;
|
||||
})(m2a || (m2a = {}));
|
||||
function m2a() {
|
||||
}
|
||||
function m2a() { }
|
||||
; // error since the module is instantiated
|
||||
var m2b;
|
||||
(function (m2b) {
|
||||
m2b.y = 2;
|
||||
})(m2b || (m2b = {}));
|
||||
function m2b() {
|
||||
}
|
||||
function m2b() { }
|
||||
; // error since the module is instantiated
|
||||
function m2c() {
|
||||
}
|
||||
function m2c() { }
|
||||
;
|
||||
var m2c;
|
||||
(function (m2c) {
|
||||
@@ -57,22 +53,18 @@ var m2cc;
|
||||
(function (m2cc) {
|
||||
m2cc.y = 2;
|
||||
})(m2cc || (m2cc = {}));
|
||||
function m2cc() {
|
||||
}
|
||||
function m2cc() { }
|
||||
; // error to have module first
|
||||
function m2f() {
|
||||
}
|
||||
function m2f() { }
|
||||
;
|
||||
function m2g() {
|
||||
}
|
||||
function m2g() { }
|
||||
;
|
||||
var m2g;
|
||||
(function (m2g) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
m2g.C = C;
|
||||
|
||||
@@ -19,7 +19,6 @@ var m3a;
|
||||
var m3a = (function () {
|
||||
function m3a() {
|
||||
}
|
||||
m3a.prototype.foo = function () {
|
||||
};
|
||||
m3a.prototype.foo = function () { };
|
||||
return m3a;
|
||||
})(); // error, class isn't ambient or declared before the module
|
||||
|
||||
@@ -22,8 +22,7 @@ module m3g { export class C { foo() { } } }
|
||||
var m3b = (function () {
|
||||
function m3b() {
|
||||
}
|
||||
m3b.prototype.foo = function () {
|
||||
};
|
||||
m3b.prototype.foo = function () { };
|
||||
return m3b;
|
||||
})();
|
||||
var m3b;
|
||||
@@ -33,8 +32,7 @@ var m3b;
|
||||
var m3c = (function () {
|
||||
function m3c() {
|
||||
}
|
||||
m3c.prototype.foo = function () {
|
||||
};
|
||||
m3c.prototype.foo = function () { };
|
||||
return m3c;
|
||||
})();
|
||||
var m3c;
|
||||
@@ -54,8 +52,7 @@ var m3g;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
m3g.C = C;
|
||||
|
||||
@@ -51,8 +51,7 @@ var m4d;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
C.prototype.foo = function () { };
|
||||
return C;
|
||||
})();
|
||||
})(m4d || (m4d = {}));
|
||||
|
||||
@@ -42,11 +42,9 @@ var x1 = 1;
|
||||
var x1 = 2;
|
||||
// var then function
|
||||
var x2 = 1; // error
|
||||
function x2() {
|
||||
} // error
|
||||
function x2() { } // error
|
||||
var x3 = 1;
|
||||
var x3 = function () {
|
||||
}; // error
|
||||
var x3 = function () { }; // error
|
||||
// var then class
|
||||
var x4 = 1; // error
|
||||
var x4 = (function () {
|
||||
@@ -58,8 +56,7 @@ var x4a = 1; // error
|
||||
var x4a = (function () {
|
||||
function x4a() {
|
||||
}
|
||||
x4a.prototype.foo = function () {
|
||||
};
|
||||
x4a.prototype.foo = function () { };
|
||||
return x4a;
|
||||
})(); // error
|
||||
// var then enum
|
||||
|
||||
@@ -33,8 +33,7 @@ b.foo();
|
||||
//// [autolift3.js]
|
||||
var B = (function () {
|
||||
function B() {
|
||||
function foo() {
|
||||
}
|
||||
function foo() { }
|
||||
foo();
|
||||
var a = 0;
|
||||
var inner = (function () {
|
||||
|
||||
@@ -20,11 +20,6 @@ interface Base2 {
|
||||
var Derived2 = (function () {
|
||||
function Derived2() {
|
||||
}
|
||||
Derived2.prototype.method = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
Derived2.prototype.method = function () { };
|
||||
return Derived2;
|
||||
})();
|
||||
|
||||
@@ -63,15 +63,9 @@ var r = true ? 1 : 2;
|
||||
var r3 = true ? 1 : {};
|
||||
var r4 = true ? a : b; // typeof a
|
||||
var r5 = true ? b : a; // typeof b
|
||||
var r6 = true ? function (x) {
|
||||
} : function (x) {
|
||||
}; // returns number => void
|
||||
var r7 = true ? function (x) {
|
||||
} : function (x) {
|
||||
};
|
||||
var r8 = true ? function (x) {
|
||||
} : function (x) {
|
||||
}; // returns Object => void
|
||||
var r6 = true ? function (x) { } : function (x) { }; // returns number => void
|
||||
var r7 = true ? function (x) { } : function (x) { };
|
||||
var r8 = true ? function (x) { } : function (x) { }; // returns Object => void
|
||||
var r10 = true ? derived : derived2; // no error since we use the contextual type in BCT
|
||||
var r11 = true ? base : derived2;
|
||||
function foo5(t, u) {
|
||||
|
||||
@@ -68,8 +68,7 @@ var ANY;
|
||||
var ANY1;
|
||||
var ANY2 = ["", ""];
|
||||
var obj;
|
||||
var obj1 = { x: "", y: function () {
|
||||
} };
|
||||
var obj1 = { x: "", y: function () { } };
|
||||
function foo() {
|
||||
var a;
|
||||
return a;
|
||||
|
||||
@@ -22,8 +22,7 @@ var Foo = (function () {
|
||||
function Foo(x) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
}
|
||||
Foo.prototype.bar1 = function () {
|
||||
};
|
||||
Foo.prototype.bar1 = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
function F1(a) {
|
||||
|
||||
@@ -30,8 +30,7 @@ var Foo = (function () {
|
||||
function Foo(x) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
}
|
||||
Foo.prototype.bar1 = function () {
|
||||
};
|
||||
Foo.prototype.bar1 = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
function F1(s) {
|
||||
|
||||
@@ -23,8 +23,7 @@ var Foo = (function () {
|
||||
function Foo(x) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
}
|
||||
Foo.prototype.bar1 = function () {
|
||||
};
|
||||
Foo.prototype.bar1 = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
//class Foo(s: String);
|
||||
|
||||
@@ -23,8 +23,7 @@ var Foo = (function () {
|
||||
function Foo(x) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
}
|
||||
Foo.prototype.bar1 = function () {
|
||||
};
|
||||
Foo.prototype.bar1 = function () { };
|
||||
return Foo;
|
||||
})();
|
||||
var f1 = new Foo("hey");
|
||||
|
||||
@@ -24,8 +24,7 @@ var Foo = (function () {
|
||||
function Foo(x) {
|
||||
// WScript.Echo("Constructor function has executed");
|
||||
}
|
||||
Foo.prototype.bar1 = function (a) {
|
||||
};
|
||||
Foo.prototype.bar1 = function (a) { };
|
||||
return Foo;
|
||||
})();
|
||||
//class Foo(s: String);
|
||||
|
||||
@@ -57,15 +57,9 @@ b.b(1);
|
||||
|
||||
//// [callSignatureWithOptionalParameterAndInitializer.js]
|
||||
// Optional parameters cannot also have initializer expressions, these are all errors
|
||||
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; }
|
||||
};
|
||||
function foo(x) { }
|
||||
var f = function foo(x) { };
|
||||
var f2 = function (x, y) { };
|
||||
foo(1);
|
||||
foo();
|
||||
f(1);
|
||||
@@ -75,9 +69,7 @@ f2(1, 2);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
};
|
||||
C.prototype.foo = function (x) { };
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
@@ -94,15 +86,9 @@ a(1);
|
||||
a.foo();
|
||||
a.foo(1);
|
||||
var b = {
|
||||
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 = ''; }
|
||||
}
|
||||
foo: function (x) { },
|
||||
a: function foo(x, y) { },
|
||||
b: function (x) { }
|
||||
};
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
|
||||
@@ -21,8 +21,7 @@ var r5 = a.f();
|
||||
|
||||
//// [callSignatureWithoutAnnotationsOrBody.js]
|
||||
// Call signatures without a return type annotation and function body return 'any'
|
||||
function foo(x) {
|
||||
}
|
||||
function foo(x) { }
|
||||
var r = foo(1); // void since there's a body
|
||||
var i;
|
||||
var r2 = i();
|
||||
|
||||
@@ -40,43 +40,27 @@ var b = {
|
||||
|
||||
//// [callSignaturesWithAccessibilityModifiersOnParameters.js]
|
||||
// Call signature parameters do not allow accessibility modifiers
|
||||
function foo(x, y) {
|
||||
}
|
||||
var f = function foo(x, y) {
|
||||
};
|
||||
var f2 = function (x, y) {
|
||||
};
|
||||
var f3 = function (x, y) {
|
||||
};
|
||||
var f4 = function (x, y) {
|
||||
};
|
||||
function foo2(x, y) {
|
||||
}
|
||||
var f5 = function foo(x, y) {
|
||||
};
|
||||
var f6 = function (x, y) {
|
||||
};
|
||||
var f7 = function (x, y) {
|
||||
};
|
||||
var f8 = function (x, y) {
|
||||
};
|
||||
function foo(x, y) { }
|
||||
var f = function foo(x, y) { };
|
||||
var f2 = function (x, y) { };
|
||||
var f3 = function (x, y) { };
|
||||
var f4 = function (x, y) { };
|
||||
function foo2(x, y) { }
|
||||
var f5 = function foo(x, y) { };
|
||||
var f6 = function (x, y) { };
|
||||
var f7 = function (x, y) { };
|
||||
var f8 = function (x, y) { };
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x, y) {
|
||||
};
|
||||
C.prototype.foo2 = function (x, y) {
|
||||
};
|
||||
C.prototype.foo3 = function (x, y) {
|
||||
};
|
||||
C.prototype.foo = function (x, y) { };
|
||||
C.prototype.foo2 = function (x, y) { };
|
||||
C.prototype.foo3 = function (x, y) { };
|
||||
return C;
|
||||
})();
|
||||
var a;
|
||||
var b = {
|
||||
foo: function (x, y) {
|
||||
},
|
||||
a: function foo(x, y) {
|
||||
},
|
||||
b: function (x, y) {
|
||||
}
|
||||
foo: function (x, y) { },
|
||||
a: function foo(x, y) { },
|
||||
b: function (x, y) { }
|
||||
};
|
||||
|
||||
@@ -40,43 +40,27 @@ var b = {
|
||||
|
||||
//// [callSignaturesWithDuplicateParameters.js]
|
||||
// Duplicate parameter names are always an error
|
||||
function foo(x, x) {
|
||||
}
|
||||
var f = function foo(x, x) {
|
||||
};
|
||||
var f2 = function (x, x) {
|
||||
};
|
||||
var f3 = function (x, x) {
|
||||
};
|
||||
var f4 = function (x, x) {
|
||||
};
|
||||
function foo2(x, x) {
|
||||
}
|
||||
var f5 = function foo(x, x) {
|
||||
};
|
||||
var f6 = function (x, x) {
|
||||
};
|
||||
var f7 = function (x, x) {
|
||||
};
|
||||
var f8 = function (x, y) {
|
||||
};
|
||||
function foo(x, x) { }
|
||||
var f = function foo(x, x) { };
|
||||
var f2 = function (x, x) { };
|
||||
var f3 = function (x, x) { };
|
||||
var f4 = function (x, x) { };
|
||||
function foo2(x, x) { }
|
||||
var f5 = function foo(x, x) { };
|
||||
var f6 = function (x, x) { };
|
||||
var f7 = function (x, x) { };
|
||||
var f8 = function (x, y) { };
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x, x) {
|
||||
};
|
||||
C.prototype.foo2 = function (x, x) {
|
||||
};
|
||||
C.prototype.foo3 = function (x, x) {
|
||||
};
|
||||
C.prototype.foo = function (x, x) { };
|
||||
C.prototype.foo2 = function (x, x) { };
|
||||
C.prototype.foo3 = function (x, x) { };
|
||||
return C;
|
||||
})();
|
||||
var a;
|
||||
var b = {
|
||||
foo: function (x, x) {
|
||||
},
|
||||
a: function foo(x, x) {
|
||||
},
|
||||
b: function (x, x) {
|
||||
}
|
||||
foo: function (x, x) { },
|
||||
a: function foo(x, x) { },
|
||||
b: function (x, x) { }
|
||||
};
|
||||
|
||||
@@ -57,12 +57,9 @@ b.b(1);
|
||||
|
||||
//// [callSignaturesWithOptionalParameters.js]
|
||||
// Optional parameters should be valid in all the below casts
|
||||
function foo(x) {
|
||||
}
|
||||
var f = function foo(x) {
|
||||
};
|
||||
var f2 = function (x, y) {
|
||||
};
|
||||
function foo(x) { }
|
||||
var f = function foo(x) { };
|
||||
var f2 = function (x, y) { };
|
||||
foo(1);
|
||||
foo();
|
||||
f(1);
|
||||
@@ -72,8 +69,7 @@ f2(1, 2);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
};
|
||||
C.prototype.foo = function (x) { };
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
@@ -90,12 +86,9 @@ a(1);
|
||||
a.foo();
|
||||
a.foo(1);
|
||||
var b = {
|
||||
foo: function (x) {
|
||||
},
|
||||
a: function foo(x, y) {
|
||||
},
|
||||
b: function (x) {
|
||||
}
|
||||
foo: function (x) { },
|
||||
a: function foo(x, y) { },
|
||||
b: function (x) { }
|
||||
};
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
|
||||
@@ -61,21 +61,17 @@ a.foo(1, 2, 3);
|
||||
|
||||
//// [callSignaturesWithOptionalParameters2.js]
|
||||
// Optional parameters should be valid in all the below casts
|
||||
function foo(x) {
|
||||
}
|
||||
function foo(x) { }
|
||||
foo(1);
|
||||
foo();
|
||||
function foo2(x, y) {
|
||||
}
|
||||
function foo2(x, y) { }
|
||||
foo2(1);
|
||||
foo2(1, 2);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
};
|
||||
C.prototype.foo2 = function (x, y) {
|
||||
};
|
||||
C.prototype.foo = function (x) { };
|
||||
C.prototype.foo2 = function (x, y) { };
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
|
||||
@@ -59,15 +59,9 @@ b.b(1);
|
||||
|
||||
//// [callSignaturesWithParameterInitializers.js]
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
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; }
|
||||
};
|
||||
function foo(x) { }
|
||||
var f = function foo(x) { };
|
||||
var f2 = function (x, y) { };
|
||||
foo(1);
|
||||
foo();
|
||||
f(1);
|
||||
@@ -77,9 +71,7 @@ f2(1, 2);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
};
|
||||
C.prototype.foo = function (x) { };
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
@@ -97,15 +89,9 @@ a(1);
|
||||
a.foo();
|
||||
a.foo(1);
|
||||
var b = {
|
||||
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; }
|
||||
}
|
||||
foo: function (x) { },
|
||||
a: function foo(x, y) { },
|
||||
b: function (x) { }
|
||||
};
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
|
||||
@@ -28,29 +28,21 @@ b.foo(1);
|
||||
//// [callSignaturesWithParameterInitializers2.js]
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
function foo(x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
function foo(x) { }
|
||||
foo(1);
|
||||
foo();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
};
|
||||
C.prototype.foo = function (x) { };
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
c.foo();
|
||||
c.foo(1);
|
||||
var b = {
|
||||
foo: function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
},
|
||||
foo: function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
foo: function (x) { },
|
||||
foo: function (x) { }
|
||||
};
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
|
||||
@@ -6,8 +6,7 @@ f<number, string>();
|
||||
f<number, string, number>();
|
||||
|
||||
//// [callWithWrongNumberOfTypeArguments.js]
|
||||
function f() {
|
||||
}
|
||||
function f() { }
|
||||
f();
|
||||
f();
|
||||
f();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user