function encodeToken(value: number | string | null | undefined) {
if (value !== null && value !== undefined) {
value = value.toString()
}
return encodeBase64(value) // typescript complains this line
}
function encodeBase64(value: string | null | undefined) { ... }
Typescript complains as below:
(parameter) value: string | number Argument of type 'string | number' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'
The "value" which I passed to encodeBase64 would be string | null | undefined, any number value will transform to string,
Does anyone know how to fix it? Very appreciated