Skip to content

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

Closed
@bradzacher

Description

@bradzacher

πŸ”Ž 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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions