From c128013f8b7ccabe67b5cd530b46c34f91d4da02 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Mon, 17 Jan 2022 16:33:55 +0800 Subject: [PATCH] houhaoyu@huawei.com Signed-off-by: houhaoyu Change-Id: Id233772e485a4de49f409980d20fd7f3cc85bcc2 --- compiler/src/process_component_class.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index 1ac7be84b..14033256e 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -82,11 +82,13 @@ export function processComponentClass(node: ts.ClassDeclaration, context: ts.Tra function checkPreview(node: ts.ClassDeclaration) { let hasPreview: boolean = false; - for (let i = 0; i < node.decorators.length; i++) { - const name: string = node.decorators[i].getText().replace(/\((.|\n)*\)/, '').trim(); - if (name === COMPONENT_DECORATOR_PREVIEW) { - hasPreview = true; - break; + if (node && node.decorators) { + for (let i = 0; i < node.decorators.length; i++) { + const name: string = node.decorators[i].getText().replace(/\((.|\n)*\)/, '').trim(); + if (name === COMPONENT_DECORATOR_PREVIEW) { + hasPreview = true; + break; + } } } return hasPreview; -- Gitee