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

Can't import EmblaCaroouselType, EmblaOptionsType, EmblaPluginType from embla-carousel-react, embla-carousel-vue and embla-carousel-svelte #647

Closed
4 tasks done
proninyaroslav opened this issue Dec 7, 2023 · 11 comments · Fixed by #651 or #658
Labels
bug Something isn't working resolved This issue is resolved typescript Issue is related to TypeScript

Comments

@proninyaroslav
Copy link

proninyaroslav commented Dec 7, 2023

Bug is related to

  • embla-carousel-react
  • embla-carousel-vue
  • embla-carousel-svelte
  • embla-carousel-solid

Embla Carousel version

  • v8.0.0-rc15

Describe the bug

Since version v8.0.0-rc15, ESLint says that the SliderPropsOptions type does not have a loop property. This happens to all properties that are in EmblaOptionsType:

image

Also because of this, useEmblaCarousel has the options argument type Partial<OptionsType> | undefined instead of EmblaOptionsType | undefined, which causes a linter error:

image

@proninyaroslav proninyaroslav added the bug Something isn't working label Dec 7, 2023
@proninyaroslav proninyaroslav changed the title loop does not exist in type SliderPropsOptions EmblaOptionsType doesn't exists in React Dec 7, 2023
@davidjerleke
Copy link
Owner

davidjerleke commented Dec 7, 2023

Thanks @proninyaroslav,

I’ve noted this bug a couple of days ago and already started working on it. However, thanks for creating a bug report so I can connect it to a pull request and devs can track it 👍🏻.

Best,
David

davidjerleke added a commit that referenced this issue Dec 11, 2023
davidjerleke added a commit that referenced this issue Dec 11, 2023
@davidjerleke davidjerleke added the resolved This issue is resolved label Dec 11, 2023
@davidjerleke davidjerleke added the typescript Issue is related to TypeScript label Dec 20, 2023
@davidjerleke
Copy link
Owner

@proninyaroslav a bug fix for this was just released in v8.0.0-rc16. Try it out and let me know if it's working as expected.

@proninyaroslav
Copy link
Author

@davidjerleke
Updated to v8.0.0-rc17 and still have this problem.

@davidjerleke
Copy link
Owner

davidjerleke commented Dec 23, 2023

@proninyaroslav then I suggest you create a CodeSandbox with your setup in order to demonstrate the problem. You didn’t provide one in your bug report but it’s a requirement as mentioned in the contribution guidelines.

@davidjerleke
Copy link
Owner

davidjerleke commented Dec 23, 2023

@proninyaroslav I think it's better to get the types directly from the main package. Because embla-carousel is a dependency, you can do this:

import { EmblaOptionsType } from 'embla-carousel'; // Get it like so
import useEmblaCarousel from 'embla-carousel-react';

I will remove the type re-exports from the library wrappers like embla-carousel-react, embla-carousel-vue etc. and will recommend the above demonstrated approach in the docs. This reduces the code complexity in the project significantly. This will be added to the docs here:

Best,
David

@proninyaroslav
Copy link
Author

@davidjerleke
It works, thank you.

@davidjerleke
Copy link
Owner

Turns out, this approach doesn’t work with pnpm so I need to solve this differently. Stay tuned.

@div-cowboy
Copy link

@davidjerleke Please let us know when the pnpm solution is ready 🙏

Appreciate all you do

@davidjerleke
Copy link
Owner

@div-cowboy, @proninyaroslav. I've added examples of how to import types to the docs. There's also information about how to do it with pnpm:

Important

Remember to switch to the React tab if you're using embla-carousel-react etc.

@davidjerleke davidjerleke changed the title EmblaOptionsType doesn't exists in React Can't import EmblaCaroouselType, EmblaOptionsType, EmblaPluginType from embla-carousel-react, embla-carousel-vue and embla-carousel-svelte Jan 8, 2024
@preetmishra preetmishra mentioned this issue Jan 24, 2024
13 tasks
@suiboli314
Copy link

suiboli314 commented Aug 1, 2024

With bun and shadcn for "embla-carousel-react": "^8.1.7",,
eslint (es2024) gives EmblaCarouselType not found in 'embla-carousel' eslint[import/named] when import { EmblaCarouselType } from "embla-carousel";.

But no complain if import type { EmblaCarouselType } from "embla-carousel";

Should I

install embla-carousel as a devDependency

as pnpm?

Edit:
It seems it is my eslint config issue.
With eslint: ^9 and some incompatible plugins ("next/core-web-vitals", "plugin:import/recommended", "plugin:jsx-a11y/recommended", "plugin:react-hooks/recommended"), recommend import { EmblaCarouselType } from "embla-carousel"; reports not found eslint[import/named].
With eslint: ^8, and "extends": ["eslint:recommended","next/core-web-vitals"], both import seems good.👍

@davidjerleke
Copy link
Owner

davidjerleke commented Aug 1, 2024

@suiboli314 yes, as the docs says:

IMG_8363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved This issue is resolved typescript Issue is related to TypeScript
Projects
None yet
4 participants