Skip to content

Default import still broken with ESM and typescript moduleResolution node16 #61

Description

@apottere

#59 was closed as complete, but the issue remains in the latest release version and also in trunk.

https://arethetypeswrong.github.io/?p=short-unique-id%405.1.1

With the newly added specs, I was able to confirm the error shown on the page above by making the following changes to the specs directory:

  • Add specs/package.json
    {
        "type": "module"
    }
  • Edit specs/import-esm.spec.ts to include .js in the import:
    import ShortUniqueId from '../dist/short-unique-id.js';
    

Then, running npx tsc in that directory produces the following error:

import-esm.spec.ts:3:18 - error TS2351: This expression is not constructable.
  Type 'typeof import("/[redacted]/short-unique-id/dist/short-unique-id")' has no construct signatures.

3 const suid = new ShortUniqueId({length: 3});
                   ~~~~~~~~~~~~~


Found 1 error in import-esm.spec.ts:3

I also confirmed that my project still has trouble building with the latest release version (short-unique-id@5.1.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions