mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 16:39:46 -05:00
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:
committed by
Mohamed Hegazy
parent
48f947f50d
commit
66c1178134
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
24
tests/baselines/reference/extendPrivateConstructorClass.js
Normal file
24
tests/baselines/reference/extendPrivateConstructorClass.js
Normal 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));
|
||||
8
tests/cases/compiler/extendPrivateConstructorClass.ts
Normal file
8
tests/cases/compiler/extendPrivateConstructorClass.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
declare namespace abc {
|
||||
class XYZ {
|
||||
private constructor();
|
||||
}
|
||||
}
|
||||
|
||||
class C extends abc.XYZ {
|
||||
}
|
||||
Reference in New Issue
Block a user