Skip to content

False error 7022, circular reference when there is actually noneΒ #43708

Closed

Description

Bug Report

πŸ”Ž Search Terms

πŸ•— Version & Regression Information

This is new code, but I'm using 3.8.3. Still occurs in 4.2.3. I asked in the Discord and they said it looks like a bug.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type UserRecord = {name: string}
async function listUsers(token: string|undefined) {
    return {users: [{uid: 1, name: 'Gary'}], pageToken: 'b'}
}

export async function listAuthUsers() {
  let nextPageToken = undefined
  const users: {[uid: string]: UserRecord} = {}
  do {
    const usersList = await listUsers(nextPageToken) // <<<< ERROR 7022 here
    usersList.users.forEach((user) => {
      users[user.uid] = user
    })
    nextPageToken = usersList.pageToken // <<< ERROR DISAPPEARS IF THIS LINE IS COMMENTED OUT
  } while (nextPageToken)
}

πŸ™ Actual behavior

Code above gives error 7022. If you comment out the line nextPageToken = usersList.pageToken then it's OK.

User webstrand on the discord says "even weirder - just the presence of an unused generic causes this issue" with this playground link

and user T6 on discord commented "The reason it's giving that error is CFA
Because the type of nextPageToken depends on usersList, which depends on nextPageToken
Though interestingly it shouldn't really depend on nextPageToken."

πŸ™‚ Expected behavior

No error.

Activity

  1. tjjfvi commented on Apr 16, 2021

    @tjjfvi
    Contributor
  2. MartinJohns commented on Apr 16, 2021

    @MartinJohns
    Contributor

    Duplicate of #43047.

  3. typescript-bot commented on Apr 19, 2021

    @typescript-bot
    Contributor

    This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions