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

203
Visualizações
type myEventHandler<T extends myEvent> = (event: T) => void;

I am new to typescript.

Wondering what exactly this line means in TS?:

type myEventHandler<T extends myEvent> = (event: T) => void;

I know that <> is a type assertion. So I guess myEventHandler should be the type of T. But the 'myEventHandler' is also a type, right? So is that mean we can define a type that belongs to another type?? I guess the event:T is a parameter, so a type can also have a parameter? This line looks like a fat arrow function... and it has a void. Can someone explain it?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

In this case <T extends myEvent> is not a type assertion. It rather declares the type as generic. You can now pass arguments of any type T, as long as the type extends myEvent.

You should read the TypeScript introduction to Generics for further reference.

about 4 years ago · Santiago Gelvez Relatório
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