Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Consider making `@types/*` dev dependencies

Open daniel-white opened this issue 2 years ago • 6 comments

It would be great if the @types/* were not direct dependencies but dev dependencies as to avoid the pit fall of having the types for node 20, but running under node 18.

daniel-white avatar Oct 24 '23 20:10 daniel-white

This cannot work today because Inquirer code accesses the node types. So it cannot ship without the @types/node as the imported types will be missing. Specifically this caused a bug in the past, see https://github.com/SBoudrias/Inquirer.js/issues/1241

I'm open to review this or change the code somewhat to get to a better result. But I'll need documentation and reference from you supporting how this is possible. We can work together on that if you're willing to.

SBoudrias avatar Oct 26 '23 14:10 SBoudrias

it looks like you only ship javascript in your package. so the types package is not directly needed. i would advise using this as a devDependency https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencie

daniel-white avatar Oct 26 '23 14:10 daniel-white

That is not the case, the types are shipped. See https://www.npmjs.com/package/@inquirer/core?activeTab=code under dist/esm/types/ for one example.

SBoudrias avatar Oct 26 '23 14:10 SBoudrias

then a peerDependency i think might be more appropriate, with the minimum supported version of node

daniel-white avatar Oct 26 '23 14:10 daniel-white

This also add quite a lot of size to install the package. 2Mb from @types/mute-stream and 2Mb from @types/node.

npx howfat @inquirer/core
@inquirer/[email protected] (28 deps, 2.57mb, 385 files, ©MIT)
├── @inquirer/[email protected] (4.54kb, 7 files, ©MIT)
├─┬ @types/[email protected] (2 deps, 2.01mb, 105 files, ©MIT)
│ ╰── @types/[email protected] (🔗, 1 dep, 2mb, 100 files, ©MIT)
├─┬ @types/[email protected] (1 dep, 2mb, 100 files, ©MIT)
│ ╰── [email protected] (71.34kb, 35 files, ©MIT)
├── @types/[email protected] (3kb, 4 files, ©MIT)
├─┬ [email protected] (1 dep, 132.26kb, 51 files, ©MIT)
│ ╰── [email protected] (116.26kb, 46 files, ©(MIT OR CC0-1.0))
├─┬ [email protected] (5 deps, 95.08kb, 33 files, ©MIT)
│ ├─┬ [email protected] (2 deps, 49.67kb, 16 files, ©MIT)
│ │ ╰─┬ [email protected] (1 dep, 33.09kb, 11 files, ©MIT)
│ │   ╰── [email protected] (6.54kb, 4 files, ©MIT)
│ ╰─┬ [email protected] (1 dep, 11.19kb, 10 files, ©MIT)
│   ╰── [email protected] (4.32kb, 5 files, ©MIT)
├── [email protected] (31.36kb, 6 files, ©MIT)
├── [email protected] (4.66kb, 5 files, ©ISC)
├─┬ [email protected] (1 dep, 14.42kb, 9 files, ©MIT)
│ ╰── [email protected] (2.63kb, 4 files, ©MIT)
├── [email protected] (6.28kb, 4 files, ©ISC)
├── [email protected] (75.16kb, 29 files, ©ISC)
├─┬ [email protected] (1 dep, 9.41kb, 10 files, ©MIT)
│ ╰── [email protected] (5.48kb, 5 files, ©MIT)
╰─┬ [email protected] (8 deps, 125.4kb, 48 files, ©MIT)
  ├─┬ [email protected] (2 deps, 49.67kb, 16 files, ©MIT)
  │ ╰─┬ [email protected] (1 dep, 33.09kb, 11 files, ©MIT)
  │   ╰── [email protected] (6.54kb, 4 files, ©MIT)
  ├─┬ [email protected] (4 deps, 66.45kb, 28 files, ©MIT)
  │ ├── [email protected] (47.12kb, 8 files, ©MIT)
  │ ├── [email protected] (4.88kb, 5 files, ©MIT)
  │ ╰── [email protected] (🔗, 1 dep, 9.41kb, 10 files, ©MIT)
  ╰── [email protected] (🔗, 1 dep, 9.41kb, 10 files, ©MIT)

tuler avatar Apr 04 '24 03:04 tuler

Like stated earlier, I'm happy to review this. But we need a solution that'll also work for typescript users.

dependencies appears to be how we need to handle this for now; see here. And you should also refer to the bug it caused in #1241.

SBoudrias avatar Apr 04 '24 13:04 SBoudrias