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 ran into pnpm/pnpm#7158 while using react-mosaic-component in a monorepo managed by pnpm that uses multiple different versions of react.
In this environment, even though I'm trying to use react-mosaic-component with react@18 and @types/react@18 in a sub-project's package.json, typescript picks up and uses @types/react@19 from the monorepo's root package.json file instead, leading to an error like the following (among others):
error TS2339: Property 'mosaicActions' does not exist on type 'unknown'.
as observed by hovering over the 'react' literal in the import React from 'react' import line in my project's copy of node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_r_5e51779fec180380ca3b15fa496dbe8d/node_modules/react-mosaic-component/lib/contextTypes.d.ts in VS Code and seeing the TypeScript intellisense report:
From pnpm/pnpm#7158 (comment) I understand the issue may be that react-mosaic-component does not declare a peer dependency on @types/react (but rather just a dev dependency):
I've found that this is caused by third-party packages which include type declarations that use react types and have a phantom dependency on @types/react. These packages should list @types/react in peerDependencies but it's fairly common for them to have it only as dev dependency, because with npm's hoisting behavior that phantom dependency typically won't cause issues.
And sure enough if I add the following to my root package.json file then all of the errors disappear and my builds/tests pass:
I ran into pnpm/pnpm#7158 while using
react-mosaic-component
in a monorepo managed bypnpm
that uses multiple different versions of react.In this environment, even though I'm trying to use
react-mosaic-component
withreact@18
and@types/react@18
in a sub-project'spackage.json
, typescript picks up and uses@types/react@19
from the monorepo's rootpackage.json
file instead, leading to an error like the following (among others):for code like this:
as observed by hovering over the
'react'
literal in theimport React from 'react'
import line in my project's copy ofnode_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]_r_5e51779fec180380ca3b15fa496dbe8d/node_modules/react-mosaic-component/lib/contextTypes.d.ts
in VS Code and seeing the TypeScript intellisense report:From pnpm/pnpm#7158 (comment) I understand the issue may be that
react-mosaic-component
does not declare a peer dependency on@types/react
(but rather just a dev dependency):And sure enough if I add the following to my root
package.json
file then all of the errors disappear and my builds/tests pass:Would you consider adding a peer dependency on
@types/react
to this project'spackage.json
file so we could avoid these errors? 🙏The text was updated successfully, but these errors were encountered: