Sandbox: alternative syntax / create component function #106
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the issues I've seen with the current syntax is the slightly awkward way in which typescript meets DLight. There are ways to make it work, but we see the mismatch in things like
as Pretty as Typedand where we assign= requiredto properties, or in the way in which @children, @content, and @props are sometimes unclear.This PR is an exploration of alternative syntax ideas. Nothing here is a proposal at this point, just a pastiche of "what if" scenarios.
One of my favorite ideas so far is using Class Expressions instead of static classes. As such, it's possible to pass a Class Expression into a
componentfunction that both re-interprets the type and returns a function that instantiates the class--meaning noas Pretty as Typed<>is necessary. (See PR's "Files changed" tab to see the types that make this possible).From what I understand, Class Expressions do not allow for decorators until Typescript 5, however, so there is a downside in the amount of annotation we can give the transpiler. I've attempted to work around this by making public properties equate with
@Props, and private properties equate with local class variables.We could also use the prop
childrento pass children in.