grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

Fix ts errors with typescript 4.6.3 #2107

Open jimmypresto opened this issue 2 years ago • 12 comments

This fixes couple typescript files failing to transpile with typescript 4.6.x. Typescript 4.6 enforces object's default type to be 'unknown', instead of 'any' and no implicit the argument value for the resolve call.

The transpilation errors under typescript 4.6: a. Object is of type 'unknown' b. Argument of type 'unknown' is not assignable to parameter of type XYZ c. Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?

To repro:

  1. cd packages/grpc-js
  2. npm install
  3. npm install [email protected]
  4. npm run build

jimmypresto avatar Apr 15 '22 15:04 jimmypresto

CLA Missing ID CLA Not Signed

We don't currently use that version of the compiler, so these issues do not impact us. Why do you want to make this change?

murgatroid99 avatar Apr 18 '22 20:04 murgatroid99

I can live with other typescript 4.x versions you prefer. Any plans to move up the 4.x? I think it has been released more than a year.

jimmypresto avatar Apr 19 '22 17:04 jimmypresto

Is there some specific reason that you want this package to switch to using TypeScript 4.x?

murgatroid99 avatar Apr 19 '22 20:04 murgatroid99

Apps with ts 4.x is unable to consume current grpc-js release build with ts 3.x implementation. Transpilation fails.

jimmypresto avatar Apr 20 '22 21:04 jimmypresto

If you are having a problem with using grpc-js, please file an issue with the details of that problem.

murgatroid99 avatar Apr 20 '22 22:04 murgatroid99

The pr description has transpilation errors, repro steps and ts changes that builds.

Sure. I can create a ticket.

jimmypresto avatar Apr 20 '22 23:04 jimmypresto

I understand that this package does not build with a different compiler version. What I am asking for is an actual use case that is actually impacted by this incompatibility. If you npm install the library, can you use it?

murgatroid99 avatar Apr 21 '22 00:04 murgatroid99

It is when npm install a grpc-js build in any apps using ts 4.x, the npm run build would fail.

As to the reasons of why I use TS 4.x:

  1. TS 4.x language features. https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html
  2. Better toolchain, perf and features.

jimmypresto avatar Apr 21 '22 17:04 jimmypresto

I cannot reproduce this failure you are describing. Please provide a specific sequence of actions to reproduce it.

murgatroid99 avatar Apr 21 '22 17:04 murgatroid99

Can you do a "npm install" before the typescript 4.x install command? I have revised the steps as follows.

  1. cd packages/grpc-js
  2. npm install
  3. npm install [email protected]
  4. npm run build

jimmypresto avatar Apr 25 '22 15:04 jimmypresto

You said

when npm install a grpc-js build in any apps using ts 4.x, the npm run build would fail.

Cloning this repository and changing the compiler version is not the normal procedure to use this package in an app. Did you experience a problem with the @grpc/grpc-js package when installing it from the npm repository?

murgatroid99 avatar Apr 25 '22 16:04 murgatroid99

What about skipping publish of source files? Won't it be enough to just publish .d.ts and .js files and just ignore .ts files?

NoxSensei avatar Sep 16 '22 13:09 NoxSensei