3 ms·
Closure Compiler already does this. Most JavaScript at Google is written with static types in JSDoc. Closure Compiler also has a DSL (sort of like template meta
by jart 10y ago
Closure Compiler already does this. Most JavaScript at Google is written with static types in JSDoc. Closure Compiler also has a DSL (sort of like template metaprogramming) where complicated generic type transitions can be defined with functional expressions.
Examples: https://github.com/google/closure-compiler/blob/d1c1673d1d891616144f1f5d0d9642dd1e232612/externs/es6.js#L1110 https://github.com/google/closure-compiler/blob/d1c1673d1d89... and https://github.com/google/closure-compiler/blob/55cf43ee31e80d89d7087af65b5542aa63987874/contrib/externs/angular-1.3-q_templated.js#L98 https://github.com/google/closure-compiler/blob/55cf43ee31e8...
Documentation: https://github.com/google/closure-compiler/blob/e7954defc514920469c79349e4742fca4c82fd58/src/com/google/javascript/jscomp/parsing/TypeTransformationParser.java#L53 https://github.com/google/closure-compiler/blob/e7954defc514... and https://github.com/google/closure-compiler/blob/b8d8d1d6c6d245a3df57feedc511f2e849b01932/test/com/google/javascript/jscomp/parsing/JsDocInfoParserTest.java#L3178 https://github.com/google/closure-compiler/blob/b8d8d1d6c6d2... and https://github.com/google/closure-compiler/blob/8829c165b30fdb1937ce7f4285d23ee38ebe3535/test/com/google/javascript/jscomp/TypeTransformationTest.java https://github.com/google/closure-compiler/blob/8829c165b30f...
Welcome to what happens when a company hires PhDs to write web pages.