message: refactor(jest-mock): clean up internal typings more
diff: @@ -1089,12 +1089,11 @@ export class ModuleMocker {
  methodKey: K,
  ): V extends ClassLike | FunctionLike ? Spied<V> : never;
  - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
  - spyOn<T extends object, K extends PropertyLikeKeys<T>>(
  + spyOn<T extends object>(
  object: T,
  - methodKey: K,
  + methodKey: keyof T,
  accessType?: 'get' | 'set',
  - ) {
  + ): MockInstance {
  if (typeof object !== 'object' && typeof object !== 'function') {
  throw new Error(
  `Cannot spyOn on a primitive value; ${this._typeOf(object)} given`,
  @@ -1168,16 +1167,16 @@ export class ModuleMocker {
  });
  }
  - return object[methodKey];
  + return object[methodKey] as Mock;
  }
  - private _spyOnProperty<T extends object, K extends PropertyLikeKeys<T>>(
  - obj: T,
  - propertyKey: K,
  + private _spyOnProperty<T extends object>(
  + object: T,
  + propertyKey: keyof T,
  accessType: 'get' | 'set',
  - ): Mock<() => T> {
  - let descriptor = Object.getOwnPropertyDescriptor(obj, propertyKey);
  - let proto = Object.getPrototypeOf(obj);
  + ): MockInstance {
  + let descriptor = Object.getOwnPropertyDescriptor(object, propertyKey);
  + let proto = Object.getPrototypeOf(object);
  while (!descriptor && proto !== null) {
  descriptor = Object.getOwnPropertyDescriptor(proto, propertyKey);
  @@ -1216,10 +1215,10 @@ export class ModuleMocker {
  descriptor[accessType] = this._makeComponent({type: 'function'}, () => {
  // @ts-expect-error: mock is assignable
  descriptor![accessType] = original;
  - Object.defineProperty(obj, propertyKey, descriptor!);
  + Object.defineProperty(object, propertyKey, descriptor!);
  });
  - (descriptor[accessType] as Mock<() => T>).mockImplementation(function (
  + (descriptor[accessType] as Mock).mockImplementation(function (
  this: unknown,
  ) {
  // @ts-expect-error - wrong context
  @@ -1227,8 +1226,8 @@ export class ModuleMocker {
  });
  }
  - Object.defineProperty(obj, propertyKey, descriptor);
  - return descriptor[accessType] as Mock<() => T>;
  + Object.defineProperty(object, propertyKey, descriptor);
  + return descriptor[accessType] as Mock;
  }
  clearAllMocks(): void {
  