How to define type for a function callback (as any function type, not universal any) used in a method parameter

Currently I have type definition as:

interface Param {
    title: string;
    callback: any;
}

I need something like:

interface Param {
    title: string;
    callback: function;
}

but the 2nd one is not being accepted.

10 s
10

The global type Function serves this purpose.

Additionally, if you intend to invoke this callback with 0 arguments and will ignore its return value, the type () => void matches all functions taking no arguments.

Leave a Comment