can't import jsonwebtoken in modern typescript esm app
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
調査の方向性
ファイルやテストは指定されていません。まず import の例と関連する issue #655 を確認し、その後、パッケージの現在のモジュールエクスポートと宣言の設定を調べてください。現代的な TypeScript ESM アプリが shim なしで sign、verify、およびそれらのオプション型を import でき、ランタイムの動作と型定義が一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
we can't properly import this library in a modern typescript project. here's the problem:
import * as jwt from "jsonwebtoken"- export
defaultcontains what i need, sign, verify, etc - however, the types won't let me have it
- export
@types/jsonwebtoken- does not have any definition for a default export
as you can see there's an incompatibility between what can actually be imported at runtime, versus what the @types typings allow us to import. on one hand, this could be seen as a deficiency in the community @types typings
on the other hand, a fundamental fix for this problem would be:
- upgrade jsonwebtoken for first-class esm support
- maintain official typings
related issue #655
in the meantime, here's the hack i used to circumvent this problem
-
create a shim module
badmodules/jsonwebtoken.tsimport * as _jsonwebtoken from "jsonwebtoken" const jsonwebtoken = <any>_jsonwebtoken import { sign as signType, verify as verifyType, SignOptions, VerifyOptions, Algorithm, } from "jsonwebtoken" const sign: typeof signType = jsonwebtoken.default.sign const verify: typeof verifyType = jsonwebtoken.default.verify export { sign, verify, Algorithm, SignOptions, VerifyOptions, } -
import the shim module instead
import {sign, verify, SignOptions, VerifyOptions, Algorithm} from "./badmodules/jsonwebtoken.js"
- 主要言語
- JavaScript
- スター
- 18.2k
- フォーク
- 1.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
auth0/node-jsonwebtoken のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
auth0/node-jsonwebtoken#1042 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
auth0/node-jsonwebtoken#1000 · コメント 2 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 65/100
auth0/node-jsonwebtoken#1046 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
auth0/node-jsonwebtoken#1034 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
auth0/node-jsonwebtoken#1032 ·
auth0/node-jsonwebtoken の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
antfu-collective/icones#398 ·
-
ECmail.com オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
wesbos/burner-email-providers#554 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
components-web-app/docs#92 ·