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
This commit is contained in:
George Kalpakas 2020-02-15 10:55:47 +02:00 committed by Miško Hevery
parent 646655d09a
commit 2baf90209b
1 changed files with 3 additions and 5 deletions

View File

@ -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.