File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -16661,26 +16661,6 @@ namespace ts {
16661
16661
return promisedType && getAwaitedType(promisedType, errorNode);
16662
16662
}
16663
16663
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
-
16684
16664
/**
16685
16665
* Gets the "promised type" of a promise.
16686
16666
* @param type The type of the promise.
@@ -16842,7 +16822,8 @@ namespace ts {
16842
16822
// of a runtime problem. If the user wants to return this value from an async
16843
16823
// function, they would need to wrap it in some other value. If they want it to
16844
16824
// 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) {
16846
16827
if (errorNode) {
16847
16828
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);
16848
16829
}
You can’t perform that action at this time.
0 commit comments