#global Headers mismatch

1 messages · Page 1 of 1 (latest)

near nestBOT
#
m.a.t.t.t#0

Preview:```ts
// @lib: es2022

import "bun-types"

type X = Headers

let x: X = new Headers()

// --debug

type W = typeof globalThis extends {onmessage: any}
? true
: false
// ^?```

floral kiln
#

@rocky niche just poking around at what those refer to: the value named Headers that's in scope (used when you new Headers()) refers to a class from undici, while the type named Headers that's in scope refers to an interface supplied by bun. see this magic in @types/node

did you have a specific question related to this behavior? i was assuming you're asking "why is it like this" and if so maybe what i wrote above is enough of an answer, but if this is causing a specific problem for you or you're looking for something else let me know

minor sundialBOT
#
interface Headers extends _Headers {}
var Headers: typeof globalThis extends {
    onmessage: any;
    Headers: infer T;
} ? T
    : typeof import("undici-types").Headers;
floral kiln
#

☝️ the type system goes into the truthy branch of that conditional type in this case, because there's already a value at globalThis['Headers']