Tslint: arrow-return-shorthand incorrect

Created on 20 Feb 2017  路  4Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 4.4.2
  • __TypeScript version__: 2.3.0-dev.20170220
  • __Running TSLint via__: Visual Studio Code as well as directly on the command-line

TypeScript code being linted

interface testInterface {
    "something": number;
}
[].map((e): testInterface => { return { "something": 1 }; });

Actual behavior

'This arrow function body can be simplified by omitting the curly braces and the keyword 'return'. (arrow-return-shorthand)'

Expected behavior

no warning as it cannot be simplified by omitting the curly bracers and the keyword 'return'.

Easy P2 Accepting PRs Enhancement

Most helpful comment

Given the comment by @MrAndersen1 I think the warning can be enhanced to handle this type of return statement and suggest to also wrap the thing into brackets

All 4 comments

Upon reading more about it, however, it turns out you can replace the return and bracers with regular parenthesis => ({ "something": 1 }) so only the warning message would need updating for this case.

Given the comment by @MrAndersen1 I think the warning can be enhanced to handle this type of return statement and suggest to also wrap the thing into brackets

I have to say, though, that wrapping the thing in parenthesis is not intuitive and doesn't look right - even though it may be.

I believe this has been fixed even though it says here that just 3 of 4 tasks are complete.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielKucal picture DanielKucal  路  3Comments

denkomanceski picture denkomanceski  路  3Comments

jacob-robertson picture jacob-robertson  路  3Comments

allbto picture allbto  路  3Comments

rajinder-yadav picture rajinder-yadav  路  3Comments