Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"@types/node" module is declared in dependencies. #1955

Closed
NurimOnsemiro opened this issue Oct 29, 2021 · 7 comments
Closed

"@types/node" module is declared in dependencies. #1955

NurimOnsemiro opened this issue Oct 29, 2021 · 7 comments

Comments

@NurimOnsemiro
Copy link

NurimOnsemiro commented Oct 29, 2021

Problem description

In the grpc-js package, "@types/node" module is declared in dependencies.

"dependencies": {
    "@grpc/proto-loader": "^0.6.4",
    "@types/node": ">=12.12.47"
  },

Wouldn't it be right to move "@types/node" module from "dependencies" to "devDependencies" in the grpc-js package?

@NurimOnsemiro NurimOnsemiro changed the title "@types/node" module is defined in dependencies. "@types/node" module is declared in dependencies. Oct 29, 2021
@murgatroid99
Copy link
Member

The @grpc/grpc-js package exports types that are derived from types in the @types/node package. So, users need the @types/node package to correctly handle those types when compiling using @grpc/grpc-js exported types.

@ericmorand
Copy link

@murgatroid99 , I'm not sure I understand. Can you please give us an actual example where this dependency is required? I have been using grpc-js for months and never had the need for those @types/node at runtime.

@murgatroid99
Copy link
Member

It's not used at runtime. It is used when users of grpc-js compile TypeScript code that uses certain grpc-js types, particularly the streaming call types.

@ericmorand
Copy link

Well, dependencies must contain only runtime dependencies.

I see that there is also @grpc/proto-loader and @types/semver as depenencies. Are they used at runtime?

@murgatroid99
Copy link
Member

Well, dependencies must contain only runtime dependencies.

Not according to the official package.json spec. The only guidance is that dependencies should not contain tools used during development like compilers and test frameworks. dependencies is for packages that dependent libraries will need when using the library. That can be both compile-time and runtime dependencies.

I see that there is also @grpc/proto-loader and @types/semver as depenencies. Are they used at runtime?

@grpc/proto-loader is used at runtime. @types/semver is not, because it is also a typescript types package. In fact, that one should be in devDependencies. It looks like it was added to dependencies by mistake.

@thernstig
Copy link

thernstig commented Dec 4, 2023

@murgatroid99 this installs @types/nodes in production. It increases install size, container size and download speed of container images. It also introduces security scanning problems, licenses problems for any serious organizations where any FOSS included in production gets scrutinized and requires extra work.

Do you need to re-export @types/node types? Could you not instead tell people to install @node/types as a development dependency if they use TypeScript and need to use those types to transpile the TS?

This is highly debated though, see microsoft/types-publisher#81. But I think for something like @node/types it'd be ok to leave that out as anyone interested in typings and using node should have that.

@ericmorand
Copy link

ericmorand commented Dec 4, 2023

Do you need to re-export @types/node types? Could you not instead tell people to install @node/types as a development dependency if they use TypeScript and need to use those types to transpile the TS?

This. And basically, it is not possible to code anything in TypeScript that depends on one of node.js library without these types, so there is not even need to tell people to install @types/node: it is a requirement for every node.js development using TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants