On the author’s point of a “debug build” with runtime type checking, there is ts-runtime-checks [0], which looks to do something similar! I don’t have any experience with it however, just seen it looking at typescript-runtime-type-benchmarks [1]. There’s a few other similar things there too
[0] https://github.com/GoogleFeud/ts-runtime-checks
[1] https://github.com/moltar/typescript-runtime-type-benchmarks