@grpc/grpc-js is incompatible with typescript definations @types/node@17.0.6
See original GitHub issueProblem description
when project already has the dependency @types/node@17.0.6
, tsc
failed to build
Reproduction steps
yarn add @types/node@17.0.6 && tsc -b
- failed with output:
node_modules/@grpc/grpc-js/build/src/object-stream.d.ts:11:18` - error TS2430: Interface 'IntermediateObjectWritable<T>' incorrectly extends interface 'Writable'.
The types returned by 'end(...)' are incompatible between these types.
Type 'void' is not assignable to type 'this'.
'this' could be instantiated with an arbitrary type which could be unrelated to 'void'.
11 export interface IntermediateObjectWritable<T> extends Writable {
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@grpc/grpc-js/build/src/server-call.d.ts:64:5 - error TS2416: Property 'end' in type 'ServerWritableStreamImpl<RequestType, ResponseType>' is not assignable to the same property in base type 'Writable'.
Type '(metadata?: any) => void' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding: BufferEncoding, cb?: () => void): this; }'.
Type 'void' is not assignable to type 'this'.
'this' could be instantiated with an arbitrary type which could be unrelated to 'void'.
64 end(metadata?: any): void;
~~~
node_modules/@grpc/grpc-js/build/src/server-call.d.ts:77:5 - error TS2416: Property 'end' in type 'ServerDuplexStreamImpl<RequestType, ResponseType>' is not assignable to the same property in base type 'Duplex'.
Type '(metadata?: any) => void' is not assignable to type '{ (cb?: () => void): this; (chunk: any, cb?: () => void): this; (chunk: any, encoding?: BufferEncoding, cb?: () => void): this; }'.
Type 'void' is not assignable to type 'this'.
'this' could be instantiated with an arbitrary type which could be unrelated to 'void'.
77 end(metadata?: any): void;
~~~
Found 3 errors.
yarn add @types/node@17.0.5 && tsc -b
- successfully built again.
Environment
- OS name, version and architecture: M1 Pro, Macbook Pro
- Node version: 16.13.0
- Node installation method: brew
- Package name and version:
"@grpc/grpc-js": "^1.4.5"
tsconfig.json
{ "compilerOptions": { "lib": [ "ES2021" ], "module": "commonjs", "moduleResolution": "node", "target": "ES2021", "esModuleInterop": true, "allowSyntheticDefaultImports": true, "outDir": "dist" }, "include": [ "src/**/*" ], "exclude": [ "node_modules", "**/*.spec.ts" ] }
It seems that the version of dependency package @types/node
should be limited, rather than current “>=12.12.47”.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:33
- Comments:23 (2 by maintainers)
Top Results From Across the Web
@types/node - npm
This package contains type definitions for Node.js (https://nodejs.org/). Details. Files were exported from https://github.com/DefinitelyTyped/ ...
Read more >typescript - Relationship between the version of node.js and ...
I think types declaration for node has not changed from version 7.0.0. There was just 4 minor updates to typings. – Misaz. Feb...
Read more >How to prevent npm install for unsupported Node.js versions
It is possible to prevent npm install for unsupported Node.js versions by specifying a couple of configuration properties. Let's see how.
Read more >@types/node | Yarn - Package Manager
TypeScript definitions for Node.js. readme. [object Object]. https://yarn.pm/@types/node. copy · DefinitelyTyped/DefinitelyTyped · @types/node. Use it.
Read more >Node.js agent release notes - New Relic Documentation
Notes Updated @grpc/grpc-js instrumentation to work with 1.8.0. Support statement: New Relic recommends that you upgrade the agent… December 6. Node.js agent ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your patience with this error. I have published
@grpc/grpc-js
version 1.4.6 with a fix for it. Please update your dependencies to use the new version.@dancamdev Just change
@types/node
version inpackage.json
to this:Then: