Skip to content

TypeError with TypeScript import #1

@molaeiali

Description

@molaeiali

"one-time-activation-code": "^1.0.16"

Having issue importing library this way in typescript:

import OneTimeActivationCode from 'one-time-activation-code'
const otac = new OneTimeActivationCode({
    expiresAfter: Number(process.env.ACTIVATION_CODE_TIMEOUT || 300),
    attemptsChance: 3,
    encodeCode: true,
})

Error:

const otac = new OneTimeActivationCode({
             ^
TypeError: one_time_activation_code_1.default is not a constructor

But there are no problems importing it this way:

const OneTimeActivationCode = require('one-time-activation-code')

tsconfig:

  "compilerOptions": {
    "lib": [
      "ES6"
    ],
    "module": "CommonJS",
    "moduleResolution": "Node",
    "outDir": "build",
    "sourceMap": true,
    "strict": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions