That seems a bit dangerous, to be honest. TypeScript has an unsound type system. If you don't think carefully, you might end up shipping runtime type errors.