Exports your types to other languages, currently supporting TypeScript.
Install
Add to your Cargo.toml
[]
= { = "https://github.com/thebluefish/burrtype", = ["typescript"] }
# I would like to remove this requirement in a future version of bevy_reflect, but for now you must include it too
= "0.11"
Use
Decorate your types with the Reflect derive macro. Optionally include the #[burr] attribute to auto-register them.
use *;
;
;
In your build.rs or another binary, we can create an exporter, add your types to be exported, and then write those types to your desired language(s).
new
// auto-registered types depended on by your types will be exported here
.with_default_mod
// create a virtual module and add our root type to it
.with_mod
// outputs ./ts/common.ts and ./ts/bar.ts
.export?
// bundles all exported types into a single file
.export?
;
The exporter and its components behave as builder patterns. Builder options typically use the suffix with_.
Inputs are organized into modules, which represent collections of items, including other modules. This module tree typically translates to the file structure being produced, with one file per module, but language constraits, features, or options can change this behavior.
See these concepts in action in the example.
Desired features going forward
- Replace panics with errors
- tests
Rust
- Support the same set of common features as TypeScript
- Generic types?