Port TypeScript#63071: Mark downlevelIteration as removed#2820
Port TypeScript#63071: Mark downlevelIteration as removed#2820jakebailey merged 7 commits intomainfrom
Conversation
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Ports the upstream TypeScript change to treat downlevelIteration as a removed compiler option (TS5102) in the Go port, and updates tests/baselines accordingly.
Changes:
- Emit a removed-option diagnostic when
downlevelIterationis explicitly set in config. - Remove
downlevelIteration-driven iteration behavior from the checker. - Update reference baselines to reflect TS5102 (and related output changes).
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/core/compileroptions.go | Moves DownlevelIteration into the deprecated/options-parsing section of CompilerOptions while keeping JSON parsing support. |
| internal/compiler/program.go | Adds validation to emit a removed-option diagnostic (TS5102) when downlevelIteration is explicitly provided. |
| internal/checker/checker.go | Removes downlevelIteration handling from iteration typing logic and refactors iterable gating/diagnostics. |
| testdata/baselines/reference/submodule/conformance/restParameterInDownlevelGenerator(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/restParameterInDownlevelGenerator(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/forAwaitPerIterationBindingDownlevel(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/forAwaitPerIterationBindingDownlevel(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyVariableDeclarationBindingPatterns02_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyVariableDeclarationBindingPatterns02_ES5iterable(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyVariableDeclarationBindingPatterns01_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyVariableDeclarationBindingPatterns01_ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns04_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns04_ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns03_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns03_ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns02_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns02_ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns01_ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/emptyAssignmentPatterns01_ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringVariableDeclaration1ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringVariableDeclaration1ES5iterable(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration7ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration7ES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration3ES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration3ES5iterable(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration1ES5iterable.errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration1ES5iterable.errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringArrayBindingPatternAndAssignment4(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringArrayBindingPatternAndAssignment4(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringArrayBindingPatternAndAssignment1ES5iterable.errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/destructuringArrayBindingPatternAndAssignment1ES5iterable.errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/asyncArrowFunction11_es5(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/asyncArrowFunction11_es5(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/arrayLiteralSpreadES5iterable(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/arrayLiteralSpreadES5iterable(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of37(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of37(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of36(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of36(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of35(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of35(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of34(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of34(target=es2015).errors.txt | Updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of33(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/conformance/ES5For-of33(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationVarInDownLevelGenerator(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/compiler/sourceMapValidationVarInDownLevelGenerator(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/compiler/blockScopedBindingsInDownlevelGenerator(target=es2015).errors.txt.diff | Updates baseline diff to TS5102 removed-option output. |
| testdata/baselines/reference/submodule/compiler/blockScopedBindingsInDownlevelGenerator(target=es2015).errors.txt | Adds/updates baseline to TS5102 removed-option output. |
Comments suppressed due to low confidence (3)
internal/checker/checker.go:1
- This change drops the
c.languageVersion >= ScriptTargetES2015gating and replaces it withiterableExists. That means ES5/ES3 targets can start treating values as iterables (and potentially acceptfor..ofover non-array iterables) merely because the ES2015 iterable lib types are present, even though emit semantics for those targets won’t support iterator-based iteration now thatdownlevelIterationis removed. Consider restoring an explicit target/languageVersion gate (e.g., only taking the iterable path when targeting ES2015+), and use that gate (notiterableExists) to decide when to report invalid-iterable errors.
internal/checker/checker.go:1 - This change drops the
c.languageVersion >= ScriptTargetES2015gating and replaces it withiterableExists. That means ES5/ES3 targets can start treating values as iterables (and potentially acceptfor..ofover non-array iterables) merely because the ES2015 iterable lib types are present, even though emit semantics for those targets won’t support iterator-based iteration now thatdownlevelIterationis removed. Consider restoring an explicit target/languageVersion gate (e.g., only taking the iterable path when targeting ES2015+), and use that gate (notiterableExists) to decide when to report invalid-iterable errors.
internal/checker/checker.go:1 - The diagnostic referenced here still tells users to use the
downlevelIterationflag, but this PR makes that option a hard-removed error (TS5102). The message should be updated to remove the suggestion to usedownlevelIterationand instead direct users to the supported alternative (e.g., requiring--target es2015or higher). This likely requires updating the underlying diagnostics entry name/text and adjusting baselines accordingly.
| } | ||
|
|
||
| createDiagnosticForOption := func(onKey bool, option1 string, option2 string, message *diagnostics.Message, args ...any) *ast.Diagnostic { | ||
| diag := createOptionDiagnosticInObjectLiteralSyntax(getCompilerOptionsObjectLiteralSyntax(), onKey, option1, option2, message, args...) |
There was a problem hiding this comment.
The removed-option diagnostic for downlevelIteration appears to provide only generic guidance (empty replacement/extra info args). Since removing downlevelIteration also removes the only ES5-compatible iterator-based iteration mode, it would be more actionable if the diagnostic included the recommended alternative (e.g., targeting ES2015+). If createRemovedOptionDiagnostic supports a hint/replacement string, consider populating it for this option.
| createRemovedOptionDiagnostic("downlevelIteration", "", "Target ES2015 or later to use native iterator-based iteration support.") |
Ports microsoft/TypeScript#63071. Rather than adding a deprecation diagnostic (TS5101) as in the upstream PR, this adds a "removed" diagnostic consistent with how the Go port handles other removed options.
internal/compiler/program.go: Emit removed-option diagnostic whendownlevelIterationis explicitly set (true or false)internal/testutil/harnessutil/harnessutil.go: Skip submodule tests that setdownlevelIteration💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.