From 4a3f81e0fccd0c0761bd435d811c9ede136bc664 Mon Sep 17 00:00:00 2001 From: jiangqianjin Date: Tue, 19 Aug 2025 14:47:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BD=AC=E6=8D=A2=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangqianjin --- build-tools/handleApiFiles.js | 6 +++--- build-tools/intToNumber.js | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 000349e56e..c5b47681cd 100755 --- a/build-tools/handleApiFiles.js +++ b/build-tools/handleApiFiles.js @@ -542,14 +542,14 @@ function handleNoTagFileInSecondType(sourceFile, outputPath, fullPath) { * @returns */ function getFileContent(newContent, filePath) { - if (isArkTsSpecialSyntax(newContent)) { + const regex = /^overload\s+.+$/; + if (isArkTsSpecialSyntax(newContent) || !regex.test(newContent)) { return newContent; } - let sourceFile = ts.createSourceFile(path.basename(filePath), newContent, ts.ScriptTarget.ES2017, true); + const sourceFile = ts.createSourceFile(path.basename(filePath), newContent, ts.ScriptTarget.ES2017, true); const printer = ts.createPrinter(); const result = ts.transform(sourceFile, [deleteOverLoadJsDoc]); const output = printer.printFile(result.transformed[0]); - sourceFile = ''; return output; } diff --git a/build-tools/intToNumber.js b/build-tools/intToNumber.js index 92a43c7f00..00efb38d76 100644 --- a/build-tools/intToNumber.js +++ b/build-tools/intToNumber.js @@ -307,7 +307,6 @@ function applJSDocTransformations(typeExpr, newTypeExpr, tagDataList, isChange) if (finalContent.includes('number') && typeExpr.kind === ts.SyntaxKind.JSDocNullableType && !finalContent.includes('?number') && isChange) { if (typeExpr.type.type && typeExpr.type.type.kind === ts.SyntaxKind.UnionType) { const data = { - isDelete: false, pos: typeExpr.pos, end: typeExpr.end, convertedText: '?' + `(${finalContent})` @@ -315,7 +314,6 @@ function applJSDocTransformations(typeExpr, newTypeExpr, tagDataList, isChange) tagDataList.push(data); } else { const data = { - isDelete: false, pos: typeExpr.pos, end: typeExpr.end, convertedText: '?' + finalContent @@ -324,7 +322,6 @@ function applJSDocTransformations(typeExpr, newTypeExpr, tagDataList, isChange) } } else if (finalContent.includes('number')) { const data = { - isDelete: true, pos: typeExpr.pos, end: typeExpr.end, convertedText: finalContent @@ -344,10 +341,10 @@ function changeContent(tagDataList) { for (const data of tagDataList) { const before = jsDocContent.substring(0, data.pos); const after = jsDocContent.substring(data.end); - if (data.isDelete) { - jsDocContent = before + `${data.convertedText}` + after; - } else { + if (jsDocContent.substring(data.pos, data.pos + 1) === ' ') { jsDocContent = before + ` ${data.convertedText}` + after; + } else { + jsDocContent = before + `${data.convertedText}` + after; } } } -- Gitee