Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
Solid JS con Typescript - "como" prop \ "componente" prop

Así que estoy tratando de hacer lo siguiente con solid-js . Pero no puedo encontrar la manera correcta con mecanografiado.

Quiero modular mi estilismo a través de mis componentes.

 type RelevantTags = Exclude<keyof JSX.IntrinsicElements, 'script' | 'object' | 'style' | 'head'>; type MustHaveProps = { class?: string; } type DynamicComponentProps<Props extends MustHaveProps> = Props & { as: Component<Props> } type DynamicHTMLTagProps<Tag extends RelevantTags> = JSX.IntrinsicElements[Tag] & { as: Tag; } type PossibleComponentTypes<Props extends MustHaveProps> = RelevantTags | Component<Props>; type MyCustomDynamicComponentProps<ComponentType extends PossibleComponentTypes<MustHaveProps> = "div"> = ComponentType extends RelevantTags ? DynamicHTMLTagProps<ComponentType> : DynamicComponentProps<ComponentProps<ComponentType>>; function MyCustomComponent<C extends PossibleComponentTypes<MustHaveProps>>(props: MyCustomDynamicComponentProps<C>){ return <Dynamic component={props.as} class={props.class} /> }

Intenté hacer esto de diferentes maneras. No puedo hacer que TypeScript funcione con los accesorios de componentes dinámicos...

Agradecería mucho alguna ayuda.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hay bastantes etiquetas más, en su mayoría SVG, declaradas en JSX.IntrinsicElements que no aceptan atributos class . Si los excluye a todos, Typescript permite acceder a props.class en la última línea

 type RelevantTags = Exclude<keyof JSX.IntrinsicElements, | 'script' | 'object' | 'style' | 'head' | 'animate' | 'animateMotion' | 'animateTransform' | 'feDistantLight' | 'feFuncA' | 'feFuncB' | 'feFuncG' | 'feFuncR' | 'feMergeNode' | 'fePointLight' | 'feSpotLight' | 'metadata' | 'view' >;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!