Skip to content

Commit 76b0309

Browse files
committed
Fix type output for unreferenced ns types
1 parent 58bd222 commit 76b0309

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function run(configuration: Configuration) {
8585
if (include.duplicates) {
8686
const duplicateExports = findDuplicateExportedNames(sourceFile);
8787
duplicateExports.forEach(symbols => {
88-
const symbol = symbols.join(',');
88+
const symbol = symbols.join('|');
8989
addIssue('duplicates', { filePath, symbol, symbols });
9090
});
9191
}
@@ -145,7 +145,7 @@ export async function run(configuration: Configuration) {
145145
// No more reasons left to think this identifier is used somewhere else, report it as unreferenced
146146
if (findReferencingNamespaceNodes(sourceFile).length > 0) {
147147
if (type) {
148-
addIssue('nsTypes', { filePath, symbol: identifierText });
148+
addIssue('nsTypes', { filePath, symbol: identifierText, symbolType: type });
149149
} else {
150150
addIssue('nsExports', { filePath, symbol: identifierText });
151151
}

src/reporters/symbols.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import path from 'node:path';
22
import type { Issue, Issues, Configuration } from '../types';
33

44
const logIssueLine = ({ issue, cwd, padding }: { issue: Issue; cwd: string; padding: number }) => {
5+
const symbols = issue.symbols ? issue.symbols.join(', ') : issue.symbol;
56
console.log(
6-
`${issue.symbol.padEnd(padding + 2)}${issue.symbolType?.padEnd(11) || ''}${path.relative(cwd, issue.filePath)}`
7+
`${symbols.padEnd(padding + 2)}${issue.symbolType?.padEnd(11) || ''}${path.relative(cwd, issue.filePath)}`
78
);
89
};
910

@@ -52,7 +53,7 @@ export default ({ issues, config, cwd }: { issues: Issues; config: Configuration
5253
}
5354

5455
if (include.nsTypes) {
55-
const unreferencedNsTypes = Object.values(issues.nsExports).map(Object.values).flat();
56+
const unreferencedNsTypes = Object.values(issues.nsTypes).map(Object.values).flat();
5657
logIssueGroupResults(unreferencedNsTypes, cwd, reportMultipleGroups && 'UNUSED TYPES IN NAMESPACE');
5758
}
5859

test/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ test('run', async () => {
3333

3434
assert(counters.duplicates === 1);
3535
assert(Object.values(issues.duplicates).length === 1);
36-
assert(issues.duplicates['dep.ts']['dep,default'].symbols?.[0] === 'dep');
36+
assert(issues.duplicates['dep.ts']['dep|default'].symbols?.[0] === 'dep');
3737
});

0 commit comments

Comments
 (0)