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

Running tsc manually crashes with "Parameter symbol already has a cached type which differs from newly assigned type" #66894

Closed
sirbrillig opened this issue Aug 23, 2022 · 7 comments · Fixed by #73991
Assignees
Labels

Comments

@sirbrillig
Copy link
Member

sirbrillig commented Aug 23, 2022

Quick summary

You can manually run the TypeScript type checks for the client directory with the command yarn tsc -p client --noEmit. This is helpful for finding TS errors before making a commit.

However, now when I run that command, I get the following unhelpful error:

/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:96888
                throw e;
                ^

Error: Debug Failure. Expected [object Object] === [object Object]. Parameter symbol already has a cached type which differs from newly assigned type
    at assignParameterType (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:64862:26)
    at assignContextualParameterTypes (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:64827:21)
    at contextuallyCheckFunctionExpressionOrObjectLiteralMethod (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:65229:29)
    at checkFunctionExpressionOrObjectLiteralMethod (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:65208:13)
    at checkExpressionWorker (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:66805:28)
    at checkExpression (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:66707:38)
    at checkExpressionWithContextualType (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:66396:28)
    at inferTypeArguments (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:62906:39)
    at chooseOverload (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:63566:53)
    at resolveCall (/Users/payton/Code/wp-calypso/node_modules/typescript/lib/tsc.js:63403:26)

This same error happens if I run yarn tsc --build client/tsconfig.json which appears to run fine in the CI environment. I tried starting with a fresh node_modules and removing .tsc-cache but neither has any effect.

It seems to have been introduced by #66817. Before that commit, running the command works as expected. Afterward, it produces the error above.

However, I can't see how that PR could have caused any problems. I tried manually undoing the changes it made and the error continues.

Steps to reproduce

  1. git checkout f0d3672658 (this is the merge commit which matches up to DSP Widget: add hook to test if enabled #66817)
  2. yarn tsc -p client --noEmit
  3. Notice that it displays a debug error.
  4. git checkout f0d3672658~1 (this is the commit before DSP Widget: add hook to test if enabled #66817)
  5. yarn tsc -p client --noEmit
  6. Notice that the process completes successfully.

What you expected to happen

tsc should run and display any TypeScript errors.

What actually happened

tsc fails.

@sirbrillig sirbrillig added [Type] Bug Needs triage Ticket needs to be triaged labels Aug 23, 2022
@sirbrillig
Copy link
Member Author

🤔 Hang on...

I ran tsc inside the client directory, which does appear to work.

cd client && tsc

... and now running yarn tsc -p client --noEmit from the top-level directory seems to work again 🙃

Ok. Nevermind, I guess?

@noahtallen
Copy link
Member

Super weird! Maybe a random bug with how yarn resolves binaries?

@sirbrillig
Copy link
Member Author

🤷 Well, hopefully if anyone else encounters this, they'll find my "solution" helpful.

@sirbrillig sirbrillig reopened this Mar 1, 2023
@sirbrillig
Copy link
Member Author

Reopening this because it really happens a lot. I'd love to find a real solution.

@danielbachhuber
Copy link
Contributor

This issue happens to me every time I miss a TypeScript error.

For example, the following diff produces a crash:

diff --git a/client/my-sites/hosting/sftp-card/ssh-keys.tsx b/client/my-sites/hosting/sftp-card/ssh-keys.tsx
index 7298936fa7..512416acab 100644
--- a/client/my-sites/hosting/sftp-card/ssh-keys.tsx
+++ b/client/my-sites/hosting/sftp-card/ssh-keys.tsx
@@ -18,7 +18,7 @@ import { useAttachSshKeyMutation } from './use-attach-ssh-key';
 import './ssh-keys.scss';
 
 interface SshKeysProps {
-	siteId: number;
+	sited: number;
 	siteSlug: string;
 	username: string;
 	disabled: boolean;

image

image

Maybe this is a known issue though? microsoft/TypeScript#50773

@Automattic/team-calypso-frameworks Is TypeScript supposed to crash this hard when there's an error? I would've expected more friendly error output...

@tyxla
Copy link
Member

tyxla commented Mar 2, 2023

I hit this same error when trying to run yarn tsc --noEmit --project client/tsconfig.json so there must be something going on. I'm investigating.

@tyxla
Copy link
Member

tyxla commented Mar 2, 2023

Got a fix for this #73991 that resolved it for me locally
Working on a fix, this still needs some work.
Finished the fix for this #73991 that resolved it for me locally - cc @danielbachhuber and @sirbrillig.

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

Successfully merging a pull request may close this issue.

4 participants