Skip to content

Invalid quick fix for function returning Promise<unknown> with isolatedDeclarations #61642

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

Open
bradzacher opened this issue May 2, 2025 · 0 comments
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@bradzacher
Copy link
Contributor

πŸ”Ž Search Terms

isolatedDeclarations, quick fix, promise

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?isolatedDeclarations=true#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVwO4CGmMAqigNYR4oAUAtgM4BccKSdARsFAJRwDeAKDhwowGEii4UwPHAAKUCHUwNgNGnwC8APgEBfHgG5B+waEixEqDNlyFiAZRhRMKAOb1mrdl14DhUXFJaVkFJRU1AB4GFzd3HQ1tPX5DEzMgA

πŸ’» Code

export function waitUnkown(ms: number) {
  return new Promise(() => {});
}
export function waitString(ms: number) {
  return new Promise<string>(() => {});
}

πŸ™ Actual behavior

The quick fix for waitUnknown is "Add return type Promise"
Image

Which annotates the return type as : Promise -- which is a type error as the argument to the promise type is required.

πŸ™‚ Expected behavior

The quick fix for waitUnknown is "Add return type Promise", which is the correct, currently inferred type.

Additional information about the issue

I was trying to codemod Canva's codebase using ts-fix and this bug created a bunch of bad code which I would need to fix up by hand.

@bradzacher bradzacher changed the title Invalid quick fix for Invalid quick fix for function returning Promise<unknown> with isolatedDeclarations May 2, 2025
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels May 2, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants