I don't know if this is a typings bug, or a library issue.
With the following versions:
"@types/jsonwebtoken": "^8.3.0"
"jsonwebtoken": "^8.3.0"
The following snippet:
const jsonWebToken = jwt.sign({
user_id, // The userID
sub: 'some-sub', // The id from above
ulimit: 2 // The usage limit
}, 'shh');
throws the error:
TS2326: Types of property 'sub' are incompatible.
Type 'string' is not assignable to type '() => string'.
But if I look at the typings:
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options?: SignOptions,
): string;
It looks correct?
Workaround:
const jsonWebToken = jwt.sign({
user_id, // The userID
sub: 'some-sub', // The id from above
ulimit: 2 // The usage limit
} as any, 'shh');
If the sub property indeed needs to be () => string I would happily like to assist with the PR to the typings, but I am not sure what the problem is 🤷🏽♂️
I don't know if this is a typings bug, or a library issue.
With the following versions:
"@types/jsonwebtoken": "^8.3.0""jsonwebtoken": "^8.3.0"The following snippet:
throws the error:
But if I look at the typings:
It looks correct?
Workaround:
If the
subproperty indeed needs to be() => stringI would happily like to assist with the PR to the typings, but I am not sure what the problem is 🤷🏽♂️