Spot the bug in profile formatting

from Type coverage
TypeScript 6 intermediate 4 min 2 issues to find

Find why this high-coverage profile formatter can still fail at runtime.

TypeScript
type Profile = {
  name: string;
};

function displayName(raw: string): string {
  const profile = JSON.parse(raw) as Profile;
  return profile.name.toUpperCase();
}

console.log(displayName('{"name":null}'));
Open in playground
Report an error