Passing function as parameter in Typescript: Expected 0 arguments, but got 1.ts

The doSomething type seems incorrect. In the type declaration – () => void it takes no arguments, but later you are passing arguments to it.

For this piece of code following would work, but you would know better what should be the arguments and their types of doSomething. Probably use a interface if you already have an abstraction in your mind.

function performAction(doSomething: (stuff: { name: string, id: string }) => void) {
  doSomething({
    name: "foo",
    id: "bar"
  });
}

Demo for above.

Also if string in your code is a variable you need to change that because string is reserved for the type. In case you don't what to fix the type of doSomething right now you can use the Function type. Demo


Update

For your updated question you need to write function performAction(doSomething: (stuff: someType) => void Demo


You type doSomething as a function with no arguments: doSomething: () => void. Make it, dunno, doSomething: (arg: SomeInterface) => void (SomeInterface being, for example, {name: string; id: string;}).