When I declared the return type of the function below as {}
, eslint flagged an error stating not to use {}
as a type because it actually means "any non-nullish value".
After understanding the meaning behind this error, I realize that specifying return type {}
allows for returning values of various types.
So, if my intention is to only return an empty object, what should be the appropriate return type to use?
function a(): {} {
return {};
// return 1; // This is NOT ALLOWED
}