In TypeScript, everything in a catch
block is always typed any
before you do any assertions on it - as literally any
thing could be throw
n in any function called from the try
block. You could throw 5
in there, you could throw new Error("foo")
in there, you could throw new Date()
in there, TypeScript doesn't know.
So, you are accessing any.response
there - and while that is perfectly valid TypeScript, you have configured your linter in a way that it warns you about it.
If you want to do that access, either disable that lint rule (assuming you gain no value from it anywhere else), or do a type assertion like (err as Something).response
here.
The whole issue has no correlation to React or Redux though.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…