TypeScript can do runtime checks like this! Granted it uses a TypeScript framework (similar to AJV) that both does the runtime checks and preserves type information for your IDE and type checker. I wrote about it here:
https://medium.com/@stevenbradleyconsulting/from-0-to-type-s...