TS variants of CardNav, PillNav, and MaskedHeading fail tsc --noEmit (ElementType dynamic components)
Bug Report
Description
The TypeScript variants (src/ts-default and src/ts-tailwind) of CardNav, PillNav, and MaskedHeading do not type-check. Running tsc --noEmit against the repository (tsconfig includes src) reports 30 errors, all caused by dynamic element components typed as ElementType (linkComponent / tag) being used as JSX tags. Because the inferred element type has no children prop, TypeScript rejects children and other props.
Affected files:
src/ts-default/Components/CardNav/CardNav.tsx(andsrc/ts-tailwind/...)src/ts-default/Components/PillNav/PillNav.tsx(andsrc/ts-tailwind/...)src/ts-default/TextAnimations/MaskedHeading/MaskedHeading.tsx(andsrc/ts-tailwind/...)
Steps to Reproduce
- Clone the repository.
- Run
npx tsc --noEmit(using the providedtsconfig.json). - Observe 30 type errors, e.g.:
src/ts-default/Components/CardNav/CardNav.tsx(466,8): error TS2745: This JSX tag's 'children' prop expects type 'never' which requires multiple children, but only a single child was provided. src/ts-default/TextAnimations/MaskedHeading/MaskedHeading.tsx(581,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'never', but multiple children were provided.
Root Cause
linkComponent is typed as ElementType (from React) and tag as ElementType. When used as <LinkComponent ...> / <Tag ...>, TypeScript resolves the element to a type whose children is never, so passing children (and in MaskedHeading, ref, className, style, etc.) fails.
Expected Behavior
The TS variants should pass tsc --noEmit cleanly. Typing the dynamic component as React.ComponentType<any> (or React.ElementType with an appropriate generic, e.g. React.ElementType<any>) and rendering with proper props would resolve the errors.
Environment
- Node.js: current LTS
- TypeScript: 5.7.3 (per package.json)
- React: 19
Suggested Fix
- In
CardNav/PillNav: changelinkComponent?: ElementTypetolinkComponent?: React.ComponentType<any>(orReact.ElementType<any>), and cast usage accordingly. - In
MaskedHeading: changetag?: ElementTypesimilarly.
This keeps runtime behavior identical while making the TS variants type-check.
Resolved in #1123. Verified the 30 reported errors on the previous main and a clean full npx tsc --noEmit after the fix. Both TypeScript variants of CardNav, PillNav, and MaskedHeading retain their existing public props and rendering behavior. The updated registry files are published in commit 66fd12b4.