Closed as not planned
Description
π Search Terms
anonymous function type, return object value
π Version & Regression Information
Same behavior for version 3.9.7, 4.9.5, 5.5.4, 5.6.0-beta and v5.6.0-dev.20240810.
β― Playground Link
π» Code
type ReturnValue = { r: number }
type ParamValue = { p: number }
function f(param: ParamValue): ReturnValue {
return {
r: param.p,
// @ts-expect-error
error: "error",
};
}
f({
p: 0,
// @ts-expect-error
error: "error"
})
type AF = (param: ParamValue) => ReturnValue;
const af: AF = (param:ParamValue) => {
return {
r: param.p,
// @ts-expect-error
error: "error",
};
};
af({
p: 0,
// @ts-expect-error
error: "error"
})
π Actual behavior
At third // @ts-expect-error
(return object of function af
) giving error because it's not used. Since there is no error at that line.
π Expected behavior
Typescript should give error about extraneous error
property, since for non-anonymous type function f
gave that error. This same error happen for parameter of both af
and f
function. I assume this should be the case for return value too.