File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -21155,7 +21155,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2115521155 }
2115621156
2115721157 function isContextSensitiveFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
21158- return hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node) || !!(getFunctionFlags( node) & FunctionFlags.Generator && node.body && forEachYieldExpression(node.body as Block, isContextSensitive) );
21158+ return hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node) || hasContextSensitiveYieldExpression( node);
2115921159 }
2116021160
2116121161 function hasContextSensitiveReturnExpression(node: FunctionLikeDeclaration) {
@@ -21168,6 +21168,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2116821168 return !!forEachReturnStatement(node.body as Block, statement => !!statement.expression && isContextSensitive(statement.expression));
2116921169 }
2117021170
21171+ function hasContextSensitiveYieldExpression(node: FunctionLikeDeclaration): boolean {
21172+ // yield expressions can be context sensitive in situations like:
21173+ //
21174+ // declare function test(gen: () => Generator<(arg: number) => string, void, void>): void;
21175+ //
21176+ // test(function* () {
21177+ // yield (arg) => String(arg);
21178+ // });
21179+ return !!(getFunctionFlags(node) & FunctionFlags.Generator && node.body && forEachYieldExpression(node.body as Block, isContextSensitive));
21180+ }
21181+
2117121182 function isContextSensitiveFunctionOrObjectLiteralMethod(func: Node): func is FunctionExpression | ArrowFunction | MethodDeclaration {
2117221183 return (isFunctionExpressionOrArrowFunction(func) || isObjectLiteralMethod(func)) &&
2117321184 isContextSensitiveFunctionLikeDeclaration(func);
You can’t perform that action at this time.
0 commit comments