marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
810 stars 56 forks source link

Type 'DeepNullable<K>' does not satisfy the constraint 'WeakKey' #130

Closed zervant-konstantin closed 3 months ago

zervant-konstantin commented 4 months ago

I am using:

NodeJS v21.7.1
typescript@5.4.2
jest-mock-extended@3.0.5

When I build project by command tsc I have these errors from ts-essentials, that is the dependency of jest-mock-extended

I understand that errors inside ts-essentials, but it effect to jest-mock-extended. jest-mock-extended uses old version ts-essentials - ^7.0.3 (latest is 9.4.1)

I created also the issue https://github.com/ts-essentials/ts-essentials/issues/381

Do you have any ideas to fix it?

node_modules/ts-essentials/dist/types.d.ts:67:13 - error TS2344: Type 'DeepNullable<K>' does not satisfy the constraint 'WeakKey'.
  Type 'symbol | object | (Builtin & object) | Map<unknown, unknown> | WeakMap<symbol | object | null, unknown> | Set<unknown> | WeakSet<symbol | object | null> | unknown[] | Promise<unknown> | null' is not assignable to type 'WeakKey'.
    Type 'null' is not assignable to type 'WeakKey'.

67   ? WeakMap<DeepNullable<K>, DeepNullable<V>>
               ~~~~~~~~~~~~~~~

node_modules/ts-essentials/dist/types.d.ts:71:13 - error TS2344: Type 'DeepNullable<U>' does not satisfy the constraint 'WeakKey'.
  Type 'symbol | object | (Builtin & object) | Map<unknown, unknown> | WeakMap<symbol | object | null, unknown> | Set<unknown> | WeakSet<symbol | object | null> | unknown[] | Promise<unknown> | null' is not assignable to type 'WeakKey'.

71   ? WeakSet<DeepNullable<U>>
               ~~~~~~~~~~~~~~~

node_modules/ts-essentials/dist/types.d.ts:91:13 - error TS2344: Type 'DeepUndefinable<K>' does not satisfy the constraint 'WeakKey'.
  Type 'symbol | object | (Builtin & object) | Map<unknown, unknown> | WeakMap<symbol | object | undefined, unknown> | Set<unknown> | WeakSet<symbol | object | undefined> | unknown[] | Promise<...> | undefined' is not assignable to type 'WeakKey'.
    Type 'undefined' is not assignable to type 'WeakKey'.

91   ? WeakMap<DeepUndefinable<K>, DeepUndefinable<V>>
               ~~~~~~~~~~~~~~~~~~

node_modules/ts-essentials/dist/types.d.ts:95:13 - error TS2344: Type 'DeepUndefinable<U>' does not satisfy the constraint 'WeakKey'.
  Type 'symbol | object | (Builtin & object) | Map<unknown, unknown> | WeakMap<symbol | object | undefined, unknown> | Set<unknown> | WeakSet<symbol | object | undefined> | unknown[] | Promise<...> | undefined' is not assignable to type 'WeakKey'.

95   ? WeakSet<DeepUndefinable<U>>
image
Beraliv commented 3 months ago

Hey @zervant-konstantin!

First of all, sorry for this inconvenience!

I've released ts-essentials@9.4.2 with TypeScript 5.3 and 5.4 support and now it is expected to be working.

Kindly ask to verify it on your side and come back to me should something doesn't work on your side

kpachbiu88 commented 3 months ago

Hey @zervant-konstantin!

First of all, sorry for this inconvenience!

I've released ts-essentials@9.4.2 with TypeScript 5.3 and 5.4 support and now it is expected to be working.

Kindly ask to verify it on your side and come back to me should something doesn't work on your side

Thank you, for fast solution!

timdavish commented 3 months ago

Adding a comment just in case the above doesn't notify ^^

See #131