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) { ... }
After applying the code, a message from Typescript popped up:
(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'
I'm passing the "value" to encodeBase64
, which should be of type string | null | undefined
. Any value that is a number
will be converted to a string
,
If you have suggestions on how to address this issue, please let me know. Thanks!