Grpc-node: Typescript compile error googleapis

Created on 1 Oct 2019  路  3Comments  路  Source: grpc/grpc-node

Problem description

i have the error then start typescript compile

Reproduction steps

my package.json file

{
  "name": "functions",
  "scripts": {
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/datastore": "^4.3.0",
    "firebase-admin": "^8.0.0",
    "firebase-functions": "^3.1.0",
    "googleapis": "^43.0.0",
    "nconf": "^0.10.0",
    "querystring": "^0.2.0"
  },
  "devDependencies": {
    "@types/nconf": "^0.10.0",
    "typescript": "^3.2.2"
  },
  "private": true
}

Environment

  • Mac OS
  • Node version 8.16.0
  • Node installation method nvm
  • Package name and version - I don't know

Additional context

> tsc

node_modules/@grpc/grpc-js/build/src/call-stream.d.ts:92:5 - error TS2416: Property '_write' in type 'Http2CallStream' is not assignable to the same property in base type 'Duplex'.
  Type '(chunk: WriteObject, encoding: string, cb: WriteCallback) => void' is not assignable to type '(chunk: any, encoding: string, callback: (err?: Error | undefined) => void) => void'.
    Types of parameters 'cb' and 'callback' are incompatible.
      Types of parameters 'err' and 'error' are incompatible.
        Type 'Error | null | undefined' is not assignable to type 'Error | undefined'.
          Type 'null' is not assignable to type 'Error | undefined'.

92     _write(chunk: WriteObject, encoding: string, cb: WriteCallback): void;
       ~~~~~~

node_modules/@grpc/grpc-js/build/src/call-stream.d.ts:92:5 - error TS2416: Property '_write' in type 'Http2CallStream' is not assignable to the same property in base type '{ cancelWithStatus(status: Status, details: string): void; getPeer(): string; sendMetadata(metadata: Metadata): void; getDeadline(): number | Date; getCredentials(): CallCredentials; setCredentials(credentials: CallCredentials): void; getStatus(): StatusObject | null; getMethod(): string; getHost(): string; } & ... ...'.
  Type '(chunk: WriteObject, encoding: string, cb: WriteCallback) => void' is not assignable to type '((chunk: WriteObject, encoding: string, callback: Function) => void) & ((chunk: any, encoding: string, callback: (err?: Error | undefined) => void) => void) & ((chunk: WriteObject, encoding: string, callback: Function) => void)'.
    Type '(chunk: WriteObject, encoding: string, cb: WriteCallback) => void' is not assignable to type '(chunk: any, encoding: string, callback: (err?: Error | undefined) => void) => void'.

92     _write(chunk: WriteObject, encoding: string, cb: WriteCallback): void;
       ~~~~~~

@grpgrpc-js

Most helpful comment

I was having the same issue, and I installed the latest types for node (even though I did not even had it installed at the first place) and it started to work again. I read somewhere that this issue is connected to the installed node typings...

npm install --save-dev @types/node@latest

All 3 comments

Can you share the output of npm ls?

I was having the same issue, and I installed the latest types for node (even though I did not even had it installed at the first place) and it started to work again. I read somewhere that this issue is connected to the installed node typings...

npm install --save-dev @types/node@latest

@agyimr thank you! Much appreciated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

respinha picture respinha  路  6Comments

Harmonickey picture Harmonickey  路  6Comments

samuela picture samuela  路  4Comments

yanbou893 picture yanbou893  路  5Comments

Slapbox picture Slapbox  路  5Comments