Typescript doesn't let you do that because there's no way that typescript can verify at compile time that the only thing the code can throw is a ValidationError.
xxxxxxxxxx
catch (err: unknown) {
if (err instanceof ValidationError) {
// Inside this block, err is known to be a ValidationError
}
}