Skip to content
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

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

Closed
garyo opened this issue Apr 16, 2021 · 3 comments
Closed

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

garyo opened this issue Apr 16, 2021 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@garyo
Copy link

garyo commented Apr 16, 2021

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.

@tjjfvi
Copy link
Contributor

tjjfvi commented Apr 16, 2021

Minimal repro

@MartinJohns
Copy link
Contributor

Duplicate of #43047.

@typescript-bot
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants