Skip to content

Commit

Permalink
apply reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Feb 23, 2024
1 parent 462c6d2 commit a5c08f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 3 additions & 10 deletions packages/eslint-plugin/src/rules/no-misused-promises.ts
Expand Up @@ -674,14 +674,7 @@ function isVoidReturningFunctionType(
*/
function returnsThenable(checker: ts.TypeChecker, node: ts.Node): boolean {
const type = checker.getApparentType(checker.getTypeAtLocation(node));

if (type.isUnion()) {
return type.types.some(t => anySignatureIsThenableType(checker, node, t));
}

if (anySignatureIsThenableType(checker, node, type)) {
return true;
}

return false;
return tsutils
.unionTypeParts(type)
.some(t => anySignatureIsThenableType(checker, node, t));
}
Expand Up @@ -1236,6 +1236,14 @@ const test: ReturnsRecord = () => {
code: `
declare function foo(cb: undefined | (() => void));
declare const bar: undefined | (() => Promise<void>);
foo(bar);
`,
errors: [{ line: 4, messageId: 'voidReturnArgument' }],
},
{
code: `
declare function foo(cb: string & (() => void));
declare const bar: string & (() => Promise<void>);
foo(bar);
`,
errors: [{ line: 4, messageId: 'voidReturnArgument' }],
Expand Down

0 comments on commit a5c08f4

Please sign in to comment.