TS8020

error TS8020: JSDoc types can only be used inside documentation comments.

Broken Code ❌

1
2
3
function add(a: number, b: number, c: number?): number {
return a + b;
}

Fixed Code ✔️

If you wanted to make c optional:

1
2
3
function add(a: number, b: number, c?: number): number {
return a + b;
}

If you wanted to document c with JSDoc:

1
2
3
4
5
6
7
8
/**
* @param a Initial quantity
* @param b Amount to add
* @param [c] Optional number to add
*/
function add(a: number, b: number, c: number): number {
return a + b;
}