Traverse the RegJS AST (a AST for JavaScript's regular expressions).
Parsing the JavaScript's RegExp in JavaScript.
What if I tell you the type checker is nothing else than executing your JavaScript code in the type domain?