UNPKG

415 BPlain TextView Raw
1import * as tsm from 'ts-morph';
2
3export function getDeclarationName({
4 exportName,
5 declaration,
6}: {
7 exportName: string;
8 declaration: tsm.ExportedDeclarations;
9}): string {
10 if (
11 exportName !== 'default' ||
12 tsm.Node.isExpression(declaration) ||
13 tsm.Node.isSourceFile(declaration)
14 ) {
15 return exportName;
16 }
17
18 return declaration.getName() ?? exportName;
19}