JWT · Issue #16989 · DefinitelyTyped/DefinitelyTyped · GitHub
Skip to content

JWT #16989

Description

@svipas

I'm using VS Code. It's based on TypeScript, it uses all TS definitions. The problem is with jsonwebtoken library. jwt.sign(...,) doesn't have Object.

// Type definitions for jsonwebtoken 7.2.0
// Project: https://github.com/auth0/node-jsonwebtoken
// Definitions by: Maxime LUCE https://github.com/SomaticIT, Daniel Heim https://github.com/danielheim
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: string | Buffer, options: SignOptions, callback: SignCallback): void;

In JWT you can pass any object you want, but simple jwt.sign({userId: 1},...) doesn't work it says:

Argument of type '{ userId: number; }' is not assignable to parameter of type 'string | object | Buffer'.
  Object literal may only specify known properties, and 'userId' does not exist in type 'string | object | Buffer'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions