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

Improve formatting of leading tokens in type union / intersection #910

Open
JohnnyMorganz opened this issue Nov 16, 2024 · 1 comment
Open
Labels
enhancement New feature or request luau Formatting related to Luau

Comments

@JohnnyMorganz
Copy link
Owner

#854 will introduce support for leading tokens in unions / interesctions, but we should format them better:

  • If single line, remove a leading token
  • If multi line, start with a leading token:
type Foo = 
    | X
    | Y
@JohnnyMorganz JohnnyMorganz added the enhancement New feature or request label Nov 16, 2024
JohnnyMorganz added a commit that referenced this issue Nov 16, 2024
Somewhat ugly code, designed to ensure there is snapshot diff.
But, the code can be made nicer in #910
JohnnyMorganz added a commit that referenced this issue Nov 16, 2024
* Update to new full-moon version

* simplify err message

* fix token

* Support Lua version customisation

* compile full moon with release optimisations

* Update to Boxed anonymous function

* Add proper handling for shebang

* Set default lua version to all features, to make it easier to get started

Means its technically not a breaking change

* Handle left associativity of type unions / intersections

* Update callback hanging snapshot

This formatting is actually correct - we don't have type pack unions,
so we should be hanging at the union type after the return

* Support LuaJIT as a separate syntax option

* Rename config option from `lua_version` to `syntax`

* Fix tests and re-enable large example in debug mode

* Use released full moon v1.1.0

* Add command line option to configure syntax and update changelog

* Bump full-moon to 1.1.1

* Fix compilation for luau

* Handle access modifier in type array and tables

* Handle new type info and union set up

Somewhat ugly code, designed to ensure there is snapshot diff.
But, the code can be made nicer in #910

* Cleanup

* Fix verify_ast for luajit

* Fix wasm build on CI

* Update changelog about luajit
@JohnnyMorganz JohnnyMorganz added the luau Formatting related to Luau label Nov 16, 2024
@JohnnyMorganz
Copy link
Owner Author

Prettier will probably be a good example for these cases.
Interestingly, they only format leading for unions, not intersections:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request luau Formatting related to Luau
Projects
None yet
Development

No branches or pull requests

1 participant