https://github.com/ahaoboy/dts2rs
convert typescript to rust
https://github.com/ahaoboy/dts2rs
rust typescript web
Last synced: about 2 months ago
JSON representation
convert typescript to rust
- Host: GitHub
- URL: https://github.com/ahaoboy/dts2rs
- Owner: ahaoboy
- Created: 2024-07-08T10:34:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-10T14:03:35.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T13:28:06.078Z (over 1 year ago)
- Topics: rust, typescript, web
- Language: TypeScript
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## dts2rs
convert typescript to rust
```bash
dts2rs ./examples --outdir=dist-rs
```
## rules
### string/number/boolean
```ts
s: string
n: number
b: boolean
```
```rs
s: String
n: f32
b: bool
```
### Optional
```ts
v?: number | null
```
```rs
v: Option
```
### Array
```ts
v: boolean[]
```
```rs
v: Vec
```
### struct
```ts
export interface A{
a: number
}
export interface B{
a: A
}
```
```rs
pub struct A;
pub struct B{
a: A
};
```
### HashMap
```ts
export interface A{
a: { [key: string]: string; }
}
```
```rs
pub struct A{
a: std::collections::HashMap
}
```
## Who's Using dts2rs?
- [serde-jellyfin](https://github.com/ahaoboy/serde-jellyfin)
## todo
- [ ] support any type
- [ ] custom convert function
- [ ] more number type