“Obiekt Keycript Keyof” Kod odpowiedzi

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
SHARKO_MAN

Obiekt Keycript Keyof

type staffKeys = 'name' | 'salary';
function getProperty<T, K extends staffKeys>(obj: T, key: K): T[K] {
return obj[key];
}
temitope agboola

Odpowiedzi podobne do “Obiekt Keycript Keyof”

Pytania podobne do “Obiekt Keycript Keyof”

Więcej pokrewnych odpowiedzi na “Obiekt Keycript Keyof” w TypeScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu