Skip to content

Circular reference misdetection (introduced after 3.6.3) #34960

Closed
@orzFly

Description

@orzFly

TypeScript Version: 3.7.2

Search Terms: 7022, referenced directly or indirectly in its own initializer

Code

let items: string[] | null = null;
items = items || [];

for (const row of []) {
  const item = items.find(() => true); // ERROR
  const result = item ? true: false    // ERROR

  switch (result) {

  }
}

Expected behavior:
No error & warnings.

const item: string | undefined
const result: boolean

Actual behavior:

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

Playground Link: Link

It works in 3.6.3 and fails in 3.7.2.

Related Issues:
I think this is not related to #33191 since this introduced after 3.6.3.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions