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

129
Views
Typescript Pick multiple keys
interface A{
  a:{
    name: string
  }
  b:{
    age: number
  }
}

type PickMultiple = ..... //todo

const child:PickMultiple<A,['a','b']> = {
   name: 'mike',
   age: 18
}

How can I extract multiple keys? it was same as Pick Child key

Ofcourse Pick<A, 'a'| 'b'> can't work as expected

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

interface A {
  a: {
    name: string
  }
  b: {
    age: number
  }
}

type Picked<T, K extends keyof T> = T[K]

const a: Picked<A, 'a' | 'b'> = {
  name: '1',
  age: 18,
}
console.log(a)
about 4 years ago · Juan Pablo Isaza Report

0

It already supports multiple keys

interface Todo {
  title: string;
  description: string;
  completed: boolean;
}
 
type TodoPreview = Pick<Todo, "title" | "completed">;
about 4 years ago · Juan Pablo Isaza Report

0

You can actually pick multiple keys by default

interface A {
  a: {
    name: string;
  };
  b: {
    age: number;
  };
}

type Picked = Pick<A, 'a' | 'b'>;

See full documentation: https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys

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!