Skip to content

Jsonwebtoken don't support verbatimModuleSyntax typescript compiler option #942

Open
@gillesdalle

Description

@gillesdalle

Description

When the verbatimModuleSyntax typescript compiler option is set to true, the import of jsonwebtoken raise an error on runtime Cannot read properties of undefined (reading 'from')

In my tsconfig.json file, I extend the @vue/tsconfig/tsconfig.dom.json file. The verbatimModuleSyntax comes from here.

Reproduction

  • Create a new project with Vite with Vue
  • import jsonwebtoken @types/jsonwebtoken @vue/tsconfig librairies
  • In the mains.ts file, add import { decode } from "jsonwebtoken";
  • In tsconfig.json file, add "extends": "@vue/tsconfig/tsconfig.dom.json"
  • Run npm dev

Environment

package.json

{
  "name": "vite-project",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vue-tsc && vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@types/jsonwebtoken": "^9.0.3",
    "@vue/tsconfig": "^0.4.0",
    "jsonwebtoken": "^9.0.2",
    "vue": "^3.3.4"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^4.2.3",
    "typescript": "^5.0.2",
    "vite": "^4.4.5",
    "vue-tsc": "^1.8.5"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions