ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.45k stars 244 forks source link

Typescript compile error with 1.21.3 #367

Closed steve-baldwin closed 1 year ago

steve-baldwin commented 1 year ago

Upgrading from 1.21.2 to 1.21.3 causes this:

[~/git/koopa-api] yarn tsc:check
yarn run v1.22.19
$ tsc --noEmit
node_modules/axios-mock-adapter/types/index.d.ts:55:6 - error TS2702: 'AxiosAdapter' only refers to a type, but is being used as a namespace here.

55 ) => AxiosAdapter.RequestHandler;
        ~~~~~~~~~~~~

Found 1 error in node_modules/axios-mock-adapter/types/index.d.ts:55

In case it matters, this is with:

The following tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": ["jest.config.js"]
}
m-radzikowski commented 1 year ago

It also causes eslint to fail on @typescript-eslint/no-unsafe-member-access and @typescript-eslint/no-unsafe-call checks:

axiosMock.onPost().reply(200, '...');

eslint with plugin:@typescript-eslint/recommended-requiring-type-checking:

  44:2  error  Unsafe member access .reply on an `any` value  @typescript-eslint/no-unsafe-member-access
  44:2  error  Unsafe call of an `any` typed value            @typescript-eslint/no-unsafe-call
waynemock commented 1 year ago

I'm seeing this issue as well

It also causes eslint to fail on @typescript-eslint/no-unsafe-member-access and @typescript-eslint/no-unsafe-call checks:

axiosMock.onPost().reply(200, '...');

eslint with plugin:@typescript-eslint/recommended-requiring-type-checking:

  44:2  error  Unsafe member access .reply on an `any` value  @typescript-eslint/no-unsafe-member-access
  44:2  error  Unsafe call of an `any` typed value            @typescript-eslint/no-unsafe-call
remcohaszing commented 1 year ago

This was fixed by https://github.com/ctimmerm/axios-mock-adapter/pull/368, but it's not yet released.

pdbhoi commented 1 year ago

This was fixed by #368, but it's not yet released.

Hello Sir When this will release #368

marcbachmann commented 1 year ago

Released as v1.21.4

pdbhoi commented 1 year ago

Released as v1.21.4

Thank you sir

mgrejanin commented 1 year ago

I'm seeing this issue as well

It also causes eslint to fail on @typescript-eslint/no-unsafe-member-access and @typescript-eslint/no-unsafe-call checks: axiosMock.onPost().reply(200, '...'); eslint with plugin:@typescript-eslint/recommended-requiring-type-checking:

  44:2  error  Unsafe member access .reply on an `any` value  @typescript-eslint/no-unsafe-member-access
  44:2  error  Unsafe call of an `any` typed value            @typescript-eslint/no-unsafe-call

I'm getting these typing errors while using v1.21.4. Rolling back to version 1.21.2 works fine.

Any solution here?