Skip to content

Commit

Permalink
fix(eslint-plugin): [return-await] allow Any and Unknown (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk authored and bradzacher committed Nov 27, 2019
1 parent e9d44f5 commit ebf5e0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 1 addition & 5 deletions packages/eslint-plugin/src/rules/return-await.ts
Expand Up @@ -68,11 +68,7 @@ export default util.createRule({
}

const type = checker.getTypeAtLocation(child);

const isThenable =
tsutils.isTypeFlagSet(type, ts.TypeFlags.Any) ||
tsutils.isTypeFlagSet(type, ts.TypeFlags.Unknown) ||
tsutils.isThenableType(checker, expression, type);
const isThenable = tsutils.isThenableType(checker, expression, type);

if (!isAwait && !isThenable) {
return;
Expand Down
10 changes: 10 additions & 0 deletions packages/eslint-plugin/tests/rules/return-await.test.ts
Expand Up @@ -148,6 +148,16 @@ ruleTester.run('return-await', rule, {
}
}`,
},
{
code: `async function test(): Promise<string> {
const res = await Promise.resolve('{}');
try {
return JSON.parse(res);
} catch (error) {
return res;
}
}`,
},
],
invalid: [
{
Expand Down

0 comments on commit ebf5e0a

Please sign in to comment.