Search code examples
javascriptnode.jstypescriptapiyarnpkg

TS2554: Expected 0 arguments, but got 2


Here is a modified version of the code that I have.

return await this.X.y(
 a,
 b,
);

and the function y looks like this:

async y(
    a: string,
    b: B,
  ) {
    return await this.foo.put(
      `${this.config.foobar}/foo/${a}`,
      b,
    );

and I have been getting the error stated above. How is it possible for the function to expect 0 arguments when it has 2 specified with it?


Solution

  • There is obvious conflicts on the expected function being ran. Without no more code to see is difficult to be precise but from that example you gave, my wild guess is that either:

    1. this.foo.put() function does really takes no arguments
    2. you are thinking you are using a function but instead at runtime is another

    Try to debug and get what is the prototype of this.foo and check again the function put() prototype also. I strongly think your line of thought scope is not the same of the running program, it is all about scope ;)