Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected 1 arguments, but got 0.ts(2554) - Disable

Tags:

typescript

For testing and migration proposes I would like to disable this option (TS2554), but I can't seem to find it regarding the name.

{
  "extends": "@quasar/app-webpack/tsconfig-preset",
  "compilerOptions": {
    "baseUrl": ".",
    "noImplicitAny": false,
    "strictPropertyInitialization": false,
    "strictNullChecks": false,
    "????": false
  }
}

Thank you,

like image 798
Júlio Almeida Avatar asked Jan 26 '26 14:01

Júlio Almeida


1 Answers

It sounds like you're trying to call a function with 0 arguments when it expects 1. As far as I know, there is no option you can specify in the tsconfig.json file to allow calls like this.

If you have control over the function signature, you could change the parameter to be optional. Then you could call the function without passing in an argument. Something like this:

function myFunction(a?: any){
  console.log(a);
}

myFunction();

If you do not have control over the function signature, you could cast the function like this:

function myFunction(a: string){
  console.log(a);
}

(myFunction as () => undefined)();

You can also use a @ts-ignore comment to tell the Typescript compiler to not type check your call to the function:

function myFunction(a: string){
  console.log(a);
}

// @ts-ignore
myFunction();

Those last 2 options are unsafe, unless you're sure that the function is equipped to handle a call without arguments.

like image 140
Jordan Avatar answered Jan 28 '26 22:01

Jordan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!