An open API service indexing awesome lists of open source software.

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

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