Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

v9: `decode` does not work with `import *` in TypeScript

Open
#875 6 comments 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Domain
api, backend

Research direction

Reproduce the failure with the shown TypeScript import * as jwt example and compare it with the working default import. Then inspect the package's module export implementation, using related issues #866 and #870 for context; done means jwt.decode("abc") is callable under the reported TypeScript setup.

Written by the indexing model from the issue text.

Description

Description

If you import * as jwt from "jsonwebtoken", then you can't call jwt.decode. It works fine if you use a default import though (import jwt from "jsonwebtoken").

Related to #866, and probably also #870.

The root cause of this is that import * in TS gets translated in such a way that only enumerable properties are copied from the module. Since decode is non-enumerable it is not properly copied.

Reproduction
import * as jwt from "jsonwebtoken";

jwt.decode("abc"); // TypeError: jwt.decode is not a function
Environment

Version 9.0.0 on Node 16.19.0 with TS 4.6.2

Dominant language
JavaScript
Stars
18.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/node-jsonwebtoken

All issues in auth0/node-jsonwebtoken

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.