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

140
Visualizações
How did the kind property get removed from (type SquareEvent & type CircleEvent)

how did the kind property get removed from SquareEvent & CircleEvent

type EventConfig<Events extends { kind: string }> = { 
  [E in Events as E["kind"]]: (event: E) => void; 
}
type SquareEvent = { kind: "square", x: number, y: number };
type CircleEvent = { kind: "circle", radius: number };
type Config = EventConfig<SquareEvent | CircleEvent> 

//  type Config = {
  square: (event: SquareEvent) => void; 
  circle: (event: CircleEvent) => void; 
} 

btw u can Find this Example code in the Typescript Handbook page 131

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can find it in Typescript Handbook, right after the snippet you posted:

// Remove the 'kind' property
type RemoveKindField<Type> = {
    [Property in keyof Type as Exclude<Property, "kind">]: Type[Property]
};
 
interface Circle {
    kind: "circle";
    radius: number;
}
 
type KindlessCircle = RemoveKindField<Circle>;
           
type KindlessCircle = {
    radius: number;
}

https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as

about 4 years ago · Juan Pablo Isaza 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