You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the res.data field in the success callback has type 'string | Record<string, any> | ArrayBuffer. This means to properly use this, I have to do this (pseudocode):
if (typeof res.data is string or array buffer) {
raise error
}
use res.data as type any object
There are two problems with this. 1. I know my backend API returns JSON in the success case, so the string and ArrayBuffer cases are never actually in use. 2. res.data is simply any object, I can't specify its type without doing an explicit cast every time.
Proposal: define wx.request as something similar to the following:
Currently, the
res.data
field in the success callback has type'string | Record<string, any> | ArrayBuffer
. This means to properly use this, I have to do this (pseudocode):There are two problems with this. 1. I know my backend API returns JSON in the success case, so the string and ArrayBuffer cases are never actually in use. 2. res.data is simply any object, I can't specify its type without doing an explicit cast every time.
Proposal: define wx.request as something similar to the following:
While we're at it, it'd be useful to define an error type as well, for the fail callback.
The text was updated successfully, but these errors were encountered: