Skip to content

Commit 96504fa

Browse files
committed
Use resolvedSymbol instead of mergedSymbol.
Fixes #5333.
1 parent 3ad29ea commit 96504fa

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11631,17 +11631,20 @@ namespace ts {
1163111631
//
1163211632
// When we get the type of the `Promise` symbol here, we get the type of the static
1163311633
// side of the `Promise` class, which would be `{ new <T>(...): Promise<T> }`.
11634-
11634+
1163511635
let promiseType = getTypeFromTypeNode(node.type);
1163611636
if (promiseType === unknownType && compilerOptions.isolatedModules) {
1163711637
// If we are compiling with isolatedModules, we may not be able to resolve the
1163811638
// type as a value. As such, we will just return unknownType;
1163911639
return unknownType;
1164011640
}
11641-
11642-
let promiseConstructor = getMergedSymbol(promiseType.symbol);
11641+
11642+
let promiseConstructor = getNodeLinks(node.type).resolvedSymbol;
1164311643
if (!promiseConstructor || !symbolIsValue(promiseConstructor)) {
11644-
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType));
11644+
let typeName = promiseConstructor
11645+
? symbolToString(promiseConstructor)
11646+
: typeToString(promiseType);
11647+
error(node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName);
1164511648
return unknownType;
1164611649
}
1164711650

tests/baselines/reference/asyncFunctionDeclaration15_es6.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(6,16): error TS1055: Type '{}' is not a valid async function return type.
22
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(7,16): error TS1055: Type 'any' is not a valid async function return type.
33
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(8,16): error TS1055: Type 'number' is not a valid async function return type.
4-
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
4+
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(9,16): error TS1055: Type 'PromiseLike' is not a valid async function return type.
55
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts(10,16): error TS1055: Type 'typeof Thenable' is not a valid async function return type.
66
Type 'Thenable' is not assignable to type 'PromiseLike<any>'.
77
Types of property 'then' are incompatible.
@@ -28,7 +28,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1
2828
!!! error TS1055: Type 'number' is not a valid async function return type.
2929
async function fn5(): PromiseLike<void> { } // error
3030
~~~
31-
!!! error TS1055: Type 'PromiseLike<void>' is not a valid async function return type.
31+
!!! error TS1055: Type 'PromiseLike' is not a valid async function return type.
3232
async function fn6(): Thenable { } // error
3333
~~~
3434
!!! error TS1055: Type 'typeof Thenable' is not a valid async function return type.

0 commit comments

Comments
 (0)