File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16661,26 +16661,6 @@ namespace ts {
1666116661 return promisedType && getAwaitedType(promisedType, errorNode);
1666216662 }
1666316663
16664- /**
16665- * Determines whether a type has a callable 'then' method.
16666- */
16667- function isThenableType(type: Type) {
16668- //
16669- // {
16670- // then( // thenFunction
16671- // ): any;
16672- // }
16673- //
16674-
16675- const thenFunction = getTypeOfPropertyOfType(type, "then");
16676- const thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, SignatureKind.Call) : emptyArray;
16677- if (thenSignatures.length > 0) {
16678- return true;
16679- }
16680-
16681- return false;
16682- }
16683-
1668416664 /**
1668516665 * Gets the "promised type" of a promise.
1668616666 * @param type The type of the promise.
@@ -16842,7 +16822,8 @@ namespace ts {
1684216822 // of a runtime problem. If the user wants to return this value from an async
1684316823 // function, they would need to wrap it in some other value. If they want it to
1684416824 // be treated as a promise, they can cast to <any>.
16845- if (isThenableType(type)) {
16825+ const thenFunction = getTypeOfPropertyOfType(type, "then");
16826+ if (thenFunction && getSignaturesOfType(thenFunction, SignatureKind.Call).length > 0) {
1684616827 if (errorNode) {
1684716828 error(errorNode, Diagnostics.Type_used_as_operand_to_await_or_the_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
1684816829 }
You can’t perform that action at this time.
0 commit comments