Trying to retrieve an object from an arrow function is posing a challenge for me, especially with the following function f
:
myMethod(f: data => {
return { someField: data.something };
});
I am aware that for simple types, you can condense the arrow function to just data => data.something
.
But is it possible to do the same when returning an object? For example:
myMethod(f: data => { someField: data.something });
This snippet does not compile, presumably because the compiler interprets the {
as the beginning of a function rather than an object.
Is there a workaround for this syntax issue, or should I stick to using the longer form with return
?