aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tslint/lib/rules/awaitPromiseRule.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/tslint/lib/rules/awaitPromiseRule.js')
-rw-r--r--node_modules/tslint/lib/rules/awaitPromiseRule.js43
1 files changed, 20 insertions, 23 deletions
diff --git a/node_modules/tslint/lib/rules/awaitPromiseRule.js b/node_modules/tslint/lib/rules/awaitPromiseRule.js
index 18c255e72..ba26774f6 100644
--- a/node_modules/tslint/lib/rules/awaitPromiseRule.js
+++ b/node_modules/tslint/lib/rules/awaitPromiseRule.js
@@ -30,27 +30,27 @@ var Rule = (function (_super) {
var tc = program.getTypeChecker();
return this.applyWithFunction(sourceFile, function (ctx) { return walk(ctx, tc, promiseTypes); });
};
+ /* tslint:disable:object-literal-sort-keys */
+ Rule.metadata = {
+ ruleName: "await-promise",
+ description: "Warns for an awaited value that is not a Promise.",
+ optionsDescription: (_a = ["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], _a.raw = ["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], Lint.Utils.dedent(_a)),
+ options: {
+ type: "list",
+ listType: {
+ type: "array",
+ items: { type: "string" },
+ },
+ },
+ optionExamples: [true, [true, "Thenable"]],
+ type: "functionality",
+ typescriptOnly: true,
+ requiresTypeInfo: true,
+ };
+ /* tslint:enable:object-literal-sort-keys */
+ Rule.FAILURE_STRING = "'await' of non-Promise.";
return Rule;
}(Lint.Rules.TypedRule));
-/* tslint:disable:object-literal-sort-keys */
-Rule.metadata = {
- ruleName: "await-promise",
- description: "Warns for an awaited value that is not a Promise.",
- optionsDescription: (_a = ["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], _a.raw = ["\n A list of 'string' names of any additional classes that should also be handled as Promises.\n "], Lint.Utils.dedent(_a)),
- options: {
- type: "list",
- listType: {
- type: "array",
- items: { type: "string" },
- },
- },
- optionExamples: [true, [true, "Thenable"]],
- type: "functionality",
- typescriptOnly: true,
- requiresTypeInfo: true,
-};
-/* tslint:enable:object-literal-sort-keys */
-Rule.FAILURE_STRING = "'await' of non-Promise.";
exports.Rule = Rule;
function walk(ctx, tc, promiseTypes) {
return ts.forEachChild(ctx.sourceFile, cb);
@@ -64,7 +64,7 @@ function walk(ctx, tc, promiseTypes) {
if (Lint.isTypeFlagSet(type, ts.TypeFlags.Any) || isPromiseType(type)) {
return true;
}
- if (isUnionType(type)) {
+ if (tsutils_1.isUnionOrIntersectionType(type)) {
return type.types.some(couldBePromise);
}
var bases = type.getBaseTypes();
@@ -75,7 +75,4 @@ function walk(ctx, tc, promiseTypes) {
return target !== undefined && target.symbol !== undefined && promiseTypes.has(target.symbol.name);
}
}
-function isUnionType(type) {
- return Lint.isTypeFlagSet(type, ts.TypeFlags.Union);
-}
var _a;