Answers for "typescript pick"

11

typescript keyof

interface Person {
  name: string;
  age: number;
  location: string;
}

type K1 = keyof Person; // "name" | "age" | "location"
type K2 = keyof Person[]; // "length" | "push" | "pop" | "concat" | ...
type K3 = keyof { [x: string]: Person }; // string
Posted by: Guest on September-20-2020
2

typescript pick

interface Tarea {
  titulo: string;
  descripcion: string;
  completado: boolean;
}

type TareaReducido = Pick<Tarea, "titulo" | "descripcion">;

const tarea: TareaReducido = {
  titulo: "Limpiar Recamara",
  descripcion: "Poner en orden todo lo que existe en la recamara",
};
Posted by: Guest on July-15-2021
4

typescript record

interface PageInfo {
  title: string;
}

type Page = "home" | "about" | "contact";

const nav: Record<Page, PageInfo> = {
  about: { title: "about" },
  contact: { title: "contact" },
  home: { title: "home" },
};

nav.about;
//   ^ = Could not get LSP result: v.a>bTry
Posted by: Guest on December-20-2020
2

typescript pick

type TodoPreview = Pick<Todo, "title" | "completed">;
Posted by: Guest on December-26-2020
0

typescript utility types merge interfaces

interface A {
    x: string
}

interface B extends Omit<A, 'x'> {
  x: number
}
Posted by: Guest on August-10-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language