diff --git a/build-tools/handleApiFiles.js b/build-tools/handleApiFiles.js index 000349e56e497b957a969e825a4830d939d94791..c5b47681cd99d0f19d541e231b8e7ba1ad7732ee 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 92a43c7f00d84e6b899ec179176da281ab2eb6d3..00efb38d76e8cc0c912644ca92f90be0e7277b24 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; } } }