Skip to content

Commit 2ee7ce1

Browse files
committed
Make TypeName.name mandatory
1 parent 6e02c82 commit 2ee7ce1

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/models/typeName.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
export class TypeName {
2-
public readonly name: string | undefined;
2+
public readonly name: string;
33
public readonly namespaces: readonly string[] | undefined;
44

5-
constructor(name: string | undefined, namespaces: readonly string[] | undefined = undefined) {
5+
constructor(name: string, namespaces: readonly string[] | undefined = undefined) {
66
this.name = name;
77
this.namespaces = namespaces;
88
}
99

1010
toString(): string {
11-
if (!this.name) {
12-
return '';
13-
}
14-
1511
if (!this.namespaces || this.namespaces.length === 0) {
1612
return this.name;
1713
}

src/parsers/componentParser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ export function augmentComponentNodes(nodes: ExportNode[], context: ParserContex
2929
hasReactNodeLikeReturnType(node.type)
3030
) {
3131
const newCallSignatures = squashComponentProps(node.type.callSignatures, context);
32+
const typeName = node.type.typeName
33+
? new TypeName(node.type.typeName?.name, node.type.typeName?.namespaces)
34+
: undefined;
3235
return new ExportNode(
3336
node.name,
34-
new ComponentNode(
35-
new TypeName(node.type.typeName?.name, node.type.typeName?.namespaces),
36-
newCallSignatures,
37-
),
37+
new ComponentNode(typeName, newCallSignatures),
3838
node.documentation,
3939
);
4040
}

0 commit comments

Comments
 (0)