Modified the emitComment logic to handle emitting leading or trailing spaces depending on flags

Leading comments have trailing separator while trailing comments have leading space
This removes the extra trailing space in the trailing comments
This commit is contained in:
Sheetal Nandi
2014-08-15 14:32:08 -07:00
parent 45e8ff8467
commit 6ab3adfd43
143 changed files with 171 additions and 163 deletions
+17 -9
View File
@@ -167,14 +167,23 @@ module ts {
});
}
function emitComments(comments: Comment[], writer: EmitTextWriter, writeComment: (comment: Comment, writer: EmitTextWriter) => void) {
function emitComments(comments: Comment[], trailingSeparator: boolean, writer: EmitTextWriter, writeComment: (comment: Comment, writer: EmitTextWriter) => void) {
var emitLeadingSpace = !trailingSeparator;
forEach(comments, comment => {
if (emitLeadingSpace) {
writer.write(" ");
emitLeadingSpace = false;
}
writeComment(comment, writer);
if (comment.hasTrailingNewLine) {
writer.writeLine();
} else {
} else if (trailingSeparator) {
writer.write(" ");
}
else {
// Emit leading space to separate comment during next comment emit
emitLeadingSpace = true;
}
});
}
@@ -1941,18 +1950,16 @@ module ts {
function emitLeadingDeclarationComments(node: Declaration) {
var leadingComments = getLeadingComments(currentSourceFile.text, node.pos);
emitNewLineBeforeLeadingComments(node, leadingComments, writer);
emitComments(leadingComments, writer, writeComment);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
emitComments(leadingComments, /*trailingSeparator*/ true, writer, writeComment);
}
function emitTrailingDeclarationComments(node: Declaration) {
// Emit the trailing declaration comments only if the parent's end doesnt match
if (node.parent.kind === SyntaxKind.SourceFile || node.end !== node.parent.end) {
var trailingComments = getTrailingComments(currentSourceFile.text, node.end);
if (trailingComments && trailingComments.length) {
// Trailing comments are emitting on same line, so write a space between comment
writer.write(" ");
}
emitComments(trailingComments, writer, writeComment);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
emitComments(trailingComments, /*trailingSeparator*/ false, writer, writeComment);
}
}
@@ -2068,7 +2075,8 @@ module ts {
if (declaration) {
var jsDocComments = getJsDocComments(declaration, currentSourceFile);
emitNewLineBeforeLeadingComments(declaration, jsDocComments, writer);
emitComments(jsDocComments, writer, writeCommentRange);
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
emitComments(jsDocComments, /*trailingSeparator*/ true, writer, writeCommentRange);
}
}
@@ -37,4 +37,4 @@ var A;
//// [test.js]
var p;
var p = A.Point.Origin;
var p = new A.Point(0, 0); // unexpected error here, bug 840000
var p = new A.Point(0, 0); // unexpected error here, bug 840000
@@ -28,4 +28,4 @@ var B = (function (_super) {
return B;
})(A);
var x;
var t = f(x, x); // Not an error
var t = f(x, x); // Not an error
@@ -18,4 +18,4 @@ var a = new x();
var b = new x('hello');
var c = new x(x);
// grammar allows this for constructors
var d = new x(x); // no error
var d = new x(x); // no error
@@ -135,4 +135,4 @@ var CC;
})(CC || (CC = {}));
var r3 = foo3(a); // any
var r3 = foo3(a); // any
var r3 = foo3(a); // any
var r3 = foo3(a); // any
@@ -56,4 +56,4 @@ var xs = [list, myList]; // {}[]
var ys = [list, list2]; // {}[]
var zs = [list, null]; // List<number>[]
var myDerivedList;
var as = [list, myDerivedList]; // List<number>[]
var as = [list, myDerivedList]; // List<number>[]
@@ -50,4 +50,4 @@ var b2;
var c2;
var z2 = [a2, b2, c2];
var r6 = z2[0];
var r7 = r6(''); // any not string
var r7 = r6(''); // any not string
@@ -29,4 +29,4 @@ var r4b = new r3(); // error
var x3;
var r5 = x2[1];
var r6 = r5();
var r6b = new r5(); // error
var r6b = new r5(); // error
@@ -59,4 +59,4 @@ var bad;
(function (bad) {
bad.apply = 0;
})(bad || (bad = {}));
var badFundule = bad; // error
var badFundule = bad; // error
@@ -26,4 +26,4 @@ var o = {};
var f = function () {
};
var v1 = o; // Should be allowed
var v2 = f; // Should be allowed
var v2 = f; // Should be allowed
@@ -16,4 +16,4 @@ var b = (() => { })[0]; // Should be Bar
//// [augmentedTypeBracketAccessIndexSignature.js]
var a = {}[0]; // Should be Foo
var b = (function () {
})[0]; // Should be Bar
})[0]; // Should be Bar
@@ -20,4 +20,4 @@ var f = function () {
var r1 = o['data']; // Should be number
var r2 = o['functionData']; // Should be any (no property found)
var r3 = f['functionData']; // Should be string
var r4 = f['data']; // Should be number
var r4 = f['data']; // Should be number
@@ -28,4 +28,4 @@ var c4 = (function () {
var c4;
(function (c4) {
c4[c4["One"] = 0] = "One";
})(c4 || (c4 = {})); // error
})(c4 || (c4 = {})); // error
@@ -22,4 +22,4 @@ var m3a = (function () {
m3a.prototype.foo = function () {
};
return m3a;
})(); // error, class isn't ambient or declared before the module
})(); // error, class isn't ambient or declared before the module
@@ -28,4 +28,4 @@ var e;
var arr = [e]; // Ellement[]
var obj = { s: e }; // { s: Ellement; [s: string]: Ellement }
var conditional = null ? e : e; // Ellement
var contextualOr = e || e; // Ellement
var contextualOr = e || e; // Ellement
@@ -7,4 +7,4 @@ var y = i(""); // y should be string
//// [callExpressionWithTypeParameterConstrainedToOuterTypeParameter.js]
var i;
var y = i(""); // y should be string
var y = i(""); // y should be string
@@ -32,4 +32,4 @@ var E = (function (_super) {
_super.apply(this, arguments);
}
return E;
})(E); // error
})(E); // error
@@ -21,4 +21,4 @@ var C = (function (_super) {
_super.apply(this, arguments);
}
return C;
})(foo); // error, cannot extend it though
})(foo); // error, cannot extend it though
@@ -48,4 +48,4 @@ var C = (function (_super) {
})(A);
var r1 = B; // error
var r2 = B; // error
var r3 = C; // ok
var r3 = C; // ok
@@ -97,4 +97,4 @@ var D3 = (function (_super) {
})(Base2);
var r4 = D3;
var d5 = new D(); // error
var d6 = new D(1); // ok
var d6 = new D(1); // ok
@@ -33,4 +33,4 @@ var D = (function () {
return D;
})();
var d = new D();
var d2 = new D(null); // error
var d2 = new D(null); // error
+1 -1
View File
@@ -80,4 +80,4 @@ var m3d;
m3d.y = 2;
})(m3d || (m3d = {}));
var r = new m3d(); // error
var r2 = new m4d(); // error
var r2 = new m4d(); // error
@@ -12,4 +12,4 @@ var a;
a.b = 10;
})(a || (a = {}));
var f = function () { return _this; };
var _this = a; // Error
var _this = a; // Error
@@ -7,4 +7,4 @@ var a = new _this(); // Error
//// [collisionThisExpressionAndAmbientClassInGlobal.js]
var _this = this;
var f = function () { return _this; };
var a = new _this(); // Error
var a = new _this(); // Error
+2 -2
View File
@@ -79,14 +79,14 @@ var c3 = (function () {
function c3() {
} // trailing comment of constructor
return c3;
})(); /* trailing comment 2 */
})(); /* trailing comment 2 */
var i3 = new c3();
var i3_c = c3;
/** Class comment*/
var c4 = (function () {
/** Constructor comment*/
function c4() {
} /* trailing comment of constructor 2*/
} /* trailing comment of constructor 2*/
return c4;
})();
var i4 = new c4();
@@ -227,7 +227,7 @@ var c1 = (function () {
/** sum with property*/
c1.prototype.p2 = function (b) {
return this.p1 + b;
}; /* trailing comment of method*/
}; /* trailing comment of method*/
Object.defineProperty(c1.prototype, "p3", {
/** getter property*/
get: function () {
@@ -266,11 +266,11 @@ var c1 = (function () {
/** static getter property*/
get: function () {
return c1.s2(c1.s1);
} /*trailing comment 1 getter*/ ,
} /*trailing comment 1 getter*/,
/** setter property*/
set: function (value) {
c1.s1 = c1.s2(value);
} /*trailing comment 2 */ /*setter*/ ,
} /*trailing comment 2 */ /*setter*/,
enumerable: true,
configurable: true
});
@@ -437,7 +437,7 @@ c1.nc_s3 = i1_s_ncprop;
var i1_c = c1;
var cProperties = (function () {
function cProperties() {
this.x = 10; /*trailing comment for property*/
this.x = 10; /*trailing comment for property*/
this.y = 10; // trailing comment of // style
}
Object.defineProperty(cProperties.prototype, "p1", {
@@ -467,7 +467,7 @@ var cProperties = (function () {
Object.defineProperty(cProperties.prototype, "nc_p2", {
set: function (value) {
this.val = value;
} /* trailing comment of setter only*/ ,
} /* trailing comment of setter only*/,
enumerable: true,
configurable: true
});
+1 -1
View File
@@ -17,7 +17,7 @@ x = Colors.FancyPink;
var Colors;
(function (Colors) {
/** Fancy name for 'blue'*/
Colors[Colors["Cornflower"] = 0] = "Cornflower"; /* blue */
Colors[Colors["Cornflower"] = 0] = "Cornflower"; /* blue */
/** Fancy name for 'pink'*/
Colors[Colors["FancyPink"] = 1] = "FancyPink";
})(Colors || (Colors = {})); // trailing comment
@@ -40,7 +40,7 @@ lambdaFoo = (a, b) => a * b; // This is trailing comment that will not get emitt
//// [commentsFunction.js]
/** This comment should appear for foo*/
function foo() {
} /* trailing comment of function */
} /* trailing comment of function */
foo();
/** This is comment for function signature*/
function fooWithParameters(a,
@@ -61,9 +61,9 @@ var lambddaNoVarComment = function (a, b) { return a * b; };
lambdaFoo(10, 20);
lambddaNoVarComment(10, 20);
function blah(a /* multiline trailing comment
multiline */ ) {
multiline */) {
}
function blah2(a /* single line multiple trailing comments */ /* second */ ) {
function blah2(a /* single line multiple trailing comments */ /* second */) {
}
function blah3(a // trailing commen single line
) {
+2 -2
View File
@@ -157,7 +157,7 @@ var m2;
m3.c = c;
})(m2.m3 || (m2.m3 = {}));
var m3 = m2.m3;
})(m2 || (m2 = {})); /* trailing dotted module comment*/
})(m2 || (m2 = {})); /* trailing dotted module comment*/
new m2.m3.c();
/** module comment of m3.m4.m5*/
var m3;
@@ -191,7 +191,7 @@ var m4;
})();
m7.c = c;
})(m6.m7 || (m6.m7 = {}));
var m7 = m6.m7; /* trailing inner module */ /* multiple comments*/
var m7 = m6.m7; /* trailing inner module */ /* multiple comments*/
})(m5.m6 || (m5.m6 = {}));
var m6 = m5.m6;
})(m4.m5 || (m4.m5 = {}));
@@ -21,5 +21,5 @@ var Person = makeClass({
*/
initialize: function (name) {
this.name = name;
} /* trailing comment 1*/
} /* trailing comment 1*/
});
@@ -22,7 +22,7 @@ var v = {
//// [commentsOnObjectLiteral3.js]
var v = {
//property
prop: 1 /* multiple trailing comments */ /*trailing comments*/ ,
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
//property
func: function () {
},
@@ -34,7 +34,7 @@ var v = {
//getter
get a() {
return this.prop;
} /*trailing 1*/ ,
} /*trailing 1*/,
//setter
set a(value) {
this.prop = value;
+2 -2
View File
@@ -52,12 +52,12 @@ var anotherVariable = 30;
var aVar = "";
/** this is multiline comment
* All these variables are of number type */
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
/** Triple slash multiline comment*/
/** another line in the comment*/
/** comment line 2*/
var x = 70; /* multiline trailing comment
this is multiline trailing comment */
this is multiline trailing comment */
x = myVariable;
/** triple slash comment1*/
/** jsdocstyle comment - only this comment should be in .d.ts file*/
@@ -2,4 +2,4 @@
var x: boolean = (true ? 1 : ""); // should be an error
//// [conditionalExpression1.js]
var x = (true ? 1 : ""); // should be an error
var x = (true ? 1 : ""); // should be an error
+1 -1
View File
@@ -19,4 +19,4 @@ var y = v1.x.a; // 'a' should be of type 'number'
//// [constraints0.js]
var v1; // should work
var v2; // should not work
var y = v1.x.a; // 'a' should be of type 'number'
var y = v1.x.a; // 'a' should be of type 'number'
@@ -37,4 +37,4 @@ var D = (function () {
var d;
var r = d.y;
var r2 = d.x; // error
var r3 = d.a; // error
var r3 = d.a; // error
@@ -46,4 +46,4 @@ var E = (function () {
return E;
})();
var e;
var r3 = e.y; // error
var r3 = e.y; // error
@@ -11,4 +11,4 @@ var r100 = map2(e2); // type arg inference should fail for S since a generic lam
var e = function (x, y) { return x.length; };
var r99 = map(e); // should be {}[] for S since a generic lambda is not inferentially typed
var e2 = function (x, y) { return x.length; };
var r100 = map2(e2); // type arg inference should fail for S since a generic lambda is not inferentially typed. Falls back to { length: number }
var r100 = map2(e2); // type arg inference should fail for S since a generic lambda is not inferentially typed. Falls back to { length: number }
@@ -14,4 +14,4 @@ function f() {
return g;
}
var h;
var x = h("", f()); // Call should succeed and x should be string. All type parameters should be instantiated to string
var x = h("", f()); // Call should succeed and x should be string. All type parameters should be instantiated to string
@@ -6,4 +6,4 @@ var r9 = f10('', () => (a => a.foo), 1); // now a should be any
//// [contextualTypingWithFixedTypeParameters1.js]
var f10;
f10('', function () { return function (a) { return a.foo; }; }, '');
var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // now a should be any
var r9 = f10('', function () { return (function (a) { return a.foo; }); }, 1); // now a should be any
@@ -66,4 +66,4 @@ var D = (function (_super) {
return D;
})(Base2);
var d = new D(); // error
var d2 = new D(new Date()); // ok
var d2 = new D(new Date()); // ok
@@ -108,4 +108,4 @@ var D2 = (function (_super) {
})(D);
var d = new D2(); // error
var d2 = new D2(new Date()); // error
var d3 = new D2(new Date(), new Date()); // ok
var d3 = new D2(new Date(), new Date()); // ok
@@ -31,4 +31,4 @@ var N;
var y; //error
})(N || (N = {}));
var z;
var z; // ok
var z; // ok
+1 -1
View File
@@ -14,4 +14,4 @@ var n = x[''].m(); // should not crash compiler
//// [emptyIndexer.js]
var x;
var n = x[''].m(); // should not crash compiler
var n = x[''].m(); // should not crash compiler
@@ -22,4 +22,4 @@ var x = new Sammy(); // error to use as constructor as there is not constructor
var y = Sammy(); // error to use interface name as call target
var z; // no error - z is of type interface Sammy from module 'M'
var a = new z(); // constructor - no error
var b = z(); // call signature - no error
var b = z(); // call signature - no error
@@ -24,4 +24,4 @@ var C = (function (_super) {
_super.apply(this, arguments);
}
return C;
})(x); // error, could not find symbol xs
})(x); // error, could not find symbol xs
@@ -22,4 +22,4 @@ var C = (function (_super) {
_super.apply(this, arguments);
}
return C;
})(Foo); // error, could not find symbol Foo
})(Foo); // error, could not find symbol Foo
+1 -1
View File
@@ -32,4 +32,4 @@ var foo3 = (function () {
function foo3() {
}
return foo3;
})(); // Should error
})(); // Should error
@@ -15,4 +15,4 @@ var e: ParserFunc = parsers.readline(); // ok
var parsers;
var c = parsers.raw; // ok!
var d = parsers.readline; // not ok
var e = parsers.readline(); // ok
var e = parsers.readline(); // ok
@@ -157,4 +157,4 @@ var r7 = i.foo4('', true); // string
var r8 = i.foo5(true, 1); // boolean
var r9 = i.foo6(); // {}
var r10 = i.foo7(''); // {}
var r11 = i.foo8(); // {}
var r11 = i.foo8(); // {}
@@ -22,4 +22,4 @@ var r = foo(1); // ok
var r2 = foo(null); // {}
var r3 = foo(new Object()); // {}
var r4 = foo(1); // error
var r5 = foo(new Date()); // no error
var r5 = foo(new Date()); // no error
@@ -67,4 +67,4 @@ function foo3(x, cb, y) {
var r7 = foo3(null, i, ''); // any
var r7b = foo3(null, a, ''); // any
var r8 = foo3(1, i2, 1); // {}
var r9 = foo3('', i2, ''); // string
var r9 = foo3('', i2, ''); // string
@@ -29,4 +29,4 @@ function foo4(cb) {
}
var r = foo4(a); // T is {} (candidates boolean and string), U is any (candidates any and boolean)
var b;
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
@@ -41,4 +41,4 @@ function foo4(cb) {
}
var r = foo4(a); // T is {} (candidates boolean and string), U is {} (candidates C and D)
var b;
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
var r2 = foo4(b); // T is {} (candidates boolean and {}), U is any (candidates any and {})
@@ -70,4 +70,4 @@ function foo3(x, a, b) {
var r;
return r;
}
var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error
var r7 = foo3(0 /* A */, function (x) { return 0 /* A */; }, function (x) { return 0 /* A */; }); // error
@@ -64,4 +64,4 @@ var r9 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); /
var r10 = foo2(null, function (x) { return ''; }, function (x) { return ''; }); // Object => Object
var x;
var r11 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // {} => {}
var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // (string => boolean) => {}
var r12 = foo2(x, function (a1) { return function (n) { return 1; }; }, function (a2) { return 2; }); // (string => boolean) => {}
@@ -53,4 +53,4 @@ var r6 = foo(y, x); // { x?: number; };
var s1;
var s2;
var r7 = foo(s1, s2); // (x: Object) => string;
var r8 = foo(s2, s1); // (x: string) => string;
var r8 = foo(s2, s1); // (x: string) => string;
@@ -17,4 +17,4 @@ var r = foo({ bar: 1, baz: '' }); // T = {}
var r2 = foo({ bar: 1, baz: 1 }); // T = number
// BUG 835724
var r3 = foo({ bar: foo, baz: foo }); // T = any
var r4 = foo({ bar: 1, baz: '' }); // T = Object
var r4 = foo({ bar: 1, baz: '' }); // T = Object
@@ -44,4 +44,4 @@ function foo(t, t2) {
var c1 = new X();
var d1 = new X();
var r = foo(c1, d1); // error
var r2 = foo(c1, c1); // ok
var r2 = foo(c1, c1); // ok
@@ -69,4 +69,4 @@ function f2(a) {
}
var r3 = f2({ x: new Derived(), y: new Derived2() }); // Derived => Derived2
var i;
var r4 = f2(i); // Base => Derived
var r4 = f2(i); // Base => Derived
@@ -33,4 +33,4 @@ function foo6(x, y, z) {
} // error
function foo7(x, y) {
if (y === void 0) { y = x; }
} // should be ok
} // should be ok
+1 -1
View File
@@ -14,7 +14,7 @@ var C = (function () {
return C;
})();
var v1;
var y = v1.x; // should be 'string'
var y = v1.x; // should be 'string'
//// [genericClasses0.d.ts]
+1 -1
View File
@@ -14,7 +14,7 @@ var C = (function () {
return C;
})();
var v1 = new C();
var y = v1.x; // should be 'string'
var y = v1.x; // should be 'string'
//// [genericClasses1.d.ts]
+1 -1
View File
@@ -24,7 +24,7 @@ var C = (function () {
var v1;
var y = v1.x; // should be 'string'
var w = v1.y.a; // should be 'string'
var z = v1.z.a; // should be 'number'
var z = v1.z.a; // should be 'number'
//// [genericClasses2.d.ts]
@@ -29,4 +29,4 @@ var MyList = (function () {
var a;
var b = a.clone(); // ok
var c = a.clone(); // bug was there was an error on this line
var d = a.clone(); // error
var d = a.clone(); // error
@@ -7,7 +7,7 @@ var x = foo<number>(5); // 'x' should be number
function foo(x) {
return x;
}
var x = foo(5); // 'x' should be number
var x = foo(5); // 'x' should be number
//// [genericFunctions0.d.ts]
@@ -7,7 +7,7 @@ var x = foo(5); // 'x' should be number
function foo(x) {
return x;
}
var x = foo(5); // 'x' should be number
var x = foo(5); // 'x' should be number
//// [genericFunctions1.d.ts]
@@ -59,4 +59,4 @@ var Z = (function () {
return undefined;
};
return Z;
})(); // { f: <T>() => T }
})(); // { f: <T>() => T }
@@ -30,4 +30,4 @@ var age_v = o.age(); // should be 'number'
var name_v = o.name("Robert"); // should be 'any'
var zz_v = o.name.N; // should be 'number'
var yy_v = o.name.g; // should be 'boolean'
var rr_v = o.name.r; // should be 'string'
var rr_v = o.name.r; // should be 'string'
@@ -43,4 +43,4 @@ var M;
var g1 = new G();
g1.bar(null).foo();
})(M || (M = {}));
var g2 = new G(); // was: error Type reference cannot refer to container 'M.C'.
var g2 = new G(); // was: error Type reference cannot refer to container 'M.C'.
+1 -1
View File
@@ -29,4 +29,4 @@ function makeArrayGOpt(item1, item2, item3) {
}
var a2Ga = makeArrayGOpt(1, "");
var a2Gb = makeArrayG(1, "");
var a2Gc = makeArrayG(1, ""); // error
var a2Gc = makeArrayG(1, ""); // error
@@ -14,4 +14,4 @@ var A = (function () {
})();
var foo = new A();
var r = new A(); // error
var r2 = foo; // error
var r2 = foo; // error
@@ -42,4 +42,4 @@ var r = new B();
var r2 = new B(); // error
var r3 = new B(); // error
var r4 = new A();
var r5 = []; // error
var r5 = []; // error
@@ -19,4 +19,4 @@ var LazyArray = (function () {
return LazyArray;
})();
var lazyArray = new LazyArray();
var value = lazyArray.array()["test"]; // used to be an error
var value = lazyArray.array()["test"]; // used to be an error
+1 -1
View File
@@ -9,7 +9,7 @@ var z = v2.x; // 'y' should be of type 'string'
//// [generics0.js]
var v2;
var z = v2.x; // 'y' should be of type 'string'
var z = v2.x; // 'y' should be of type 'string'
//// [generics0.d.ts]
@@ -13,7 +13,7 @@ var v4: G<G<A, B>, C>; // Ok
//// [generics1NoError.js]
var v1; // Ok
var v2; // Ok, equivalent to G<A, C>
var v4; // Ok
var v4; // Ok
//// [generics1NoError.d.ts]
@@ -20,7 +20,7 @@ var v4: G<G<A, B>, C>; // Ok
//// [generics2NoError.js]
var v1; // Ok
var v2; // Ok, equivalent to G<A, C>
var v4; // Ok
var v4; // Ok
//// [generics2NoError.d.ts]
+1 -1
View File
@@ -2,4 +2,4 @@
var __e = Math.E; // should not generate 'this.Math.E'
//// [globalThis.js]
var __e = Math.E; // should not generate 'this.Math.E'
var __e = Math.E; // should not generate 'this.Math.E'
@@ -6,4 +6,4 @@ var x: any = new Point(); // error at "new"
function Point() {
this.x = 3;
}
var x = new Point(); // error at "new"
var x = new Point(); // error at "new"
+1 -1
View File
@@ -4,4 +4,4 @@ var r: Date = dateMap["hello"] // result type includes indexer using BCT
//// [indexer3.js]
var dateMap = {};
var r = dateMap["hello"]; // result type includes indexer using BCT
var r = dateMap["hello"]; // result type includes indexer using BCT
@@ -8,4 +8,4 @@ var i = result[0].x; // number
var pair;
var zipWith;
var result = zipWith([1, 2], ['a', 'b'], pair);
var i = result[0].x; // number
var i = result[0].x; // number
@@ -23,4 +23,4 @@ var Foo = (function () {
})();
var i;
var r = i.y;
var r2 = i.x; // error
var r2 = i.x; // error
@@ -46,4 +46,4 @@ var Baz = (function () {
var i;
var r = i.z;
var r2 = i.x; // error
var r3 = i.y; // error
var r3 = i.y; // error
@@ -243,4 +243,4 @@ var rf6 = a6 || undefined; // enum || undefined is E
var rf7 = a7 || undefined; // object || undefined is object
var rf8 = a8 || undefined; // array || undefined is array
var rf9 = null || undefined; // null || undefined is any
var rf10 = undefined || undefined; // undefined || undefined is any
var rf10 = undefined || undefined; // undefined || undefined is any
@@ -81,4 +81,4 @@ var r = c.foo(1); // error
var d;
var r2 = d.foo(2); // error
var r3 = C.foo(1); // error
var r4 = D.bar(''); // error
var r4 = D.bar(''); // error
@@ -75,4 +75,4 @@ var D = (function () {
var c;
var r = c.foo(1); // error
var d;
var r2 = d.foo(2); // error
var r2 = d.foo(2); // error
@@ -43,4 +43,4 @@ var E = (function () {
return E;
})();
var a;
var r = a.x; // error
var r = a.x; // error
@@ -64,4 +64,4 @@ var E = (function (_super) {
})(C2);
var a;
var r = a.x; // error
var r2 = a.w; // error
var r2 = a.w; // error
@@ -18,4 +18,4 @@ var c: C; // error
//// [moduleWithNoValuesAsType.js]
var a; // error
var b; // error
var c; // error
var c; // error
@@ -10,4 +10,4 @@ var A;
(function (A) {
var b = 1;
})(A || (A = {}));
var a; // no error
var a; // no error
@@ -7,4 +7,4 @@ var y = new i(""); // y should be string
//// [newExpressionWithTypeParameterConstrainedToOuterTypeParameter.js]
var i;
var y = new i(""); // y should be string
var y = new i(""); // y should be string
@@ -23,4 +23,4 @@ var Bar = (function (_super) {
_super.apply(this, arguments);
}
return Bar;
})(Foo); // Valid
})(Foo); // Valid
@@ -4,4 +4,4 @@ var y: typeof undefined = null; // ok, widened
//// [nullAssignedToUndefined.js]
var x = undefined = null; // error
var y = null; // ok, widened
var y = null; // ok, widened
@@ -16,4 +16,4 @@ var r2: string = i2[1]; // error: numeric indexer returns the type of the string
var i;
var r = i[1]; // error: numeric indexer returns the type of the string indexer
var i2;
var r2 = i2[1]; // error: numeric indexer returns the type of the string indexer
var r2 = i2[1]; // error: numeric indexer returns the type of the string indexer
@@ -34,4 +34,4 @@ var I2 = (function (_super) {
var i;
var r = i[1]; // error: numeric indexer returns the type of the string indexer
var i2;
var r2 = i2[1]; // error: numeric indexer returns the type of the string indexere
var r2 = i2[1]; // error: numeric indexer returns the type of the string indexere
@@ -2,4 +2,4 @@
var a = { b: 10, c: b }; // Should give error for attempting to reference b.
//// [objectLiteralReferencingInternalProperties.js]
var a = { b: 10, c: b }; // Should give error for attempting to reference b.
var a = { b: 10, c: b }; // Should give error for attempting to reference b.
@@ -44,4 +44,4 @@ var r2 = x.apply;
var r2b = x.call;
var r2c = x.arguments;
var r2d = x.data;
var r2e = x['hm']; // should be Object
var r2e = x['hm']; // should be Object
@@ -41,4 +41,4 @@ var r2 = x.apply;
var r2b = x.call;
var r2c = x.arguments;
var r2d = x.data;
var r2e = x['hm']; // should be Object
var r2e = x['hm']; // should be Object
@@ -7,4 +7,4 @@ var i2: I = { x1: (a: number, cb: (x: 'hi') => number) => { } }; // error
//// [overloadOnConstInObjectLiteralImplementingAnInterface.js]
var i2 = { x1: function (a, cb) {
} }; // error
} }; // error
@@ -45,4 +45,4 @@ function foo4(bar) {
return bar;
}
;
var x = foo4({ a: true }); // error
var x = foo4({ a: true }); // error
@@ -64,4 +64,4 @@ function bar(x, items) {
}
var d = bar("hi", []); // D
var e = bar("bye", []); // E
var f = bar("um", []); // C
var f = bar("um", []); // C

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