@supabase/middleware - v0.4.0
    Preparing search index...

    Type Alias NoConflict<Key, Base, Handler>

    NoConflict: IsAny<Base> extends true
        ? Handler
        : Key extends keyof Base ? Conflict<Key> : Handler

    The collision check Middleware applies: resolves to Handler when Key is free on Base, and to a Conflict sentinel when it is not.

    Site it on the handler parameter, not the Base constraint. TypeScript substitutes a failed constraint silently but prints a failed parameter verbatim, so on the parameter the sentinel's text reaches the reader and the error is reported on the offending call rather than the one enclosing it. pipeline has always taken this route (see ValidateEntries); the Middleware overloads are the nesting equivalent.

    Reuse it in a middleware with a bespoke generic signature (e.g. one that adds a Payload type parameter) by wrapping the handler parameter and leaving the Base constraint to In & BaseContext:

    <Base extends In & BaseContext>(
    handler: NoConflict<Key, Base, (req: Request, ctx: Base & …) => Promise<Response>>,
    ): Produced<Base, In>

    Every overload that can accept the handler needs the wrap. One left unguarded will accept the call the guarded one rejected, resolve its own Base to something unusable, and push the error back out to the enclosing call — which is the failure mode this type exists to remove.

    Type Parameters

    • Key extends string
    • Base
    • Handler

      The handler type to resolve to when Key is free.