I having been doing Swift Development for past 3 years and recently switch to typescript.
In Swift an error of type NSError and which gives us some properties.
In JavaScript an error is of any.
Why error is of any? How can I create custom class with some properties and use it in whole project?
try {
const decodedResult = decode(token)
// Adding userId in the headers to use in the models.
req.headers.userId = decodedResult.paylod.id
next()
} catch (error) {
console.log(error)
new errorController(401, 'Authentication required.', res)
}
Now error object here is of type any. I want it to be strongly typed.