Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async / Await Refactoring - Not offered on promise returning functions without an explicit return type #26374

Closed
elizabethdinella opened this issue Aug 10, 2018 · 0 comments · Fixed by #26749
Assignees
Labels
Bug A bug in TypeScript

Comments

@elizabethdinella
Copy link
Contributor

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
3 participants