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:
parent
646655d09a
commit
2baf90209b
|
@ -291,16 +291,14 @@ export class Esm5ReflectionHost extends Esm2015ReflectionHost {
|
||||||
*
|
*
|
||||||
* Given the outer variable declaration, we want to get to the inner function declaration.
|
* 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
|
* @param checker the TS program TypeChecker
|
||||||
* @returns the inner function declaration or `undefined` if it is not a "class".
|
* @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 {
|
|undefined {
|
||||||
if (!ts.isVariableDeclaration(node)) return undefined;
|
|
||||||
|
|
||||||
// Extract the IIFE body (if any).
|
// Extract the IIFE body (if any).
|
||||||
const iifeBody = getIifeBody(node);
|
const iifeBody = getIifeBody(decl);
|
||||||
if (!iifeBody) return undefined;
|
if (!iifeBody) return undefined;
|
||||||
|
|
||||||
// Extract the function declaration from inside the IIFE.
|
// Extract the function declaration from inside the IIFE.
|
||||||
|
|
Loading…
Reference in New Issue