I am currently utilizing the jasonwebtoken package and have encountered a new javascript/typescript behavior.
interface JwtPayload {
[key: string]: any;
iss?: string | undefined;
sub?: string | undefined;
aud?: string | string[] | undefined;
exp?: number | undefined;
nbf?: number | undefined;
iat?: number | undefined;
jti?: string | undefined;
}
let payload: JwtPayload | string
let id: string | undefined
id = payload.sub
When attempting the assignment, an error is thrown. What could be causing this issue?
Type 'string | (() => string) | undefined' is not assignable to type 'string | undefined'.
Type '() => string' is not assignable to type 'string'.(2322)