8000 Constructor error (TS2351) in TypeScript when using ESM since v5 · Issue #81 · rawify/Fraction.js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000
Constructor error (TS2351) in TypeScript when using ESM since v5 #81
Open
@abouvier

Description

@abouvier

package.json

{
  "type": "module",
  "dependencies": {
    "fraction.js": "^5.1.0"
  },
  "devDependencies": {
    "typescript": "^5.6.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "node16"
  }
}

test.ts

import Fraction from "fraction.js";

let x = new Fraction(1.88);

Compilation error:

$ npx tsc
test.ts:3:13 - error TS2351: This expression is not constructable.
  Type 'typeof import(".../node_modules/fraction.js/fraction")' has no construct signatures.

3 let x = new Fraction(1.88);
              ~~~~~~~~


Found 1 error in test.ts:3

It worked fine in v4, and it works again if "type": "module" is added back to node_modules/fraction.js/package.json.

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

      0