Skip to content
Quiz · Unions and literal types · lesson 4 of 8

Quiz — the type after ??

Which type does TypeScript infer for shown?

TypeScript
function label(city: string | null) {
    const shown = city ?? "—";
    return shown;
}

console.log(label(null));