Skip to content

Commit

Permalink
Include package.json#types and typings (resolves #607)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed May 4, 2024
1 parent ab8952b commit 296ab06
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"private": true,
"type": "module",
"types": "client.d.ts",
"dependencies": {
"@workspaces-dts/shared": "*"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"private": true,
"type": "module",
"typings": "server.d.ts",
"dependencies": {
"@workspaces-dts/shared": "*"
}
Expand Down
Empty file.
5 changes: 4 additions & 1 deletion packages/knip/src/util/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const getEntryPathFromManifest = (
manifest: PackageJson,
sharedGlobOptions: { cwd: string; workingDir: string; gitignore: boolean; ignore: string[] }
) => {
const { main, bin, exports } = manifest;
const { main, bin, exports, types, typings } = manifest;

const entryPaths = new Set<string>();

Expand All @@ -59,6 +59,9 @@ export const getEntryPathFromManifest = (
for (const item of getStringValues(exports)) entryPaths.add(item);
}

if (typeof types === 'string') entryPaths.add(types);
if (typeof typings === 'string') entryPaths.add(typings);

// Use glob, as we only want source files that:
// - exist
// - are not (generated) files that are .gitignore'd
Expand Down
4 changes: 2 additions & 2 deletions packages/knip/test/workspaces-dts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('Find unused un-built exports across workspaces', async () => {
assert.deepEqual(counters, {
...baseCounters,
exports: 1,
processed: 6,
total: 6,
processed: 8,
total: 8,
});
});

0 comments on commit 296ab06

Please sign in to comment.