TS2372

error TS2372: Parameter ‘score‘ cannot reference itself.

Broken Code ❌

1
2
3
function printScore(score: number = score): void {
console.log(score);
}

Fixed Code ✔️

If you want to use a default value for a parameter, then you have to set it to a fixed value instead of referencing the parameter to itself:

1
2
3
function printScore(score: number = 0): void {
console.log(score);
}