Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
typescript Pick versus direct property reference

I know there's Pick feature in typescript, like so

type Article = {
  title: string;
  body: string;
  image: string;
}

type ArticlePreview = Pick<Article, 'title'>

but actually you can access the property

type ArticleTitle = Article['title']

what's the advantage of using Pick? I see the second option is more simple and straight forward.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It computes a different type, the two types have different usage (ArticlePreview vs ArticleTitle).

  • ArticlePreview: we compute a type subset of the Article type ;
  • ArticleTitle: we retrieve the type of the title property from the Article type.
type ArticlePreview = Pick<Article, 'title'>;
// equivalent to:
type ArticlePreview = { title: string };
// or to:
type ArticlePreview = { title: Article['title'] };
// You could pick more properties using union inside the generic
type ArticlePreview2 = Pick<Article, 'title' | 'image'>

// While

type ArticleTitle = Article['title']
// is equivalent to:
type ArticleTitle = string
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda