Skip to content

Exported fetch declaration is slightly non-standard #4741

@maxnachlinger

Description

@maxnachlinger

Found in: apollo-server-env@master

Expected: The exported fetch function declaration adheres to the fetch standard.

Actual: It differs from the fetch standard via marking the initial argument as optional.

declare function fetch(
  input?: RequestInfo, // <--- this is what I'm on about
  init?: RequestInit,
): Promise<Response>;

Background:

IMHO the exported fetch function shouldn't allow the first argument to be omitted. The MDN fetch page shows this arg as required as does the living fetch standard - fetch args are really Request ctor args :)

Why am I bothering you about this?
I've created my own fun fetch function and want to pass it along to a RemoteGraphQLDataSource , since the first arg to my fetch function isn't optional, tsc is complaining.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🧬 typingsRelates to TypeScript changes or improvements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions