I doubt it can be done as Nim's `|` operator for types does not do what TS's does, so "Inferring" `MyError1 | MyError2` is downright impossible.
On the bright side though, you can simply use Nim's builtin effect system (which is not an effect system but nobody noticed for 10 years, so it's good enough :P ).