-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Typescript Error: "Cannot find module or its corresponding type declarations" #2029
Comments
Hi, I'll look into it, possibly this will help you for now - #1957 (comment) |
Hi @dimsemenov. Thx for your time. |
Same issue. |
same issue. // src/types/photoswipe.d.ts
declare module 'photoswipe/lightbox' {
import PhotoSwipeLightBox from 'photoswipe/dist/types/lightbox/lightbox'
export default PhotoSwipeLightBox
} // src/some.tsx
import PhotoSwipeLightbox from 'photoswipe/lightbox'
...
// pswp is `PhotoSwipe` type
const pswp = new PhotoSwipeLightbox({ ... }) |
Is there a way to integrate this into the main library? It seems that many people are running into this issue |
The problem seems coming from
Right now types are working only with |
Newer versions of TypeScript would not pick up the types when importing from `photoswipe/lightbox` as the types were restricted to version 4.7 or lower. The types works perfectly fine with newer versions of TS, so by simply removing the restriction everything works as expected. fixes dimsemenov#2029
Newer versions of TypeScript would not pick up the types when importing from `photoswipe/lightbox` as the types were restricted to version 4.7 or lower. The types works perfectly fine with newer versions of TS, so by simply removing the restriction everything works as expected. fixes #2029
Newer versions of TypeScript would not pick up the types when importing from `photoswipe/lightbox` as the types were restricted to version 4.7 or lower. The types works perfectly fine with newer versions of TS, so by simply removing the restriction everything works as expected. fixes dimsemenov/PhotoSwipe#2029
Hi devs.
I'm running a react project with next.js v13 with typescript v5. And I keep getting a TS error even with the suggestions of this related issue: #1983.
If compilerOptions.moduleResolution is "node" the ts error is: "Cannot find module 'photoswipe/lightbox' or its corresponding type declarations.ts(2307)"
Is compilerOptions.moduleResolution is "node16" or "nodenext" the ts error is: "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("photoswipe/lightbox")' call instead. To convert this file to an ECMAScript module, add the field "type": "module" to 'd:/project/package.json'.ts(1479)"
I mean... the code works and I even get types autocompletion, but i dont know the origin of the error. I supose that is related to some kind of incompatibility between compilation sources.
The only solution I find right now is setting a // @ts-ignore in the line above the import.
NEXTJS v13.2.4
REACTJS v18.2.0
TYPESCRIPT v5.0.2
PHOTOSWIPE v5.3.7
The text was updated successfully, but these errors were encountered: