We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 3.9.2, 4.0.0-beta, 4.1.0-dev.20200820
Search Terms: Convert to async function, quick fix, 80006, This may be converted to an async function
Code
const wait = (delay: number): Promise<(msg: string) => void> => new Promise(resolve => setTimeout(() => { const f = (msg: string) => console.log(msg) resolve(f) }, delay) ) const f = () => { return wait(1000).then(res => res('hello')) }
Expected behavior: Running 'Convert to async function' on f should generate code like below.
f
const wait = (delay: number): Promise<(msg: string) => void> => new Promise(resolve => setTimeout(() => { const f = (msg: string) => console.log(msg) resolve(f) }, delay) ) const f = async () => { const res = await wait(1000) return res('hello') }
Actual behavior: Running 'Convert to async function' on f generates code like below.
const wait = (delay: number): Promise<(msg: string) => void> => new Promise(resolve => setTimeout(() => { const f = (msg: string) => console.log(msg) resolve(f) }, delay) ) const f = async () => { const msg=await wait(1000) return res('hello') }
Playground Link: https://www.typescriptlang.org/play?#code/MYewdgzgLgBA7gQwJawLwwBQBMCmAbBATwC4YwBXAWwCMcAnASlIAU6RKkIcAeDSiAOalodJGAEMYqAHwwAbiCRZZMgFAwNZHHBit2nHBjo4IIPHJxTp6zba5QAKkko4Q5KBgySZMAN43bQJhQSFgAMylMfiEYETEJK2DwUzwcADo8EAE+QQYAoM1jFIsMMLyCmABfABoYXAJCcs081RDoGAj0L0T-W2MocjoweGQPAEYABimGNKgACxwwIxNEoowAcgW8TPWGPMrVIA
Related Issues: with imported functions #39858
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
TypeScript Version: 3.9.2, 4.0.0-beta, 4.1.0-dev.20200820
Search Terms:
Convert to async function, quick fix, 80006, This may be converted to an async function
Code
Expected behavior:
Running 'Convert to async function' on
f
should generate code like below.Actual behavior:
Running 'Convert to async function' on
f
generates code like below.Playground Link: https://www.typescriptlang.org/play?#code/MYewdgzgLgBA7gQwJawLwwBQBMCmAbBATwC4YwBXAWwCMcAnASlIAU6RKkIcAeDSiAOalodJGAEMYqAHwwAbiCRZZMgFAwNZHHBit2nHBjo4IIPHJxTp6zba5QAKkko4Q5KBgySZMAN43bQJhQSFgAMylMfiEYETEJK2DwUzwcADo8EAE+QQYAoM1jFIsMMLyCmABfABoYXAJCcs081RDoGAj0L0T-W2MocjoweGQPAEYABimGNKgACxwwIxNEoowAcgW8TPWGPMrVIA
Related Issues:
with imported functions #39858
The text was updated successfully, but these errors were encountered: