mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-25 02:50:59 -05:00
Emit comments for expression statements
This commit is contained in:
@@ -917,10 +917,12 @@ module ts {
|
||||
|
||||
function emitExpressionStatement(node: ExpressionStatement) {
|
||||
var isArrowExpression = node.expression.kind === SyntaxKind.ArrowFunction;
|
||||
emitLeadingComments(node);
|
||||
if (isArrowExpression) write("(");
|
||||
emit(node.expression);
|
||||
if (isArrowExpression) write(")");
|
||||
write(";");
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
|
||||
function emitIfStatement(node: IfStatement) {
|
||||
|
||||
@@ -23,6 +23,6 @@ exports.someClass = someClass;
|
||||
//// [aliasAssignments_1.js]
|
||||
var moduleA = require("aliasAssignments_moduleA");
|
||||
var x = moduleA;
|
||||
x = 1;
|
||||
x = 1; // Should be error
|
||||
var y = 1;
|
||||
y = moduleA;
|
||||
y = moduleA; // should be error
|
||||
|
||||
@@ -24,5 +24,5 @@ var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be err
|
||||
//// [aliasOnMergedModuleInterface_0.js]
|
||||
//// [aliasOnMergedModuleInterface_1.js]
|
||||
var z;
|
||||
z.bar("hello");
|
||||
z.bar("hello"); // This should be ok
|
||||
var x = foo.bar("hello"); // foo.A should be ok but foo.bar should be error
|
||||
|
||||
@@ -31,5 +31,6 @@ exports.b = b;
|
||||
var mod = require("aliasUsedAsNameValue_0");
|
||||
var b = require("aliasUsedAsNameValue_1");
|
||||
exports.a = function () {
|
||||
//var x = mod.id; // TODO needed hack that mod is loaded
|
||||
b.b(mod);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ var TestClass = (function () {
|
||||
TestClass.prototype.bar = function (x) {
|
||||
};
|
||||
TestClass.prototype.foo = function (x) {
|
||||
this.bar(x);
|
||||
this.bar(x); // should not error
|
||||
};
|
||||
return TestClass;
|
||||
})();
|
||||
|
||||
@@ -7,5 +7,5 @@ function foo(a) {
|
||||
//// [argumentsBindsToFunctionScopeArgumentList.js]
|
||||
var arguments = 10;
|
||||
function foo(a) {
|
||||
arguments = 10;
|
||||
arguments = 10; /// This shouldnt be of type number and result in error.
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ var f = (function () {
|
||||
}
|
||||
return f;
|
||||
})();
|
||||
f += '';
|
||||
f += 1;
|
||||
f -= 1;
|
||||
f *= 1;
|
||||
f /= 1;
|
||||
f %= 1;
|
||||
f &= 1;
|
||||
f |= 1;
|
||||
f <<= 1;
|
||||
f >>= 1;
|
||||
f >>>= 1;
|
||||
f ^= 1;
|
||||
f += ''; // error
|
||||
f += 1; // error
|
||||
f -= 1; // error
|
||||
f *= 1; // error
|
||||
f /= 1; // error
|
||||
f %= 1; // error
|
||||
f &= 1; // error
|
||||
f |= 1; // error
|
||||
f <<= 1; // error
|
||||
f >>= 1; // error
|
||||
f >>>= 1; // error
|
||||
f ^= 1; // error
|
||||
|
||||
@@ -153,29 +153,32 @@ var i1_error = []; // should be an error - is
|
||||
var c1_error = []; // should be an error - is
|
||||
var c2_error = []; // should be an error - is
|
||||
var c3_error = []; // should be an error - is
|
||||
arr_any = arr_i1;
|
||||
arr_any = arr_c1;
|
||||
arr_any = arr_c2;
|
||||
arr_any = arr_c3;
|
||||
arr_i1 = arr_i1;
|
||||
arr_i1 = arr_c1;
|
||||
arr_i1 = arr_c2;
|
||||
arr_i1 = arr_c3;
|
||||
arr_c1 = arr_c1;
|
||||
arr_c1 = arr_c2;
|
||||
arr_c1 = arr_i1;
|
||||
arr_c1 = arr_c3;
|
||||
arr_c2 = arr_c2;
|
||||
arr_c2 = arr_c1;
|
||||
arr_c2 = arr_i1;
|
||||
arr_c2 = arr_c3;
|
||||
arr_c3 = arr_c2_2;
|
||||
arr_c3 = arr_c1_2;
|
||||
arr_c3 = arr_i1_2;
|
||||
arr_any = f1;
|
||||
arr_any = o1;
|
||||
arr_any = a1;
|
||||
arr_any = c1;
|
||||
arr_any = c2;
|
||||
arr_any = c3;
|
||||
arr_any = i1;
|
||||
arr_any = arr_i1; // should be ok - is
|
||||
arr_any = arr_c1; // should be ok - is
|
||||
arr_any = arr_c2; // should be ok - is
|
||||
arr_any = arr_c3; // should be ok - is
|
||||
arr_i1 = arr_i1; // should be ok - subtype relationship - is
|
||||
arr_i1 = arr_c1; // should be ok - subtype relationship - is
|
||||
arr_i1 = arr_c2; // should be ok - subtype relationship - is
|
||||
arr_i1 = arr_c3; // should be an error - is
|
||||
arr_c1 = arr_c1; // should be ok - subtype relationship - is
|
||||
arr_c1 = arr_c2; // should be ok - subtype relationship - is
|
||||
arr_c1 = arr_i1; // should be an error - is
|
||||
arr_c1 = arr_c3; // should be an error - is
|
||||
arr_c2 = arr_c2; // should be ok - subtype relationship - is
|
||||
arr_c2 = arr_c1; // should be an error - subtype relationship - is
|
||||
arr_c2 = arr_i1; // should be an error - subtype relationship - is
|
||||
arr_c2 = arr_c3; // should be an error - is
|
||||
// "clean up bug" occurs at this point
|
||||
// if you move these three expressions to another file, they raise an error
|
||||
// something to do with state from the above propagating forward?
|
||||
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 = o1; // should be an error - is
|
||||
arr_any = a1; // should be ok - is
|
||||
arr_any = c1; // should be an error - is
|
||||
arr_any = c2; // should be an error - is
|
||||
arr_any = c3; // should be an error - is
|
||||
arr_any = i1; // should be an error - is
|
||||
|
||||
@@ -123,16 +123,17 @@ var arr_i1_2 = [];
|
||||
var arr_c1_2 = [];
|
||||
var arr_c2_2 = [];
|
||||
var arr_c3 = [];
|
||||
arr_c3 = arr_c2_2;
|
||||
arr_c3 = arr_c1_2;
|
||||
arr_c3 = arr_i1_2;
|
||||
arr_any = f1;
|
||||
// "clean up error" occurs at this point
|
||||
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;
|
||||
};
|
||||
arr_any = o1;
|
||||
arr_any = a1;
|
||||
arr_any = c1;
|
||||
arr_any = c2;
|
||||
arr_any = c3;
|
||||
arr_any = i1;
|
||||
}; // 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
|
||||
arr_any = c2; // should be an error - is
|
||||
arr_any = c3; // should be an error - is
|
||||
arr_any = i1; // should be an error - is
|
||||
|
||||
@@ -51,5 +51,5 @@ var o1 = { one: 1 };
|
||||
var arr_any = [];
|
||||
arr_any = function () {
|
||||
return null;
|
||||
};
|
||||
arr_any = c3;
|
||||
}; // should be an error - is
|
||||
arr_any = c3; // should be an error - is
|
||||
|
||||
@@ -7,5 +7,8 @@
|
||||
<{ id: number; }[]>[{ foo: "s" }, {}];
|
||||
|
||||
//// [arrayCast.js]
|
||||
// Should fail. Even though the array is contextually typed with { id: number }[], it still
|
||||
// has type { foo: string }[], which is not assignable to { id: number }[].
|
||||
[{ foo: "s" }];
|
||||
// Should succeed, as the {} element causes the type of the array to be {}[]
|
||||
[{ foo: "s" }, {}];
|
||||
|
||||
@@ -51,11 +51,11 @@ function bar(animals) {
|
||||
foo([
|
||||
new Giraffe(),
|
||||
new Elephant()
|
||||
]);
|
||||
]); // Legal because of the contextual type IAnimal provided by the parameter
|
||||
bar([
|
||||
new Giraffe(),
|
||||
new Elephant()
|
||||
]);
|
||||
]); // Legal because of the contextual type IAnimal provided by the parameter
|
||||
var arr = [new Giraffe(), new Elephant()];
|
||||
foo(arr);
|
||||
bar(arr);
|
||||
foo(arr); // Error because of no contextual type
|
||||
bar(arr); // Error because of no contextual type
|
||||
|
||||
@@ -120,6 +120,7 @@ var Derived = (function (_super) {
|
||||
}
|
||||
return Derived;
|
||||
})(Base);
|
||||
// Arrow function as function argument
|
||||
window.setTimeout(function () { return null; }, 100);
|
||||
// Arrow function as value in array literal
|
||||
var obj = function (n) { return ''; };
|
||||
@@ -158,6 +159,7 @@ var M2;
|
||||
}
|
||||
return Derived;
|
||||
})(Base);
|
||||
// Arrow function as function argument
|
||||
window.setTimeout(function () { return null; }, 100);
|
||||
// Arrow function as value in array literal
|
||||
var obj = function (n) { return ''; };
|
||||
|
||||
@@ -30,5 +30,5 @@ a = x;
|
||||
a = b;
|
||||
b = a;
|
||||
b = x;
|
||||
x = a;
|
||||
x = b;
|
||||
x = a; // expected error
|
||||
x = b; // expected error
|
||||
|
||||
@@ -34,5 +34,5 @@ a = x;
|
||||
a = b;
|
||||
b = a;
|
||||
b = x;
|
||||
x = a;
|
||||
x = b;
|
||||
x = a; // expected error
|
||||
x = b; // expected error
|
||||
|
||||
@@ -57,5 +57,5 @@ a = x;
|
||||
a = b;
|
||||
b = a;
|
||||
b = x;
|
||||
x = a;
|
||||
x = b;
|
||||
x = a; // expected error
|
||||
x = b; // expected error
|
||||
|
||||
@@ -13,7 +13,7 @@ var A;
|
||||
A[A["foo"] = 0] = "foo";
|
||||
A[A["bar"] = 1] = "bar";
|
||||
})(A || (A = {}));
|
||||
A = undefined;
|
||||
A = 1 /* bar */;
|
||||
0 /* foo */ = 1;
|
||||
0 /* foo */ = 1 /* bar */;
|
||||
A = undefined; // invalid LHS
|
||||
A = 1 /* bar */; // invalid LHS
|
||||
0 /* foo */ = 1; // invalid LHS
|
||||
0 /* foo */ = 1 /* bar */; // invalid LHS
|
||||
|
||||
@@ -3,4 +3,4 @@ module A {}
|
||||
A = undefined; // invalid LHS
|
||||
|
||||
//// [assignToModule.js]
|
||||
A = undefined;
|
||||
A = undefined; // invalid LHS
|
||||
|
||||
@@ -40,7 +40,7 @@ b3 = {
|
||||
|
||||
//// [assignmentCompatBug2.js]
|
||||
var b2 = { a: 0 }; // error
|
||||
b2 = { a: 0 };
|
||||
b2 = { a: 0 }; // error
|
||||
b2 = { b: 0, a: 0 };
|
||||
var b3;
|
||||
b3 = {
|
||||
@@ -51,7 +51,7 @@ b3 = {
|
||||
return 0;
|
||||
},
|
||||
m: 0
|
||||
};
|
||||
}; // ok
|
||||
b3 = {
|
||||
f: function (n) {
|
||||
return 0;
|
||||
@@ -59,13 +59,13 @@ b3 = {
|
||||
g: function (s) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}; // error
|
||||
b3 = {
|
||||
f: function (n) {
|
||||
return 0;
|
||||
},
|
||||
m: 0
|
||||
};
|
||||
}; // error
|
||||
b3 = {
|
||||
f: function (n) {
|
||||
return 0;
|
||||
@@ -78,7 +78,7 @@ b3 = {
|
||||
k: function (a) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}; // ok
|
||||
b3 = {
|
||||
f: function (n) {
|
||||
return 0;
|
||||
@@ -90,4 +90,4 @@ b3 = {
|
||||
k: function (a) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}; // error
|
||||
|
||||
@@ -6,7 +6,7 @@ foo({ id: 1234, name: false }); // Error, name of wrong type
|
||||
foo({ name: "hello" }); // Error, id required but missing
|
||||
|
||||
//// [assignmentCompatFunctionsWithOptionalArgs.js]
|
||||
foo({ id: 1234 });
|
||||
foo({ id: 1234, name: "hello" });
|
||||
foo({ id: 1234, name: false });
|
||||
foo({ name: "hello" });
|
||||
foo({ id: 1234 }); // Ok
|
||||
foo({ id: 1234, name: "hello" }); // Ok
|
||||
foo({ id: 1234, name: false }); // Error, name of wrong type
|
||||
foo({ name: "hello" }); // Error, id required but missing
|
||||
|
||||
@@ -15,4 +15,4 @@ var Foo = (function () {
|
||||
;
|
||||
function bar(x) {
|
||||
}
|
||||
bar(Foo);
|
||||
bar(Foo); // Error, but should be allowed
|
||||
|
||||
@@ -66,6 +66,7 @@ a = function (x) {
|
||||
};
|
||||
var s2;
|
||||
var a3;
|
||||
// these are errors
|
||||
t = s2;
|
||||
t = a3;
|
||||
t = function (x) { return 1; };
|
||||
|
||||
@@ -74,6 +74,7 @@ a = { f: function (x) { return 1; } };
|
||||
a = { f: function (x) {
|
||||
return '';
|
||||
} };
|
||||
// errors
|
||||
t = function () { return 1; };
|
||||
t = function (x) {
|
||||
return '';
|
||||
@@ -84,6 +85,7 @@ a = function (x) {
|
||||
};
|
||||
var s2;
|
||||
var a3;
|
||||
// these are errors
|
||||
t = s2;
|
||||
t = a3;
|
||||
t = function (x) { return 1; };
|
||||
|
||||
@@ -152,56 +152,56 @@ var a16;
|
||||
var a17;
|
||||
var a18;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // ok
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
var b3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // ok
|
||||
b3 = a3; // ok
|
||||
var b4;
|
||||
a4 = b4;
|
||||
b4 = a4;
|
||||
a4 = b4; // ok
|
||||
b4 = a4; // ok
|
||||
var b5;
|
||||
a5 = b5;
|
||||
b5 = a5;
|
||||
a5 = b5; // ok
|
||||
b5 = a5; // ok
|
||||
var b6;
|
||||
a6 = b6;
|
||||
b6 = a6;
|
||||
a6 = b6; // ok
|
||||
b6 = a6; // ok
|
||||
var b7;
|
||||
a7 = b7;
|
||||
b7 = a7;
|
||||
a7 = b7; // ok
|
||||
b7 = a7; // ok
|
||||
var b8;
|
||||
a8 = b8;
|
||||
b8 = a8;
|
||||
a8 = b8; // ok
|
||||
b8 = a8; // ok
|
||||
var b9;
|
||||
a9 = b9;
|
||||
b9 = a9;
|
||||
a9 = b9; // ok
|
||||
b9 = a9; // ok
|
||||
var b10;
|
||||
a10 = b10;
|
||||
b10 = a10;
|
||||
a10 = b10; // ok
|
||||
b10 = a10; // ok
|
||||
var b11;
|
||||
a11 = b11;
|
||||
b11 = a11;
|
||||
a11 = b11; // ok
|
||||
b11 = a11; // ok
|
||||
var b12;
|
||||
a12 = b12;
|
||||
b12 = a12;
|
||||
a12 = b12; // ok
|
||||
b12 = a12; // ok
|
||||
var b13;
|
||||
a13 = b13;
|
||||
b13 = a13;
|
||||
a13 = b13; // ok
|
||||
b13 = a13; // ok
|
||||
var b14;
|
||||
a14 = b14;
|
||||
b14 = a14;
|
||||
a14 = b14; // ok
|
||||
b14 = a14; // ok
|
||||
var b15;
|
||||
a15 = b15;
|
||||
b15 = a15;
|
||||
a15 = b15; // ok
|
||||
b15 = a15; // ok
|
||||
var b16;
|
||||
a16 = b16;
|
||||
b16 = a16;
|
||||
a16 = b16; // ok
|
||||
b16 = a16; // ok
|
||||
var b17; // ok
|
||||
a17 = b17;
|
||||
b17 = a17;
|
||||
a17 = b17; // ok
|
||||
b17 = a17; // ok
|
||||
var b18;
|
||||
a18 = b18;
|
||||
b18 = a18;
|
||||
a18 = b18; // ok
|
||||
b18 = a18; // ok
|
||||
|
||||
@@ -154,8 +154,8 @@ var Errors;
|
||||
a7 = b7;
|
||||
b7 = a7;
|
||||
var b8;
|
||||
a8 = b8;
|
||||
b8 = a8;
|
||||
a8 = b8; // error, { foo: number } and Base are incompatible
|
||||
b8 = a8; // error, { foo: number } and Base are incompatible
|
||||
var b10;
|
||||
a10 = b10;
|
||||
b10 = a10;
|
||||
|
||||
@@ -111,35 +111,35 @@ var a16;
|
||||
var a17;
|
||||
var a18;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // ok
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
var b3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // ok
|
||||
b3 = a3; // ok
|
||||
var b4;
|
||||
a4 = b4;
|
||||
b4 = a4;
|
||||
a4 = b4; // ok
|
||||
b4 = a4; // ok
|
||||
var b5;
|
||||
a5 = b5;
|
||||
b5 = a5;
|
||||
a5 = b5; // ok
|
||||
b5 = a5; // ok
|
||||
var b6;
|
||||
a6 = b6;
|
||||
b6 = a6;
|
||||
a6 = b6; // ok
|
||||
b6 = a6; // ok
|
||||
var b11;
|
||||
a11 = b11;
|
||||
b11 = a11;
|
||||
a11 = b11; // ok
|
||||
b11 = a11; // ok
|
||||
var b15;
|
||||
a15 = b15;
|
||||
b15 = a15;
|
||||
a15 = b15; // ok, T = U, T = V
|
||||
b15 = a15; // ok
|
||||
var b16;
|
||||
a15 = b16;
|
||||
b15 = a16;
|
||||
a15 = b16; // ok
|
||||
b15 = a16; // ok
|
||||
var b17;
|
||||
a17 = b17;
|
||||
b17 = a17;
|
||||
a17 = b17; // ok
|
||||
b17 = a17; // ok
|
||||
var b18;
|
||||
a18 = b18;
|
||||
b18 = a18;
|
||||
a18 = b18; // ok
|
||||
b18 = a18; // ok
|
||||
|
||||
@@ -72,55 +72,55 @@ var a5: (x?: number, y?: number) => number;
|
||||
//// [assignmentCompatWithCallSignaturesWithOptionalParameters.js]
|
||||
var b;
|
||||
var a;
|
||||
a = function () { return 1; };
|
||||
a = function (x) { return 1; };
|
||||
a = function (x) { return 1; };
|
||||
a = b.a;
|
||||
a = b.a2;
|
||||
a = b.a3;
|
||||
a = b.a4;
|
||||
a = b.a5;
|
||||
a = b.a6;
|
||||
a = function () { return 1; }; // ok, same number of required params
|
||||
a = function (x) { return 1; }; // ok, same number of required params
|
||||
a = function (x) { return 1; }; // error, too many required params
|
||||
a = b.a; // ok
|
||||
a = b.a2; // ok
|
||||
a = b.a3; // error
|
||||
a = b.a4; // error
|
||||
a = b.a5; // ok
|
||||
a = b.a6; // error
|
||||
var a2;
|
||||
a2 = function () { return 1; };
|
||||
a2 = function (x) { return 1; };
|
||||
a2 = function (x) { return 1; };
|
||||
a2 = b.a;
|
||||
a2 = b.a2;
|
||||
a2 = b.a3;
|
||||
a2 = b.a4;
|
||||
a2 = b.a5;
|
||||
a2 = b.a6;
|
||||
a2 = function () { return 1; }; // ok, same number of required params
|
||||
a2 = function (x) { return 1; }; // ok, same number of required params
|
||||
a2 = function (x) { return 1; }; // ok, same number of params
|
||||
a2 = b.a; // ok
|
||||
a2 = b.a2; // ok
|
||||
a2 = b.a3; // ok, same number of params
|
||||
a2 = b.a4; // ok, excess params are optional in b.a3
|
||||
a2 = b.a5; // ok
|
||||
a2 = b.a6; // error
|
||||
var a3;
|
||||
a3 = function () { return 1; };
|
||||
a3 = function (x) { return 1; };
|
||||
a3 = function (x) { return 1; };
|
||||
a3 = function (x, y) { return 1; };
|
||||
a3 = b.a;
|
||||
a3 = b.a2;
|
||||
a3 = b.a3;
|
||||
a3 = b.a4;
|
||||
a3 = b.a5;
|
||||
a3 = b.a6;
|
||||
a3 = function () { return 1; }; // ok, fewer required params
|
||||
a3 = function (x) { return 1; }; // ok, fewer required params
|
||||
a3 = function (x) { return 1; }; // ok, same number of required params
|
||||
a3 = function (x, y) { return 1; }; // error, too many required params
|
||||
a3 = b.a; // ok
|
||||
a3 = b.a2; // ok
|
||||
a3 = b.a3; // ok
|
||||
a3 = b.a4; // ok
|
||||
a3 = b.a5; // ok
|
||||
a3 = b.a6; // error
|
||||
var a4;
|
||||
a4 = function () { return 1; };
|
||||
a4 = function (x, y) { return 1; };
|
||||
a4 = function (x) { return 1; };
|
||||
a4 = function (x, y) { return 1; };
|
||||
a4 = b.a;
|
||||
a4 = b.a2;
|
||||
a4 = b.a3;
|
||||
a4 = b.a4;
|
||||
a4 = b.a5;
|
||||
a4 = b.a6;
|
||||
a4 = function () { return 1; }; // ok, fewer required params
|
||||
a4 = function (x, y) { return 1; }; // ok, fewer required params
|
||||
a4 = function (x) { return 1; }; // ok, same number of required params
|
||||
a4 = function (x, y) { return 1; }; // ok, same number of params
|
||||
a4 = b.a; // ok
|
||||
a4 = b.a2; // ok
|
||||
a4 = b.a3; // ok
|
||||
a4 = b.a4; // ok
|
||||
a4 = b.a5; // ok
|
||||
a4 = b.a6; // ok, same number of params
|
||||
var a5;
|
||||
a5 = function () { return 1; };
|
||||
a5 = function (x, y) { return 1; };
|
||||
a5 = function (x) { return 1; };
|
||||
a5 = function (x, y) { return 1; };
|
||||
a5 = b.a;
|
||||
a5 = b.a2;
|
||||
a5 = b.a3;
|
||||
a5 = b.a4;
|
||||
a5 = b.a5;
|
||||
a5 = b.a6;
|
||||
a5 = function () { return 1; }; // ok, fewer required params
|
||||
a5 = function (x, y) { return 1; }; // ok, fewer required params
|
||||
a5 = function (x) { return 1; }; // ok, fewer params in lambda
|
||||
a5 = function (x, y) { return 1; }; // ok, same number of params
|
||||
a5 = b.a; // ok
|
||||
a5 = b.a2; // ok
|
||||
a5 = b.a3; // ok, fewer params in b.a3
|
||||
a5 = b.a4; // ok, same number of params
|
||||
a5 = b.a5; // ok
|
||||
a5 = b.a6; // ok, same number of params
|
||||
|
||||
@@ -47,76 +47,76 @@ var a4: (x?: number, y?: string, ...z: number[]) => number;
|
||||
|
||||
//// [assignmentCompatWithCallSignaturesWithRestParameters.js]
|
||||
var a; // ok, same number of required params
|
||||
a = function () { return 1; };
|
||||
a = function () { return 1; }; // ok, same number of required params
|
||||
a = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
}; // ok, same number of required params
|
||||
a = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
a = function (x) { return 1; };
|
||||
a = function (x, y, z) { return 1; };
|
||||
a = function (x) { return 1; };
|
||||
a = function (x) { return 1; };
|
||||
}; // error, type mismatch
|
||||
a = function (x) { return 1; }; // ok, same number of required params
|
||||
a = function (x, y, z) { return 1; }; // ok, same number of required params
|
||||
a = function (x) { return 1; }; // ok, rest param corresponds to infinite number of params
|
||||
a = function (x) { return 1; }; // error, incompatible type
|
||||
var a2;
|
||||
a2 = function () { return 1; };
|
||||
a2 = function () { return 1; }; // ok, fewer required params
|
||||
a2 = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
a2 = function (x) { return 1; };
|
||||
a2 = function (x) { return 1; };
|
||||
}; // ok, fewer required params
|
||||
a2 = function (x) { return 1; }; // ok, fewer required params
|
||||
a2 = function (x) { return 1; }; // ok, same number of required params
|
||||
a2 = function (x) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
}; // ok, same number of required params
|
||||
a2 = function (x) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
a2 = function (x, y) { return 1; };
|
||||
a2 = function (x, y) { return 1; };
|
||||
}; // should be type mismatch error
|
||||
a2 = function (x, y) { return 1; }; // ok, rest param corresponds to infinite number of params
|
||||
a2 = function (x, y) { return 1; }; // ok, same number of required params
|
||||
var a3;
|
||||
a3 = function () { return 1; };
|
||||
a3 = function (x) { return 1; };
|
||||
a3 = function (x) { return 1; };
|
||||
a3 = function (x, y) { return 1; };
|
||||
a3 = function (x, y, z) { return 1; };
|
||||
a3 = function () { return 1; }; // ok, fewer required params
|
||||
a3 = function (x) { return 1; }; // ok, fewer required params
|
||||
a3 = function (x) { return 1; }; // ok, same number of required params
|
||||
a3 = function (x, y) { return 1; }; // ok, all present params match
|
||||
a3 = function (x, y, z) { return 1; }; // error
|
||||
a3 = function (x) {
|
||||
var z = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
z[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
a3 = function (x, y, z) { return 1; };
|
||||
}; // error
|
||||
a3 = function (x, y, z) { return 1; }; // error
|
||||
var a4;
|
||||
a4 = function () { return 1; };
|
||||
a4 = function (x, y) { return 1; };
|
||||
a4 = function (x) { return 1; };
|
||||
a4 = function (x, y) { return 1; };
|
||||
a4 = function (x, y) { return 1; };
|
||||
a4 = function () { return 1; }; // ok, fewer required params
|
||||
a4 = function (x, y) { return 1; }; // error, type mismatch
|
||||
a4 = function (x) { return 1; }; // ok, all present params match
|
||||
a4 = function (x, y) { return 1; }; // error, second param has type mismatch
|
||||
a4 = function (x, y) { return 1; }; // ok, same number of required params with matching types
|
||||
a4 = function (x) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
}; // error, rest params have type mismatch
|
||||
|
||||
@@ -49,6 +49,7 @@ a = s;
|
||||
a = a2;
|
||||
var s2;
|
||||
var a3;
|
||||
// these are errors
|
||||
t = s2;
|
||||
t = a3;
|
||||
t = function (x) { return 1; };
|
||||
|
||||
@@ -53,6 +53,7 @@ t = s;
|
||||
t = a2;
|
||||
a = s;
|
||||
a = a2;
|
||||
// errors
|
||||
t = function () { return 1; };
|
||||
t = function (x) {
|
||||
return '';
|
||||
@@ -63,6 +64,7 @@ a = function (x) {
|
||||
};
|
||||
var s2;
|
||||
var a3;
|
||||
// these are errors
|
||||
t = s2;
|
||||
t = a3;
|
||||
t = function (x) { return 1; };
|
||||
|
||||
@@ -152,56 +152,56 @@ var a16;
|
||||
var a17;
|
||||
var a18;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // ok
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
var b3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // ok
|
||||
b3 = a3; // ok
|
||||
var b4;
|
||||
a4 = b4;
|
||||
b4 = a4;
|
||||
a4 = b4; // ok
|
||||
b4 = a4; // ok
|
||||
var b5;
|
||||
a5 = b5;
|
||||
b5 = a5;
|
||||
a5 = b5; // ok
|
||||
b5 = a5; // ok
|
||||
var b6;
|
||||
a6 = b6;
|
||||
b6 = a6;
|
||||
a6 = b6; // ok
|
||||
b6 = a6; // ok
|
||||
var b7;
|
||||
a7 = b7;
|
||||
b7 = a7;
|
||||
a7 = b7; // ok
|
||||
b7 = a7; // ok
|
||||
var b8;
|
||||
a8 = b8;
|
||||
b8 = a8;
|
||||
a8 = b8; // ok
|
||||
b8 = a8; // ok
|
||||
var b9;
|
||||
a9 = b9;
|
||||
b9 = a9;
|
||||
a9 = b9; // ok
|
||||
b9 = a9; // ok
|
||||
var b10;
|
||||
a10 = b10;
|
||||
b10 = a10;
|
||||
a10 = b10; // ok
|
||||
b10 = a10; // ok
|
||||
var b11;
|
||||
a11 = b11;
|
||||
b11 = a11;
|
||||
a11 = b11; // ok
|
||||
b11 = a11; // ok
|
||||
var b12;
|
||||
a12 = b12;
|
||||
b12 = a12;
|
||||
a12 = b12; // ok
|
||||
b12 = a12; // ok
|
||||
var b13;
|
||||
a13 = b13;
|
||||
b13 = a13;
|
||||
a13 = b13; // ok
|
||||
b13 = a13; // ok
|
||||
var b14;
|
||||
a14 = b14;
|
||||
b14 = a14;
|
||||
a14 = b14; // ok
|
||||
b14 = a14; // ok
|
||||
var b15;
|
||||
a15 = b15;
|
||||
b15 = a15;
|
||||
a15 = b15; // ok
|
||||
b15 = a15; // ok
|
||||
var b16;
|
||||
a16 = b16;
|
||||
b16 = a16;
|
||||
a16 = b16; // ok
|
||||
b16 = a16; // ok
|
||||
var b17; // ok
|
||||
a17 = b17;
|
||||
b17 = a17;
|
||||
a17 = b17; // ok
|
||||
b17 = a17; // ok
|
||||
var b18;
|
||||
a18 = b18;
|
||||
b18 = a18;
|
||||
a18 = b18; // ok
|
||||
b18 = a18; // ok
|
||||
|
||||
@@ -148,47 +148,47 @@ var Errors;
|
||||
var a16;
|
||||
var a17;
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
var b7;
|
||||
a7 = b7;
|
||||
b7 = a7;
|
||||
a7 = b7; // ok
|
||||
b7 = a7; // ok
|
||||
var b8;
|
||||
a8 = b8;
|
||||
b8 = a8;
|
||||
a8 = b8; // error, type mismatch
|
||||
b8 = a8; // error
|
||||
var b10;
|
||||
a10 = b10;
|
||||
b10 = a10;
|
||||
a10 = b10; // ok
|
||||
b10 = a10; // ok
|
||||
var b11;
|
||||
a11 = b11;
|
||||
b11 = a11;
|
||||
a11 = b11; // ok
|
||||
b11 = a11; // ok
|
||||
var b12;
|
||||
a12 = b12;
|
||||
b12 = a12;
|
||||
a12 = b12; // ok
|
||||
b12 = a12; // ok
|
||||
var b15;
|
||||
a15 = b15;
|
||||
b15 = a15;
|
||||
a15 = b15; // ok
|
||||
b15 = a15; // ok
|
||||
var b15a;
|
||||
a15 = b15a;
|
||||
b15a = a15;
|
||||
a15 = b15a; // ok
|
||||
b15a = a15; // ok
|
||||
var b16;
|
||||
a16 = b16;
|
||||
b16 = a16;
|
||||
a16 = b16; // error
|
||||
b16 = a16; // error
|
||||
var b17;
|
||||
a17 = b17;
|
||||
b17 = a17;
|
||||
a17 = b17; // error
|
||||
b17 = a17; // error
|
||||
})(WithNonGenericSignaturesInBaseType || (WithNonGenericSignaturesInBaseType = {}));
|
||||
var WithGenericSignaturesInBaseType;
|
||||
(function (WithGenericSignaturesInBaseType) {
|
||||
// target type has generic call signature
|
||||
var a2;
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
// target type has generic call signature
|
||||
var a3;
|
||||
var b3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // ok
|
||||
b3 = a3; // ok
|
||||
})(WithGenericSignaturesInBaseType || (WithGenericSignaturesInBaseType = {}));
|
||||
})(Errors || (Errors = {}));
|
||||
|
||||
@@ -111,35 +111,35 @@ var a16;
|
||||
var a17;
|
||||
var a18;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // ok
|
||||
var b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // ok
|
||||
var b3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // ok
|
||||
b3 = a3; // ok
|
||||
var b4;
|
||||
a4 = b4;
|
||||
b4 = a4;
|
||||
a4 = b4; // ok
|
||||
b4 = a4; // ok
|
||||
var b5;
|
||||
a5 = b5;
|
||||
b5 = a5;
|
||||
a5 = b5; // ok
|
||||
b5 = a5; // ok
|
||||
var b6;
|
||||
a6 = b6;
|
||||
b6 = a6;
|
||||
a6 = b6; // ok
|
||||
b6 = a6; // ok
|
||||
var b11;
|
||||
a11 = b11;
|
||||
b11 = a11;
|
||||
a11 = b11; // ok
|
||||
b11 = a11; // ok
|
||||
var b15;
|
||||
a15 = b15;
|
||||
b15 = a15;
|
||||
a15 = b15; // ok
|
||||
b15 = a15; // ok
|
||||
var b16;
|
||||
a15 = b16;
|
||||
b15 = a16;
|
||||
a15 = b16; // ok
|
||||
b15 = a16; // ok
|
||||
var b17;
|
||||
a17 = b17;
|
||||
b17 = a17;
|
||||
a17 = b17; // ok
|
||||
b17 = a17; // ok
|
||||
var b18;
|
||||
a18 = b18;
|
||||
b18 = a18;
|
||||
a18 = b18; // ok
|
||||
b18 = a18; // ok
|
||||
|
||||
@@ -55,37 +55,37 @@ var a5: new (x?: number, y?: number) => number;
|
||||
//// [assignmentCompatWithConstructSignaturesWithOptionalParameters.js]
|
||||
var b;
|
||||
var a;
|
||||
a = b.a;
|
||||
a = b.a2;
|
||||
a = b.a3;
|
||||
a = b.a4;
|
||||
a = b.a5;
|
||||
a = b.a6;
|
||||
a = b.a; // ok
|
||||
a = b.a2; // ok
|
||||
a = b.a3; // error
|
||||
a = b.a4; // error
|
||||
a = b.a5; // ok
|
||||
a = b.a6; // error
|
||||
var a2;
|
||||
a2 = b.a;
|
||||
a2 = b.a2;
|
||||
a2 = b.a3;
|
||||
a2 = b.a4;
|
||||
a2 = b.a5;
|
||||
a2 = b.a6;
|
||||
a2 = b.a; // ok
|
||||
a2 = b.a2; // ok
|
||||
a2 = b.a3; // ok
|
||||
a2 = b.a4; // ok
|
||||
a2 = b.a5; // ok
|
||||
a2 = b.a6; // error
|
||||
var a3;
|
||||
a3 = b.a;
|
||||
a3 = b.a2;
|
||||
a3 = b.a3;
|
||||
a3 = b.a4;
|
||||
a3 = b.a5;
|
||||
a3 = b.a6;
|
||||
a3 = b.a; // ok
|
||||
a3 = b.a2; // ok
|
||||
a3 = b.a3; // ok
|
||||
a3 = b.a4; // ok
|
||||
a3 = b.a5; // ok
|
||||
a3 = b.a6; // error
|
||||
var a4;
|
||||
a4 = b.a;
|
||||
a4 = b.a2;
|
||||
a4 = b.a3;
|
||||
a4 = b.a4;
|
||||
a4 = b.a5;
|
||||
a4 = b.a6;
|
||||
a4 = b.a; // ok
|
||||
a4 = b.a2; // ok
|
||||
a4 = b.a3; // ok
|
||||
a4 = b.a4; // ok
|
||||
a4 = b.a5; // ok
|
||||
a4 = b.a6; // ok
|
||||
var a5;
|
||||
a5 = b.a;
|
||||
a5 = b.a2;
|
||||
a5 = b.a3;
|
||||
a5 = b.a4;
|
||||
a5 = b.a5;
|
||||
a5 = b.a6;
|
||||
a5 = b.a; // ok
|
||||
a5 = b.a2; // ok
|
||||
a5 = b.a3; // ok
|
||||
a5 = b.a4; // ok
|
||||
a5 = b.a5; // ok
|
||||
a5 = b.a6; // ok
|
||||
|
||||
@@ -11,5 +11,5 @@ g = f; // ok
|
||||
// some complex cases of assignment compat of generic signatures that stress contextual signature instantiation
|
||||
var f;
|
||||
var g;
|
||||
f = g;
|
||||
g = f;
|
||||
f = g; // ok
|
||||
g = f; // ok
|
||||
|
||||
@@ -20,5 +20,6 @@ b = a;
|
||||
//// [assignmentCompatWithGenericCallSignatures2.js]
|
||||
var a;
|
||||
var b;
|
||||
// Both ok
|
||||
a = b;
|
||||
b = a;
|
||||
|
||||
@@ -13,4 +13,4 @@ g = h // ok
|
||||
//// [assignmentCompatWithGenericCallSignatures3.js]
|
||||
var g;
|
||||
var h;
|
||||
g = h;
|
||||
g = h; // ok
|
||||
|
||||
@@ -16,5 +16,6 @@ y = x
|
||||
//// [assignmentCompatWithGenericCallSignatures4.js]
|
||||
var x;
|
||||
var y;
|
||||
// These both do not make sense as we would eventually be comparing I2<T> to I2<I2<T>>, and they are self referencing anyway
|
||||
x = y;
|
||||
y = x;
|
||||
|
||||
@@ -138,24 +138,24 @@ var ClassTypeParam;
|
||||
function Base() {
|
||||
var _this = this;
|
||||
this.init = function () {
|
||||
_this.a = function () { return null; };
|
||||
_this.a = function (x) { return null; };
|
||||
_this.a = function (x) { return null; };
|
||||
_this.a2 = function () { return null; };
|
||||
_this.a2 = function (x) { return null; };
|
||||
_this.a2 = function (x) { return null; };
|
||||
_this.a3 = function () { return null; };
|
||||
_this.a3 = function (x) { return null; };
|
||||
_this.a3 = function (x) { return null; };
|
||||
_this.a3 = function (x, y) { return null; };
|
||||
_this.a4 = function () { return null; };
|
||||
_this.a4 = function (x, y) { return null; };
|
||||
_this.a4 = function (x) { return null; };
|
||||
_this.a4 = function (x, y) { return null; };
|
||||
_this.a5 = function () { return null; };
|
||||
_this.a5 = function (x, y) { return null; };
|
||||
_this.a5 = function (x) { return null; };
|
||||
_this.a5 = function (x, y) { return null; };
|
||||
_this.a = function () { return null; }; // ok, same T of required params
|
||||
_this.a = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a = function (x) { return null; }; // error, too many required params
|
||||
_this.a2 = function () { return null; }; // ok, same T of required params
|
||||
_this.a2 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a2 = function (x) { return null; }; // ok, same number of params
|
||||
_this.a3 = function () { return null; }; // ok, fewer required params
|
||||
_this.a3 = function (x) { return null; }; // ok, fewer required params
|
||||
_this.a3 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a3 = function (x, y) { return null; }; // error, too many required params
|
||||
_this.a4 = function () { return null; }; // ok, fewer required params
|
||||
_this.a4 = function (x, y) { return null; }; // ok, fewer required params
|
||||
_this.a4 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a4 = function (x, y) { return null; }; // ok, same number of params
|
||||
_this.a5 = function () { return null; }; // ok, fewer required params
|
||||
_this.a5 = function (x, y) { return null; }; // ok, fewer required params
|
||||
_this.a5 = function (x) { return null; }; // ok, all present params match
|
||||
_this.a5 = function (x, y) { return null; }; // ok, same number of params
|
||||
};
|
||||
}
|
||||
return Base;
|
||||
@@ -176,6 +176,7 @@ var GenericSignaturesInvalid;
|
||||
function foo() {
|
||||
var b;
|
||||
var t;
|
||||
// all errors
|
||||
b.a = t.a;
|
||||
b.a = t.a2;
|
||||
b.a = t.a3;
|
||||
@@ -209,24 +210,24 @@ var GenericSignaturesValid;
|
||||
function Base2() {
|
||||
var _this = this;
|
||||
this.init = function () {
|
||||
_this.a = function () { return null; };
|
||||
_this.a = function (x) { return null; };
|
||||
_this.a = function (x) { return null; };
|
||||
_this.a2 = function () { return null; };
|
||||
_this.a2 = function (x) { return null; };
|
||||
_this.a2 = function (x) { return null; };
|
||||
_this.a3 = function () { return null; };
|
||||
_this.a3 = function (x) { return null; };
|
||||
_this.a3 = function (x) { return null; };
|
||||
_this.a3 = function (x, y) { return null; };
|
||||
_this.a4 = function () { return null; };
|
||||
_this.a4 = function (x, y) { return null; };
|
||||
_this.a4 = function (x) { return null; };
|
||||
_this.a4 = function (x, y) { return null; };
|
||||
_this.a5 = function () { return null; };
|
||||
_this.a5 = function (x, y) { return null; };
|
||||
_this.a5 = function (x) { return null; };
|
||||
_this.a5 = function (x, y) { return null; };
|
||||
_this.a = function () { return null; }; // ok, same T of required params
|
||||
_this.a = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a = function (x) { return null; }; // error, too many required params
|
||||
_this.a2 = function () { return null; }; // ok, same T of required params
|
||||
_this.a2 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a2 = function (x) { return null; }; // ok, same number of params
|
||||
_this.a3 = function () { return null; }; // ok, fewer required params
|
||||
_this.a3 = function (x) { return null; }; // ok, fewer required params
|
||||
_this.a3 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a3 = function (x, y) { return null; }; // error, too many required params
|
||||
_this.a4 = function () { return null; }; // ok, fewer required params
|
||||
_this.a4 = function (x, y) { return null; }; // ok, fewer required params
|
||||
_this.a4 = function (x) { return null; }; // ok, same T of required params
|
||||
_this.a4 = function (x, y) { return null; }; // ok, same number of params
|
||||
_this.a5 = function () { return null; }; // ok, fewer required params
|
||||
_this.a5 = function (x, y) { return null; }; // ok, fewer required params
|
||||
_this.a5 = function (x) { return null; }; // ok, all present params match
|
||||
_this.a5 = function (x, y) { return null; }; // ok, same number of params
|
||||
};
|
||||
}
|
||||
return Base2;
|
||||
|
||||
@@ -58,10 +58,10 @@ var A = (function () {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
b2 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
var A = (function () {
|
||||
@@ -79,13 +79,13 @@ var Generics;
|
||||
function foo() {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // error
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // error
|
||||
b2 = a; // error
|
||||
var b3;
|
||||
a = b3;
|
||||
b3 = a;
|
||||
a = b3; // ok
|
||||
b3 = a; // ok
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -47,22 +47,22 @@ module Generics {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
b2 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
function foo() {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // error
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // error
|
||||
b2 = a; // error
|
||||
var b3;
|
||||
a = b3;
|
||||
b3 = a;
|
||||
a = b3; // ok
|
||||
b3 = a; // ok
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -54,8 +54,8 @@ var A = (function () {
|
||||
})();
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // error
|
||||
b = a; // ok
|
||||
var B2 = (function (_super) {
|
||||
__extends(B2, _super);
|
||||
function B2() {
|
||||
@@ -64,8 +64,8 @@ var B2 = (function (_super) {
|
||||
return B2;
|
||||
})(A);
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // ok
|
||||
b2 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
var A = (function () {
|
||||
@@ -76,10 +76,10 @@ var Generics;
|
||||
function foo() {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // error
|
||||
b = a; // ok
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // ok
|
||||
b2 = a; // ok
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -138,25 +138,25 @@ var OnlyDerived;
|
||||
var b;
|
||||
var a2 = { foo: new Derived() };
|
||||
var b2 = { foo: new Derived2() };
|
||||
s = t;
|
||||
t = s;
|
||||
s = s2;
|
||||
s = a2;
|
||||
s2 = t2;
|
||||
t2 = s2;
|
||||
s2 = t;
|
||||
s2 = b;
|
||||
s2 = a2;
|
||||
a = b;
|
||||
b = a;
|
||||
a = s;
|
||||
a = s2;
|
||||
a = a2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b;
|
||||
a2 = t2;
|
||||
a2 = t;
|
||||
s = t; // error
|
||||
t = s; // error
|
||||
s = s2; // ok
|
||||
s = a2; // ok
|
||||
s2 = t2; // error
|
||||
t2 = s2; // error
|
||||
s2 = t; // error
|
||||
s2 = b; // error
|
||||
s2 = a2; // ok
|
||||
a = b; // error
|
||||
b = a; // error
|
||||
a = s; // ok
|
||||
a = s2; // ok
|
||||
a = a2; // ok
|
||||
a2 = b2; // error
|
||||
b2 = a2; // error
|
||||
a2 = b; // error
|
||||
a2 = t2; // error
|
||||
a2 = t; // error
|
||||
})(OnlyDerived || (OnlyDerived = {}));
|
||||
var WithBase;
|
||||
(function (WithBase) {
|
||||
@@ -197,23 +197,23 @@ var WithBase;
|
||||
var b;
|
||||
var a2 = { foo: new Base() };
|
||||
var b2 = { foo: new Derived2() };
|
||||
s = t;
|
||||
t = s;
|
||||
s = s2;
|
||||
s = a2;
|
||||
s2 = t2;
|
||||
t2 = s2;
|
||||
s2 = t;
|
||||
s2 = b;
|
||||
s2 = a2;
|
||||
a = b;
|
||||
b = a;
|
||||
a = s;
|
||||
a = s2;
|
||||
a = a2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b;
|
||||
a2 = t2;
|
||||
a2 = t;
|
||||
s = t; // ok
|
||||
t = s; // error
|
||||
s = s2; // ok
|
||||
s = a2; // ok
|
||||
s2 = t2; // ok
|
||||
t2 = s2; // error
|
||||
s2 = t; // ok
|
||||
s2 = b; // ok
|
||||
s2 = a2; // ok
|
||||
a = b; // ok
|
||||
b = a; // error
|
||||
a = s; // ok
|
||||
a = s2; // ok
|
||||
a = a2; // ok
|
||||
a2 = b2; // ok
|
||||
b2 = a2; // error
|
||||
a2 = b; // ok
|
||||
a2 = t2; // ok
|
||||
a2 = t; // ok
|
||||
})(WithBase || (WithBase = {}));
|
||||
|
||||
@@ -22,5 +22,5 @@ var C = (function () {
|
||||
})();
|
||||
var c;
|
||||
var i;
|
||||
c = i;
|
||||
i = c;
|
||||
c = i; // error
|
||||
i = c; // error
|
||||
|
||||
@@ -138,23 +138,23 @@ var TargetIsPublic;
|
||||
a = b;
|
||||
a = i;
|
||||
a = d;
|
||||
a = e;
|
||||
a = e; // error
|
||||
b = a;
|
||||
b = i;
|
||||
b = d;
|
||||
b = e;
|
||||
b = e; // error
|
||||
i = a;
|
||||
i = b;
|
||||
i = d;
|
||||
i = e;
|
||||
i = e; // error
|
||||
d = a;
|
||||
d = b;
|
||||
d = i;
|
||||
d = e;
|
||||
e = a;
|
||||
e = b;
|
||||
e = i;
|
||||
e = d;
|
||||
d = e; // error
|
||||
e = a; // errror
|
||||
e = b; // errror
|
||||
e = i; // errror
|
||||
e = d; // errror
|
||||
e = e;
|
||||
})(TargetIsPublic || (TargetIsPublic = {}));
|
||||
var TargetIsPublic;
|
||||
@@ -181,27 +181,27 @@ var TargetIsPublic;
|
||||
})();
|
||||
var d;
|
||||
var e;
|
||||
a = b;
|
||||
a = i;
|
||||
a = b; // error
|
||||
a = i; // error
|
||||
a = d;
|
||||
a = e;
|
||||
b = a;
|
||||
a = e; // error
|
||||
b = a; // error
|
||||
b = i;
|
||||
b = d;
|
||||
b = e;
|
||||
b = d; // error
|
||||
b = e; // error
|
||||
b = b;
|
||||
i = a;
|
||||
i = a; // error
|
||||
i = b;
|
||||
i = d;
|
||||
i = e;
|
||||
i = d; // error
|
||||
i = e; // error
|
||||
i = i;
|
||||
d = a;
|
||||
d = b;
|
||||
d = i;
|
||||
d = e;
|
||||
e = a;
|
||||
e = b;
|
||||
e = i;
|
||||
e = d;
|
||||
d = b; // error
|
||||
d = i; // error
|
||||
d = e; // error
|
||||
e = a; // errror
|
||||
e = b; // errror
|
||||
e = i; // errror
|
||||
e = d; // errror
|
||||
e = e;
|
||||
})(TargetIsPublic || (TargetIsPublic = {}));
|
||||
|
||||
@@ -123,6 +123,7 @@ var TargetHasOptional;
|
||||
var d;
|
||||
var e;
|
||||
var f;
|
||||
// all ok
|
||||
c = d;
|
||||
c = e;
|
||||
c = f;
|
||||
@@ -145,17 +146,17 @@ var SourceHasOptional;
|
||||
var d;
|
||||
var e;
|
||||
var f;
|
||||
c = d;
|
||||
c = e;
|
||||
c = f;
|
||||
c = a;
|
||||
a = d;
|
||||
a = e;
|
||||
a = f;
|
||||
a = c;
|
||||
b = d;
|
||||
b = e;
|
||||
b = f;
|
||||
b = a;
|
||||
b = c;
|
||||
c = d; // error
|
||||
c = e; // error
|
||||
c = f; // ok
|
||||
c = a; // ok
|
||||
a = d; // error
|
||||
a = e; // error
|
||||
a = f; // ok
|
||||
a = c; // ok
|
||||
b = d; // error
|
||||
b = e; // error
|
||||
b = f; // ok
|
||||
b = a; // ok
|
||||
b = c; // ok
|
||||
})(SourceHasOptional || (SourceHasOptional = {}));
|
||||
|
||||
@@ -125,6 +125,7 @@ var TargetHasOptional;
|
||||
var d;
|
||||
var e;
|
||||
var f;
|
||||
// all ok
|
||||
c = d;
|
||||
c = e;
|
||||
c = f;
|
||||
@@ -147,17 +148,17 @@ var SourceHasOptional;
|
||||
var d;
|
||||
var e;
|
||||
var f;
|
||||
c = d;
|
||||
c = e;
|
||||
c = f;
|
||||
c = a;
|
||||
a = d;
|
||||
a = e;
|
||||
a = f;
|
||||
a = c;
|
||||
b = d;
|
||||
b = e;
|
||||
b = f;
|
||||
b = a;
|
||||
b = c;
|
||||
c = d; // error
|
||||
c = e; // error
|
||||
c = f; // error
|
||||
c = a; // ok
|
||||
a = d; // error
|
||||
a = e; // error
|
||||
a = f; // error
|
||||
a = c; // ok
|
||||
b = d; // error
|
||||
b = e; // error
|
||||
b = f; // error
|
||||
b = a; // ok
|
||||
b = c; // ok
|
||||
})(SourceHasOptional || (SourceHasOptional = {}));
|
||||
|
||||
@@ -110,7 +110,7 @@ var JustStrings;
|
||||
var b2 = { '1': '' };
|
||||
s = t;
|
||||
t = s;
|
||||
s = s2;
|
||||
s = s2; // ok
|
||||
s = a2;
|
||||
s2 = t2;
|
||||
t2 = s2;
|
||||
@@ -124,8 +124,8 @@ var JustStrings;
|
||||
a = a2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b;
|
||||
a2 = t2;
|
||||
a2 = b; // ok
|
||||
a2 = t2; // ok
|
||||
a2 = t;
|
||||
})(JustStrings || (JustStrings = {}));
|
||||
var NumbersAndStrings;
|
||||
@@ -148,24 +148,24 @@ var NumbersAndStrings;
|
||||
var b;
|
||||
var a2 = { '1.0': '' };
|
||||
var b2 = { 1.: '' };
|
||||
s = t;
|
||||
t = s;
|
||||
s = s2;
|
||||
s = a2;
|
||||
s2 = t2;
|
||||
t2 = s2;
|
||||
s2 = t;
|
||||
s2 = b;
|
||||
s2 = a2;
|
||||
a = b;
|
||||
b = a;
|
||||
a = s;
|
||||
a = s2;
|
||||
a = a2;
|
||||
a = b2;
|
||||
a2 = b2;
|
||||
b2 = a2;
|
||||
a2 = b;
|
||||
a2 = t2;
|
||||
a2 = t;
|
||||
s = t; // ok
|
||||
t = s; // ok
|
||||
s = s2; // ok
|
||||
s = a2; // error
|
||||
s2 = t2; // ok
|
||||
t2 = s2; // ok
|
||||
s2 = t; // ok
|
||||
s2 = b; // ok
|
||||
s2 = a2; // error
|
||||
a = b; // error
|
||||
b = a; // error
|
||||
a = s; // error
|
||||
a = s2; // error
|
||||
a = a2; // error
|
||||
a = b2; // error
|
||||
a2 = b2; // error
|
||||
b2 = a2; // error
|
||||
a2 = b; // error
|
||||
a2 = t2; // error
|
||||
a2 = t; // error
|
||||
})(NumbersAndStrings || (NumbersAndStrings = {}));
|
||||
|
||||
@@ -44,14 +44,14 @@ function f4(x) {
|
||||
return undefined;
|
||||
}
|
||||
var g;
|
||||
g = f1;
|
||||
g = f2;
|
||||
g = f3;
|
||||
g = f4;
|
||||
g = f1; // OK
|
||||
g = f2; // Error
|
||||
g = f3; // Error
|
||||
g = f4; // Error
|
||||
var C = (function () {
|
||||
function C(x) {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var d;
|
||||
d = C;
|
||||
d = C; // Error
|
||||
|
||||
@@ -67,11 +67,11 @@ var A = (function () {
|
||||
})();
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // ok
|
||||
b2 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
var A = (function () {
|
||||
@@ -88,8 +88,8 @@ var Generics;
|
||||
})(A);
|
||||
var b1;
|
||||
var a1;
|
||||
a1 = b1;
|
||||
b1 = a1;
|
||||
a1 = b1; // ok
|
||||
b1 = a1; // error
|
||||
var B2 = (function (_super) {
|
||||
__extends(B2, _super);
|
||||
function B2() {
|
||||
@@ -98,15 +98,15 @@ var Generics;
|
||||
return B2;
|
||||
})(A);
|
||||
var b2;
|
||||
a1 = b2;
|
||||
b2 = a1;
|
||||
a1 = b2; // ok
|
||||
b2 = a1; // error
|
||||
function foo() {
|
||||
var b3;
|
||||
var a3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // error
|
||||
b3 = a3; // error
|
||||
var b4;
|
||||
a3 = b4;
|
||||
b4 = a3;
|
||||
a3 = b4; // error
|
||||
b4 = a3; // error
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -56,27 +56,27 @@ module Generics {
|
||||
//// [assignmentCompatWithStringIndexer2.js]
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // ok
|
||||
b = a; // error
|
||||
var b2;
|
||||
a = b2;
|
||||
b2 = a;
|
||||
a = b2; // ok
|
||||
b2 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
var b1;
|
||||
var a1;
|
||||
a1 = b1;
|
||||
b1 = a1;
|
||||
a1 = b1; // ok
|
||||
b1 = a1; // error
|
||||
var b2;
|
||||
a1 = b2;
|
||||
b2 = a1;
|
||||
a1 = b2; // ok
|
||||
b2 = a1; // error
|
||||
function foo() {
|
||||
var b3;
|
||||
var a3;
|
||||
a3 = b3;
|
||||
b3 = a3;
|
||||
a3 = b3; // error
|
||||
b3 = a3; // error
|
||||
var b4;
|
||||
a3 = b4;
|
||||
b4 = a3;
|
||||
a3 = b4; // error
|
||||
b4 = a3; // error
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -26,8 +26,8 @@ module Generics {
|
||||
//// [assignmentCompatWithStringIndexer3.js]
|
||||
var a;
|
||||
var b1;
|
||||
a = b1;
|
||||
b1 = a;
|
||||
a = b1; // error
|
||||
b1 = a; // error
|
||||
var Generics;
|
||||
(function (Generics) {
|
||||
var A = (function () {
|
||||
@@ -38,7 +38,7 @@ var Generics;
|
||||
function foo() {
|
||||
var a;
|
||||
var b;
|
||||
a = b;
|
||||
b = a;
|
||||
a = b; // error
|
||||
b = a; // error
|
||||
}
|
||||
})(Generics || (Generics = {}));
|
||||
|
||||
@@ -32,6 +32,7 @@ fn(a => { });
|
||||
|
||||
//// [assignmentCompatability_checking-apply-member-off-of-function-interface.js]
|
||||
var x;
|
||||
// Should fail
|
||||
x = '';
|
||||
x = [''];
|
||||
x = 4;
|
||||
@@ -43,9 +44,11 @@ function f() {
|
||||
x = f;
|
||||
function fn(c) {
|
||||
}
|
||||
// Should Fail
|
||||
fn('');
|
||||
fn(['']);
|
||||
fn(4);
|
||||
fn({});
|
||||
// Should work
|
||||
fn(function (a) {
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ fn(a => { });
|
||||
|
||||
//// [assignmentCompatability_checking-call-member-off-of-function-interface.js]
|
||||
var x;
|
||||
// Should fail
|
||||
x = '';
|
||||
x = [''];
|
||||
x = 4;
|
||||
@@ -43,9 +44,11 @@ function f() {
|
||||
x = f;
|
||||
function fn(c) {
|
||||
}
|
||||
// Should Fail
|
||||
fn('');
|
||||
fn(['']);
|
||||
fn(4);
|
||||
fn({});
|
||||
// Should work
|
||||
fn(function (a) {
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@ function fn1(x2) {
|
||||
var x3;
|
||||
x3.a = value;
|
||||
x3['a'] = value;
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) = value;
|
||||
function fn2(x4) {
|
||||
(x4) = value;
|
||||
|
||||
@@ -73,66 +73,66 @@ C = undefined; // Error
|
||||
|
||||
//// [assignmentToParenthesizedIdentifiers.js]
|
||||
var x;
|
||||
x = 3;
|
||||
(x) = 3;
|
||||
x = '';
|
||||
(x) = '';
|
||||
x = 3; // OK
|
||||
(x) = 3; // OK
|
||||
x = ''; // Error
|
||||
(x) = ''; // Error
|
||||
var M;
|
||||
(function (M) {
|
||||
M.y;
|
||||
})(M || (M = {}));
|
||||
M.y = 3;
|
||||
(M).y = 3;
|
||||
(M.y) = 3;
|
||||
M.y = '';
|
||||
(M).y = '';
|
||||
(M.y) = '';
|
||||
M = { y: 3 };
|
||||
(M) = { y: 3 };
|
||||
M.y = 3; // OK
|
||||
(M).y = 3; // OK
|
||||
(M.y) = 3; // OK
|
||||
M.y = ''; // Error
|
||||
(M).y = ''; // Error
|
||||
(M.y) = ''; // Error
|
||||
M = { y: 3 }; // Error
|
||||
(M) = { y: 3 }; // Error
|
||||
var M2;
|
||||
(function (M2) {
|
||||
(function (M3) {
|
||||
M3.x;
|
||||
})(M2.M3 || (M2.M3 = {}));
|
||||
var M3 = M2.M3;
|
||||
M3 = { x: 3 };
|
||||
M3 = { x: 3 }; // Error
|
||||
})(M2 || (M2 = {}));
|
||||
M2.M3 = { x: 3 };
|
||||
(M2).M3 = { x: 3 };
|
||||
(M2.M3) = { x: 3 };
|
||||
M2.M3 = { x: '' };
|
||||
(M2).M3 = { x: '' };
|
||||
(M2.M3) = { x: '' };
|
||||
M2.M3 = { x: 3 }; // OK
|
||||
(M2).M3 = { x: 3 }; // OK
|
||||
(M2.M3) = { x: 3 }; // OK
|
||||
M2.M3 = { x: '' }; // Error
|
||||
(M2).M3 = { x: '' }; // Error
|
||||
(M2.M3) = { x: '' }; // Error
|
||||
function fn() {
|
||||
}
|
||||
fn = function () { return 3; };
|
||||
(fn) = function () { return 3; };
|
||||
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) {
|
||||
x = 3;
|
||||
(x) = 3;
|
||||
x = '';
|
||||
(x) = '';
|
||||
(y).t = 3;
|
||||
(y.t) = 3;
|
||||
(y).t = '';
|
||||
(y.t) = '';
|
||||
y['t'] = 3;
|
||||
(y)['t'] = 3;
|
||||
(y['t']) = 3;
|
||||
y['t'] = '';
|
||||
(y)['t'] = '';
|
||||
(y['t']) = '';
|
||||
(x) = 3; // OK
|
||||
x = ''; // Error
|
||||
(x) = ''; // Error
|
||||
(y).t = 3; // OK
|
||||
(y.t) = 3; // OK
|
||||
(y).t = ''; // Error
|
||||
(y.t) = ''; // Error
|
||||
y['t'] = 3; // OK
|
||||
(y)['t'] = 3; // OK
|
||||
(y['t']) = 3; // OK
|
||||
y['t'] = ''; // Error
|
||||
(y)['t'] = ''; // Error
|
||||
(y['t']) = ''; // Error
|
||||
}
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
})(E || (E = {}));
|
||||
E = undefined;
|
||||
(E) = undefined;
|
||||
E = undefined; // Error
|
||||
(E) = undefined; // Error
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
C = undefined;
|
||||
(C) = undefined;
|
||||
C = undefined; // Error
|
||||
(C) = undefined; // Error
|
||||
|
||||
@@ -32,25 +32,25 @@ interface I { }
|
||||
I = null; // Error
|
||||
|
||||
//// [assignments.js]
|
||||
M = null;
|
||||
M = null; // Error
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
C = null;
|
||||
C = null; // Error
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
})(E || (E = {}));
|
||||
E = null;
|
||||
0 /* A */ = null;
|
||||
E = null; // Error
|
||||
0 /* A */ = null; // OK per spec, Error per implementation (509581)
|
||||
function fn() {
|
||||
}
|
||||
fn = null;
|
||||
fn = null; // Should be error
|
||||
var v;
|
||||
v = null;
|
||||
v = null; // OK
|
||||
function fn2(p) {
|
||||
p = null;
|
||||
p = null; // OK
|
||||
}
|
||||
I = null;
|
||||
I = null; // Error
|
||||
|
||||
@@ -26,7 +26,7 @@ function f() {
|
||||
var y = f(); // error void fn
|
||||
var why = f(); // error void fn
|
||||
var w;
|
||||
w = f();
|
||||
w = f(); // error void fn
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ var ResultIsNumber18 = ~(undefined + undefined);
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber19 = ~~ANY;
|
||||
var ResultIsNumber20 = ~~~(ANY + ANY1);
|
||||
//miss assignment operators
|
||||
~ANY;
|
||||
~ANY1;
|
||||
~ANY2[0];
|
||||
|
||||
@@ -69,6 +69,7 @@ var ResultIsNumber6 = ~foo();
|
||||
var ResultIsNumber7 = ~A.foo();
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber8 = ~~BOOLEAN;
|
||||
// miss assignment operators
|
||||
~true;
|
||||
~BOOLEAN;
|
||||
~foo();
|
||||
|
||||
@@ -34,6 +34,7 @@ var ResultIsNumber2 = ~ENUM1[1];
|
||||
var ResultIsNumber3 = ~(ENUM1[1] + ENUM1[2]);
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber4 = ~~~(ENUM1[1] + ENUM1[2]);
|
||||
// miss assignment operators
|
||||
~ENUM1;
|
||||
~ENUM1[1];
|
||||
~ENUM1[1], ~ENUM1[2];
|
||||
|
||||
@@ -83,6 +83,7 @@ var ResultIsNumber11 = ~(NUMBER + NUMBER);
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber12 = ~~NUMBER;
|
||||
var ResultIsNumber13 = ~~~(NUMBER + NUMBER);
|
||||
// miss assignment operators
|
||||
~NUMBER;
|
||||
~NUMBER1;
|
||||
~foo();
|
||||
|
||||
@@ -83,6 +83,7 @@ var ResultIsNumber12 = ~STRING.charAt(0);
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber13 = ~~STRING;
|
||||
var ResultIsNumber14 = ~~~(STRING + STRING);
|
||||
//miss assignment operators
|
||||
~STRING;
|
||||
~STRING1;
|
||||
~foo();
|
||||
|
||||
@@ -11,5 +11,5 @@ bar = foo; // error
|
||||
//// [callConstructAssignment.js]
|
||||
var foo;
|
||||
var bar;
|
||||
foo = bar;
|
||||
bar = foo;
|
||||
foo = bar; // error
|
||||
bar = foo; // error
|
||||
|
||||
@@ -13,4 +13,4 @@ declare class C { constructor(value: number); }
|
||||
//// [callOnInstance.js]
|
||||
var s1 = D(); // OK
|
||||
var s2 = (new D(1))();
|
||||
(new C(1))();
|
||||
(new C(1))(); // Error for calling an instance
|
||||
|
||||
@@ -13,6 +13,6 @@ function foo() {
|
||||
//// [callSignaturesShouldBeResolvedBeforeSpecialization.js]
|
||||
function foo() {
|
||||
var test;
|
||||
test("expects boolean instead of string");
|
||||
test(true);
|
||||
test("expects boolean instead of string"); // should not error - "test" should not expect a boolean
|
||||
test(true); // should error - string expected
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ new (<any>A());
|
||||
|
||||
|
||||
//// [castExpressionParentheses.js]
|
||||
// parentheses should be omitted
|
||||
// literals
|
||||
{ a: 0 };
|
||||
[1, 3, ];
|
||||
"string";
|
||||
@@ -48,6 +50,7 @@ new (<any>A());
|
||||
false;
|
||||
true;
|
||||
null;
|
||||
// names and dotted names
|
||||
this;
|
||||
this.x;
|
||||
a.x;
|
||||
@@ -55,6 +58,7 @@ a;
|
||||
a[0];
|
||||
a.b["0"];
|
||||
a().x;
|
||||
// should keep the parentheses in emit
|
||||
(new A).foo;
|
||||
(typeof A).x;
|
||||
(-A).x;
|
||||
@@ -64,5 +68,7 @@ new (A());
|
||||
(function foo() {
|
||||
})();
|
||||
(-A).x;
|
||||
// nested cast, should keep one pair of parenthese
|
||||
(-A).x;
|
||||
// nested parenthesized expression, should keep one pair of parenthese
|
||||
(A);
|
||||
|
||||
@@ -43,5 +43,5 @@ var Z = (function () {
|
||||
var c1 = new X(3);
|
||||
var c2 = new Y(5);
|
||||
var c3 = new Z();
|
||||
c1 = c2 = c3;
|
||||
c2 = c3;
|
||||
c1 = c2 = c3; // a bug made this not report the same error as below
|
||||
c2 = c3; // Error TS111: Cannot convert Z to Y
|
||||
|
||||
@@ -47,5 +47,6 @@ a = b = null;
|
||||
a = b = new B();
|
||||
b = a = new B();
|
||||
a.id = b.value = null;
|
||||
// error cases
|
||||
b = a = new A();
|
||||
a = b = new A();
|
||||
|
||||
@@ -43,4 +43,4 @@ var Z = (function () {
|
||||
var c1 = new X(3);
|
||||
var c2 = new Y(5);
|
||||
var c3 = new Z();
|
||||
c1 = c2 = c3;
|
||||
c1 = c2 = c3; // Should be error
|
||||
|
||||
@@ -54,4 +54,5 @@ var C = (function (_super) {
|
||||
}
|
||||
return C;
|
||||
})(B);
|
||||
// Ok to go down the chain, but error to try to climb back up
|
||||
(new Chain(new A)).then(function (a) { return new B; }).then(function (b) { return new C; }).then(function (c) { return new B; }).then(function (b) { return new A; });
|
||||
|
||||
@@ -49,8 +49,11 @@ var Chain = (function () {
|
||||
Chain.prototype.then = function (cb) {
|
||||
var t;
|
||||
var s;
|
||||
// Ok to go down the chain, but error to climb up the chain
|
||||
(new Chain(t)).then(function (tt) { return s; }).then(function (ss) { return t; });
|
||||
// But error to try to climb up the chain
|
||||
(new Chain(s)).then(function (ss) { return t; });
|
||||
// Staying at T or S should be fine
|
||||
(new Chain(t)).then(function (tt) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; });
|
||||
(new Chain(s)).then(function (ss) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; });
|
||||
return null;
|
||||
@@ -65,7 +68,11 @@ var Chain2 = (function () {
|
||||
var i;
|
||||
var t;
|
||||
var s;
|
||||
// Ok to go down the chain, check the constraint at the end.
|
||||
// Should get an error that we are assigning a string to a number
|
||||
(new Chain2(i)).then(function (ii) { return t; }).then(function (tt) { return s; }).value.x = "";
|
||||
// Staying at T or S should keep the constraint.
|
||||
// Get an error when we assign a string to a number in both cases
|
||||
(new Chain2(i)).then(function (ii) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; }).then(function (tt) { return t; }).value.x = "";
|
||||
(new Chain2(i)).then(function (ii) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; }).then(function (ss) { return s; }).value.x = "";
|
||||
return null;
|
||||
|
||||
@@ -15,5 +15,5 @@ var s3 = s2.each(x => { x.key /* Type is K, should be number */ });
|
||||
var s;
|
||||
var s2 = s.groupBy(function (s) { return s.length; });
|
||||
var s3 = s2.each(function (x) {
|
||||
x.key;
|
||||
x.key; /* Type is K, should be number */
|
||||
});
|
||||
|
||||
@@ -58,5 +58,5 @@ var c;
|
||||
var c2;
|
||||
c = c2;
|
||||
c2 = c;
|
||||
c.bar();
|
||||
c2.bar();
|
||||
c.bar(); // error
|
||||
c2.bar(); // should error
|
||||
|
||||
@@ -25,7 +25,7 @@ var aaa = 1;
|
||||
var CCC = (function () {
|
||||
function CCC(aaa) {
|
||||
this.y = aaa;
|
||||
this.y = '';
|
||||
this.y = ''; // was: error, cannot assign string to number
|
||||
}
|
||||
CCC.staticY = aaa; // This shouldnt be error
|
||||
return CCC;
|
||||
|
||||
@@ -37,12 +37,12 @@ var Test = (function () {
|
||||
this.field = field;
|
||||
this.messageHandler = function () {
|
||||
var field = _this.field;
|
||||
console.log(field);
|
||||
console.log(field); // Using field here shouldnt be error
|
||||
};
|
||||
}
|
||||
Test.staticMessageHandler = function () {
|
||||
var field = Test.field;
|
||||
console.log(field);
|
||||
console.log(field); // Using field here shouldnt be error
|
||||
};
|
||||
return Test;
|
||||
})();
|
||||
@@ -51,11 +51,11 @@ var Test1 = (function () {
|
||||
function Test1(field1) {
|
||||
this.field1 = field1;
|
||||
this.messageHandler = function () {
|
||||
console.log(field1);
|
||||
console.log(field1); // But this should be error as the field1 will resolve to var field1
|
||||
};
|
||||
}
|
||||
Test1.staticMessageHandler = function () {
|
||||
console.log(field1);
|
||||
console.log(field1); // This shouldnt be error as its a static property
|
||||
};
|
||||
return Test1;
|
||||
})();
|
||||
|
||||
@@ -24,7 +24,7 @@ var Test1 = (function () {
|
||||
function Test1(field1) {
|
||||
this.field1 = field1;
|
||||
this.messageHandler = function () {
|
||||
console.log(field1);
|
||||
console.log(field1); // But this should be error as the field1 will resolve to var field1
|
||||
};
|
||||
}
|
||||
return Test1;
|
||||
|
||||
@@ -15,7 +15,7 @@ class Greeter {
|
||||
var Greeter = (function () {
|
||||
function Greeter(message) {
|
||||
this.messageHandler = function (message) {
|
||||
console.log(message);
|
||||
console.log(message); // This shouldnt be error
|
||||
};
|
||||
}
|
||||
return Greeter;
|
||||
|
||||
@@ -42,7 +42,7 @@ var C2 = (function (_super) {
|
||||
})(A);
|
||||
var a;
|
||||
var c;
|
||||
a.bar();
|
||||
c.bar();
|
||||
A.bar();
|
||||
C2.bar();
|
||||
a.bar(); // static off an instance - should be an error
|
||||
c.bar(); // static off an instance - should be an error
|
||||
A.bar(); // valid
|
||||
C2.bar(); // valid
|
||||
|
||||
@@ -61,8 +61,8 @@ var T3;
|
||||
})(m3d || (m3d = {}));
|
||||
var r = new m3d();
|
||||
r.foo();
|
||||
r.bar();
|
||||
r.y;
|
||||
r.bar(); // error
|
||||
r.y; // error
|
||||
})(T3 || (T3 = {}));
|
||||
var T4;
|
||||
(function (T4) {
|
||||
@@ -72,8 +72,8 @@ var T4;
|
||||
})(m3d || (m3d = {}));
|
||||
var r = new m3d();
|
||||
r.foo();
|
||||
r.bar();
|
||||
r.y;
|
||||
r.bar(); // error
|
||||
r.y; // error
|
||||
})(T4 || (T4 = {}));
|
||||
var m3d;
|
||||
(function (m3d) {
|
||||
|
||||
@@ -16,7 +16,7 @@ var Foo = (function () {
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
console.log(_i);
|
||||
console.log(_i); // This should result in error
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
|
||||
@@ -31,7 +31,7 @@ var Foo = (function (_super) {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Foo.prototype.x = function () {
|
||||
console.log(_super);
|
||||
console.log(_super); // Error as this doesnt not resolve to user defined _super
|
||||
};
|
||||
return Foo;
|
||||
})(base);
|
||||
|
||||
@@ -6,4 +6,4 @@ _this = 10; // Error
|
||||
//// [collisionThisExpressionAndAmbientVarInGlobal.js]
|
||||
var _this = this;
|
||||
var f = function () { return _this; };
|
||||
_this = 10;
|
||||
_this = 10; // Error
|
||||
|
||||
@@ -21,7 +21,7 @@ var Foo = (function () {
|
||||
var _this = 10; // Local var. No this capture in x(), so no conflict.
|
||||
function inner() {
|
||||
var _this = this;
|
||||
console.log(_this);
|
||||
console.log(_this); // Error as this doesnt not resolve to user defined _this
|
||||
return function (x) { return _this; }; // New scope. So should inject new _this capture into function inner
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ var STRING;
|
||||
var resultIsBoolean;
|
||||
var resultIsNumber;
|
||||
var resultIsString;
|
||||
//Expect errors when the results type is different form the second operand
|
||||
resultIsBoolean = (BOOLEAN, STRING);
|
||||
resultIsBoolean = (BOOLEAN, NUMBER);
|
||||
resultIsNumber = (NUMBER, BOOLEAN);
|
||||
|
||||
@@ -43,6 +43,7 @@ var BOOLEAN;
|
||||
var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
//The second operand type is any
|
||||
ANY, ANY;
|
||||
BOOLEAN, ANY;
|
||||
NUMBER, ANY;
|
||||
|
||||
@@ -41,6 +41,7 @@ var BOOLEAN;
|
||||
var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
//The second operand type is boolean
|
||||
ANY, BOOLEAN;
|
||||
BOOLEAN, BOOLEAN;
|
||||
NUMBER, BOOLEAN;
|
||||
@@ -52,6 +53,7 @@ var resultIsBoolean2 = (BOOLEAN, BOOLEAN);
|
||||
var resultIsBoolean3 = (NUMBER, BOOLEAN);
|
||||
var resultIsBoolean4 = (STRING, BOOLEAN);
|
||||
var resultIsBoolean5 = (OBJECT, BOOLEAN);
|
||||
//Literal and expression
|
||||
null, BOOLEAN;
|
||||
ANY = undefined, BOOLEAN;
|
||||
1, true;
|
||||
|
||||
@@ -41,6 +41,7 @@ var BOOLEAN;
|
||||
var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
//The second operand type is number
|
||||
ANY, NUMBER;
|
||||
BOOLEAN, NUMBER;
|
||||
NUMBER, NUMBER;
|
||||
@@ -52,6 +53,7 @@ var resultIsNumber2 = (BOOLEAN, NUMBER);
|
||||
var resultIsNumber3 = (NUMBER, NUMBER);
|
||||
var resultIsNumber4 = (STRING, NUMBER);
|
||||
var resultIsNumber5 = (OBJECT, NUMBER);
|
||||
//Literal and expression
|
||||
null, NUMBER;
|
||||
ANY = undefined, NUMBER;
|
||||
true, 1;
|
||||
|
||||
@@ -50,6 +50,7 @@ var CLASS = (function () {
|
||||
}
|
||||
return CLASS;
|
||||
})();
|
||||
//The second operand type is Object
|
||||
ANY, OBJECT;
|
||||
BOOLEAN, OBJECT;
|
||||
NUMBER, OBJECT;
|
||||
@@ -61,6 +62,7 @@ var resultIsObject2 = (BOOLEAN, OBJECT);
|
||||
var resultIsObject3 = (NUMBER, OBJECT);
|
||||
var resultIsObject4 = (STRING, OBJECT);
|
||||
var resultIsObject5 = (OBJECT, OBJECT);
|
||||
//Literal and expression
|
||||
null, OBJECT;
|
||||
ANY = null, OBJECT;
|
||||
true, {};
|
||||
|
||||
@@ -44,6 +44,7 @@ var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
var resultIsString;
|
||||
//The second operand is string
|
||||
ANY, STRING;
|
||||
BOOLEAN, STRING;
|
||||
NUMBER, STRING;
|
||||
@@ -55,6 +56,7 @@ var resultIsString2 = (BOOLEAN, STRING);
|
||||
var resultIsString3 = (NUMBER, STRING);
|
||||
var resultIsString4 = (STRING, STRING);
|
||||
var resultIsString5 = (OBJECT, STRING);
|
||||
//Literal and expression
|
||||
null, STRING;
|
||||
ANY = new Date(), STRING;
|
||||
true, "";
|
||||
|
||||
@@ -32,6 +32,7 @@ var BOOLEAN;
|
||||
var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
//Expected: work well
|
||||
ANY, BOOLEAN, NUMBER;
|
||||
BOOLEAN, NUMBER, STRING;
|
||||
NUMBER, STRING, OBJECT;
|
||||
@@ -43,6 +44,7 @@ var resultIsBoolean1 = (OBJECT, ANY, BOOLEAN);
|
||||
var resultIsNumber1 = (ANY, BOOLEAN, NUMBER);
|
||||
var resultIsString1 = (BOOLEAN, NUMBER, STRING);
|
||||
var resultIsObject1 = (NUMBER, STRING, OBJECT);
|
||||
//Literal and expression
|
||||
null, true, 1;
|
||||
++NUMBER, STRING.charAt(0), new Object();
|
||||
var resultIsNumber2 = (null, true, 1);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
1 + 1; // Comment.
|
||||
|
||||
//// [commentOnExpressionStatement1.js]
|
||||
1 + 1;
|
||||
1 + 1; // Comment.
|
||||
|
||||
@@ -406,6 +406,7 @@ var c1 = (function () {
|
||||
/** setter property
|
||||
*/
|
||||
set: function (value) {
|
||||
/** setter */
|
||||
c1.b_s1 = c1.b_s2(value);
|
||||
},
|
||||
enumerable: true,
|
||||
|
||||
@@ -35,7 +35,10 @@ function blah3(a: string // trailing commen single line
|
||||
) {
|
||||
}
|
||||
|
||||
lambdaFoo = (a, b) => a * b; // This is trailing comment that will not get emitted since we are not emitting statement comments yet
|
||||
lambdaFoo = (a, b) => a * b; // This is trailing comment
|
||||
|
||||
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/(() => 0); //trailing comment
|
||||
|
||||
//// [commentsFunction.js]
|
||||
/** This comment should appear for foo*/
|
||||
@@ -68,7 +71,10 @@ function blah2(a /* single line multiple trailing comments */ /* second */) {
|
||||
function blah3(a // trailing commen single line
|
||||
) {
|
||||
}
|
||||
lambdaFoo = function (a, b) { return a * b; };
|
||||
lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment
|
||||
/*leading comment*/ (
|
||||
/*leading comment*/ function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/ (function () { return 0; }); //trailing comment
|
||||
|
||||
|
||||
//// [commentsFunction.d.ts]
|
||||
|
||||
@@ -176,6 +176,7 @@ var c1 = (function () {
|
||||
})();
|
||||
var i1_i;
|
||||
var c1_i = new c1();
|
||||
// assign to interface
|
||||
i1_i = c1_i;
|
||||
var c2 = (function () {
|
||||
/** c2 constructor*/
|
||||
@@ -253,6 +254,7 @@ var c3 = (function (_super) {
|
||||
})(c2);
|
||||
var c2_i = new c2(10);
|
||||
var c3_i = new c3();
|
||||
// assign
|
||||
c2_i = c3_i;
|
||||
var c4 = (function (_super) {
|
||||
__extends(c4, _super);
|
||||
@@ -264,6 +266,7 @@ var c4 = (function (_super) {
|
||||
var c4_i = new c4(10);
|
||||
var i2_i;
|
||||
var i3_i;
|
||||
// assign to interface
|
||||
i2_i = i3_i;
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* m
|
||||
/** comment line 2*/
|
||||
var x = 70; /* multiline trailing comment
|
||||
this is multiline trailing comment */
|
||||
/** Triple slash comment on the assignement shouldnt be in .d.ts file*/
|
||||
x = myVariable;
|
||||
/** triple slash comment1*/
|
||||
/** jsdocstyle comment - only this comment should be in .d.ts file*/
|
||||
|
||||
@@ -50,6 +50,7 @@ x3.a *= value;
|
||||
x3.a += value;
|
||||
x3['a'] *= value;
|
||||
x3['a'] += value;
|
||||
// parentheses, the contained expression is reference
|
||||
(x1) *= value;
|
||||
(x1) += value;
|
||||
function fn2(x4) {
|
||||
|
||||
@@ -68,16 +68,19 @@ var exprBoolean2;
|
||||
var exprNumber2;
|
||||
var exprString2;
|
||||
var exprIsObject2;
|
||||
//Cond is a boolean type variable
|
||||
condBoolean ? exprAny1 : exprAny2;
|
||||
condBoolean ? exprBoolean1 : exprBoolean2;
|
||||
condBoolean ? exprNumber1 : exprNumber2;
|
||||
condBoolean ? exprString1 : exprString2;
|
||||
condBoolean ? exprIsObject1 : exprIsObject2;
|
||||
//Cond is a boolean type literal
|
||||
true ? exprAny1 : exprAny2;
|
||||
false ? exprBoolean1 : exprBoolean2;
|
||||
true ? exprNumber1 : exprNumber2;
|
||||
false ? exprString1 : exprString2;
|
||||
true ? exprIsObject1 : exprIsObject2;
|
||||
//Cond is a boolean type expression
|
||||
!true ? exprAny1 : exprAny2;
|
||||
typeof "123" == "string" ? exprBoolean1 : exprBoolean2;
|
||||
2 > 1 ? exprNumber1 : exprNumber2;
|
||||
|
||||
@@ -71,11 +71,13 @@ var exprBoolean2;
|
||||
var exprNumber2;
|
||||
var exprString2;
|
||||
var exprIsObject2;
|
||||
//Cond is a number type variable
|
||||
condNumber ? exprAny1 : exprAny2;
|
||||
condNumber ? exprBoolean1 : exprBoolean2;
|
||||
condNumber ? exprNumber1 : exprNumber2;
|
||||
condNumber ? exprString1 : exprString2;
|
||||
condNumber ? exprIsObject1 : exprIsObject2;
|
||||
//Cond is a number type literal
|
||||
1 ? exprAny1 : exprAny2;
|
||||
0 ? exprBoolean1 : exprBoolean2;
|
||||
0.123456789 ? exprNumber1 : exprNumber2;
|
||||
|
||||
@@ -80,16 +80,19 @@ var C = (function () {
|
||||
return C;
|
||||
})();
|
||||
;
|
||||
//Cond is an object type variable
|
||||
condObject ? exprAny1 : exprAny2;
|
||||
condObject ? exprBoolean1 : exprBoolean2;
|
||||
condObject ? exprNumber1 : exprNumber2;
|
||||
condObject ? exprString1 : exprString2;
|
||||
condObject ? exprIsObject1 : exprIsObject2;
|
||||
//Cond is an object type literal
|
||||
(function (a) { return a.length; }) ? exprAny1 : exprAny2;
|
||||
(function (a) { return a.length; }) ? exprBoolean1 : exprBoolean2;
|
||||
({}) ? exprNumber1 : exprNumber2;
|
||||
({ a: 1, b: "s" }) ? exprString1 : exprString2;
|
||||
({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2;
|
||||
//Cond is an object type expression
|
||||
foo() ? exprAny1 : exprAny2;
|
||||
new Date() ? exprBoolean1 : exprBoolean2;
|
||||
new C() ? exprNumber1 : exprNumber2;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user