Skip to content

Commit 49b7173

Browse files
authored
fix(legacy-json): prevent parseSignature from dropping arguments on un-backticked definitions (#687)
1 parent 34a67f3 commit 49b7173

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/generators/legacy-json/utils/__tests__/parseSignature.test.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,26 @@ describe('parseSignature', () => {
273273
],
274274
},
275275
},
276+
{
277+
name: 'handles un-backticked method signatures without dropping arguments',
278+
input: {
279+
textRaw: 'new Console(options)',
280+
markdown: [{ name: 'options' }],
281+
},
282+
expected: {
283+
params: [{ name: 'options' }],
284+
},
285+
},
286+
{
287+
name: 'handles standard method signatures without backticks',
288+
input: {
289+
textRaw: 'foo(a, b)',
290+
markdown: [{ name: 'a' }, { name: 'b' }],
291+
},
292+
expected: {
293+
params: [{ name: 'a' }, { name: 'b' }],
294+
},
295+
},
276296
];
277297

278298
for (const testCase of testCases) {

src/generators/legacy-json/utils/parseSignature.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default (textRaw, markdownParameters) => {
190190
* @example `[sources[, options]]`
191191
*/
192192
let [, declaredParameters] =
193-
textRaw.substring(1, textRaw.length - 1).match(PARAM_EXPRESSION) || [];
193+
textRaw.replace(/^`|`$/g, '').match(PARAM_EXPRESSION) || [];
194194

195195
if (!declaredParameters) {
196196
return signature;

0 commit comments

Comments
 (0)