Skip to content

Commit b9f56e0

Browse files
committed
simplified checking if type should be rendered
1 parent eb87d44 commit b9f56e0

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,16 @@ 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 omited */
32+
/** Fix for #2717. If type is the same as value the type is omitted */
3333
function shouldRenderType() {
3434
if (props.type && props.type.type === "literal") {
35-
const typeObject = props.type.toObject();
36-
const value = typeObject.value;
37-
if (!value) {
38-
// should be unreachable
39-
return true;
40-
}
41-
if (typeof value === "object") {
42-
return true;
43-
}
44-
const reflectionTypeString: string = value.toString();
45-
let defaultValue = props.defaultValue!;
46-
if (defaultValue) {
47-
// If the default value is string and it's wrapped in ' in the code, the value is wrapped in " and vice-versa
48-
if (
49-
(defaultValue[0] === '"' && defaultValue[defaultValue.length - 1] === '"') ||
50-
(defaultValue[0] === "'" && defaultValue[defaultValue.length - 1] === "'")
51-
) {
52-
defaultValue = defaultValue.slice(1, -1);
53-
}
54-
}
35+
const reflectionTypeString = props.type.toString();
36+
37+
const defaultValue = props.defaultValue;
5538

56-
if (reflectionTypeString === defaultValue.toString()) {
39+
if (defaultValue === undefined || reflectionTypeString === defaultValue.toString()) {
5740
return false;
5841
}
59-
return true;
6042
}
6143
return true;
6244
}

0 commit comments

Comments
 (0)