@kezh/my-custom-js-converter 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/util/ast.js +12 -3
- package/package.json +1 -1
package/core/util/ast.js
CHANGED
|
@@ -57,9 +57,18 @@ function fixMisplacedLineComments(code) {
|
|
|
57
57
|
function outputObjectMethods(outPath, methods) {
|
|
58
58
|
let dist = methods
|
|
59
59
|
.map((m) => {
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
//
|
|
60
|
+
var _a;
|
|
61
|
+
// 区分处理 leadingComments:
|
|
62
|
+
// - CommentBlock(/** ... */ JSDoc):属于方法自身的文档注释,encode 扁平化时应删除。
|
|
63
|
+
// - CommentLine(// ...):Babel 会把上一属性/方法的行尾注释错挂到当前方法的
|
|
64
|
+
// leadingComments,删除会导致行尾注释丢失,因此保留,交由 fixMisplacedLineComments
|
|
65
|
+
// 在生成后还原到上一属性行尾。
|
|
66
|
+
if ((_a = m.leadingComments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
67
|
+
m.leadingComments = m.leadingComments.filter((c) => c.type === "CommentLine");
|
|
68
|
+
if (!m.leadingComments.length) {
|
|
69
|
+
m.leadingComments = undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
63
72
|
return m;
|
|
64
73
|
})
|
|
65
74
|
.map((m) => (0, generator_1.default)(m))
|