primer / react

An implementation of GitHub's Primer Design System using React
https://primer.style/guides/react
MIT License
3.1k stars 533 forks source link

RelativeTime component appears broken #4836

Open pveierland opened 1 month ago

pveierland commented 1 month ago

Description

The typing and import of RelativeTime component appears broken in v36.27.

Steps to reproduce

  1. Create App.tsx with:
import { RelativeTime } from "@primer/react";

export default function App() {
  return (
    <RelativeTime date={new Date("2020-01-01T00:00:00Z")} noTitle={true} />
  );
}
  1. When compiling locally with 36.27.0, this results in the type error Type 'Date' is not assignable to type 'never'.

CodeSandbox 36.27.0 Error: Could not find module in path: '@primer/react/lib/node_modules/@oddbird/popover-polyfill/dist/popover-fn.js' relative to '/node_modules/@primer/react/lib/TooltipV2/Tooltip.js'

CodeSandbox 35.10.0: Error: Module '"@primer/react"' has no exported member 'RelativeTime'.

Version

v36.27

Browser

Chrome, Firefox

Raj3110 commented 1 month ago

image

Code runs perfectly fine!! despite of having type errors.

github-actions[bot] commented 1 month ago

Uh oh! @Raj3110, the image you shared is missing helpful alt text. Check https://github.com/primer/react/issues/4836#issuecomment-2282756633.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

lesliecdubs commented 3 weeks ago

Hi, thanks for reporting. Are you able to share more about the environment where you're running into this? Are you using a framework like Next.js?

0xtrou commented 3 weeks ago

while building our nextjs app, I got error

unhandledRejection Error: Cannot find module '../node_modules/@oddbird/popover-polyfill/dist/popover-fn.js'

pveierland commented 3 weeks ago

Hi, thanks for reporting. Are you able to share more about the environment where you're running into this? Are you using a framework like Next.js?

Yes, using @next==14.2.5 and typescript==5.5.4 locally.

lesliecdubs commented 2 weeks ago

Hi, thanks for letting us know. We think this likely has to do with the popover polyfill mentioned in https://github.com/primer/react/issues/4836#issuecomment-2301665592. Another instance of this bug here: https://github.com/primer/react/issues/4280#issuecomment-2308790144.

@keithamus do you know of any workarounds for folks using Primer who run into this?