Skip to content

Commit

Permalink
address comments and add another test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanzander authored and Gerrit0 committed Jun 12, 2024
1 parent b55a0b5 commit d8de993
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
28 changes: 0 additions & 28 deletions src/lib/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,39 +908,11 @@ export class ReferenceType extends Type {
return new ReferenceType(name, target, project, name);
}

/**
* In certain cases, TypeScript returns the name `default` for the name of a type that is defined with
* the format `export default class` or `export default function`. This method checks for that case and returns the
* declaration of the export instead of the name `default`.
*/
private static getNameForDefaultExport(
symbol: ts.Symbol,
): string | undefined {
if (
symbol.name !== "default" ||
symbol.valueDeclaration === undefined
) {
return;
}

const name = ts.getNameOfDeclaration(symbol.valueDeclaration);

if (!name) {
return;
}

if (ts.isIdentifier(name)) {
return name.text;
}
}

static createSymbolReference(
symbol: ts.Symbol,
context: Context,
name?: string,
) {
name ??= this.getNameForDefaultExport(symbol);

const ref = new ReferenceType(
name ?? symbol.name,
new ReflectionSymbolId(symbol),
Expand Down
1 change: 0 additions & 1 deletion src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
type ProjectReflection,
QueryType,
ReferenceReflection,
ReferenceType,
ReflectionKind,
ReflectionType,
SignatureReflection,
Expand Down

0 comments on commit d8de993

Please sign in to comment.