-
Notifications
You must be signed in to change notification settings - Fork 885
Conversation
[bugfix] `--test` works correctly with any `compilerOptions.target`
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.
minor comments. let's get this in 5.8.0
function isPromiseType(type: ts.Type): boolean { | ||
const { target } = type as ts.TypeReference; | ||
return target !== undefined && target.symbol !== undefined && promiseTypes.has(target.symbol.name); | ||
function containsType(type: ts.Type, predicate: (name: string) => boolean): boolean { |
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.
seems like a utility we might want in language/utils.ts
, what do you think?
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.
Makes sense. We also use a similar function in return-undefined
and probably in other rules, too.
We need to find a better abstraction than the one used here to make it work for other cases. Will do that in a follow-up PR.
src/rules/awaitPromiseRule.ts
Outdated
@@ -42,6 +42,7 @@ export class Rule extends Lint.Rules.TypedRule { | |||
/* tslint:enable:object-literal-sort-keys */ | |||
|
|||
public static FAILURE_STRING = "'await' of non-Promise."; | |||
public static FAILURE_FOR_AWAIT_OF = "'for-await-of' of non-AsyncIterable."; |
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.
I realized both of these error messages are a bit too terse -- how about
- "Invalid 'await' of a non-Promise value"
- "Invalid 'for-await-of' of a non-AsyncIterable value"
PR checklist
Overview of change:
[enhancement]
await-promise
enforces thatfor-await-of
is only used withAsyncIterableIterator
Fixes: #3232
Is there anything you'd like reviewers to focus on?
Depends on: #3296
CHANGELOG.md entry: