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

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

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