Back

sdk-for-node throwing type errors with typescript project

  • 0
  • Self Hosted
  • Web
  • REST API
Saurabh
12 Apr, 2024, 05:14

I was using node sdk in ts projects (v4.3.5 && v5.4.5). I received same type error in both versions, related to same objects in declaration file, which had signature like "export const ImageFormat: Readonly<{type implementation }>" then error i received was "ImageFormat' refers to a value, but is being used as a type here. Did you mean 'typeof ImageFormat'" because this uninitialized variable was used as type in some places in declaration file. What i tried in local version of declaration file is changing it to "export type ImageFormat=Readonly<{type implementation}>" so this became type object instead of uninitialized js variable. It was working fine after this change no errors and i also tested some methods provided by sdk, working fine as well. Please let me know if i am missing something and if it could be worked without modifying original declaration

TL;DR
Developers are experiencing type errors with the SDK for Node in TypeScript projects due to an uninitialized variable being used as a type in the declaration file. A workaround is to change the uninitialized variable to a type object in the declaration file, which resolves the errors and allows the SDK methods to work fine as well. This workaround can be applied locally, but developers are inquiring if there is a way to solve this issue without modifying the original declaration.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more