Here are the codes:
function a(fn: (a: string) => void) {
fn("Hello, World");
}
a(function b() {
return 1
});
By adding the type annotation to the callback of function a, it means function a must receive a function which has a argument of type string and a return value of type void. But when I passed function b which couldn't satisfy the conditions of the type annotation, TS still didn't throw an compile error. Why?
Also, when I changed the value passed to fn from "Hello, world"(string) to 123(number), it did throw an error. In this case, the type annotation worked.