Skip to content

typscript 4.2.4 multiple errors "error TS2304: Cannot find name 'Request'" #201

Open
@JustFly1984

Description

@JustFly1984

I'm working on updating some parts of an API, and tests as part of an API with typescript version 4.

I'm running tsc --noEmit without --skipLibCheck flag, and I see multiple typescript errors in logs.

node_modules/jest-fetch-mock/types/index.d.ts:20:39 - error TS2304: Cannot find name 'Response'.

20     extends jest.MockInstance<Promise<Response>, [string | Request | undefined, RequestInit | undefined]> {
                                         ~~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:20:60 - error TS2304: Cannot find name 'Request'.

20     extends jest.MockInstance<Promise<Response>, [string | Request | undefined, RequestInit | undefined]> {
                                                              ~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:20:81 - error TS2304: Cannot find name 'RequestInit'.

20     extends jest.MockInstance<Promise<Response>, [string | Request | undefined, RequestInit | undefined]> {
                                                                                   ~~~~~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:21:23 - error TS2304: Cannot find name 'Request'.

21     (input?: string | Request, init?: RequestInit): Promise<Response>;
                         ~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:21:39 - error TS2304: Cannot find name 'RequestInit'.

21     (input?: string | Request, init?: RequestInit): Promise<Response>;
                                         ~~~~~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:21:61 - error TS2304: Cannot find name 'Response'.

21     (input?: string | Request, init?: RequestInit): Promise<Response>;
                                                               ~~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:44:31 - error TS2304: Cannot find name 'Request'.

44     isMocking(input: string | Request): boolean;
                                 ~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:97:57 - error TS2304: Cannot find name 'Request'.

97 export type UrlOrPredicate = string | RegExp | ((input: Request) => boolean);
                                                           ~~~~~~~

node_modules/jest-fetch-mock/types/index.d.ts:99:50 - error TS2304: Cannot find name 'Request'.

99 export type MockResponseInitFunction = (request: Request) => Promise<MockResponseInit | string>;
                                                    ~~~~~~~

I have found that this error is possibly related to Request type coming from typescript browser dom library, which is missing in node.js projects, hence causing the missing type.

I found similar issues in github: meilisearch/meilisearch-js#661

Screen Shot 2021-05-13 at 2 40 07 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions