-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Bug] [Yarn Berry] TS2742: The inferred type of 'testContext' cannot be named without a reference to './.yarn/cache/...' #36675
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
Comments
This specific instance is the error message telling you the truth |
import { createContext } from "react";
import type { Context } from "react";
export const testContext = createContext(0); Just importing the inferred type seems to be enough make this work. Why is TypeScript unable to infer that There seem to be many issues regarding this problem. Having a different import path than the expected Is there anything the Yarn team could change on their end to make this work? Some transparency as to how typescript infers the import would certainly help. |
@skoging if you use |
This was definitely a PnP issue. We ended up upgraded to Yarn 2 by using I'll close the issue. |
TypeScript Version: 3.8.0-dev.20200207
Also tested on 3.5, 3.6 and 3.7 with the same results.
Search Terms: Yarn Berry TS2742 inferred type cannot be named
Code
Example file: https://gist.github.com/skoging/72262b3ac553899b61ad7b6844b3b2b3
Expected behavior:
Yarn 1:
Actual behavior:
Yarn 2
Playground Link:
Related Issues:
#29808
#32970
#29221
#30858
These other issues are likely due the same underlying problem. But based on the comments on some of them, it seems a separate issue with simple reproduction steps is preferred.
This issue is specifically about this problem in Yarn 2 (Yarn Berry).
Yarn:
yarnpkg/berry#919
yarnpkg/berry#736
The text was updated successfully, but these errors were encountered: