i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
450 stars 69 forks source link

RequestResponse should have data as optional type #82

Closed znikola closed 2 years ago

znikola commented 2 years ago

🐛 Bug Report

RequestResponse interface should have data property as an optional type. Currently, in case of an error, we can't pass null for the data property, but it is mentioned in your README.md :

'res' should be an object with a 'status' property and a 'data' property containing a stringified object instance beeing the key:value translation pairs for the
  //            requested language and namespace, or null in case of an error.

To Reproduce

// throws an error `Type 'null' is not assignable to type 'string'.ts(2322)`
callback(error, { data: null, status: error.status })

Expected behavior

// not to throw a TS error.
callback(error, { data: null, status: error.status })

Your Environment

adrai commented 2 years ago

Would you like to send a Pull Request to address this?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.