From b9f56e0eeec74a8464905693fa35c1e36cb135e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Van=C3=A1t?= Date: Mon, 30 Sep 2024 18:06:49 +0200 Subject: [PATCH] simplified checking if type should be rendered --- .../default/partials/member.declaration.tsx | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/lib/output/themes/default/partials/member.declaration.tsx b/src/lib/output/themes/default/partials/member.declaration.tsx index bd9ce6aec..830e106a9 100644 --- a/src/lib/output/themes/default/partials/member.declaration.tsx +++ b/src/lib/output/themes/default/partials/member.declaration.tsx @@ -29,34 +29,16 @@ export function memberDeclaration(context: DefaultThemeRenderContext, props: Dec const visitor = { reflection: renderTypeDeclaration }; - /** Fix for #2717. If type is the same as value the type is omited */ + /** Fix for #2717. If type is the same as value the type is omitted */ function shouldRenderType() { if (props.type && props.type.type === "literal") { - const typeObject = props.type.toObject(); - const value = typeObject.value; - if (!value) { - // should be unreachable - return true; - } - if (typeof value === "object") { - return true; - } - const reflectionTypeString: string = value.toString(); - let defaultValue = props.defaultValue!; - if (defaultValue) { - // If the default value is string and it's wrapped in ' in the code, the value is wrapped in " and vice-versa - if ( - (defaultValue[0] === '"' && defaultValue[defaultValue.length - 1] === '"') || - (defaultValue[0] === "'" && defaultValue[defaultValue.length - 1] === "'") - ) { - defaultValue = defaultValue.slice(1, -1); - } - } + const reflectionTypeString = props.type.toString(); + + const defaultValue = props.defaultValue; - if (reflectionTypeString === defaultValue.toString()) { + if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) { return false; } - return true; } return true; }