Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'. Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical. #687

Closed
fmvilas opened this issue Nov 12, 2018 · 2 comments
Labels
🌹 has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository

Comments

@fmvilas
Copy link

fmvilas commented Nov 12, 2018

Hi! I'm using apollo-server with Typescript, and it raises the following error:

node_modules/apollo-env/lib/global-fetch.d.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: RequestInfo, Headers, HeadersInit, Body, Request, RequestInit, RequestMode, RequestCredentials, RequestCache, RequestRedirect, ReferrerPolicy, Response, ResponseInit, BodyInit, URLSearchParams

1 declare function fetch(
  ~~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:25:1
    25 interface Account {
       ~~~~~~~~~
    Conflicts are in this file.

node_modules/typescript/lib/lib.dom.d.ts:25:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: RequestInfo, Headers, HeadersInit, Body, Request, RequestInit, RequestMode, RequestCredentials, RequestCache, RequestRedirect, ReferrerPolicy, Response, ResponseInit, BodyInit, URLSearchParams

25 interface Account {
   ~~~~~~~~~

  node_modules/apollo-env/lib/global-fetch.d.ts:1:1
    1 declare function fetch(
      ~~~~~~~
    Conflicts are in this file.

node_modules/typescript/lib/lib.dom.d.ts:16316:11 - error TS2320: Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'.
  Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical.

16316 interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch, WindowOrWorkerGlobalScope, WindowEventHandlers {
                ~~~~~~

It looks like it's related with a change you did 3 days ago in apollo-env but can't confirm this is the real issue.

How to reproduce the error?

Just create a simple project using apollo-server and typescript, and you'll face it when running tsc.

Edit: You can find a sample here: https://github.com/fmvilas/apollo-ts-bug.

Hope it helps!
Thanks!

@fmvilas fmvilas changed the title Apollo + Typescript is broken Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'. Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical. Nov 12, 2018
@ghost ghost added blocking 🌹 has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository labels Nov 12, 2018
@fmvilas
Copy link
Author

fmvilas commented Nov 12, 2018

Just in case it helps, I found that commenting the following lines in apollo-env/lib/global-fetch.d.ts, fixes the problem:

// declare function fetch(
//   input?: RequestInfo,
//   init?: RequestInit
// ): Promise<Response>;
//
// declare interface GlobalFetch {
//   fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
// }

// type RequestInfo = import("./fetch").RequestInfo;
// type Headers = import("./fetch").Headers;
// type HeadersInit = import("./fetch").HeadersInit;
// type Body = import("./fetch").Body;
// type Request = import("./fetch").Request;
type RequestAgent = import("./fetch").RequestAgent;
// type RequestInit = import("./fetch").RequestInit;
// type RequestMode = import("./fetch").RequestMode;
// type RequestCredentials = import("./fetch").RequestCredentials;
// type RequestCache = import("./fetch").RequestCache;
// type RequestRedirect = import("./fetch").RequestRedirect;
// type ReferrerPolicy = import("./fetch").ReferrerPolicy;
// type Response = import("./fetch").Response;
// type ResponseInit = import("./fetch").ResponseInit;
// type BodyInit = import("./fetch").BodyInit;
// type URLSearchParams = import("./url").URLSearchParams;
type URLSearchParamsInit = import("./url").URLSearchParamsInit;

Sorry that I can't help further, I don't really have enough context on how everything is built.

@fmvilas
Copy link
Author

fmvilas commented Nov 12, 2018

Updated the description with a minimal example that reproduces the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌹 has-reproduction ❤ Has a reproduction in a codesandbox or single minimal repository
Projects
None yet
Development

No branches or pull requests

2 participants