From 042c148b5d5543ded91dd50f4e844dd53540fb1b Mon Sep 17 00:00:00 2001 From: farewell-zy <84722638+farewell-zy@users.noreply.github.com> Date: Mon, 10 Oct 2022 22:58:13 +0800 Subject: [PATCH] =?UTF-8?q?start=EF=BC=8Cend=E5=AD=98=E5=9C=A8undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/babel-generator/src/printer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel-generator/src/printer.ts b/packages/babel-generator/src/printer.ts index 70cf22cf6721..9acbe5dd4bee 100644 --- a/packages/babel-generator/src/printer.ts +++ b/packages/babel-generator/src/printer.ts @@ -951,8 +951,8 @@ class Printer { const comment = comments[i]; if (hasLoc && "loc" in comment && !this._printedComments.has(comment)) { - const commentStartLine = comment.loc.start.line; - const commentEndLine = comment.loc.end.line; + const commentStartLine = comment.loc?.start.line; + const commentEndLine = comment.loc?.end.line; if (type === COMMENT_TYPE.LEADING) { let offset = 0; if (i === 0) {