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

fix(types): type fix of TypeError: random_org_1.default is not a cons… #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FoolishNinja
Copy link

In TypeScript (specifically in Nest.js) if I use the import
import RandomOrg from 'random-org';
as shown in the README.md, I get following error
TypeError: random_org_1.default is not a constructor
If I use
import * as RandomOrg from 'random-org';
It does work but I get following type error when creating a new instance of RandomOrg with new RandomOrg:

error TS2351: This expression is not constructable.
  Type 'typeof import("/workspace/node_modules/random-org/index")' has no construct signatures.

With the edits I did both of those issues are solved, but the import is changed to
import * as RandomOrg from 'random-org';
which I also adjusted in the README file

…tructor or other type errors when importing correctly
@willfrew
Copy link
Owner

Hi! Thanks very much for the PR 🙏

Could you post your tsconfig & typescript version so I can try to reproduce on my end? Thanks in advance

@FoolishNinja
Copy link
Author

Hello there again!
My typescript version is 4.7.4 and my tsconfig is as follows:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false,
    "resolveJsonModule": true
  }
}

Maybe the issue is on my end :)

@ramiroaraujo
Copy link

Yey!! I have the same issue, and @FoolishNinja PR fixed it.

For the record, I'm on "typescript": "^5.1.3"

and my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}

Until this is merged, can be installed with npm:

npm install FoolishNinja/node-random-org#bugfix/not-a-constructor

With yarn:

yarn add FoolishNinja/node-random-org#bugfix/not-a-constructor

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

Successfully merging this pull request may close these issues.

3 participants