There's already "use strict" that does some of this to enable optimizations and other stuff. Maybe it should be even stricter or something similar could be used.
It still has to verify that those assertions are true in practice. Any random person at the console can call a function and pass whatever they like.
The only real way to make that work would be a new `<script type="typed-module" />` variant that implemented a subset of JS in a typed environment.
My guess is that this could happen in the future, but everyone is watching Typescript as a testing ground to find exactly what works, what doesn't, and what works, but isn't desirable.
There's already a mechanism for bailing out when optimization assumptions are violated; they could be made more eagerly but retain the ability to degrade
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...