tatethurston / TwirpScript

A protobuf RPC framework for JavaScript and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type error: `symbol` is not present in `IncomingMessage`

AnatolyRugalev opened this issue · comments

commented

I'm getting this type error when building my package:

node_modules/twirpscript/runtime/server/index.d.ts:24:52 - error TS2344: Type 'symbol | "headers" | "method" | "url"' does not satisfy the constraint 'keyof IncomingMessage'.
  Type 'symbol' is not assignable to type 'keyof IncomingMessage'.

Declaration of this type looks like this:

declare type ServerRequest = Pick<IncomingMessage, "method" | "url" | "headers" | typeof Symbol.asyncIterator>;

I dropped last part typeof Symbol.asyncIterator and it fixed the problem for me.

Thanks

Hey @AnatolyRugalev do you have a repo I could take a look at? If not, could you let me know the version of TypeScript you're using, and could you paste your tsconfig.json here?

commented

@tatethurston I have to admit that I have no idea what I'm doing when it comes to the TypeScript. I am essentially working on API itself and I need JS compatible client for our testing framework. I will certainly provide you with everything I can, but please forgive me for my ignorance.

This is the repo that I use for twirp generation:
https://github.com/GetStream/stream-chat-js/tree/twirp-api

The repo is set up for ES5 target in tsconfig.json, so I bumped it to ES2020 to fix other compilation errors. I also changed parser version in .eslintrc.json to 2020 which, I assume, corresponds to ES2020 build target.

You can find all changes that I did to make it work with TwirpScript in this commit: GetStream/stream-chat-js@e66385e

Thanks @AnatolyRugalev. I’ll take a look and see if I can recreate the type error. Off the top of my head, it could be very old @types/node but I’ll let you know what I find. In theory, if you’re just building a client and not using the server then @node/types should be unnecessary — I’ll check and if that is not the case I’ll update twirpscript.

As a design goal, I would like TwirpScript to “just work” with any starter tsconfig, no Typescript knowledge required. This will help me provide some guidance for minimal supported versions for typescript and node.

This has been resolved in v0.0.60. Thanks @AnatolyRugalev!