diff --git a/src/lib/converter/symbols.ts b/src/lib/converter/symbols.ts index 691e21832..9d43d90cb 100644 --- a/src/lib/converter/symbols.ts +++ b/src/lib/converter/symbols.ts @@ -968,7 +968,6 @@ function convertVariable( setModifiers(symbol, declaration, reflection); reflection.defaultValue = convertDefaultValue(declaration); - context.finalizeDeclarationReflection(reflection); return ts.SymbolFlags.Property; diff --git a/src/lib/output/themes/default/partials/member.declaration.tsx b/src/lib/output/themes/default/partials/member.declaration.tsx index 0dc770370..830e106a9 100644 --- a/src/lib/output/themes/default/partials/member.declaration.tsx +++ b/src/lib/output/themes/default/partials/member.declaration.tsx @@ -29,12 +29,26 @@ export function memberDeclaration(context: DefaultThemeRenderContext, props: Dec const visitor = { reflection: renderTypeDeclaration }; + /** Fix for #2717. If type is the same as value the type is omitted */ + function shouldRenderType() { + if (props.type && props.type.type === "literal") { + const reflectionTypeString = props.type.toString(); + + const defaultValue = props.defaultValue; + + if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) { + return false; + } + } + return true; + } + return ( <>
{wbr(props.name)} {renderTypeParametersSignature(context, props.typeParameters)} - {props.type && ( + {shouldRenderType() && ( <> {!!props.flags.isOptional && "?"}:{" "} {context.type(props.type)}