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 a package B, that uses a function from library A that is also in my monorepo, that uses @types/testing-library__react that uses @types/testing-library__dom.
So B => A => testing-library-react => testing-library-dom
library A emits declarations, no problem. (when I set tsconfig to have preserveSymlinks, before, I had the same kind of error for A) B uses function from A, tries to generate its own declarations, same tsconfig.
Expected behavior: B generates declarations without errors.
Actual behavior: B fails with
error TS2742: The inferred type of 'renderWithStore' cannot be named without a reference to '@package/A/node_modules/@types/testing-library__dom/queries'. This is likely not portable. A type annotation is necessary.
This happens with yarn as well as with pnpm and I never check with npm.
I know the behavior of TS that does that when there are multiple versions of typings and the compiler cannot guess which one is right and decides to error out instead. It's all good, but here I have 100% the same version of typings everywhere physically on the disk and in yarn.lock and it's probably a bug. It's just I have one that is symlinked and deep, and one that is laying around in node_modules/@types/testing-library__dom and one that is nested in my symlinked package that makes it node_modules/@package/A/node_modules/@types/testing-library__dom
So there are indeed two versions physically (copies), but they are exactly the same as per yarn.lock so it should emit correctly based on their package.json without additional clarification/annotation? Isn't it?
Adding this to file in B fixes it tho, but it's a hack and I don't want to relate on them :(
import * as _ from '@testing-library/dom'
And working with monorepo this happens to me ALL THE TIME quite randomly :(
TypeScript Version: 3.7.5
Search Terms:
symlink, rush, yarn, pnpm, not portable
Code
I'm using Rush that is heavy on symlinks.
I have sure thing only one version of typings of problematic packages as per my
yarn.lock
file.Same with TL/R
I have a package
B
, that uses a function from libraryA
that is also in my monorepo, that uses@types/testing-library__react
that uses@types/testing-library__dom
.So
B => A => testing-library-react => testing-library-dom
library
A
emits declarations, no problem. (when I settsconfig
to havepreserveSymlinks
, before, I had the same kind of error forA
)B
uses function fromA
, tries to generate its own declarations, sametsconfig
.Expected behavior:
B
generates declarations without errors.Actual behavior:
B
fails withThis happens with
yarn
as well as withpnpm
and I never check withnpm
.I know the behavior of TS that does that when there are multiple versions of typings and the compiler cannot guess which one is right and decides to error out instead. It's all good, but here I have 100% the same version of typings everywhere physically on the disk and in
yarn.lock
and it's probably a bug. It's just I have one that is symlinked and deep, and one that is laying around innode_modules/@types/testing-library__dom
and one that is nested in my symlinked package that makes itnode_modules/@package/A/node_modules/@types/testing-library__dom
So there are indeed two versions physically (copies), but they are exactly the same as per
yarn.lock
so it should emit correctly based on theirpackage.json
without additional clarification/annotation? Isn't it?Adding this to file in
B
fixes it tho, but it's a hack and I don't want to relate on them :(And working with monorepo this happens to me ALL THE TIME quite randomly :(
Related Issues:
#30858
The text was updated successfully, but these errors were encountered: