#Monorepo confusion

1 messages · Page 1 of 1 (latest)

sudden steepleBOT
#
m.a.t.t.t#0

Preview:ts import {IRequest} from "itty-router" type Request = IRequest & {id: string; pos: string} type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false type RouteType = Equal<Request, IRequest> extends true ? "foo" : "bar"

tidal basin
#

in my monorepo, this same code in different packages leads to different results... I have checked every setting - all the tsconfig files are exactly the same. what might be happening?

tidal basin
#

solved it.. IRequest refers to globalThis.Request
one package had a fetch.d.ts with the following contents, and the other did not:

import {
  type FormData as FormDataType,
  type Headers as HeadersType,
  type Request as RequestType,
  type Response as ResponseType,
} from 'undici'

declare global {
  // Re-export undici fetch function and various classes to global scope.
  // These are classes and functions expected to be at global scope according to Node.js v18 API
  // documentation.
  // See: https://nodejs.org/dist/latest-v18.x/docs/api/globals.html
  export const {
    FormData,
    Headers,
    Request,
    Response,
    fetch,
  }: typeof import('undici')

  type FormData = FormDataType
  type Headers = HeadersType
  type Request = RequestType
  type Response = ResponseType
}
#

!solved