diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f3273c6e614..a3772ac78f0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7284,8 +7284,11 @@ namespace ts { */ function getSuperCallInConstructor(constructor: ConstructorDeclaration): ExpressionStatement { const links = getNodeLinks(constructor); - if (!links.superCall) { + + // Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result + if (links.hasSuperCall === undefined) { links.superCall = findFirstSuperCall(constructor.body); + links.hasSuperCall = links.superCall ? true : false; } return links.superCall; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b99b7a29518..d0f1deff584 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -459,7 +459,6 @@ namespace ts { IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement, } - /* @internal */ export const enum RelationComparisonResult { Succeeded = 1, // Should be truthy @@ -2088,6 +2087,7 @@ namespace ts { importOnRightSide?: Symbol; // for import declarations - import that appear on the right side jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element + hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt. superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing }