Faster JavaScript Calls
I've brought this up before, but I wonder if a "JS constraint spec" could be added to the JS standard that guarantees against this sort of (already uncommon) dynamic behavior in certain cases, so that code can be more aggressively optimized when possible<p>If you're already using TypeScript to constrain your code, why couldn't it generate interpreter/compiler hints?<p>These could take the form of a language-agnostic metadata file, similar to source maps, that optionally ships alongside the JS bundle<p>Edit: Several people have misunderstood, so I must not have articulated this well. What I meant was <i>not</i> a new/stricter subset of JS that forbids certain dynamic behaviors across the board. What I'm talking about is having TypeScript (or otherwise), which knows things at compile-time about how specific pieces of code are and are not called, manifest this information in a way that V8 can digest and act on directly, for that specific codebase. V8 already tries to guess this information and uses it to decide which things to optimize and how, but it's treating the JS bundle as a black box even though in many cases, an earlier stage of the pipeline already had this information on-hand and threw it away.<p>In addition to being more granular, this (like TypeScript itself) would allow parts of a codebase to continue being fully dynamic while other parts are well-constrained.