Skip to content

Unsafe Argument matchers due to return any #38

Open
@ratoaq2

Description

@ratoaq2

When trying to enable the recommended-type-checked from typescript eslint, I found out that most of ts-mockito argument matchers are actually unsafe since most of them returns any, which completely disables type checking.

An example of a common violated rule when using argument matchers, is no-unsafe-argument

Probably, returning any should be avoided for all argument matchers. Here's a suggestion that I'm evaluating:

export declare function anyOfClass<T>(expectedClass: new (...args: any[]) => T): T;
export declare function anyFunction(): Function;
export declare function anyNumber(): number;
export declare function anyString(): string;
export declare function anything<T>(): T;
export declare function between(min: number, max: number): number;
export declare function deepEqual<T>(expectedValue: T): T;
export declare function notNull<T>(): T;
export declare function strictEqual<T>(expectedValue: T): T;
export declare function match(expectedValue: RegExp | string): string;
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
export declare function objectContaining<T extends Object, V extends Optional<T, keyof T>>(expectedValue: V): T;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions