-
Notifications
You must be signed in to change notification settings - Fork 20
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". This is likely not portable. #508
Comments
After investigation, I have found a less imperfect fix: In It suppresses warnings, but is imperfect because there is no way to know there is an issue until you encounter it by consuming your package |
Thanks for the issue @GuillaumeLagrange, you did a great job pinpointing the issue to this simple cause 💪
Here it would be better to put: ... and not when running Can you open an issue on the In the meantime, the fix you mentioned can be used. And I would recommend adding a comment linking to this issue above the |
@GuillaumeLagrange is this fixed by #541 ? |
Nope, I have managed to reproduce the issue in a minimal repo, and opened an issue on pnpm repo to see if anybody has an idea of what is happening. Interestingly enough, the issue occurs when running |
This seems sensible, we'll keep the issue open during this time |
I just had the same problem on a project, but this time on a service package, not a shared code library. It seems that this issue is happening more and more on more and more monorepos with Hopefully, this fix can help when the above fix mentioned by @GuillaumeLagrange does not work. The following properties are important: {
"extends": "../../tsconfig.options.json",
"compilerOptions": {
"baseUrl": ".",
"composite": false,
"noEmit": true,
"declaration": false,
"declarationMap": false,
"emitDeclarationOnly": false,
},
"references": [ ... ],
"include": ["./**/*.ts"]
} |
@GuillaumeLagrange we ought to try this microsoft/TypeScript#42873 (comment) |
FYI I added a comment in TypeScript#47663 which has workarounds for this issue when using pnpm monorepos. |
Thank you for this, it really sums up quite clearly the different workarounds and their eventual downsides. Not much more we can do than wait on a root fix from either Typescript or pnpm now, not sure how they would go about that though. |
Thanks @pkerschbaum for the link to the detailed explanation! Since the problem occurs only on packages not meant to be consumed by others, we will go with the solution of setting |
Description
With how PNPM manages packages, in a swarmion project we can easily run into the following issue:
@my-app/shared-foo
packages haspackage-a
as dependency, exporting aTypeA
typesharedFunction
whose return type depends directly onTypeA
@my-app/backend-user
has@my-app/shared-foo
as dependency and usessharedFunction
.In
@my-app/backend-user
:This will create an LSP warning
The inferred type of 'bar' cannot be named without a reference to '../path/to/shared-foo/node_modules/package-a'. This is likely not portable. A type annotation is necessary.
Minimal reproduction on the full stack example: 8442a7b (line 15@
examples/swarmion-full-stack/frontend/app/src/main.tsx
)Imperfect fix
package-a
indevDependencies
of@my-app/backend-user
, importe theTypeA
and explicitely type the return value of the functionsPossible leads
Related issues
The text was updated successfully, but these errors were encountered: