Narrowing down error type in catch

Viewed 43003

For this piece of code

try {
  throw new CustomError();
}
catch (err) {
  console.log(err.aPropThatDoesNotExistInCustomError);
}

err is any and doesn't trigger type errors. How can it be narrowed down to the type that error is expected to be?

1 Answers
Related