Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types/jsonwebtoken has broken backward compatibility #17007

Closed
4 tasks done
eliprand opened this issue Jun 6, 2017 · 4 comments
Closed
4 tasks done

@types/jsonwebtoken has broken backward compatibility #17007

eliprand opened this issue Jun 6, 2017 · 4 comments

Comments

@eliprand
Copy link

eliprand commented Jun 6, 2017

  • I tried using the @types/jsonwebtoken package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.

The change introduced 4 days ago with this commit has broken backwards compatibility. It is not accepting generic objects such as {id:1234}.

The following line of code:
const signed = jsonwebtoken.sign({id:1234}, 'secret');

gets the following error:
Object literal may only specify known properties, and 'id' does not exist in type 'string | object | Buffer'.

Using tsc 2.2.2 same results at tsc 2.3.4

I believe this was mentioned in #16989

@ghost
Copy link

ghost commented Jun 6, 2017

Should be fixed by microsoft/TypeScript#16290. Please try it out with typescript@next once that's in.

@eliprand
Copy link
Author

eliprand commented Jun 6, 2017

@andy-ms I will revert to 7.2.0 for now until the next release of TypeScript comes out. ETA?

@mdebruijne
Copy link
Contributor

As @andy-ms mentioned, this is due to a bug in TypeScript (microsoft/TypeScript#16235)

The workaround is to use type inference (or casting), for example;

const payload = { "foo": "bar" }

jwt.sign(payload, secret)

@orta orta closed this as completed Jun 7, 2021
@orta
Copy link
Collaborator

orta commented Jun 7, 2021

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants