Turn on typesToColors pass in DefaultPassConfig
@@ -63,6 +63,7 @@ import com.google.javascript.jscomp.lint.CheckUselessBlocks;
import com.google.javascript.jscomp.modules.ModuleMapCreator;
import com.google.javascript.jscomp.parsing.ParserRunner;
import com.google.javascript.jscomp.parsing.parser.FeatureSet;
+import com.google.javascript.jscomp.serialization.ConvertTypesToColors;
import com.google.javascript.rhino.IR;
import com.google.javascript.rhino.Node;
import java.util.ArrayList;
@@ -777,6 +778,10 @@ public final class DefaultPassConfig extends PassConfig {
passes.add(ambiguateProperties);
}
+ if (options.checkTypes || options.inferTypes) {
+ passes.add(typesToColors);
+ }
+
if (!options.shouldUnsafelyPreserveTypesForDebugging()) {
passes.add(removeTypes);
}
@@ -2854,6 +2859,14 @@ public final class DefaultPassConfig extends PassConfig {
.setFeatureSetForChecks()
.build();
+ /** Convert types from type-checking to optimization "colors" */
+ private final PassFactory typesToColors =
+ PassFactory.builder()
+ .setName("typesToColors")
+ .setInternalFactory(ConvertTypesToColors::new)
+ .setFeatureSetForOptimizations()
+ .build();
+
/** Remove types */
private final PassFactory removeTypes =
PassFactory.builder()
