Skip to content

RequestInit interface does not support all of the props in dom RequestInit interface #1172

@btakita

Description

@btakita

Bug Description

The RequestInit interface does not have many of the props in the dom version of RequestInit.

undici RequestInit

undici/types/fetch.d.ts

Lines 95 to 103 in 5d52423

export interface RequestInit {
readonly method?: string
readonly keepalive?: boolean
readonly headers?: HeadersInit
readonly body?: BodyInit
readonly redirect?: RequestRedirect
readonly integrity?: string
readonly signal?: AbortSignal
}

dom RequestInit

interface RequestInit {
    /** A BodyInit object or null to set request's body. */
    body?: BodyInit | null;
    /** A string indicating how the request will interact with the browser's cache to set request's cache. */
    cache?: RequestCache;
    /** A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. */
    credentials?: RequestCredentials;
    /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
    headers?: HeadersInit;
    /** A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
    integrity?: string;
    /** A boolean to set request's keepalive. */
    keepalive?: boolean;
    /** A string to set request's method. */
    method?: string;
    /** A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. */
    mode?: RequestMode;
    /** A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
    redirect?: RequestRedirect;
    /** A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. */
    referrer?: string;
    /** A referrer policy to set request's referrerPolicy. */
    referrerPolicy?: ReferrerPolicy;
    /** An AbortSignal to set request's signal. */
    signal?: AbortSignal | null;
    /** Can only be null. Used to disassociate request from any Window. */
    window?: null;
}

Reproducible By

fetch('https://example.com', { mode: 'cors' })

Expected Behavior

No type errors

Logs & Screenshots

TS2345: Argument of type '{ mode: string; }' is not assignable to parameter of type 'RequestInit'.
  Object literal may only specify known properties, and 'mode' does not exist in type 'RequestInit'.

Environment

Node v17.3.1

Additional context

Even if the props are not implemented, it is still useful to have them to properly support isomorphic fetch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions