|
1 | | -// Minimal ambient declarations for ts-mockito to satisfy type-checking in tests |
| 1 | +/* |
| 2 | +Minimal ambient declarations for ts-mockito to satisfy type-checking in tests |
| 3 | +Why this exists: |
| 4 | +- ts-mockito ships its own type definitions, but our web test TypeScript config |
| 5 | + (see test-tsconfigs/tsconfig.web.json) targets WebWorker libs and intentionally |
| 6 | + omits Node types. The official ts-mockito typings may pull in Node types, which |
| 7 | + would force us to enable `node` types/globals for web tests. |
| 8 | +- Enabling Node types in the web config is undesirable, since it pollutes the |
| 9 | + browser-targeted environment with Node globals. |
| 10 | +
|
| 11 | +This ambient declaration only exposes the subset of ts-mockito APIs we use with |
| 12 | +permissive types. It keeps both desktop and web test builds type-clean without |
| 13 | +adding Node typings to the web configuration. |
| 14 | +
|
| 15 | +If you remove this file, consider either: |
| 16 | +- adding `node` to `types` in test-tsconfigs/tsconfig.web.json; or |
| 17 | +- excluding ts-mockito-dependent tests from the web runner. |
| 18 | +*/ |
2 | 19 | declare module 'ts-mockito' { |
3 | 20 | export function mock<T>(clazz?: new (...args: any[]) => T): T; |
4 | 21 | export function instance<T>(mocked: T): T; |
5 | 22 | export function verify<T>(value: any): any; |
6 | | - export function capture<T>(value: any): { last(): [any, ...any[]] }; |
| 23 | + export function capture<T>(value: any): { |
| 24 | + first(): [any, ...any[]]; |
| 25 | + second(): [any, ...any[]]; |
| 26 | + third(): [any, ...any[]]; |
| 27 | + last(): [any, ...any[]]; |
| 28 | + }; |
7 | 29 | export function anything(): any; |
| 30 | + export function anyString(): string; |
| 31 | + export function spy<T>(instance: T): T; |
8 | 32 | export function reset<T>(mocked: T): void; |
9 | 33 | } |
10 | | - |
11 | | - |
|
0 commit comments