imbrn/v8n

v8n import typescript - has no call signatures

stefanwerfling opened this issue · 5 comments

I've been trying to integrate the v8n into my project for a few days now. But that fails once when typescript is compiled with the import or with the call of v8n().

TS2349: This expression is not callable.   Type 'typeof import("/node_modules/v8n/types/index")' has no call signatures.

I have now tried the following:
import v8n from 'v8n';

v8n().number()

or

v8n.default().number()

This allows Typescript and then translates it into Javascript but when you start in nodejs the object is not found on "default".

My tsconfig:

{
  "compileOnSave": true,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "module": "NodeNext",
    "target": "ES2022",
    "strict": true,
    "baseUrl": "./",
    "outDir": "dist",
    "sourceMap": true,
    "removeComments": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "importHelpers": true,
    "esModuleInterop": true,
    "types": [
      "node"
    ],
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "include": [
    "./src/**/*.ts"
  ]
}

Does it have to be imported differently? Or is that a bug?

imbrn commented

Hello, @stefanwerfling. Thank you for reporting this issue. I'll check that as soon as possible and let you know about any updates.

imbrn commented

HEY @stefanwerfling , I hope you're doing well today :)

Can you share the NodeJS and Typescript versions you are using, please?

Hey @imbrn, thank you! :)

I use Node.js v14.21.2 or in docker FROM node:18-bullseye.
By Typescript i use:

"@typescript-eslint/eslint-plugin": "^5.56.0", "@typescript-eslint/parser": "^5.56.0", "eslint": "^8.36.0", "eslint-plugin-prefer-arrow": "^1.2.3", "tslib": "^2.5.0", "tslint": "^6.1.3", "typescript": "^4.9.5"

I Hope you can found the problem!

imbrn commented

Hello @stefanwerfling , thank you for sharing your configs.

I'm trying to reproduce the error in a few ways, but I couldn't get the mentioned problem to occur on my machine.
I'm using the same configuration as yours, except that I'm using my local environment instead of a docker container.

Could you reproduce this problem using some shareable online service like Codesandbox or something similar? Maybe I have some different configurations here on my local project.

Have a good one.

Hello @imbrn, I work with phpstorm as IDE. The IDE can not usw

import v8n from "v8n";

and change it to import with umd.

then the error comes in the docker container.