Skip to content

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

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

Closed
denis-sokolov opened this issue Jun 3, 2022 · 8 comments · Fixed by #49740
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@denis-sokolov
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.0-dev.20220603

⏯ Playground Link

Does not reproduce in the playground, only reproduces in CLI. To reproduce, run tsc code.ts with the code below.

💻 Code

function wrap<Args extends unknown[]>(_: (...args: Args) => void) {}
wrap(({ cancelable } = {}) => {});

🙁 Actual behavior

Error: Debug Failure. Expected [object Object] === [object Object]. Parameter symbol already has a cached type which differs from newly assigned type
    at assignParameterType (node_modules/typescript/lib/tsc.js:64861:26)
    at assignContextualParameterTypes (node_modules/typescript/lib/tsc.js:64826:21)
    at contextuallyCheckFunctionExpressionOrObjectLiteralMethod (node_modules/typescript/lib/tsc.js:65228:29)
    at checkFunctionExpressionOrObjectLiteralMethod (node_modules/typescript/lib/tsc.js:65207:13)
    at checkExpressionWorker (node_modules/typescript/lib/tsc.js:66804:28)
    at checkExpression (node_modules/typescript/lib/tsc.js:66706:38)
    at checkExpressionWithContextualType (node_modules/typescript/lib/tsc.js:66395:28)
    at inferTypeArguments (node_modules/typescript/lib/tsc.js:62905:39)
    at chooseOverload (node_modules/typescript/lib/tsc.js:63565:53)
    at resolveCall (node_modules/typescript/lib/tsc.js:63402:26)

🙂 Expected behavior

No crash.

(Ideally an error about an implicit any)

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jun 6, 2022
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.8.0 milestone Jun 6, 2022
@jkillian
Copy link

For anyone else who runs in to this, you can work around the crash for now by adding an explicit type to the function argument. Given the example above, this will fix the crash:

function wrap<Args extends unknown[]>(_: (...args: Args) => void) {}
wrap(({ cancelable }: { cancelable?: boolean } = {}) => {});

@jakebailey
Copy link
Member

Unfortunately this bisected to #43845, which introduced the debug message, so that's no indication other than that this has to do with parameter fixing (a la #43835).

This same error had been showing up a lot in fuzzer runs; I think @weswigham said to ping if this sort of thing continued?

@weswigham
Copy link
Member

Right. Anywhere this asset fires is somewhere we're erroneously trying to fix a parameter multiple times and need to, well, not (sometimes that can mean ignoring the second fix, or sometimes that can mean combining the secondary and primary results into the first fix).

@albertodvc
Copy link

I'm still having this issue with v4.8.3.

@jakebailey
Copy link
Member

@albertodvc If you have a case that is still broken, I'd certainly appreciate a new issue with the code snippet.

@albertodvc
Copy link

#50773

@TrySpace
Copy link

I 'fixed' this by updating yarn, I was running an old version (1.x). Then I deleted node_modules and yarn.lock and reinstalled.

Not really a fix though, because I think typescript should give some indication of which code is giving the error.

@gaitho
Copy link

gaitho commented Jun 2, 2023

In my case, I had a dev-dependency of @types/node that was not matching the version of node ( ^20 vs ^16 ). Downgradeing @node/types to 16 resolved it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants