-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve S4123 (no-invalid-await): allow Pick<Promise> type #2755
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I left a minor suggestion. Also, I would rename the PR (and the ticket maybe) because it's more about fixing the detection of Promise.prototype.then()
than allowing Pick<Promise> type
.
if (thenProperty && thenProperty.declarations && thenProperty.declarations?.length > 0) { | ||
const declaration = thenProperty.declarations[0]; | ||
return ( | ||
declaration.kind === ts.SyntaxKind.MethodSignature || | ||
declaration.kind === ts.SyntaxKind.MethodDeclaration | ||
); | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (thenProperty && thenProperty.declarations && thenProperty.declarations?.length > 0) { | |
const declaration = thenProperty.declarations[0]; | |
return ( | |
declaration.kind === ts.SyntaxKind.MethodSignature || | |
declaration.kind === ts.SyntaxKind.MethodDeclaration | |
); | |
} | |
return false; | |
return thenProperty?.declarations?.some( | |
d => d.kind === ts.SyntaxKind.MethodSignature || d.kind === ts.SyntaxKind.MethodDeclaration, | |
); |
SonarQube Quality Gate |
Fixes #2658