How to define a new type in TypeScript

Solution 1:

You can define it as:

type DayOfWeek = 'Sun' | 'Mon' | 'Tue' | 'Wed' | 'Thu' | 'Fri' | 'Sat';

function setDay(day: DayOfWeek) { ... }