Being a beginner to typescript, I'm wrapping my head around the type notations.
I can across lot of solutions, in github to define it as useState<any>
, but in my case it isn't array of objects.
code:
export default async function xhttp(
input: NetworkParam,
config?: NetworkRequestConfig
): Promise<NetworkSuccessResponse | NetworkErrorResponse | any> {
try {
const CancelToken = axios.CancelToken;
const source = CancelToken.source();
if (config && config.cancelPrevious) {
input.cancelToken = source.token;
// remove previous from network store
const storeState = store.getState();
if (storeState && "network" in storeState) {
const networkState = storeState.network;
// cancel previous
if (config.requestType && networkState.hasOwnProperty(config.requestType)) {
try {
networkState[config.requestType].cancel();
} catch (e) {
console.log(e);
}
}
}
I get : property "network" does not exists on 'never'.
This above code is a .tsx file.