Use symbol fully-qualified name instead of node text in error message (#11761)

* Add test

* Add baselines

* Use fqn of symbol instead of node text
This commit is contained in:
Asad Saeeduddin
2016-10-25 14:45:32 -04:00
committed by Mohamed Hegazy
parent 48f947f50d
commit 66c1178134
4 changed files with 48 additions and 1 deletions

View File

@@ -17234,7 +17234,7 @@ namespace ts {
if (declaration && getModifierFlags(declaration) & ModifierFlags.Private) {
const typeClassDeclaration = <ClassLikeDeclaration>getClassLikeDeclarationOfSymbol(type.symbol);
if (!isNodeWithinClass(node, typeClassDeclaration)) {
error(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, (<Identifier>node.expression).text);
error(node, Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
}
}
}

View File

@@ -0,0 +1,15 @@
tests/cases/compiler/extendPrivateConstructorClass.ts(7,17): error TS2675: Cannot extend a class 'abc.XYZ'. Class constructor is marked as private.
==== tests/cases/compiler/extendPrivateConstructorClass.ts (1 errors) ====
declare namespace abc {
class XYZ {
private constructor();
}
}
class C extends abc.XYZ {
~~~~~~~
!!! error TS2675: Cannot extend a class 'abc.XYZ'. Class constructor is marked as private.
}

View File

@@ -0,0 +1,24 @@
//// [extendPrivateConstructorClass.ts]
declare namespace abc {
class XYZ {
private constructor();
}
}
class C extends abc.XYZ {
}
//// [extendPrivateConstructorClass.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var C = (function (_super) {
__extends(C, _super);
function C() {
return _super.apply(this, arguments) || this;
}
return C;
}(abc.XYZ));

View File

@@ -0,0 +1,8 @@
declare namespace abc {
class XYZ {
private constructor();
}
}
class C extends abc.XYZ {
}