-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Wonderful! 😍❤️💕
It is not possible to see this and not think about typescript. How to share this type definition with a ts code without repeating that?
Is this possible to have the same feature with decorators and class definitions instead tagged literals?
I think it can get highlighting benefits and somehow share typing definition.
let { Node, Leaf } = scrap`
data Node { left: Node | Leaf, right: Node | Leaf }
data Leaf { data: any }
`;could be
@scrap class Node {
@data('Node | Leaf') left: Node | Leaf
@data('Node | Leaf') right: Node | Leaf
}
@scrap class Leaf {
data: any // A prop without decorator could be inferred as type `any` by `@scrap`.
}I can't see now how to not repeat union types or non base types, however it is editor friendly and will allow highlighting and autocomplete.
This second example (if i'm right) can use type inference and we don't need to repeat:
let { Pair } = scrap`
data Pair { left: number, right: number }
`could be
@scrap class Pair {
@data.number left
@data.number right
}...OR...
Do scrap really need to know the data type while using typescript? If it don't, so the double typing problem is gone. A base Scrap class to be extended must be enough.
Metadata
Metadata
Assignees
Labels
No labels