Emit comments for class and constructor

This commit is contained in:
Sheetal Nandi
2014-08-14 06:42:18 -07:00
parent 72cff32c96
commit 6d6f27cdce
237 changed files with 2442 additions and 1940 deletions
+11 -1
View File
@@ -1401,10 +1401,13 @@ module ts {
function emitClassDeclaration(node: ClassDeclaration) {
var ctor = getFirstConstructorWithBody(node);
emitLeadingComments(node);
write("var ");
emit(node.name);
write(" = (function (");
if (node.baseType) write("_super");
if (node.baseType) {
write("_super");
}
write(") {");
increaseIndent();
scopeEmitStart(node);
@@ -1417,6 +1420,9 @@ module ts {
emitEnd(node.baseType);
}
writeLine();
if (ctor) {
emitLeadingComments(ctor);
}
emitStart(<Node>ctor || node);
write("function ");
emit(node.name);
@@ -1456,6 +1462,9 @@ module ts {
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
scopeEmitEnd();
emitEnd(<Node>ctor || node);
if (ctor) {
emitTrailingComments(ctor);
}
emitMemberFunctions(node);
emitMemberAssignments(node, NodeFlags.Static);
writeLine();
@@ -1485,6 +1494,7 @@ module ts {
emitEnd(node);
write(";");
}
emitTrailingComments(node);
}
function emitEnumDeclaration(node: EnumDeclaration) {
@@ -50,6 +50,7 @@ module clodule4 {
//// [ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.js]
// all expected to be errors
var clodule1 = (function () {
function clodule1() {
}
@@ -46,6 +46,7 @@ var X;
var X;
(function (X) {
(function (Y) {
// duplicate identifier
var Point = (function () {
function Point(x, y) {
this.x = x;
@@ -62,6 +63,7 @@ var A;
(function (A) {
A.Instance = new A();
})(A || (A = {}));
// duplicate identifier
var A = (function () {
function A() {
}
@@ -44,6 +44,7 @@ var A;
})(A || (A = {}));
var A;
(function (A) {
// expected error
var Point = (function () {
function Point() {
}
@@ -70,6 +71,7 @@ var X;
(function (X) {
(function (Y) {
(function (Z) {
// expected error
var Line = (function () {
function Line() {
}
@@ -28,11 +28,14 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
var Base = (function () {
function Base() {
}
return Base;
})();
// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T)
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived() {
@@ -45,6 +48,7 @@ var Base2 = (function () {
}
return Base2;
})();
// is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
@@ -18,11 +18,14 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// subtype checks use the apparent type of the target type
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
var Base = (function () {
function Base() {
}
return Base;
})();
// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T)
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived() {
@@ -15,6 +15,9 @@ var xx = new a(null, 7, new B());
//// [arrayAssignmentTest3.js]
// The following gives no error
// Michal saw no error if he used number instead of B,
// but I do...
var B = (function () {
function B() {
}
@@ -78,6 +78,7 @@ var classTypeArray;
var context1 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
var context2;
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
var Base = (function () {
function Base() {
}
@@ -106,6 +106,7 @@ var __extends = this.__extends || function (d, b) {
with (window) {
var p = function () { return this; };
}
// Arrow function as argument to super call
var Base = (function () {
function Base(n) {
}
@@ -140,6 +141,7 @@ var M2;
with (window) {
var p = function () { return this; };
}
// Arrow function as argument to super call
var Base = (function () {
function Base(n) {
}
@@ -106,6 +106,8 @@ var c;
var d = function (n) { return c = n; };
var d = function (n) { return c = n; };
var d;
// Arrow function used in class member initializer
// Arrow function used in class member function
var MyClass = (function () {
function MyClass() {
var _this = this;
@@ -106,6 +106,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// these are all permitted with the current rules, since we do not do contextual signature instantiation
var Base = (function () {
function Base() {
}
@@ -72,6 +72,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking assignment compat for function types. No errors in this file
var Base = (function () {
function Base() {
}
@@ -49,6 +49,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking assignment compatibility relations for function types. All valid
var Base = (function () {
function Base() {
}
@@ -106,6 +106,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking assignment compatibility relations for function types. All of these are valid.
var Base = (function () {
function Base() {
}
@@ -72,6 +72,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking assignment compat for function types. All valid
var Base = (function () {
function Base() {
}
@@ -49,6 +49,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking assignment compatibility relations for function types. All valid.
var Base = (function () {
function Base() {
}
@@ -43,6 +43,8 @@ a2 = t;
//// [assignmentCompatWithObjectMembers2.js]
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// additional optional properties do not cause errors
var S = (function () {
function S() {
}
@@ -43,6 +43,8 @@ a2 = t;
//// [assignmentCompatWithObjectMembers3.js]
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// additional optional properties do not cause errors
var S = (function () {
function S() {
}
@@ -112,6 +112,7 @@ module TargetIsPublic {
//// [assignmentCompatWithObjectMembersAccessibility.js]
var TargetIsPublic;
(function (TargetIsPublic) {
// targets
var Base = (function () {
function Base() {
}
@@ -120,6 +121,7 @@ var TargetIsPublic;
var a;
var b;
var i;
// sources
var D = (function () {
function D() {
}
@@ -156,6 +158,7 @@ var TargetIsPublic;
})(TargetIsPublic || (TargetIsPublic = {}));
var TargetIsPublic;
(function (TargetIsPublic) {
// targets
var Base = (function () {
function Base() {
}
@@ -164,6 +167,7 @@ var TargetIsPublic;
var a;
var b;
var i;
// sources
var D = (function () {
function D() {
}
@@ -43,6 +43,8 @@ a2 = t;
//// [assignmentCompatWithObjectMembersNumericNames.js]
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// numeric named properties work correctly, no errors expected
var S = (function () {
function S() {
}
@@ -95,6 +95,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// Derived member is not optional but base member is, should be ok
var Base = (function () {
function Base() {
}
@@ -96,6 +96,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// M is optional and S contains no property with the same name as M
// N is optional and T contains no property with the same name as N
var Base = (function () {
function Base() {
}
@@ -8,6 +8,7 @@ class c4 { public foo() { } }
enum c4 { One } // error
//// [augmentedTypesClass.js]
//// class then var
var c1 = (function () {
function c1() {
}
@@ -16,6 +17,7 @@ var c1 = (function () {
return c1;
})();
var c1 = 1;
//// class then enum
var c4 = (function () {
function c4() {
}
@@ -31,6 +31,8 @@ class c44 {
//// [augmentedTypesClass2.js]
// Checking class with other things in type space not value space
// class then interface
var c11 = (function () {
function c11() {
}
@@ -39,6 +41,8 @@ var c11 = (function () {
};
return c11;
})();
// class then class - covered
// class then enum
var c33 = (function () {
function c33() {
}
@@ -52,6 +56,7 @@ var c33;
c33[c33["One"] = 0] = "One";
})(c33 || (c33 = {}));
;
// class then import
var c44 = (function () {
function c44() {
}
@@ -5,6 +5,7 @@ function c2() { } // error
var c2 = () => { }
//// [augmentedTypesClass2a.js]
//// class then function
var c2 = (function () {
function c2() {
}
@@ -14,6 +14,7 @@ class c5c { public foo() { } }
//import c5c = require('');
//// [augmentedTypesClass3.js]
// class then module
var c5 = (function () {
function c5() {
}
@@ -43,6 +44,7 @@ var c5b;
(function (c5b) {
c5b.y = 2;
})(c5b || (c5b = {}));
//// class then import
var c5c = (function () {
function c5c() {
}
@@ -5,6 +5,7 @@ class c3 { public bar() { } } // error
//// [augmentedTypesClass4.js]
//// class then class
var c3 = (function () {
function c3() {
}
@@ -31,6 +31,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist)
// these are errors
var Base = (function () {
function Base() {
}
@@ -76,6 +76,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
var Base = (function () {
function Base() {
}
@@ -56,6 +56,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
var Base = (function () {
function Base() {
}
@@ -55,6 +55,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithCallSignatures2 just with an extra level of indirection in the inheritance chain
var Base = (function () {
function Base() {
}
@@ -57,6 +57,9 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithCallSignatures4 but using class type parameters instead of generic signatures
// all are errors
var Base = (function () {
function Base() {
}
@@ -77,6 +77,7 @@ var D = (function (_super) {
var r2 = D;
var d = new D();
var d2 = new D(1);
// specialized base class
var D2 = (function (_super) {
__extends(D2, _super);
function D2() {
@@ -26,6 +26,7 @@ c = i;
i = c;
//// [classWithOnlyPublicMembersEquivalentToInterface.js]
// no errors expected
var C = (function () {
function C() {
}
@@ -28,6 +28,7 @@ c = i;
i = c;
//// [classWithOnlyPublicMembersEquivalentToInterface2.js]
// no errors expected
var C = (function () {
function C() {
}
@@ -7,6 +7,7 @@ class boolean { }
class string { }
//// [classWithPredefinedTypesAsNames.js]
// classes cannot use predefined types as names
var any = (function () {
function any() {
}
@@ -23,6 +23,7 @@ var r7: string = C.f();
var r8: string = C.g();
//// [classWithPrivateProperty.js]
// accessing any private outside the class is an error
var C = (function () {
function C() {
this.a = '';
@@ -87,6 +87,7 @@ declare class c6NoError {
}
//// [collisionArgumentsClassConstructor.js]
// Constructors
var c1 = (function () {
function c1(i) {
var arguments = [];
@@ -67,6 +67,7 @@ declare class c6NoError {
}
//// [collisionRestParameterClassConstructor.js]
// Constructors
var c1 = (function () {
function c1(_i) {
var restParameters = [];
@@ -66,6 +66,7 @@ var i8_c = c8;
//// [commentsClass.js]
/** This is class c2 without constuctor*/
var c2 = (function () {
function c2() {
}
@@ -74,19 +75,23 @@ var c2 = (function () {
var i2 = new c2();
var i2_c = c2;
var c3 = (function () {
/** Constructor comment*/
function c3() {
}
return c3;
})();
var i3 = new c3();
var i3_c = c3;
/** Class comment*/
var c4 = (function () {
/** Constructor comment*/
function c4() {
}
return c4;
})();
var i4 = new c4();
var i4_c = c4;
/** Class with statics*/
var c5 = (function () {
function c5() {
}
@@ -94,21 +99,29 @@ var c5 = (function () {
})();
var i5 = new c5();
var i5_c = c5;
/// class with statics and constructor
var c6 = (function () {
/// constructor comment
function c6() {
}
return c6;
})();
var i6 = new c6();
var i6_c = c6;
// class with statics and constructor
var c7 = (function () {
// constructor comment
function c7() {
}
return c7;
})();
var i7 = new c7();
var i7_c = c7;
/** class with statics and constructor
*/
var c8 = (function () {
/** constructor comment
*/
function c8() {
}
return c8;
@@ -216,7 +216,9 @@ cProperties_i.nc_p2 = cProperties_i.nc_p1;
//// [commentsClassMembers.js]
/** This is comment for c1*/
var c1 = (function () {
/** Constructor method*/
function c1() {
}
/** sum with property*/
@@ -283,6 +283,7 @@ function divide(a, b) {
function jsDocParamTest(a, b, c, d) {
return a + b + c + d;
}
/**/
var NoQuickInfoClass = (function () {
function NoQuickInfoClass() {
}
@@ -11,6 +11,7 @@ export module outerModule.InnerModule {
define(["require", "exports"], function (require, exports) {
(function (outerModule) {
(function (InnerModule) {
/// class b comment
var b = (function () {
function b() {
}
@@ -71,6 +71,7 @@ define(["require", "exports"], function (require, exports) {
return m1.b;
}
(function (m2) {
/** class comment;*/
var c = (function () {
function c() {
}
@@ -100,6 +101,7 @@ define(["require", "exports"], function (require, exports) {
return m4.b;
}
(function (m2) {
/** class comment; */
var c = (function () {
function c() {
}
@@ -178,6 +178,7 @@ var i1_i;
var c1_i = new c1();
i1_i = c1_i;
var c2 = (function () {
/** c2 constructor*/
function c2(a) {
this.c2_p1 = a;
}
@@ -107,6 +107,7 @@ var m1;
return m1.b;
}
(function (m2) {
/** class comment;*/
var c = (function () {
function c() {
}
@@ -144,6 +145,7 @@ var myvar = new m1.m2.c();
var m2;
(function (m2) {
(function (m3) {
/** Exported class comment*/
var c = (function () {
function c() {
}
@@ -158,6 +160,7 @@ var m3;
(function (m3) {
(function (m4) {
(function (m5) {
/** Exported class comment*/
var c = (function () {
function c() {
}
@@ -175,6 +178,7 @@ var m4;
(function (m5) {
(function (m6) {
(function (m7) {
/** Exported class comment*/
var c = (function () {
function c() {
}
@@ -194,6 +198,7 @@ var m5;
(function (m6) {
(function (m7) {
(function (m8) {
/** Exported class comment*/
var c = (function () {
function c() {
}
@@ -212,6 +217,7 @@ var m6;
(function (m6) {
(function (m7) {
(function (m8) {
/** Exported class comment*/
var c = (function () {
function c() {
}
@@ -228,17 +234,20 @@ var m7;
(function (m7) {
(function (m8) {
(function (m9) {
/** Exported class comment*/
var c = (function () {
function c() {
}
return c;
})();
m9.c = c;
/** class d */
var d = (function () {
function d() {
}
return d;
})();
// class e
var e = (function () {
function e() {
}
@@ -39,6 +39,7 @@ new multiM.d();
//// [commentsMultiModuleMultiFile_0.js]
define(["require", "exports"], function (require, exports) {
(function (multiM) {
/// class b comment
var b = (function () {
function b() {
}
@@ -48,12 +49,14 @@ define(["require", "exports"], function (require, exports) {
})(exports.multiM || (exports.multiM = {}));
var multiM = exports.multiM;
(function (multiM) {
/** class c comment*/
var c = (function () {
function c() {
}
return c;
})();
multiM.c = c;
// class e comment
var e = (function () {
function e() {
}
@@ -68,12 +71,14 @@ define(["require", "exports"], function (require, exports) {
//// [commentsMultiModuleMultiFile_1.js]
define(["require", "exports"], function (require, exports) {
(function (multiM) {
/** class d comment*/
var d = (function () {
function d() {
}
return d;
})();
multiM.d = d;
/// class f comment
var f = (function () {
function f() {
}
@@ -27,12 +27,14 @@ new multiM.c();
//// [commentsMultiModuleSingleFile.js]
var multiM;
(function (multiM) {
/** class b*/
var b = (function () {
function b() {
}
return b;
})();
multiM.b = b;
// class d
var d = (function () {
function d() {
}
@@ -42,12 +44,14 @@ var multiM;
})(multiM || (multiM = {}));
var multiM;
(function (multiM) {
/** class c comment*/
var c = (function () {
function c() {
}
return c;
})();
multiM.c = c;
/// class e
var e = (function () {
function e() {
}
@@ -236,11 +236,13 @@ var c3 = (function () {
return c3;
})();
var c4 = (function () {
/** c4 3 */
function c4(aorb) {
}
return c4;
})();
var c5 = (function () {
/** c5 implementation*/
function c5(aorb) {
}
return c5;
@@ -98,7 +98,9 @@ function foo(p) {
var fooVar;
foo(50);
fooVar();
/**class comment*/
var c = (function () {
/** constructor comment*/
function c() {
/** property comment */
this.b = 10;
@@ -131,6 +133,7 @@ var i = new c();
var i1_i;
var m1;
(function (m1) {
/** class b */
var b = (function () {
function b(x) {
this.x = x;
@@ -98,7 +98,9 @@ function foo(p) {
var fooVar;
foo(50);
fooVar();
/**class comment*/
var c = (function () {
/** constructor comment*/
function c() {
/** property comment */
this.b = 10;
@@ -131,6 +133,7 @@ var i = new c();
var i1_i;
var m1;
(function (m1) {
/** class b */
var b = (function () {
function b(x) {
this.x = x;
@@ -54,6 +54,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// There should be no errors in this file
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived() {
@@ -6,6 +6,7 @@ f += '';
//// [concatClassAndString.js]
// Shouldn't compile (the long form f = f + ""; doesn't):
var f = (function () {
function f() {
}
@@ -54,6 +54,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have identical best common type
var X = (function () {
function X() {
}
@@ -28,6 +28,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
//Cond ? Expr1 : Expr2, Expr1 and Expr2 have no identical best common type
var X = (function () {
function X() {
}
@@ -26,6 +26,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// No errors
var Constraint = (function () {
function Constraint() {
}
@@ -72,6 +72,9 @@ var b;
foo(b);
foo2(b);
foo4(b);
//function foo5<T extends String, U extends T>(x: T, y: U): T { return null; }
//foo5(a, a);
//foo5<any, any>(b, b);
var C = (function () {
function C(x) {
this.x = x;
@@ -88,6 +91,11 @@ var C2 = (function () {
})();
var c3 = new C2(a);
var c4 = new C2(b);
//class C3<T extends T[]> {
// constructor(public x: T) { }
//}
//var c5 = new C3(a);
//var c6 = new C3<any>(b);
var C4 = (function () {
function C4(x) {
this.x = x;
@@ -76,6 +76,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
var Base = (function () {
function Base() {
}
@@ -66,6 +66,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
var Base = (function () {
function Base() {
}
@@ -55,6 +55,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithConstructSignatures2 just with an extra level of indirection in the inheritance chain
var Base = (function () {
function Base() {
}
@@ -57,6 +57,9 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// checking subtype relations for function types as it relates to contextual signature instantiation
// same as subtypingWithConstructSignatures4 but using class type parameters instead of generic signatures
// all are errors
var Base = (function () {
function Base() {
}
@@ -30,6 +30,7 @@ var b: {
}
//// [constructSignatureWithAccessibilityModifiersOnParameters.js]
// Parameter properties are only valid in constructor definitions, not even in other forms of construct signatures
var C = (function () {
function C(x, y) {
this.x = x;
@@ -37,6 +37,7 @@ var b: {
}
//// [constructSignatureWithAccessibilityModifiersOnParameters2.js]
// Parameter properties are not valid in overloads of constructors
var C = (function () {
function C(x, y) {
this.x = x;
@@ -50,6 +50,7 @@ var b: {
var r6 = new b(1, '');
//// [constructSignaturesWithIdenticalOverloads.js]
// Duplicate overloads of construct signatures should generate errors
var C = (function () {
function C(x) {
}
@@ -51,6 +51,7 @@ var b: {
var r6 = new b(1, '');
//// [constructSignaturesWithOverloads.js]
// No errors expected for basic overloads of construct signatures
var C = (function () {
function C(x) {
}
@@ -40,6 +40,8 @@ var r4 = new i2(1, '');
var r5 = new i2(1, 1);
//// [constructSignaturesWithOverloads2.js]
// No errors expected for basic overloads of construct signatures with merged declarations
// clodules
var C = (function () {
function C(x) {
}
@@ -33,6 +33,7 @@ var b: {
}
//// [constructSignaturesWithOverloadsThatDifferOnlyByReturnType.js]
// Error for construct signature overloads to differ only by return type
var C = (function () {
function C(x) {
}
@@ -39,6 +39,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// the constructor function itself does not need to be a subtype of the base type constructor function
var Base = (function () {
function Base(x) {
}
@@ -53,6 +54,7 @@ var Derived = (function (_super) {
})(Base);
var Derived2 = (function (_super) {
__extends(Derived2, _super);
// ok, not enforcing assignability relation on this
function Derived2(x) {
_super.call(this, x);
return 1;
@@ -20,6 +20,8 @@ class B<T> {
var b = new B<number>();
//// [constructorReturningAPrimitive.js]
// technically not allowed by JavaScript but we don't have a 'not-primitive' constraint
// functionally only possible when your class is otherwise devoid of members so of little consequence in practice
var A = (function () {
function A() {
return 1;
@@ -7,6 +7,7 @@ class test {
//// [constructorStaticParamName.js]
// static as constructor parameter name should only give error if 'use strict'
var test = (function () {
function test(static) {
}
@@ -36,6 +36,7 @@ class G<T> {
}
//// [constructorWithAssignableReturnExpression.js]
// a class constructor may return an expression, it must be assignable to the class instance type to be valid
var C = (function () {
function C() {
return 1;
@@ -44,11 +44,13 @@ interface I2 {
}
//// [constructorsWithSpecializedSignatures.js]
// errors
var D = (function () {
function D(x) {
}
return D;
})();
// overloads are ok
var D2 = (function () {
function D2(x) {
}
@@ -232,4 +232,4 @@ var x: B = { };
//// [contextualTyping.js]
var C1T5 = (function () {\n function C1T5() {\n this.foo = function (i) {\n return i;\n };\n }\n return C1T5;\n})();\nvar C2T5;\n(function (C2T5) {\n C2T5.foo = function (i) {\n return i;\n };\n})(C2T5 || (C2T5 = {}));\n// CONTEXT: Variable declaration\nvar c3t1 = (function (s) {\n return s;\n});\nvar c3t2 = ({\n n: 1\n});\nvar c3t3 = [];\nvar c3t4 = function () {\n return ({});\n};\nvar c3t5 = function (n) {\n return ({});\n};\nvar c3t6 = function (n, s) {\n return ({});\n};\nvar c3t7 = function (n) {\n return n;\n};\nvar c3t8 = function (n) {\n return n;\n};\nvar c3t9 = [[], []];\nvar c3t10 = [({}), ({})];\nvar c3t11 = [function (n, s) {\n return s;\n}];\nvar c3t12 = {\n foo: ({})\n};\nvar c3t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c3t14 = ({\n a: []\n});\nvar C4T5 = (function () {\n function C4T5() {\n this.foo = function (i, s) {\n return s;\n };\n }\n return C4T5;\n})();\nvar C5T5;\n(function (C5T5) {\n C5T5.foo;\n C5T5.foo = function (i, s) {\n return s;\n };\n})(C5T5 || (C5T5 = {}));\n// CONTEXT: Variable assignment\nvar c6t5;\nc6t5 = function (n) {\n return ({});\n};\n// CONTEXT: Array index assignment\nvar c7t2;\nc7t2[0] = ({ n: 1 });\nvar objc8 = ({});\nobjc8.t1 = (function (s) {\n return s;\n});\nobjc8.t2 = ({\n n: 1\n});\nobjc8.t3 = [];\nobjc8.t4 = function () {\n return ({});\n};\nobjc8.t5 = function (n) {\n return ({});\n};\nobjc8.t6 = function (n, s) {\n return ({});\n};\nobjc8.t7 = function (n) {\n return n;\n};\nobjc8.t8 = function (n) {\n return n;\n};\nobjc8.t9 = [[], []];\nobjc8.t10 = [({}), ({})];\nobjc8.t11 = [function (n, s) {\n return s;\n}];\nobjc8.t12 = {\n foo: ({})\n};\nobjc8.t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nobjc8.t14 = ({\n a: []\n});\n// CONTEXT: Function call\nfunction c9t5(f) {\n}\n;\nc9t5(function (n) {\n return ({});\n});\n// CONTEXT: Return statement\nvar c10t5 = function () {\n return function (n) {\n return ({});\n };\n};\nvar C11t5 = (function () {\n function C11t5(f) {\n }\n return C11t5;\n})();\n;\nvar i = new C11t5(function (n) {\n return ({});\n});\n// CONTEXT: Type annotated expression\nvar c12t1 = (function (s) {\n return s;\n});\nvar c12t2 = ({\n n: 1\n});\nvar c12t3 = [];\nvar c12t4 = function () {\n return ({});\n};\nvar c12t5 = function (n) {\n return ({});\n};\nvar c12t6 = function (n, s) {\n return ({});\n};\nvar c12t7 = function (n) {\n return n;\n};\nvar c12t8 = function (n) {\n return n;\n};\nvar c12t9 = [[], []];\nvar c12t10 = [({}), ({})];\nvar c12t11 = [function (n, s) {\n return s;\n}];\nvar c12t12 = {\n foo: ({})\n};\nvar c12t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c12t14 = ({\n a: []\n});\nfunction EF1(a, b) {\n return a + b;\n}\nvar efv = EF1(1, 2);\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n return this;\n}\nPoint.origin = new Point(0, 0);\nPoint.prototype.add = function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n};\nPoint.prototype = {\n x: 0,\n y: 0,\n add: function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n }\n};\nvar x = {};\n//# sourceMappingURL=contextualTyping.js.map
// CONTEXT: Class property declaration\nvar C1T5 = (function () {\n function C1T5() {\n this.foo = function (i) {\n return i;\n };\n }\n return C1T5;\n})();\nvar C2T5;\n(function (C2T5) {\n C2T5.foo = function (i) {\n return i;\n };\n})(C2T5 || (C2T5 = {}));\n// CONTEXT: Variable declaration\nvar c3t1 = (function (s) {\n return s;\n});\nvar c3t2 = ({\n n: 1\n});\nvar c3t3 = [];\nvar c3t4 = function () {\n return ({});\n};\nvar c3t5 = function (n) {\n return ({});\n};\nvar c3t6 = function (n, s) {\n return ({});\n};\nvar c3t7 = function (n) {\n return n;\n};\nvar c3t8 = function (n) {\n return n;\n};\nvar c3t9 = [[], []];\nvar c3t10 = [({}), ({})];\nvar c3t11 = [function (n, s) {\n return s;\n}];\nvar c3t12 = {\n foo: ({})\n};\nvar c3t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c3t14 = ({\n a: []\n});\n// CONTEXT: Class property assignment\nvar C4T5 = (function () {\n function C4T5() {\n this.foo = function (i, s) {\n return s;\n };\n }\n return C4T5;\n})();\nvar C5T5;\n(function (C5T5) {\n C5T5.foo;\n C5T5.foo = function (i, s) {\n return s;\n };\n})(C5T5 || (C5T5 = {}));\n// CONTEXT: Variable assignment\nvar c6t5;\nc6t5 = function (n) {\n return ({});\n};\n// CONTEXT: Array index assignment\nvar c7t2;\nc7t2[0] = ({ n: 1 });\nvar objc8 = ({});\nobjc8.t1 = (function (s) {\n return s;\n});\nobjc8.t2 = ({\n n: 1\n});\nobjc8.t3 = [];\nobjc8.t4 = function () {\n return ({});\n};\nobjc8.t5 = function (n) {\n return ({});\n};\nobjc8.t6 = function (n, s) {\n return ({});\n};\nobjc8.t7 = function (n) {\n return n;\n};\nobjc8.t8 = function (n) {\n return n;\n};\nobjc8.t9 = [[], []];\nobjc8.t10 = [({}), ({})];\nobjc8.t11 = [function (n, s) {\n return s;\n}];\nobjc8.t12 = {\n foo: ({})\n};\nobjc8.t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nobjc8.t14 = ({\n a: []\n});\n// CONTEXT: Function call\nfunction c9t5(f) {\n}\n;\nc9t5(function (n) {\n return ({});\n});\n// CONTEXT: Return statement\nvar c10t5 = function () {\n return function (n) {\n return ({});\n };\n};\n// CONTEXT: Newing a class\nvar C11t5 = (function () {\n function C11t5(f) {\n }\n return C11t5;\n})();\n;\nvar i = new C11t5(function (n) {\n return ({});\n});\n// CONTEXT: Type annotated expression\nvar c12t1 = (function (s) {\n return s;\n});\nvar c12t2 = ({\n n: 1\n});\nvar c12t3 = [];\nvar c12t4 = function () {\n return ({});\n};\nvar c12t5 = function (n) {\n return ({});\n};\nvar c12t6 = function (n, s) {\n return ({});\n};\nvar c12t7 = function (n) {\n return n;\n};\nvar c12t8 = function (n) {\n return n;\n};\nvar c12t9 = [[], []];\nvar c12t10 = [({}), ({})];\nvar c12t11 = [function (n, s) {\n return s;\n}];\nvar c12t12 = {\n foo: ({})\n};\nvar c12t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c12t14 = ({\n a: []\n});\nfunction EF1(a, b) {\n return a + b;\n}\nvar efv = EF1(1, 2);\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n return this;\n}\nPoint.origin = new Point(0, 0);\nPoint.prototype.add = function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n};\nPoint.prototype = {\n x: 0,\n y: 0,\n add: function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n }\n};\nvar x = {};\n//# sourceMappingURL=contextualTyping.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -102,6 +102,7 @@ class c2 {
}
//// [declFileAccessors_0.js]
/** This is comment for c1*/
var c1 = (function () {
function c1() {
}
@@ -184,6 +185,7 @@ var c1 = (function () {
})();
exports.c1 = c1;
//// [declFileAccessors_1.js]
/** This is comment for c2 - the global class*/
var c2 = (function () {
function c2() {
}
@@ -99,12 +99,14 @@ class GlobalConstructorWithParameterInitializer {
//// [declFileConstructors_0.js]
var SimpleConstructor = (function () {
/** This comment should appear for foo*/
function SimpleConstructor() {
}
return SimpleConstructor;
})();
exports.SimpleConstructor = SimpleConstructor;
var ConstructorWithParameters = (function () {
/** This is comment for function signature*/
function ConstructorWithParameters(a, /** this is comment for b*/
b) {
var d = a;
@@ -160,11 +162,13 @@ var ConstructorWithParameterInitializer = (function () {
exports.ConstructorWithParameterInitializer = ConstructorWithParameterInitializer;
//// [declFileConstructors_1.js]
var GlobalSimpleConstructor = (function () {
/** This comment should appear for foo*/
function GlobalSimpleConstructor() {
}
return GlobalSimpleConstructor;
})();
var GlobalConstructorWithParameters = (function () {
/** This is comment for function signature*/
function GlobalConstructorWithParameters(a, /** this is comment for b*/
b) {
var d = a;
@@ -39,6 +39,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// derived class constructors must contain a super call
var Base = (function () {
function Base() {
}
@@ -29,6 +29,7 @@ var Base = (function () {
}
return Base;
})();
// ok, use assignment compatibility
var Derived = (function (_super) {
__extends(Derived, _super);
function Derived() {
@@ -41,6 +42,7 @@ var Base2 = (function () {
}
return Base2;
})();
// ok, use assignment compatibility
var Derived2 = (function (_super) {
__extends(Derived2, _super);
function Derived2() {
@@ -101,6 +101,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// ordering of super calls in derived constructors matters depending on other class contents
var Base = (function () {
function Base() {
}
@@ -179,6 +180,7 @@ var Derived8 = (function (_super) {
}
return Derived8;
})(Base);
// generic cases of Derived7 and Derived8
var Base2 = (function () {
function Base2() {
}
@@ -27,6 +27,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// subclassing is not transitive when you can remove required parameters and add optional parameters
var C = (function () {
function C() {
}
@@ -27,6 +27,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// subclassing is not transitive when you can remove required parameters and add optional parameters
var C = (function () {
function C() {
}
@@ -27,6 +27,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// subclassing is not transitive when you can remove required parameters and add optional parameters
var C = (function () {
function C() {
}
@@ -53,6 +53,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// automatic constructors with a class hieararchy of depth > 2
var Base = (function () {
function Base(x) {
this.a = 1;
@@ -43,6 +43,7 @@ var Foo;
})(Foo || (Foo = {}));
var Foo;
(function (Foo) {
// Should not be an error
var Helper = (function () {
function Helper() {
}
@@ -67,6 +67,7 @@ var F;
})(F || (F = {}));
var F;
(function (F) {
// Should not be an error
var Helper = (function () {
function Helper() {
}
@@ -83,6 +84,7 @@ var Foo;
})(Foo || (Foo = {}));
var Foo;
(function (Foo) {
// Should not be an error
var Helper = (function () {
function Helper() {
}
@@ -101,6 +103,7 @@ var Gar;
})(Foo || (Foo = {}));
var Foo;
(function (Foo) {
// Should not be an error
var Helper = (function () {
function Helper() {
}
@@ -149,6 +149,7 @@ moduleType1.baz1 = 3;
moduleType\u0031.baz1 = 3;
moduleType2.baz2 = 3;
moduleType\u0032.baz2 = 3;
// classes
var classType1 = (function () {
function classType1() {
}
@@ -175,6 +176,7 @@ var interfaceType2Object1 = { bar2: 0 };
interfaceType2Object1.bar2 = 2;
var interfaceType2Object2 = { bar2: 0 };
interfaceType2Object2.bar2 = 2;
// arguments
var testClass = (function () {
function testClass() {
}
@@ -186,6 +188,7 @@ var testClass = (function () {
};
return testClass;
})();
// constructors
var constructorTestClass = (function () {
function constructorTestClass(arg1, arg\u0032, arg\u0033, arg4) {
this.arg1 = arg1;
@@ -192,6 +192,7 @@ var n = function () {
return 3;
return 5;
}();
// FunctionExpression with no return type annotation with multiple return statements with subtype relation between returns
var Base = (function () {
function Base() {
}
@@ -29,6 +29,7 @@ var f3: {
} = D;
//// [functionLiteralForOverloads2.js]
// basic uses of function literals with constructor overloads
var C = (function () {
function C(x) {
}
@@ -142,6 +142,7 @@ function fn11() {
}
function fn12() {
}
//Function overloads that differ by accessibility
var cls = (function () {
function cls() {
}
@@ -114,6 +114,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// Basic type inference with generic calls and constraints, no errors expected
var Base = (function () {
function Base() {
}
@@ -23,6 +23,7 @@ var b: {
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
//// [genericCallWithFunctionTypedArguments4.js]
// No inference is made from function typed arguments which have multiple call signatures
var C = (function () {
function C() {
}
@@ -34,6 +34,8 @@ var r = foo2(c1, d1);
var r2 = foo2(c1, c1);
//// [genericCallWithObjectTypeArgsAndConstraints.js]
// Generic call with constraints infering type parameter from object member properties
// No errors expected
var C = (function () {
function C() {
}
@@ -45,6 +45,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// Generic call with constraints infering type parameter from object member properties
// No errors expected
var Base = (function () {
function Base() {
}
@@ -44,6 +44,7 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
// Generic call with constraints infering type parameter from object member properties
var Base = (function () {
function Base() {
}
@@ -34,6 +34,7 @@ function other<T, U extends T>() {
//// [genericCallWithObjectTypeArgsAndConstraints4.js]
// Generic call with constraints infering type parameter from object member properties
var C = (function () {
function C() {
}
@@ -25,6 +25,7 @@ function other<T, U extends T>() {
//// [genericCallWithObjectTypeArgsAndConstraints5.js]
// Generic call with constraints infering type parameter from object member properties
var C = (function () {
function C() {
}
@@ -61,6 +61,8 @@ module Interface {
}
//// [genericClassWithObjectTypeArgsAndConstraints.js]
// Generic call with constraints infering type parameter from object member properties
// No errors expected
var C = (function () {
function C() {
}
@@ -18,6 +18,7 @@ class Foo<T> {
//// [genericClassWithStaticsUsingTypeArguments.js]
// Should be error to use 'T' in all declarations within Foo.
var Foo = (function () {
function Foo() {
}
@@ -18,6 +18,7 @@ class Vec2_T<A>
}
//// [genericClasses4.js]
// once caused stack overflow
var Vec2_T = (function () {
function Vec2_T(x, y) {
this.x = x;

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