Skip to content

Conversation

harshith1118
Copy link

Summary
This PR fixes the indentation issue with nested ternary expressions in TypeScript code. Previously, nested
ternary operations were getting increasingly indented, causing poor readability. This change ensures that
nested ternary expressions align at the same indentation level, improving code formatting consistency.

Details
The fix modifies the logic in src/services/formatting/smartIndenter.ts within the
childIsUnindentedBranchOfConditionalExpression function. Previously, when handling nested ternary
expressions (conditional expressions), the formatter was not properly handling the alignment of subsequent
ternary operations in a chain.

Before:

1 var current =
2 0 ? 1 :
3 2 ? 3 :
4 4;

After:

1 var expected =
2 0 ? 1 :
3 2 ? 3 :
4 4;

Tests

  • Added tests/cases/compiler/nestedTernaryFormatting.ts to verify the ternary indentation fix
  • Added tests/cases/compiler/privateMethodQuickFix.ts for private method quick fix related changes

Code Review

  • The change is minimal and targeted to the specific issue
  • Follows existing code patterns in the formatting logic
  • Maintains backward compatibility

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Oct 3, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 3, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@MartinJohns
Copy link
Contributor

Your before and after look the same.

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Oct 6, 2025
@harshith1118 harshith1118 deleted the fix-ternary-indentation branch October 6, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants