From 2baf90209bf79e23f93a729d2bbe35cf85a1c710 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Sat, 15 Feb 2020 10:55:47 +0200 Subject: [PATCH] refactor(ngcc): tighten method parameter type to avoid redundant check (#35527) `Esm5ReflectionHost#getInnerFunctionDeclarationFromClassDeclaration()` was already called with `ts.Declaration`, not `ts.Node`, so we can tighten its parameter type and get rid of a redundant check. `getIifeBody()` (called inside `getInnerFunctionDeclarationFromClassDeclaration()`) will check whether the given `ts.Declaration` is a `ts.VariableDeclaration`. PR Close #35527 --- packages/compiler-cli/ngcc/src/host/esm5_host.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/host/esm5_host.ts b/packages/compiler-cli/ngcc/src/host/esm5_host.ts index 4307af7d23..ad14081330 100644 --- a/packages/compiler-cli/ngcc/src/host/esm5_host.ts +++ b/packages/compiler-cli/ngcc/src/host/esm5_host.ts @@ -291,16 +291,14 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost { * * Given the outer variable declaration, we want to get to the inner function declaration. * - * @param node a node that could be the variable expression outside an ES5 class IIFE. + * @param decl a declaration node that could be the variable expression outside an ES5 class IIFE. * @param checker the TS program TypeChecker * @returns the inner function declaration or `undefined` if it is not a "class". */ - protected getInnerFunctionDeclarationFromClassDeclaration(node: ts.Node): ts.FunctionDeclaration + protected getInnerFunctionDeclarationFromClassDeclaration(decl: ts.Declaration): ts.FunctionDeclaration |undefined { - if (!ts.isVariableDeclaration(node)) return undefined; - // Extract the IIFE body (if any). - const iifeBody = getIifeBody(node); + const iifeBody = getIifeBody(decl); if (!iifeBody) return undefined; // Extract the function declaration from inside the IIFE.