@@ -9858,7 +9858,7 @@ namespace ts {
98589858 return aggregatedTypes;
98599859 }
98609860
9861- /*
9861+ /*
98629862 *TypeScript Specification 1.0 (6.3) - July 2014
98639863 * An explicitly typed function whose return type isn't the Void or the Any type
98649864 * must have at least one return statement somewhere in its body.
@@ -9893,7 +9893,7 @@ namespace ts {
98939893 }
98949894 else {
98959895 // This function does not conform to the specification.
9896- // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
9896+ // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
98979897 error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
98989898 }
98999899 }
@@ -11914,19 +11914,25 @@ namespace ts {
1191411914 return unknownType;
1191511915 }
1191611916
11917+ // If the constructor, resolved locally, is an alias symbol we should mark it as referenced.
11918+ const promiseName = getEntityNameFromTypeNode(node.type);
11919+ const promiseNameOrNamespaceRoot = getFirstIdentifier(promiseName);
11920+ const promiseAliasSymbol = resolveName(node, promiseNameOrNamespaceRoot.text, SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
11921+ if (promiseAliasSymbol) {
11922+ markAliasSymbolAsReferenced(promiseAliasSymbol);
11923+ }
11924+
1191711925 // Validate the promise constructor type.
1191811926 const promiseConstructorType = getTypeOfSymbol(promiseConstructor);
1191911927 if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) {
1192011928 return unknownType;
1192111929 }
1192211930
1192311931 // Verify there is no local declaration that could collide with the promise constructor.
11924- const promiseName = getEntityNameFromTypeNode(node.type);
11925- const root = getFirstIdentifier(promiseName);
11926- const rootSymbol = getSymbol(node.locals, root.text, SymbolFlags.Value);
11932+ const rootSymbol = getSymbol(node.locals, promiseNameOrNamespaceRoot.text, SymbolFlags.Value);
1192711933 if (rootSymbol) {
1192811934 error(rootSymbol.valueDeclaration, Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions,
11929- root .text,
11935+ promiseNameOrNamespaceRoot .text,
1193011936 getFullyQualifiedName(promiseConstructor));
1193111937 return unknownType;
1193211938 }
@@ -12119,8 +12125,8 @@ namespace ts {
1211912125 const symbol = getSymbolOfNode(node);
1212012126 const localSymbol = node.localSymbol || symbol;
1212112127
12122- // Since the javascript won't do semantic analysis like typescript,
12123- // if the javascript file comes before the typescript file and both contain same name functions,
12128+ // Since the javascript won't do semantic analysis like typescript,
12129+ // if the javascript file comes before the typescript file and both contain same name functions,
1212412130 // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
1212512131 const firstDeclaration = forEach(localSymbol.declarations,
1212612132 // Get first non javascript function declaration
0 commit comments