Skip to content

Commit ff4eb89

Browse files
committed
Call getTypeName once
1 parent b44377a commit ff4eb89

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/parsers/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getTypeName(
44
type: ts.Type,
55
typeSymbol: ts.Symbol | undefined,
66
checker: ts.TypeChecker,
7-
useFallback: boolean = true,
7+
useFallback: boolean = false,
88
): string | undefined {
99
const symbol = typeSymbol ?? type.aliasSymbol ?? type.getSymbol();
1010
if (!symbol) {

src/parsers/typeResolver.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export function resolveType(
7070
}
7171
}
7272

73+
const typeName = getTypeName(type, typeSymbol, checker);
7374
const namespaces = typeSymbol ? getTypeSymbolNamespaces(typeSymbol) : getTypeNamespaces(type);
7475

7576
try {
@@ -100,7 +101,6 @@ export function resolveType(
100101
}
101102

102103
if (!includeExternalTypes && isTypeExternal(type, checker)) {
103-
const typeName = getTypeName(type, typeSymbol, checker);
104104
// Fixes a weird TS behavior where it doesn't show the alias name but resolves to the actual type in case of RefCallback.
105105
if (typeName === 'bivarianceHack') {
106106
return new ReferenceNode('RefCallback', []);
@@ -132,13 +132,11 @@ export function resolveType(
132132
}
133133

134134
if (type.isUnion()) {
135-
const typeName = getTypeName(type, typeSymbol, checker, false);
136135
return resolveUnionType(type, typeName, typeNode, context, namespaces);
137136
}
138137

139138
if (type.isIntersection()) {
140139
const memberTypes: TypeNode[] = [];
141-
const typeName = getTypeName(type, typeSymbol, checker, false);
142140

143141
for (const memberType of type.types) {
144142
memberTypes.push(resolveType(memberType, undefined, context));
@@ -239,7 +237,6 @@ export function resolveType(
239237
type.flags & ts.TypeFlags.Object ||
240238
(type.flags & ts.TypeFlags.NonPrimitive && checker.typeToString(type) === 'object')
241239
) {
242-
const typeName = getTypeName(type, typeSymbol, checker, false);
243240
return new ObjectNode(typeName, namespaces, [], undefined);
244241
}
245242

0 commit comments

Comments
 (0)