Which fix removes the bug?
function parse(input: string): number {
return JSON.parse(input);
}
- Validate the parsed value
- Change the return to any
- Cast the result as number
- Add a try/catch block
JSON.parse returns any, so the annotation is a promise the code never checks.