Skip to content

Commit 0d8f63e

Browse files
committed
fix: 生成的文档注释在特定情况下可能提前结束
1 parent bc946ba commit 0d8f63e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/lib/generate-comments.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ export const generateComments = (opts: {
1010
if (opts.method) comments.push(` * @method ${opts.method.toUpperCase()}`);
1111
if (opts.deprecated) comments.push('* @deprecated');
1212

13-
return comments.length ? `\n/**\n${comments.join('\n')}\n*/\n` : '';
13+
return comments.length
14+
? `\n/**\n${comments.join('\n').replaceAll('*/', '*\\/')}\n*/\n`
15+
: '';
1416
};

test/lib/generate-comment.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,14 @@ test('method', () => {
6464
"
6565
`);
6666
});
67+
68+
test('避免文档注释提前结束', () => {
69+
expect(generateComments({ description: 'foo */ **/ / *\/ bar' }))
70+
.toMatchInlineSnapshot(`
71+
"
72+
/**
73+
* foo *\\/ **\\/ / *\\/ bar
74+
*/
75+
"
76+
`);
77+
});

0 commit comments

Comments
 (0)