Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pretty-printing for union types #12584

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Conversation

shenglol
Copy link
Contributor

@shenglol shenglol commented Nov 29, 2023

Main changes:

  • Updated the grammar and parser to allow an optional leading | as part of a union type expression.
  • Improved the pretty-printing layout rule to handle union types surpassing the width limit. In such cases, a leading | will now be included to enhance readability. For instance:
// Before
type tupleUnion = ['foo', 'bar', 'baz'] | ['fizz', 'buzz'] | ['snap', 'crackle', 'pop']

// After
type tupleUnion =
  | ['foo', 'bar', 'baz']
  | ['fizz', 'buzz']
  | ['snap', 'crackle', 'pop']
Microsoft Reviewers: Open in CodeFlow

Copy link
Contributor

github-actions bot commented Nov 29, 2023

Test this change out locally with the following install scripts (Action run 7050176699)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 7050176699
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 7050176699"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 7050176699
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 7050176699"

Copy link
Contributor

github-actions bot commented Nov 29, 2023

Test Results

     143 files  +     11       143 suites  +11   4h 12m 29s ⏱️ - 15m 59s
10 860 tests ±       0  10 859 ✔️  -        1  0 💤 ±0  1 +1 
55 223 runs  +2 860  55 222 ✔️ +2 859  0 💤 ±0  1 +1 

For more details on these failures, see this check.

Results for commit 0d681aa. ± Comparison against base commit 49b3002.

♻️ This comment has been updated with latest results.

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

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

:shipit:

@shenglol shenglol merged commit 81b4a22 into main Nov 30, 2023
46 of 47 checks passed
@shenglol shenglol deleted the shenglol/pprint-union-types branch November 30, 2023 17:36
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.

None yet

3 participants