Skip to content

Commit f37a7f5

Browse files
author
Arthur Ozga
committed
Merge pull request microsoft#3712 from Microsoft/abstractExtraError
Abstract extra error
2 parents 6775d88 + 2331531 commit f37a7f5

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8456,6 +8456,7 @@ namespace ts {
84568456
let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration);
84578457
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
84588458
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
8459+
return resolveErrorCall(node);
84598460
}
84608461

84618462
// TS 1.0 spec: 4.11

tests/baselines/reference/classAbstractInstantiations1.errors.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'.
2-
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'.
2+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'.
3+
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'.
34

45

5-
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ====
6+
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ====
67

78
abstract class A {}
89

@@ -12,6 +13,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
1213

1314
new A;
1415
~~~~~
16+
!!! error TS2511: Cannot create an instance of the abstract class 'A'.
17+
new A(1); // should report 1 error
18+
~~~~~~~~
1519
!!! error TS2511: Cannot create an instance of the abstract class 'A'.
1620
new B;
1721
new C;

tests/baselines/reference/classAbstractInstantiations1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class B extends A {}
77
abstract class C extends B {}
88

99
new A;
10+
new A(1); // should report 1 error
1011
new B;
1112
new C;
1213

@@ -45,6 +46,7 @@ var C = (function (_super) {
4546
return C;
4647
})(B);
4748
new A;
49+
new A(1); // should report 1 error
4850
new B;
4951
new C;
5052
var a;

tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class B extends A {}
66
abstract class C extends B {}
77

88
new A;
9+
new A(1); // should report 1 error
910
new B;
1011
new C;
1112

0 commit comments

Comments
 (0)