Skip to content

Commit

Permalink
Merge pull request #2721 from Corso02/master
Browse files Browse the repository at this point in the history
TypeDoc displays a superfluous type on number constants implementation
  • Loading branch information
Gerrit0 authored Oct 3, 2024
2 parents 3723b58 + b9f56e0 commit 1dbfe3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/lib/converter/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,6 @@ function convertVariable(
setModifiers(symbol, declaration, reflection);

reflection.defaultValue = convertDefaultValue(declaration);

context.finalizeDeclarationReflection(reflection);

return ts.SymbolFlags.Property;
Expand Down
16 changes: 15 additions & 1 deletion src/lib/output/themes/default/partials/member.declaration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<div class="tsd-signature">
<span class={getKindClass(props)}>{wbr(props.name)}</span>
{renderTypeParametersSignature(context, props.typeParameters)}
{props.type && (
{shouldRenderType() && (
<>
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
{context.type(props.type)}
Expand Down

0 comments on commit 1dbfe3a

Please sign in to comment.