mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(44123): forbid convert to async for generator callbacks (#44147)
This commit is contained in:
@@ -174,6 +174,11 @@ namespace ts {
|
||||
switch (arg.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
const functionFlags = getFunctionFlags(arg as FunctionDeclaration | FunctionExpression);
|
||||
if (functionFlags & FunctionFlags.Generator) {
|
||||
return false;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.ArrowFunction:
|
||||
visitedNestedConvertibleFunctions.set(getKeyFromNode(arg as FunctionLikeDeclaration), true);
|
||||
// falls through
|
||||
|
||||
@@ -1706,6 +1706,16 @@ class Foo {
|
||||
return Promise.resolve(1).then(n => n);
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunctionFailed("convertToAsyncFunction__NoSuggestionForGeneratorCallbacks", `
|
||||
function [#|foo|](p: Promise<string[]>) {
|
||||
return p.then(function* (strings) {
|
||||
for (const s of strings) {
|
||||
yield s.toUpperCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
`);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user