Skip to content

Commit

Permalink
Move transpilation of rest/spread after the post-typecheck check passes.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201435647
  • Loading branch information
concavelenz authored and brad4d committed Jun 21, 2018
1 parent 9cfa692 commit cc38b48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/TranspilationPasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ static void addPreTypecheckTranspilationPasses(
// support the transpiled features.
// TODO(b/73387406): Move each pass above here temporarily, then into
// addEs6PostCheck Passes once the pass supports propagating type information
passes.add(es6RewriteRestAndSpread);
}
}
}
Expand All @@ -140,6 +139,7 @@ public static void addPostCheckTranspilationPasses(List<PassFactory> passes) {
// TODO(b/73387406): Move passes here as typechecking & other check passes are updated to cope
// with the features they transpile and as the passes themselves are updated to propagate type
// information to the transpiled code.
passes.add(es6RewriteRestAndSpread);
passes.add(lateConvertEs6ToEs3);
passes.add(es6ForOf);
passes.add(rewriteBlockScopedFunctionDeclaration);
Expand Down
13 changes: 4 additions & 9 deletions test/com/google/javascript/jscomp/TypeCheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2476,15 +2476,10 @@ public void testRestParameterWithTemplateType() {
"}",
"/** @type {null} */ var a = firstOf('hi', 1);",
""),
ImmutableList.of(
// TODO(b/79707793): This will be fixed when transpilation of REST parameters moves
// after type checking.
"Bad type annotation. Unknown type T",
lines(
"initializing variable", // preserve newlinues
"found : (number|string)",
"required: null")),
/* isError= */ false);
lines(
"initializing variable", // preserve newlines
"found : (number|string)",
"required: null"));
}

// Test that when transpiling we don't use T in the body of f; it would cause a spurious
Expand Down

0 comments on commit cc38b48

Please sign in to comment.