tatethurston / TwirpScript

A protobuf RPC framework for JavaScript and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ServerRequest Type Definition Fails to Compile

arranf opened this issue · comments

I'm running into this error when compiling an example server using TS 4.1.3 on Node 16.3.

I will provide a reduced example which I'll PR to the /examples directory.

Type 'symbol | "headers" | "method" | "url"' does not satisfy the constraint '"push" | "complete" | "pause" | "readable" | "resume" | "unshift" | "aborted" | "headers" | "on" | "off" | "pipe" | "unpipe" | "socket" | "trailers" | "connection" | "removeListener" | ... 35 more ... | "eventNames"'.
  Type 'symbol' is not assignable to type '"push" | "complete" | "pause" | "readable" | "resume" | "unshift" | "aborted" | "headers" | "on" | "off" | "pipe" | "unpipe" | "socket" | "trailers" | "connection" | "removeListener" | ... 35 more ... | "eventNames"'.

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

Playing around with this I don't think it's possible to use typeof in a Pick type as typeof runs at runtime but Pick is compile time. I could be completely missing something here because I don't get a linting error just a tsc error though.

After further testing I can no longer replicate this. I think it might've been a race condition in my build step possibly.