Closed
Description
Search Terms:
Async, Await, Refactoring, Code Fix, Explicit Type
Code
function f() {
return Promise.resolve().then(res => 1);
}
Expected behavior:
A Code Action: "Convert To Async Function" is offered.
Actual behavior:
No Code Actions are available.
This bug is due to using node.type rather than calling checker.getTypeAtLocation()
in suggestionDiagnostics addConvertToAsyncFunctionDiagnostics()
:
const functionType = node.type ? checker.getTypeFromTypeNode(node.type) : undefined;
Changing the code to the following fixes this bug, but introduces bugs in the unused variable detection, at least when running tests.
const functionType = checker.getTypeAtLocation(node);
Activity