Skip to content

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

@admwx7

Description

@admwx7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions