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

Module import error #6803

Closed
5 of 6 tasks
GiyoMoon opened this issue Jul 3, 2023 · 3 comments
Closed
5 of 6 tasks

Module import error #6803

GiyoMoon opened this issue Jul 3, 2023 · 3 comments

Comments

@GiyoMoon
Copy link

GiyoMoon commented Jul 3, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://github.com/GiyoMoon/swiper-modules-error

Bug description

Importing modules since v10 doesn't work as expected when using typescript.

  • Importing from swiper gives a runtime error. E.g import { Navigation } from 'swiper';
  • Importing from swiper/modules gives a typescript error. E.g import { Navigation } from 'swiper/modules';

Expected Behavior

I expect that the import from swiper either doesn't work anymore, or no runtime error is being thrown.
Also, the import from swiper/modules shouldn't give a typescript error.

Actual Behavior

I'm having issues while trying to import modules. It looks like that the modules have to be imported from swiper/modules since v10, but this gives a typescript error:

import { Navigation } from 'swiper/modules';

^ gives: Cannot find module 'swiper/modules' or its corresponding type declarations.

Importing from swiper directly works at first sight, but then a runtime error is thrown:

import { Navigation } from 'swiper';

^ gives this error when trying to render the swiper:
image

Swiper version

10.0.1

Platform/Target and Browser Versions

Chrome

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@RobinKamps
Copy link

RobinKamps commented Jul 3, 2023

ran into the same error category (but import SwiperOptions, Swiper)- quick fixed by import { SwiperOptions, Swiper } from './types/index.d'; (without .ts)

@RobinKamps
Copy link

Thank you very much - 10.0.2 imports are working again.

@GiyoMoon
Copy link
Author

GiyoMoon commented Jul 3, 2023

Thanks! works again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants