diff --git a/packages/compiler-cli/src/ngtsc/reflection/src/util.ts b/packages/compiler-cli/src/ngtsc/reflection/src/util.ts index f49d0b531e..8aaffc8b24 100644 --- a/packages/compiler-cli/src/ngtsc/reflection/src/util.ts +++ b/packages/compiler-cli/src/ngtsc/reflection/src/util.ts @@ -11,15 +11,19 @@ import {ClassDeclaration} from './host'; export function isNamedClassDeclaration(node: ts.Node): node is ClassDeclaration { - return ts.isClassDeclaration(node) && (node.name !== undefined); + return ts.isClassDeclaration(node) && isIdentifier(node.name); } export function isNamedFunctionDeclaration(node: ts.Node): node is ClassDeclaration { - return ts.isFunctionDeclaration(node) && (node.name !== undefined); + return ts.isFunctionDeclaration(node) && isIdentifier(node.name); } export function isNamedVariableDeclaration(node: ts.Node): node is ClassDeclaration { - return ts.isVariableDeclaration(node) && (node.name !== undefined); + return ts.isVariableDeclaration(node) && isIdentifier(node.name); +} + +function isIdentifier(node: ts.Node|undefined): node is ts.Identifier { + return node !== undefined && ts.isIdentifier(node); }