@@ -4763,40 +4763,35 @@ namespace ts {
4763
4763
let targetSignatures = getSignaturesOfType(target, kind);
4764
4764
let result = Ternary.True;
4765
4765
let saveErrorInfo = errorInfo;
4766
+
4767
+ // Because the "abstractness" of a class is the same across all construct signatures
4768
+ // (internally we are checking the corresponding declaration), it is enough to perform
4769
+ // the check and report an error once over all pairs of source and target construct signatures.
4770
+ let sourceErasedSignature = getErasedSignature(s);
4771
+ let targetErasedSignature = getErasedSignature(t);
4772
+
4773
+ let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
4774
+ let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
4775
+
4776
+ let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration);
4777
+ let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration);
4778
+ let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract;
4779
+ let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract;
4780
+
4781
+ if (sourceIsAbstract && !targetIsAbstract) {
4782
+ if (reportErrors) {
4783
+ reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
4784
+ }
4785
+ result = Ternary.False;
4786
+ }
4787
+
4766
4788
outer: for (let t of targetSignatures) {
4767
4789
if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) {
4768
4790
let localErrors = reportErrors;
4769
4791
let checkedAbstractAssignability = false;
4770
4792
for (let s of sourceSignatures) {
4771
4793
if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) {
4772
- let related = Ternary.True;
4773
-
4774
- // Because the "abstractness" of a class is the same across all construct signatures
4775
- // (internally we are checking the corresponding declaration), it is enough to perform
4776
- // the check and report an error once over all pairs of source and target construct signatures.
4777
- if (!checkedAbstractAssignability) {
4778
- checkedAbstractAssignability = true;
4779
-
4780
- let sourceErasedSignature = getErasedSignature(s);
4781
- let targetErasedSignature = getErasedSignature(t);
4782
-
4783
- let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
4784
- let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
4785
-
4786
- let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration);
4787
- let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration);
4788
- let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract;
4789
- let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract;
4790
-
4791
- if (sourceIsAbstract && !targetIsAbstract) {
4792
- if (reportErrors) {
4793
- reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
4794
- }
4795
- related = Ternary.False;
4796
- }
4797
- }
4798
-
4799
- related &= signatureRelatedTo(s, t, localErrors);
4794
+ let related = signatureRelatedTo(s, t, localErrors);
4800
4795
if (related) {
4801
4796
result &= related;
4802
4797
errorInfo = saveErrorInfo;
0 commit comments