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.

Hi there,

first of all: Thanks a lot for creating trpc 😃 I just recently stumpled upon it and I’m quite enthusiastic about it’s design.

Now to the problem:

I’m trying to use trpc in a pnpm-driven monorepo. When I try to compile the package that’s using trpc (both @trpc/server and @trpc/client), tsc fails with:

../../../../node_modules/.pnpm/@trpc+server@9.23.4/node_modules/@trpc/server/dist/declarations/src/adapters/node-http/types.d.ts:3:16 - error TS2307: Cannot find module 'qs' or its corresponding type declarations.

3 import qs from 'qs';

[...]

../../../../node_modules/.pnpm/@trpc+server@9.23.4/node_modules/@trpc/server/dist/declarations/src/adapters/standalone.d.ts:5:107 - error TS2344: Type 'IncomingMessage' does not satisfy the constraint 'NodeHTTPRequest'.
  Type 'IncomingMessage' is not assignable to type '{ method?: string; query?: any; body?: unknown; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
    Types of property 'method' are incompatible.
      Type 'string | undefined' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.

5 export declare type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;

The first one

TS2307: Cannot find module 'qs' or its corresponding type declarations.

can be fixed by installing @types/qs. However, I don’t think that should be necessary.

The second one

TS2344: Type 'IncomingMessage' does not satisfy the constraint 'NodeHTTPRequest'.

isn’t explicable to me but at least resembles one of the errors documented in #1022.

This issue was closed by #1151, which should be included with the trpc version I’m using (9.23.4).

It’s possible that this is related to my use of pnpm.

Any hint would be appreciated 😃 I’ll keep you posted, if I find anything myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
grebaldicommented, May 23, 2022

Thanks a lot, @sachinraja & @KATT - fix works like a charm.

You guys are great! 👍

1reaction
grebaldicommented, May 21, 2022

@sachinraja

As a side note, what server adapter are you using? I think most people don’t get the @types/qs error because they have @types/express installed (which depends on @types/qs).

Then it’s plausible I’m getting the error, because I’m using fastify 😃

@KATT

Here’s a minimal reproduction: https://github.com/grebaldi/trpc-1904-repro

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type I & Type II Errors | Differences, Examples, Visualizations
In statistics, a Type I error is a false positive conclusion, while a Type II error is a false negative conclusion.
Read more >
Type I and type II errors - Wikipedia
In statistical hypothesis testing, a type I error is the mistaken rejection of an actually true null hypothesis (also known as a "false...
Read more >
What are Type I and Type II Errors? - Simply Psychology
A type 1 error is also known as a false positive and occurs when a researcher incorrectly rejects a true null hypothesis. This...
Read more >
Statistics: What are Type 1 and Type 2 Errors? - AB Tasty
Type 1 errors – often assimilated with false positives – happen in hypothesis testing when the null hypothesis is true but rejected.
Read more >
Type II Error Explained, Plus Example & vs. Type I Error
A Type II error can be contrasted with a type I error is the rejection of a true null hypothesis, whereas a type...
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