ui
ui copied to clipboard
[bug]: inferred type of 'MenubarMenu' cannot be named without a reference
Describe the bug
next build gives the following error:
Checking validity of types .../src/components/ui/menubar.tsx:13:7
Type error: The inferred type of 'MenubarMenu' cannot be named without a reference to '.pnpm/@[email protected][email protected][email protected]/node_modules/@radix-ui/react-context'. This is likely not portable. A type annotation is necessary.
11 | import { cn } from "@/lib/utils"
12 |
> 13 | const MenubarMenu = MenubarPrimitive.Menu
| ^
14 |
15 | const MenubarGroup = MenubarPrimitive.Group
16 |
Affected component/components
MenuBar
How to reproduce
- execute 'next build'
Codesandbox/StackBlitz link
No response
Logs
Checking validity of types .../src/components/ui/menubar.tsx:13:7
Type error: The inferred type of 'MenubarMenu' cannot be named without a reference to '.pnpm/@[email protected][email protected][email protected]/node_modules/@radix-ui/react-context'. This is likely not portable. A type annotation is necessary.
11 | import { cn } from "@/lib/utils"
12 |
> 13 | const MenubarMenu = MenubarPrimitive.Menu
| ^
14 |
15 | const MenubarGroup = MenubarPrimitive.Group
16 |
System Info
Node.js v22.8.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.0.0: Sat Jul 13 00:54:59 PDT 2024; root:xnu-11215.0.165.0.4~50/RELEASE_ARM64_T6031
Available memory (MB): 131072
Available CPU cores: 16
Binaries:
Node: 22.8.0
npm: 10.8.2
Yarn: N/A
pnpm: 9.9.0
Relevant Packages:
next: 15.0.0-canary.146 // Latest available version is detected (15.0.0-canary.146).
eslint-config-next: N/A
react: 19.0.0-rc-a03254bc-20240905
react-dom: 19.0.0-rc-a03254bc-20240905
typescript: 5.5.4
Next.js Config:
output: N/A
### Before submitting
- [X] I've made research efforts and searched the documentation
- [X] I've searched for existing issues
I was able to solve a similar issue by just installing @radix-ui/react-context in my ui package (using a turbo monorepo).
I am running on the stable version of next and react though
Any luck, i am still facing this?
Tried @tefkah idea to install @radix-ui/react-context in my repo but still same, unable to build
I fixed it by just adding the type annotation
export const MenubarMenu: typeof MenubarPrimitive.Menu = MenubarPrimitive.Menu;
Also I think this is a pnpm only issue as I just switched to it and got this error.