Skip to content

Port TypeScript#63071: Mark downlevelIteration as removed#2820

Merged
jakebailey merged 7 commits intomainfrom
copilot/add-removed-diag-for-downleveliteration
Apr 17, 2026
Merged

Port TypeScript#63071: Mark downlevelIteration as removed#2820
jakebailey merged 7 commits intomainfrom
copilot/add-removed-diag-for-downleveliteration

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 18, 2026

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 when downlevelIteration is explicitly set (true or false)
  • internal/testutil/harnessutil/harnessutil.go: Skip submodule tests that set downlevelIteration
  • Baselines: Delete 118 now-unused baseline files from newly skipped tests

💡 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.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Add removed diagnostic for downlevelIteration Port TypeScript#63071: Mark downlevelIteration as removed Feb 18, 2026
Copilot AI requested a review from jakebailey February 18, 2026 03:51
@jakebailey jakebailey marked this pull request as ready for review April 16, 2026 23:35
Copilot AI review requested due to automatic review settings April 16, 2026 23:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 downlevelIteration is 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 >= ScriptTargetES2015 gating and replaces it with iterableExists. That means ES5/ES3 targets can start treating values as iterables (and potentially accept for..of over 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 that downlevelIteration is removed. Consider restoring an explicit target/languageVersion gate (e.g., only taking the iterable path when targeting ES2015+), and use that gate (not iterableExists) to decide when to report invalid-iterable errors.
    internal/checker/checker.go:1
  • This change drops the c.languageVersion >= ScriptTargetES2015 gating and replaces it with iterableExists. That means ES5/ES3 targets can start treating values as iterables (and potentially accept for..of over 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 that downlevelIteration is removed. Consider restoring an explicit target/languageVersion gate (e.g., only taking the iterable path when targeting ES2015+), and use that gate (not iterableExists) to decide when to report invalid-iterable errors.
    internal/checker/checker.go:1
  • The diagnostic referenced here still tells users to use the downlevelIteration flag, but this PR makes that option a hard-removed error (TS5102). The message should be updated to remove the suggestion to use downlevelIteration and instead direct users to the supported alternative (e.g., requiring --target es2015 or 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...)
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
createRemovedOptionDiagnostic("downlevelIteration", "", "Target ES2015 or later to use native iterator-based iteration support.")

Copilot uses AI. Check for mistakes.
@jakebailey jakebailey added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit fe0f97b Apr 17, 2026
21 checks passed
@jakebailey jakebailey deleted the copilot/add-removed-diag-for-downleveliteration branch April 17, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants