Open coolaj86 opened 1 year ago
Another example:
let resp = await fetch(url, opts);
/** @type {Record<String,String|Array<String>>} */
let headers = {};
for (let [key, value] of resp.headers.entries()) {
if (headers[key]) {
let isArray = Array.isArray(headers[key]);
if (!isArray) {
//@ts-ignore
headers[key] = [headers[key]];
}
//@ts-ignore
headers[key].push(value);
}
}
It should know that it's an array in the one case and not in the other.
See https://github.com/dashhive/DashHD.js/issues/26.
Depending on the string value,
xKey
could be of the generic typeHDKey
, but it could be of a more specific type - such asHDWalletKey
,HDAccountKey
,HDXKey
, orHDAddressKey
.The logic for returning the types is not yet implemented, but it could be.
None of the branching logic will depend on anything but how the string is split and operated on, so it's possible to analyze at dev time.