js-sdk: Can't get type declarations to work in ES Module project
I’ve read a bunch of other issues which gave me the impression that with the "type": "module"
setup, it should work out of the box, but I’m clearly doing something else wrong.
The warning on the import statement is:
Could not find a declaration file for module 'pocketbase'. 's:/New folder (5)/pocketbase/node_modules/pocketbase/dist/pocketbase.es.mjs' implicitly has an 'any' type.
Thanks in advance for any help with this.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (9 by maintainers)
Commits related to this issue
- [#92] changed ts declarion extension to .d.mts — committed to pocketbase/js-sdk by ganigeorgiev 2 years ago
I still have this issue. Tried to use latest TypeScript 5+ and 4.9.4
My tsconfig.json:
PS: Pocketbase js-sdk verison 0.15.2
Encountered this issue with pocketbase v.0.9.1.
Resolved by updating TS to v4.9.4, as mentioned by @ganigeorgiev.
The “fix” should be available with the v0.8.3 release.
I think I found the related TS issue - https://github.com/microsoft/TypeScript/issues/50762.
It seems that the problem is with how the
exports
is resolved and ts for some reason makes a guess where the declaration file is located instead of loading it directly from thetypes
prop (either in the root level or as part of anexports
block; the position of thetypes
key also seems to matter).I’ll reopen the issue and will update sometime later the file extension to generate it with
.mts
.Thank you so much!
I don’t know what’s wrong with my setup. Maybe you can reproduce it with Docker?
It is also possible that TS is looking for
.mts
ending definition file since the exported has.mjs
extension, or in other words you can test renaming the definition file to.mts
.