type Direction = 'up' | 'down' | 'left' | 'right';
function move(direction: Direction) {
console.log('Moving', direction);
}
move('up'); // valid
move('right'); // valid
// move('forward'); // error
type Readonly<T> = {
readonly [K in keyof T]: T[K];
};
interface Car {
make: string;
model: string;
year: number;
}
const myCar: Readonly<Car> = {
make: 'Toyota',
model: 'Corolla',
year: 2020
};
// myCar.make = 'Honda'; // error