diff --git a/src/parser.ts b/src/parser.ts index e5b19cc..58917b3 100755 --- a/src/parser.ts +++ b/src/parser.ts @@ -533,7 +533,7 @@ function addDefaultValueToDescription(tag: Spec): Spec { let { description } = tag; // remove old note - description = description.replace(/[ \t]*Default is `.*`\.?$/, ""); + description = description.replace(/[\s]*Default[\s]*is[\s]*`.*`\.?$/, ""); // add a `.` at the end of previous sentences if (description && !/[.\n]$/.test(description)) { diff --git a/tests/__snapshots__/main.test.ts.snap b/tests/__snapshots__/main.test.ts.snap index 232c2bd..8d716cd 100644 --- a/tests/__snapshots__/main.test.ts.snap +++ b/tests/__snapshots__/main.test.ts.snap @@ -413,6 +413,15 @@ exports[`Sould keep params ordering when more than 10 tags are present 1`] = ` " `; +exports[`default type parameter 1`] = ` +"/** + * @template [BAR=({bar:true}&{foo:false}&{buggy:true})] Default is + * \`({bar:true}&{foo:false}&{buggy:true})\` + * @typedef {{ foo: BAR }} SomeType + */ +" +`; + exports[`example 1`] = ` "/** * ABCCCC diff --git a/tests/main.test.ts b/tests/main.test.ts index 1d225c8..def03d4 100755 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -802,3 +802,21 @@ test("satisfies", async () => { expect(result).toMatchSnapshot(); }); + +test("default type parameter ", async () => { + function _subject(str: string) { + return subject(str, { + jsdocAddDefaultToDescription: true, + }); + } + const result = await _subject( + ` + /** + * @template [BAR=({bar:true}&{foo:false}&{buggy:true})] + * @typedef {{foo: BAR}} SomeType + */ +`, + ); + + expect(await _subject(await _subject(result))).toMatchSnapshot(); +});