You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an issue in my monorepo using pnpm and typescript, which started to occur after my migration from yarn to pnpm.
Here is the gist of how to reproduce the issue
Package @my-app/lib-b package has random-package (not important) as dependency, exporting a TypeFromDependency type
In this package, define a function sharedFunction whose return type depends directly on TypeFromDependency
Service @my-app/lib-a has @my-app/lib-a as dependency and uses sharedFunction as follows:
exportconstbar=sharedFunction();
This produces the following warning
The inferred type of 'bar' cannot be named without a reference to '../../lib-b/node_modules/random-package/dist'. This is likely not portable. A type annotation is necessary.
Run pnpm package (the command will fail because tsc fails in libA workspace, this is the issue)
Open packages/lib-a/src/libA.ts in VSCode/your IDE, see the following error
The inferred type of 'exportedLibB' cannot be named without a reference to '../../lib-b/node_modules/random/dist'. This is likely not portable. A type annotation is necessary.
Expected behavior:
Unless I am mistaken, no type error should occur, lib-a exports a variable which is the return value of a lib-b function, declared as dependency
Actual behavior:
The inferred type of 'exportedLibB' cannot be named without a reference to '../../lib-b/node_modules/random/dist'. This is likely not portable. A type annotation is necessary.
Additional information:
node -v prints: v16.19.0
Windows, macOS, or Linux?: Reproduced on MacOS and Linux, no windows computer to test this out.
Notes
The issue occurs with $ pnpm tsc in packages/lib-a
But does not occur when running $ pnpm tsc --noEmit in packages/lib-a
web/src/lib/trpc.tsx:7:14 - error TS2742: The inferred type of 'trpc' cannot be named without a reference to '../../../api/node_modules/@snaplet/sdk/src'. This is likely not portable. A type annotation is necessary.
7 export const trpc = createReactQueryHooks<WebRouter>()
I had the same issue involving @prisma/client and @trpc/server, I was able to resolve them by adding both to public hoisting and manually deleting their local symlink in packages/api/node_modules/{@prisma/client,@trpc/server}.
The main issue now is that web being one of my own packages in my workspace, I have no option to hoist it to the root with pnpm.
Using node-linker=hoisted fixes the issue. However, it causes the post-install scripts to run every time you run the install. But it is worth fixing this issue.
I have an issue in my monorepo using pnpm and typescript, which started to occur after my migration from yarn to pnpm.
Here is the gist of how to reproduce the issue
@my-app/lib-b
package has random-package (not important) as dependency, exporting aTypeFromDependency
typesharedFunction
whose return type depends directly onTypeFromDependency
@my-app/lib-a
has@my-app/lib-a
as dependency and usessharedFunction
as follows:This produces the following warning
pnpm version:
7.27.0
Code to reproduce the issue:
https://github.com/GuillaumeLagrange/type-issue
tsc
fails in libA workspace, this is the issue)packages/lib-a/src/libA.ts
in VSCode/your IDE, see the following errorExpected behavior:
Unless I am mistaken, no type error should occur, lib-a exports a variable which is the return value of a lib-b function, declared as dependency
Actual behavior:
The inferred type of 'exportedLibB' cannot be named without a reference to '../../lib-b/node_modules/random/dist'. This is likely not portable. A type annotation is necessary.
Additional information:
node -v
prints:v16.19.0
Notes
The issue occurs with
$ pnpm tsc in packages/lib-a
But does not occur when running
$ pnpm tsc --noEmit in packages/lib-a
It looks like microsoft/TypeScript#47663
I have originally opened the issue in here swarmion/swarmion#508
The text was updated successfully, but these errors were encountered: