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

139
Views
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 answers
Answer question

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 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!