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

Debug Failure. Parameter symbol already has a cached type which differs from newly assigned type. #50773

Closed
albertodvc opened this issue Sep 14, 2022 · 8 comments
Assignees
Labels
Bug A bug in TypeScript

Comments

@albertodvc
Copy link

Bug Report

🔎 Search Terms

Error: Debug Failure. Expected [object Object] === [object Object]. Parameter symbol already has a cached type which differs from newly assigned type

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 4.6.4 and 4.7.2
  • This is still happening with the currently latest 4.8.3

⏯ Playground Link

Can't reproduce in the playgorund. To reproduce, run:

tsc code.js --allowJs --noEmit --target esnext.

💻 Code

code.js

class Model {
  save() {
    return this.createMissingLabels()
      .then(() => this.$store.save(this));
  }

  createMissingLabels() {
    if (this.labels && Array.isArray(this.labels)) {
      return Promise.all(this.labels.map(
        label => this.$store.createLabel(label)
      )).then(labels => (this.labels = labels));
    }
    return Promise.resolve();
  }
}

🙁 Actual behavior

Debug Failure. Expected [object Object] === [object Object]. Parameter symbol already has a cached type which differs from newly assigned type

🙂 Expected behavior

No crash

@jakebailey
Copy link
Member

Unsurprisingly, this bisects to #43845, so this appears to be another case where we are accidentally fixing a parameter more than once, but what must be a different code path than #49740.

@jakebailey jakebailey added the Bug A bug in TypeScript label Sep 14, 2022
@smleake
Copy link

smleake commented Oct 14, 2022

Seeing this same issue on 4.7.2 (and latest, 4.8.4). Switching to 4.6.4 remedied the problem, but definitely less than ideal.

@TrySpace
Copy link

TrySpace commented Nov 17, 2022

I've been stuck on ts 4.1.5 for a while now, and I can't figure out which type/code is causing the error, when I update to any higher version like from 4.2.0 through 4.9.3 all give the same error...

And since the error only gives a path to typescript internals: node_modules\typescript\lib\typescript.js:79411:26 from assignParameterType, and no stacktrace, it's really hard to debug

Also with --verbose output I can't see which code it is.

Which part of your code causes the error exactly? And which from: #49383?

See also this duplicate (now closed) issue: #49966 it mentions the lack of error message that you would normally expect to be able to debug.

( It seems the error was meant for internal typescript-library development use, not for outside "consumer-devs"? However in practice this error also occurs outside of the internal development)

@jhmaster2000
Copy link

jhmaster2000 commented Nov 30, 2022

I've just ran into this issue on 4.9.3 and while it for some reason fails to reproduce on TSPlayground I did manage to make it reproduce on the TS Bug Workbench. Interestingly, it does not reproduce on the current Nighty (5.0.0-dev.20221130) and instead produces proper TS errors:

It seems to be related to implicit inferred types? Given that explicitly setting the same type as it infers causes it to be fixed on 4.9.3...

@danthegoodman
Copy link

I ran into this when upgrading TS from 4.2.3 to 4.9.3 on a large internal project. I can't boil it down to a reproducable set of code, but here are the steps I followed to find the offending section of code so I could refactor how the types were specified.

  1. Run tsc with --generateTrace traceOutputDir
  2. Then run npx @typescript/analyze-trace traceOutputDir

At the top of the output was a path to the file that was last processed. I was then able to comment out all of the code in the file, verify that the compile was successful and then slowly reintroduce code until necessary.

In my case, I was able to add an explicit type to a generic function that was trying to do type inference.

You can read more about that analyze-trace tool here

@marekdedic
Copy link
Contributor

Hi,
I'm running into this issue here: https://github.com/skaut/wordpress-version-checker/actions/runs/6865709436/job/18670310204?pr=1051

I know the file where the issue happens (here), but have no idea how to fix this. And unlike others, I'm on TS 5.2.2

Happy to help investigating this, just don't really know how. On my local machine, it's a heisenbug :(

@andrewbranch
Copy link
Member

This was fixed in TypeScript 5.0. @marekdedic if you can still reproduce a bug with the same error message, please file a new issue with some repro steps. The logs from the CI run you linked have expired. Thanks!

@marekdedic
Copy link
Contributor

Hi @andrewbranch

Thanks for the response, unfortunately, I am still getting this with TS 5.3. I filed a new issue (#57435) with a repro. Could you please take a look at it there and let me know if there's anything more you need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

9 participants