Comments (3)
hey @RandyMarsh1, thanks for reporting this :)
Let me know if 1.7.0 doesn't work for you. I think eventually what we'll want to do is namespace a lot of this output. Closing this for now, feel free to re-open it
from tsync.
Thanks, nested structs within structs now works, this is a great improvement 👍
However the specific scenario I was hoping for was Rust Enums that take a struct of the same name as input parameter like this:
#[tsync]
#[derive(Serialize)]
enum Message {
MyStruct1(MyStruct1), <-- enum variant name == struct name
MyStruct2(MyStruct2),
}
This currently does not output anything and is skipped.
The following does output a type but the variants are Strings, not Interfaces.
#[tsync]
#[derive(Serialize)]
enum Message2 {
MyStruct1,
MyStruct2,
}
This admittable requires a somewhat opinionated structure but I think is a nice clean way of generating JSON with the Enum variant as key and Struct as Value. The Example code in original post should compile and demonstrates the use case.
from tsync.
Ah that should be possible too -- do you mind lending me a hand with this one?
- Update
fn make_externally_tagged_variant(..)
here to output the type separately and use the identifier, similar to the approach used in #26. - Run
./test/enum/tsync.sh
and see if the./test/enum/typescript.d.ts
file changes appropriately
from tsync.
Related Issues (16)
- Feature Request: Generate documentation in jsdoc format HOT 3
- Feature request - `undefined` fields using the "optional parameter" `?` syntax HOT 1
- Feature Request: Supporting `const` scalars such as numbers and strings + enums (?) HOT 5
- tsync from other proc-macros? HOT 3
- Const JSON does not compile HOT 4
- error[E0603]: enum `TokenTree` is private HOT 3
- Custom type mapping HOT 1
- [feature request] Honour `#[serde(rename = "...")]` in the generated TypeScript types HOT 2
- [feature request] Tuples HOT 3
- [bug] Numeric enum is not converted correctly on v2.0.0. HOT 1
- Feature request: support tuple structs HOT 4
- [feature request] Support serde flatten HOT 3
- Support for const enums HOT 3
- Fix broken CI workflow
- Enhanced enum support and types HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsync.