In TypeScript, what exactly is type \'{}\' and how does it relate to other built-in types?
For example, the last line of the following example gives
You need to have your call function like this:
function call(fn: NoArgsFn): T {
return fn();
}
In your original call function you had 2 generic types which you did not pass when calling the function and the compiler failed to infer what types they are.
Type {} is an object literal (as far as I'm aware), and so you can face the same error like this:
var o = {};
var n: number = o; // Error: Type '{}' is not assignable to type 'number'
I'm not exactly sure why the compiler inferred that the function returns {} in your example.