One of my jQuery plugins has a prompt function that accepts a callback function with setPrompt as the only parameter:
Here is an example of how the code looks:
obj.prompt(function(setPrompt) {
setPrompt(10);
});
I am wondering if it is possible to enforce the parameter of setPrompt to be a string in the d.ts file so that an error is shown when passing a number like 10 without the user explicitly adding a type to the callback.
In my d.ts file, I have the following:
type setStringFunction = (value: string) => void;
type cmdPrompt = (setPrompt: setStringFunction) => void;
interface Cmd extends JQuery {
prompt(cmdPrompt): Cmd;
prompt(): cmdPrompt;
}