If I have a function like this:
function say(message: string) {
alert(message);
return say;
}
it has the interesting property that I can chain calls to it:
say("Hello,")("how")("are")("you?");
The compiler will generate a warning if I pass a number into the first call, but it will allow me to put numbers into subsequent calls.
say("Hello")(1)(2)(3)(4)
What type annotation do I need to add to the say function to make the compiler generate warnings when I pass in invalid types to the chained calls?
A type that references itself must have a name. For example,
then you can annotate
sayas anOmegaString,then the following code will type-check.
but the following will not,