Extending structs
See original GitHub issueIs there an easy way to extend struct objects? I read through the documentation and couldn’t figure out how to do it. I’d like to write something like this:
class A {
someProp = "";
static validationStruct = object({ someProp: string() });
}
class B extends A {
anotherProp = 0;
static validationStruct = A.validationStruct.extend({ anotherProp: number() });
}
const b = new B();
assert(b, B.validationStruct)
Maybe this is an anti-pattern or there’s a better way. Would love any insight you can offer. Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Can I 'extend' a struct in C? - Stack Overflow
because I have an 'object' struct which heads all the structs in the project). I could simply embed the struct like you mention...
Read more >Tip 63: Seamlessly extend C structures - Modeling with Data
The syntax: include another struct in the declaration of the new structure. All of the elements of the other structure are included in...
Read more >Extending struct with another : r/learnrust - Reddit
lets say i have struct struct Base { w: u64, h: u64, } which i want to extend with other structs struct Extension1...
Read more >Extending Structure Functionality - ALM Works Help Center
You can extend Structure add-on's functionality with your own add-on by using one of the available extension points. Creating a New Column Type...
Read more >Extension Methods for Structs - YouTube
Value types pass by value and reference types pass by reference. But interfaces are implemented by both value and reference types.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@xiaoyu-tamu hoping to merge it imminently.
I ended up specifying the extended properties directly, e.g.:
Not very elegant, but it works fine for my purposes.