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

Allow trailing delimited in most locations #4837

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Oct 23, 2024

fix #2284
fix #809

Extracted the parser change from pr #4372 and made it more generic to cover also issue #809

@azure-sdk
Copy link
Collaborator

azure-sdk commented Oct 23, 2024

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - feature ✏️

Allow trailing delimiter in array values, tuple, decorator declaration, scalar initializer, etc.

@@ -269,7 +267,6 @@ namespace ListKind {
delimiter: Token.Comma,
toleratedDelimiter: Token.Semicolon,
toleratedDelimiterIsValid: false,
trailingDelimiterIsValid: false,
invalidAnnotationTarget: "expression",
Copy link
Member Author

Choose a reason for hiding this comment

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

There is one case where it still doesn't work and its the heritage case.

interface A {}; 
interface B {};
interface O extends A, B, {} // Bad diagnostic, which is curious

that was already not showing the trailing-token error before either and this really also feels pointless to really support as the goal of trailing delimiter is usally to reduce diff when adding a new line on multi line and for interface interitance the last line is already trailed with {

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow trailing commas in array [Implementation] Allow trailing list delimiter everywhere
2 participants