arethetypeswrong / arethetypeswrong.github.io

Tool for analyzing TypeScript types of npm packages
https://arethetypeswrong.github.io
MIT License
1.12k stars 38 forks source link

Add support for the `workspace:` protocol #173

Closed goestav closed 2 months ago

goestav commented 2 months ago

I'm using a PNPM workspace for my project but when I use the workspace: protocol with the pnpm attw --pack . command I get the following error:

error while checking file:
Command failed: npm pack

Running npm pack manually reveals the following in the debug file:

14 verbose stack TypeError: Cannot set properties of null (setting 'peer')
14 verbose stack     at visit (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:101:54)
14 verbose stack     at visitNode (/opt/homebrew/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:58:25)
14 verbose stack     at next (/opt/homebrew/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
14 verbose stack     at depth (/opt/homebrew/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:83:10)
14 verbose stack     at depth (/opt/homebrew/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
14 verbose stack     at unsetFlag (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:96:5)
14 verbose stack     at /opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:63:7
14 verbose stack     at CIMap.forEach (<anonymous>)
14 verbose stack     at calcDepFlagsStep (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:41:17)
14 verbose stack     at calcDepFlagsStep (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:38:12)
15 error Cannot set properties of null (setting 'peer')

I currently use pnpm attw $(pnpm pack) as workaround but it would be nice if the --pack option used the same package manager. This could be detected automatically with a package like detect-package-manager or passed manually as an option. Yarn seems to use this protocol too for workspaces.

andrewbranch commented 2 months ago

I would accept a PR adopting detect-package-manager!