Skip to content

Commit

Permalink
Always check types/classes for referenced in exported type
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 5, 2024
1 parent 42d626f commit 50bc125
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/knip/src/typescript/get-imports-and-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
isDestructuring,
isImportSpecifier,
isReferencedInExportedType,
isTypeDeclaration,
} from './ast-helpers.js';
import { findInternalReferences } from './find-internal-references.js';
import getDynamicImportVisitors from './visitors/dynamic-imports/index.js';
Expand Down Expand Up @@ -371,7 +372,11 @@ const getImportsAndExports = (
}
}

if (ignoreExportsUsedInFile && !isTopLevel && isReferencedInExportedType(node)) {
if (
(ignoreExportsUsedInFile || isTypeDeclaration(node) || ts.isClassDeclaration(node)) &&
!isTopLevel &&
isReferencedInExportedType(node)
) {
// @ts-expect-error
referencedSymbolsInExportedTypes.add(symbol.exportSymbol);
}
Expand Down

0 comments on commit 50bc125

Please sign in to comment.