diff --git a/src/com/google/javascript/jscomp/DefaultPassConfig.java b/src/com/google/javascript/jscomp/DefaultPassConfig.java index d8e7830eec0..e03185f7957 100644 --- a/src/com/google/javascript/jscomp/DefaultPassConfig.java +++ b/src/com/google/javascript/jscomp/DefaultPassConfig.java @@ -202,6 +202,25 @@ protected List getWhitespaceOnlyPasses() { return passes; } + private void addOldTypeCheckerPasses( + List checks, CompilerOptions options) { + if (options.checkTypes || options.inferTypes) { + checks.add(resolveTypes); + checks.add(inferTypes); + if (options.checkTypes) { + checks.add(checkTypes); + } else { + checks.add(inferJsDocInfo); + } + + // We assume that only clients who don't run optimizations will try to + // query the typed scope creator after the compile job. + if (!options.preservesDetailedSourceInfo()) { + checks.add(clearTypedScopePass); + } + } + } + @Override protected List getChecks() { List checks = new ArrayList<>(); @@ -359,20 +378,14 @@ protected List getChecks() { checks.add(inlineTypeAliases); - if (options.checkTypes || options.inferTypes) { - checks.add(resolveTypes); - checks.add(inferTypes); - if (options.checkTypes) { - checks.add(checkTypes); - } else { - checks.add(inferJsDocInfo); - } + if (!options.getNewTypeInference()) { + addOldTypeCheckerPasses(checks, options); + } - // We assume that only IDE-mode clients will try to query the - // typed scope creator after the compile job. - if (!options.preservesDetailedSourceInfo()) { - checks.add(clearTypedScopePass); - } + // NOTE(dimvar): This will move later into the checks as we convert checks + // to handle types from the new type inference + if (options.getNewTypeInference()) { + addOldTypeCheckerPasses(checks, options); } if (options.generateExportsAfterTypeChecking && options.generateExports) {