question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@grpc/grpc-js is incompatible with typescript definations @types/node@17.0.6

See original GitHub issue

Problem 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:closed
  • Created 2 years ago
  • Reactions:33
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
murgatroid99commented, Jan 4, 2022

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.

13reactions
johnnyoshikacommented, Jan 2, 2022

@dancamdev Just change @types/node version in package.json to this:

"@types/node": "14.18.3"

Then:

npm install
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found