resend / react-email

💌 Build and send emails using React
https://react.email
MIT License
12.57k stars 571 forks source link

types(row, tailwind, menu): Replace explicit children typing with React's propsWithChildren generic type #1406

Open rossreicks opened 1 month ago

rossreicks commented 1 month ago

I was running into an error building a project with webpack that specifies a property and children on the Tailwind and Row components.

example code:

  <Row className='mt-6'>
          <Column>
              <Text className='text-base font-medium m-0'>{item.title}</Text>
          </Column>
          <Column>
              <Text className='text-base m-0 text-right'>{item.daysListed} Days</Text>
          </Column>
  </Row>

The webpack error:

Argument of type '{ className: string; }' is not assignable to parameter of type 'Attributes & Readonly<RowProps>'.
      Property 'children' is missing in type '{ className: string; }' but required in type 'Readonly<RowProps>'

If I manually changed the types from the package to propsWithChildren is seemed to work. It seems like webpack is not recognizing the children prop when building and the propsWithChildren allows children to be undefined.

This is specific to using a babel-loader with a babel plugin for typescript, if I ts-loader the typescript first, then babel the react, it works just fine.

It seems pretty harmless but open to any criticisms, first PR so hopefully I am following the rules.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 2:54pm
vercel[bot] commented 1 month ago

@rossreicks is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.