Which fix removes the bug?
function parseFlag(v?: string): boolean {
return v.toLowerCase() === "true";
}
- Guard:
return v?.toLowerCase() === "true" - Change the return type to
string - Remove the
?fromv?in the body - Change
===to==in the comparison
v may be undefined; use optional chaining before calling.