-
Notifications
You must be signed in to change notification settings - Fork 58
RFC: Declaration syntax #118
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
base: master
Are you sure you want to change the base?
Conversation
I do think if we're going to formalize this, it's worth revisiting the class declaration syntax. It's completely out of wack with the rest of the Luau type system, and we can probably do better. Perhaps just giving it a similar syntax to the table types we already have instead of treating it like a block? As an example: declare class Animal = {
legs: number,
}
declare class Dog extends Animal = {
tail_wagging: boolean,
} This runs into problems with how functions are currently declared in classes, but I'm not sure there's a compelling reason to use the |
|
||
## Alternatives | ||
|
||
The alternative to this is to leave this as an implementation detail. However this makes it inconvenient for embedders of Luau to use the declaration syntax. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it make it inconvenient to use? luau-lsp is using it right now.
|
||
## Motivation | ||
|
||
RIght now the declaration syntax used by the Luau parser is undocumented and an unstable implementation detail. By defining the syntax, it allows for embedders of Luau to have typechecking for their apis without having to resort to empty modules. This should allow tools like luau-lsp to be able to provide easier ways to use these declarations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
luau-lsp already uses declaration files as they are, so it's not really clear what we hope to actually gain here. the syntax of declaration files has been essentially unchanged since they were introduced, and it seems like the only thing this RFC has actually done is inspire conversation to make changes to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, my feeling about this RFC is that it doesn't actually do anything. The syntax for declaration files has been just as stable as the rest of Luau's syntax has been, and it's not clear what problem we're aiming to solve by having an RFC that just says it "formalizes" the syntax without actually formalizing the syntax at all. There's no formal characterization of the syntax present in this RFC in any form, and the motivation for it as-stated is completely imagined since it talks about luau-lsp using declaration files when it already does use them.
Rendered