jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
887 stars 119 forks source link

Typescript resolving "jest" to "jest-fetch-mock" location #155

Open sadsa opened 4 years ago

sadsa commented 4 years ago

I am using RushJS for maintaining a mono-repo and I got a strange error that prevented me from running any TS tests.

../../common/temp/node_modules/.pnpm/registry.npmjs.org/@jest/core/25.1.0/node_modules/@jest/core/build/cli/index.d.ts:10:53 - error TS2694: Namespace 'yargs' has no exported member 'Arguments'.

10 export declare const runCLI: (argv: import("yargs").Arguments<Partial<{
                                                       ~~~~~~~~~

../../common/temp/node_modules/.pnpm/registry.npmjs.org/jest-cli/25.1.0/node_modules/jest-cli/build/cli/index.d.ts:10:77 - error TS2694: Namespace 'yargs' has no exported member 'Arguments'.

10 export declare const buildArgv: (maybeArgv?: string[] | undefined) => yargs.Arguments<Partial<{
                                                                               ~~~~~~~~~

After some investigating I ran npx tsc --traceResolution and saw that typescript was resolving jest to jest-fetch-mock's path on disk. I think this may be the module resolution strategy being defaulted to "NodeJS".

======== Resolving module 'jest' from 'C:/Users/Josh/Projects/***/***/common/temp/node_modules/.pnpm/registry.npmjs.org/jest-fetch-mock/3.0.2/node_modules/jest-fetch-mock/types/index.d.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.

Any ideas are welcome, as I can't use this library until it's resolved.

jefflau commented 4 years ago

What version are you using? Any ideas @yinzara?