Dev Highlights

Доки по разработке

This project is maintained by teniryte

Модификаторы свойств

Принципы

Пример

type Nullable<T> = { [P in keyof T]: T[P] | null };

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

const person: Nullable<Person> = { name: null, age: null };

type PersonWithAllPropertiesOptional = Partial<Person>;
const person2: PersonWithAllPropertiesOptional = { name: 'Me' };

const readonlyPerson: Readonly<Person> = { name: 'Alex' };
// readonlyPerson.name = 'Bob'; // Ошибка

Практика