What is the difference between the parameters of the ts function (callback?: () = > void) and (callback?:void)?

function render (callback?: () = > void): string
the parameter of the ts function means that the return value of callback is the return value of the function. The return value of the function is void

The argument to the ts function

function render (callback?:void): string
means that the return value of callback is void

am I right to understand this?

Mar.22,2021

callback?: () = > void, indicates that callback is a function type and does not return a value. It does not mean that the return value is a function. It is written here by ts itself, which not only means the arrow function, but also specifies the parameter type and return value of the function.

callback?:void cannot prove that callback is a function. Ts will think that callback is of type void. You must have reported an error in passing the function.


there's nothing wrong with your understanding. You can actually get a type alias

.
type Callback = () => void;
function render(callback: Callback):string{}
Menu