diff --git a/packages/typedoc-plugin-markdown/src/resources/helpers/type-parameter-table.ts b/packages/typedoc-plugin-markdown/src/resources/helpers/type-parameter-table.ts index 2cef9e6c..cdcd59d6 100644 --- a/packages/typedoc-plugin-markdown/src/resources/helpers/type-parameter-table.ts +++ b/packages/typedoc-plugin-markdown/src/resources/helpers/type-parameter-table.ts @@ -45,6 +45,9 @@ function table(parameters: any) { ); } if (parameter.default) { + if (parameter.type) { + typeCol.push(' = '); + } typeCol.push(Handlebars.helpers.type.call(parameter.default)); } row.push(typeCol.join('')); diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/generics.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/generics.spec.ts.snap index 9df04603..ae4df6a8 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/generics.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/generics.spec.ts.snap @@ -56,6 +56,21 @@ exports[`Generics: should compile function with complex type params' 1`] = ` " `; +exports[`Generics: should compile generics with defaults' 1`] = ` +"▸ **genericsWithDefaults**: \`void\` + +[partial: comment] + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| \`Type\` | extends \`boolean\` = \`boolean\` | + +[partial: member.sources] +" +`; + exports[`Generics: should compile type with nested generics' 1`] = ` "Ƭ **nestedGenerics**: [\`Generic1\`](../modules.md#generic1)<[\`Generic2\`](../modules.md#generic2)<[\`Generic3\`](../modules.md#generic3)<\`string\`\\\\>\\\\>\\\\> diff --git a/packages/typedoc-plugin-markdown/test/specs/generics.spec.ts b/packages/typedoc-plugin-markdown/test/specs/generics.spec.ts index aca20c59..2e9e6c1b 100644 --- a/packages/typedoc-plugin-markdown/test/specs/generics.spec.ts +++ b/packages/typedoc-plugin-markdown/test/specs/generics.spec.ts @@ -64,4 +64,14 @@ describe(`Generics:`, () => { ), ).toMatchSnapshot(); }); + + test(`should compile generics with defaults'`, () => { + expect( + TestApp.compileTemplate( + declarationPartial, + testApp.findReflection('genericsWithDefaults') + .signatures[0] as SignatureReflection, + ), + ).toMatchSnapshot(); + }); }); diff --git a/packages/typedoc-plugin-markdown/test/stubs/src/generics.ts b/packages/typedoc-plugin-markdown/test/stubs/src/generics.ts index 4b628c7c..8c0700cb 100644 --- a/packages/typedoc-plugin-markdown/test/stubs/src/generics.ts +++ b/packages/typedoc-plugin-markdown/test/stubs/src/generics.ts @@ -21,6 +21,10 @@ export const functionWithTypeParams = < C = string, >() => true; +export function genericsWithDefaults() { + return; +} + export function functionWithGenericConstraints( obj: Type, key: Key,