A project I'm on has decided to warn on typescript-eslint/consistent-type-assertions with options { assertionStyle: 'as', objectLiteralTypeAssertions: 'never' }. Most of the time I like its recommendations. But it can make lambda's too verbose. Compare the following:
x.map((y) => ({ name: 'name', id: 'id' } as SomeType));
and
x.map((y) => {
const item: SomeType = { name: 'name', id: 'id' };
return item;
});
I prefer the first for it's brevity. It is especially preferable when chaining a lot of functions together.
Is there anyway to satisfy typescript-eslint/consistent-type-assertions in this case without introducing a temporary variable and an extra code block with a return?