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

203
Views
Generating TypeScript types from a Map

Is it possible to generate typescript type from a JS Map or equivalent objects? eg.

type SampleType<T> = {
    name: string;
    handle: (value: string) => T;
 };

I have a list of objects like this

[{name: "update", handle: (value: string) => new Date(value)} as SampleType<Date>, {name: "orig", handle: (value: string) => value} as SampleType<string>, {name: "age", handle: parseFloat} as SampleType<number>]

(I mentioned JS Map cause as I can easily convert this into a map where the name is the key, and rest of the object is the value)

Now, I want to generate a type dynamically such that the value of the "name" is the key, and the type is derived from the handle function (or from type of SampleType<>) i.e.

type Result = {
    update: Date;
    orig: string;
    age: number;
};

Is it possible to generate such a type dynamically in typescript?

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