Skip to content

Bug: implicit any flags renamed destructuring from async/await within loops when shadowing variable names #36666

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

Closed
admwx7 opened this issue Feb 7, 2020 · 1 comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@admwx7
Copy link

admwx7 commented Feb 7, 2020

NOTE: this issue is quite similar to #32278 though I could only reproduce my exact issue when using a loop and async functions with a let/var. The conditions were different enough I though it made sense to open a separate issue.

TypeScript Version: 3.8.0-dev.20200205

Search Terms:
circular, implicit, referenced directly

Code

async function inner(param1: string | undefined): Promise<{ param1?: string }> {
  return { param1: '' };
}

async function outer() {
  let param1;
  do {
    const { param1: newParam } = await inner(param1);
    param1 = newParam;
  } while (param1)
}

Expected behavior:
No error

Actual behavior:
newParam is flagged with the following error:

const newParam: any
'newParam' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

Playground Link:
playground

Related Issues:
#33191
#29414
#32278

@RyanCavanaugh
Copy link
Member

This is definitely a circularity, thus the error. We can avoid some circularity errors but not all of them, but this isn't one we're equipped to avoid.

@RyanCavanaugh RyanCavanaugh added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

2 participants