Skip to content

@types/jasmine: False compile error when methods are overloaded #34080

@fknittel

Description

@fknittel

Since #33860 we get false compile errors when spying on overloaded methods.

Minimal example:

interface I {
  f(): string;
  f(x: any): number;
}

const spyObject = jasmine.createSpyObj<I>("spyObject", ["f"]);
spyObject.f.and.returnValue("a string, erroneously required to be a number");

Results in:

TS2345: Argument of type '"a string, erroneously required to be a number"' is not assignable to parameter of type 'number'.

Our expectation: The accepted parameter type of returnValue should be string | number, not only number.

(Unfortunately the problematic method overloading (as demonstrated in the I example interface) occurs in external libraries we use, so we can't change that part.)

CC PR author: @kolodny

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