Description
The Rating component compiles and appears to work normally in development mode, but it fails during production build due to a TypeScript error.
In dev mode, the issue may not surface clearly (or may appear only as a type warning depending on tooling), but during next build / tsc --noEmit, the build fails.
Steps to Reproduce
- Import the Rating component:
import { Rating } from "reui";
- Use it normally:
<Rating rating={4} maxRating={5} />
- Run production build:
npm run build
# or
next build
Actual Behavior
Build fails with:
Argument of type 'Element' is not assignable to parameter of type 'never'
Dev vs Build Behavior
- In development mode, the issue may not immediately block rendering
- In some setups, it may only appear as a TypeScript warning
- In production build (strict TS check), it becomes a hard failure and blocks compilation
Root Cause
Inside renderStars():
const stars = []
stars.push(<div>...</div>)
TypeScript infers:
Because:
- The array is initialized empty
- No explicit type is provided
- Strict mode infers
never[]
- JSX elements cannot be assigned to
never
Fix
Recommended fix:
const stars: JSX.Element[] = []
Alternative:
const stars: React.ReactNode[] = []
Suggested Improvement (optional refactor)
Instead of mutation:
const stars = Array.from({ length: maxRating }, (_, i) => {
const star = i + 1
return (
<div key={star}>
...
</div>
)
})
This avoids type inference issues entirely and is more idiomatic React.
Impact
- ❌ Blocks production builds in strict TypeScript setups
- ⚠️ May go unnoticed in dev mode
- 🚫 Affects adoption in modern frameworks (Next.js, Vite + strict TS, etc.)
Environment
- React
- TypeScript strict mode
- Next.js / production build pipeline (
tsc check enabled)
🙌 Contribution Note
Happy to contribute a fix PR if needed because this is a small but important typing issue that improves build reliability.
Description
The
Ratingcomponent compiles and appears to work normally in development mode, but it fails during production build due to a TypeScript error.In dev mode, the issue may not surface clearly (or may appear only as a type warning depending on tooling), but during
next build/tsc --noEmit, the build fails.Steps to Reproduce
npm run build # or next buildActual Behavior
Build fails with:
Dev vs Build Behavior
Root Cause
Inside
renderStars():TypeScript infers:
Because:
never[]neverFix
Recommended fix:
Alternative:
Suggested Improvement (optional refactor)
Instead of mutation:
This avoids type inference issues entirely and is more idiomatic React.
Impact
Environment
tsccheck enabled)🙌 Contribution Note
Happy to contribute a fix PR if needed because this is a small but important typing issue that improves build reliability.