Skip to content

Add "type: module" (nodenext) support alongside commonjs #481

Closed
@chronoDave

Description

@chronoDave

Bug is related to

  • embla-carousel (core package)
  • embla-carousel-react
  • embla-carousel-vue
  • embla-carousel-svelte
  • embla-carousel-autoplay
  • embla-carousel-auto-height
  • embla-carousel-class-names

Embla Carousel version

  • 8.0.0-rc05

Describe the bug

When using node16 esm import in TypeScript, TypeScript with incorrectly flag up the embla-carousel default import as missing. This is due to incorrect typing: https://arethetypeswrong.github.io/?p=embla-carousel%408.0.0-rc05

image

This error can be ignored using @ts-expect-error or something similar as I can confirm that the default import does work, it's just the typing that's incorrect.

CodeSandbox

Unfortutately this bug does not occur when usign CodeSandbox. If needed, I can create a simple repository demonstrating this behaviour.

package.json

{
  "name": "nodenext",
  "type": "module",
  "dependencies": {
    "embla-carousel": "^8.0.0-rc03",
    "typescript": "^5.0.4"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "NodeNext",
  }
}

index.ts

import EmblaCarousel from 'embla-carousel';

const carousel = EmblaCarousel();

Steps to reproduce

Simply hover over the EmblaCarousel error in your IDE of choice (mine being VSC)

Expected behavior

I expect the default export to be typed correctly.

Additional context

It seems to be a common issue:

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestresolvedThis issue is resolvedtypescriptIssue is related to TypeScript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions