mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 01:43:59 -05:00
Merge pull request #3712 from Microsoft/abstractExtraError
Abstract extra error
This commit is contained in:
@@ -8456,6 +8456,7 @@ namespace ts {
|
||||
let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration);
|
||||
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
|
||||
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
// TS 1.0 spec: 4.11
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ====
|
||||
|
||||
abstract class A {}
|
||||
|
||||
@@ -12,6 +13,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
|
||||
new A;
|
||||
~~~~~
|
||||
!!! error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
new A(1); // should report 1 error
|
||||
~~~~~~~~
|
||||
!!! error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
new B;
|
||||
new C;
|
||||
|
||||
@@ -7,6 +7,7 @@ class B extends A {}
|
||||
abstract class C extends B {}
|
||||
|
||||
new A;
|
||||
new A(1); // should report 1 error
|
||||
new B;
|
||||
new C;
|
||||
|
||||
@@ -45,6 +46,7 @@ var C = (function (_super) {
|
||||
return C;
|
||||
})(B);
|
||||
new A;
|
||||
new A(1); // should report 1 error
|
||||
new B;
|
||||
new C;
|
||||
var a;
|
||||
|
||||
@@ -6,6 +6,7 @@ class B extends A {}
|
||||
abstract class C extends B {}
|
||||
|
||||
new A;
|
||||
new A(1); // should report 1 error
|
||||
new B;
|
||||
new C;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user