mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 11:46:08 -05:00
Ban inferred return type on async and generator functions. (#58628)
This commit is contained in:
committed by
GitHub
parent
ddf43cd0e0
commit
a203ace7af
@@ -14,10 +14,12 @@ import {
|
||||
Expression,
|
||||
forEachReturnStatement,
|
||||
FunctionExpression,
|
||||
FunctionFlags,
|
||||
FunctionLikeDeclaration,
|
||||
GetAccessorDeclaration,
|
||||
getEffectiveReturnTypeNode,
|
||||
getEffectiveTypeAnnotationNode,
|
||||
getFunctionFlags,
|
||||
getJSDocTypeAssertionType,
|
||||
getStrictOptionValue,
|
||||
HasInferredType,
|
||||
@@ -469,6 +471,8 @@ export function createSyntacticTypeNodeBuilder(options: CompilerOptions, resolve
|
||||
function typeFromSingleReturnExpression(declaration: FunctionLikeDeclaration | undefined, context: SyntacticTypeNodeBuilderContext): boolean | undefined {
|
||||
let candidateExpr: Expression | undefined;
|
||||
if (declaration && !nodeIsMissing(declaration.body)) {
|
||||
if (getFunctionFlags(declaration) & FunctionFlags.AsyncGenerator) return undefined;
|
||||
|
||||
const body = declaration.body;
|
||||
if (body && isBlock(body)) {
|
||||
forEachReturnStatement(body, s => {
|
||||
|
||||
Reference in New Issue
Block a user