Type declaration not working correctly

Hey, I'm using TypeScript and when trying to import anything from moonlink I get the following error
Could not find a declaration file for module 'moonlink.js'. 'node_modules/moonlink.js/dist/index.mjs' implicitly has an 'any' type.
There are types at 'node_modules/moonlink.js/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'moonlink.js' library may need to update its package.json or typings. ts(7016)
Could not find a declaration file for module 'moonlink.js'. 'node_modules/moonlink.js/dist/index.mjs' implicitly has an 'any' type.
There are types at 'node_modules/moonlink.js/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'moonlink.js' library may need to update its package.json or typings. ts(7016)
Not sure if this is something on my side but every other package is working fine.
18 Replies
1Lucas1.apk
1Lucas1.apk•2y ago
Do you transpile it into ecmascript?
like-gold
like-goldOP•2y ago
yep
1Lucas1.apk
1Lucas1.apk•2y ago
Could you do a test for me, put it in tsconfig.json "skipLibCheck": true
like-gold
like-goldOP•2y ago
already is set to true
1Lucas1.apk
1Lucas1.apk•2y ago
🤔 Does this error appear every time you try to start your project?
like-gold
like-goldOP•2y ago
I'm not even starting it, IntelliSense is already showing me that error and typings simply dont work But yeah, it also comes up when starting the project
1Lucas1.apk
1Lucas1.apk•2y ago
I just want to understand the problem, because the project has all definitions of all files Try putting it on the import side // @ts-ignore If it works I'll have to think of another way to declare
like-gold
like-goldOP•2y ago
When looking up the error I found this interesting answer on StackOverflow: https://stackoverflow.com/a/76212193 After looking at the package.json of your project it seems like we have a similar problem here
Stack Overflow
The xxxx library may need to update its package.json or typings.ts
I have a public component library call rd-component, when I used this component "rd-component": "^0.1.47" in the new project, the visual studio code show error like this: Could ...
1Lucas1.apk
1Lucas1.apk•2y ago
No description
1Lucas1.apk
1Lucas1.apk•2y ago
I'll try to put types in the .
like-gold
like-goldOP•2y ago
Worth a try
MEE6
MEE6•2y ago
GG @Dome, you just advanced to level 1!
like-gold
like-goldOP•2y ago
Changed it locally in my node modules folder and can confirm it is working now
1Lucas1.apk
1Lucas1.apk•2y ago
Finished, install new version and test please I also updated the typescript of the package to see if it wasn't that too I also found an interesting if this way does not work
like-gold
like-goldOP•2y ago
working fine now! thanks for the quick help!
1Lucas1.apk
1Lucas1.apk•2y ago
You're welcome, have a great day 🙂
like-gold
like-goldOP•2y ago
you too :)

Did you find this page helpful?