Skip to content

Commit 1dbfe3a

Browse files
authored
Merge pull request #2721 from Corso02/master
TypeDoc displays a superfluous type on number constants implementation
2 parents 3723b58 + b9f56e0 commit 1dbfe3a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/lib/converter/symbols.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,6 @@ function convertVariable(
968968
setModifiers(symbol, declaration, reflection);
969969

970970
reflection.defaultValue = convertDefaultValue(declaration);
971-
972971
context.finalizeDeclarationReflection(reflection);
973972

974973
return ts.SymbolFlags.Property;

src/lib/output/themes/default/partials/member.declaration.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,26 @@ export function memberDeclaration(context: DefaultThemeRenderContext, props: Dec
2929

3030
const visitor = { reflection: renderTypeDeclaration };
3131

32+
/** Fix for #2717. If type is the same as value the type is omitted */
33+
function shouldRenderType() {
34+
if (props.type && props.type.type === "literal") {
35+
const reflectionTypeString = props.type.toString();
36+
37+
const defaultValue = props.defaultValue;
38+
39+
if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) {
40+
return false;
41+
}
42+
}
43+
return true;
44+
}
45+
3246
return (
3347
<>
3448
<div class="tsd-signature">
3549
<span class={getKindClass(props)}>{wbr(props.name)}</span>
3650
{renderTypeParametersSignature(context, props.typeParameters)}
37-
{props.type && (
51+
{shouldRenderType() && (
3852
<>
3953
<span class="tsd-signature-symbol">{!!props.flags.isOptional && "?"}:</span>{" "}
4054
{context.type(props.type)}

0 commit comments

Comments
 (0)