-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
"The inferred type of X cannot be named without a reference to Y" (TS2742) still happens, when working with npm link to link packages manually #58914
Comments
I did not go into vivid detail into what could possibly be causing this issue, when it has supposedly been fixed in the general case for pnpm, because I frankly do not know what it could be, but the repository is not very big and contains everything needed to reproduce the error. I'm suspecting this instance has something to do with |
It doesn't really have anything to do with |
Thanks for the answer @weswigham, as an aspiring Compiler Technician myself I actually entirely understand, and was honestly a little surprised as a similar problem causing this error had been solved via #42873, so it gave me hope that maybe this could be solved too, somehow. This problem occurs to me at work, and while I obviously can't disclose the details, the situation (and the problem) is pretty much identical. The part that frustrates me the most, is that we used to only use Javascript + JSDoc and simply TypeScript-checked all of our files. Now that we are transitioning to full-typescript, this has become an issue, almost out of nowhere. It's befuddling, and frustrating. I must try and check, if the problem persists in the minimal repository if the files were instead JS+JSDoc+autogenerated Typescript Declaration files, but I suspect the problem would not exist there. This is especially frustrating again, because we have a lot of repositories, and using them via published npm-packages works just fine (ie. the tarball works), but manually linking the packages together during development, to make development easier, now breaks :/ |
I'm seeing a similar issue in a monorepo on 5.5 (
The module from which we import If this isn't expected or it's unclear why it'd be happening I can try and come up with a small repro. |
As I promised here, after a while I've made the necessary changes in jsdoc-branch of the original referenced project. I also updated the expected typescript version to a newer My question really is, can you explain why this is? At work, I've for years wanted to move from javascript (+jsdoc) onto true typescript, because of multiple benefits that I see with using just typescript, but for some reason that I can't really explain, we've had issues like these emerge.. "out of nowhere"? With basically identical source code, and identical typescript-configuration files, just moving from javascript to typescript. I thought the move would be easier. |
Recently upgraded to 5.5.4 without any of these issues, when I installed |
π Search Terms
is:issue is:open 2742
π Version & Regression Information
This seems to not be a regression bug
β― Playground Link
https://github.com/Teascade/typescript-error-demonstration
π» Code
Replacing this with
π Actual behavior
Produces
src/index.ts(4,14): error TS2742: The inferred type of 'a' cannot be named without a reference to '@privateprefix/lib/node_modules/joi'. This is likely not portable. A type annotation is necessary.
π Expected behavior
No error is to be expected
Additional information about the issue
In #42873 (comment) it was mentioned, that this issue would now be resolved in TypeScript beta 5.5.0, but it seems to still be broken in this specific scenario
I've made a minimal repository to reroduce this issue in https://github.com/Teascade/typescript-error-demonstration
The GitHub repository has a github action in which the issue is reproduced: https://github.com/Teascade/typescript-error-demonstration/actions/runs/9568149578/job/26377636108
The text was updated successfully, but these errors were encountered: