Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
Type definition for a react/jsx element that accepts a specific set of props?

If I have the following:

interface TestProps { test: string }
const TestComponent = (props: TestProps) => <>{props.test}</>;

interface OtherProps { test2: number }
const OtherComponent = (props: OtherProps) => <>{props.test2}</>;

How can I ensure that a variable is a JSX element derived from TestComponent, but not OtherComponent?

E.g. the following should work fine:

const testElement: ReactElement<TestProps> = <TestComponent test="hi"/>; // OK

But this should not work:

const testElement: ReactElement<TestProps> = <OtherComponent test2={6}/>; // Warning

Help greatly appreciated

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda