diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d72e74f748eb6..b68dc3c2e6fc7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt index 0221ce07f959a..6171ef2efab66 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -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; diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js index 39e6754292641..f3a0eecada9e9 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -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; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts index c9ca4afb18d88..4daf27b53e44f 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -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;