Skip to content

Commit

Permalink
Add Changelog (#24)
Browse files Browse the repository at this point in the history
* Added changelog
* Fix typo in readme
  • Loading branch information
siefkenj authored Apr 11, 2024
1 parent 011268d commit 24434dd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 41 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# tsify-next Changelog

## v0.5.1

- @Pantamis contributed #22, implementing more `From` traits for more ergonomic use of Futures.
- Fix: empty enums now produce a valid type of `void` rather than producing invalid Typescript.

## v0.5.0

- Forked from `tsify` merging most PRs that were queued on Github
84 changes: 43 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tsify-next

Tsify-next is a library for generating TypeScript definitions from Rust code. The original [Tsify](https://github.com/madonoharu/tsify) appears to be in hybernation mode, so this for incorporates updates until main Tsify project comes back to life.
Tsify-next is a library for generating TypeScript definitions from Rust code. The original [Tsify](https://github.com/madonoharu/tsify) appears to be in hibernation mode. This repository will maintain updates until main Tsify project comes back to life.

Using this with [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) will automatically output the types to `.d.ts`.

Expand Down Expand Up @@ -57,45 +57,45 @@ export function into_js(): Point;
*/
export function from_js(point: Point): void;
export interface Point {
x: number;
y: number;
x: number;
y: number;
}
```

This is the behavior due to [`typescript_custom_section`](https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-rust-exports/typescript_custom_section.html) and [`Rust Type conversions`](https://rustwasm.github.io/docs/wasm-bindgen/contributing/design/rust-type-conversions.html).

## Crate Features

- `json` (default) enables serialization through [`serde_json`](https://github.com/serde-rs/json).
- `js` enables serialization through [`serde-wasm-bindgen`](https://github.com/cloudflare/serde-wasm-bindgen) and generates the appropriate types for it. This will be the default in future versions.
- `json` (default) enables serialization through [`serde_json`](https://github.com/serde-rs/json).
- `js` enables serialization through [`serde-wasm-bindgen`](https://github.com/cloudflare/serde-wasm-bindgen) and generates the appropriate types for it. This will be the default in future versions.

## Attributes

Tsify container attributes

- `into_wasm_abi` implements `IntoWasmAbi` and `OptionIntoWasmAbi`. This can be converted directly from Rust to JS via `serde_json` or `serde-wasm-bindgen`.
- `from_wasm_abi` implements `FromWasmAbi` and `OptionFromWasmAbi`. This is the opposite operation of the above.
- `namespace` generates a namespace for the enum variants.
- `into_wasm_abi` implements `IntoWasmAbi` and `OptionIntoWasmAbi`. This can be converted directly from Rust to JS via `serde_json` or `serde-wasm-bindgen`.
- `from_wasm_abi` implements `FromWasmAbi` and `OptionFromWasmAbi`. This is the opposite operation of the above.
- `namespace` generates a namespace for the enum variants.

Tsify field attributes

- `type`
- `optional`
- `type`
- `optional`

Serde attributes

- `rename`
- `rename-all`
- `tag`
- `content`
- `untagged`
- `skip`
- `skip_serializing`
- `skip_deserializing`
- `skip_serializing_if = "Option::is_none"`
- `flatten`
- `default`
- `transparent`
- `rename`
- `rename-all`
- `tag`
- `content`
- `untagged`
- `skip`
- `skip_serializing`
- `skip_deserializing`
- `skip_serializing_if = "Option::is_none"`
- `flatten`
- `default`
- `transparent`

## Type Override

Expand All @@ -113,7 +113,7 @@ Generated type:

```ts
export interface Foo {
x: 0 | 1 | 2;
x: 0 | 1 | 2;
}
```

Expand All @@ -135,9 +135,9 @@ Generated type:

```ts
export interface Optional {
a?: number;
b?: string;
c?: number;
a?: number;
b?: string;
c?: number;
}
```

Expand All @@ -162,11 +162,11 @@ Generated type:

```ts
export type Color =
| "Red"
| "Blue"
| "Green"
| { Rgb: [number, number, number] }
| { Hsv: { hue: number; saturation: number; value: number } };
| "Red"
| "Blue"
| "Green"
| { Rgb: [number, number, number] }
| { Hsv: { hue: number; saturation: number; value: number } };
```

## Enum with namespace
Expand All @@ -191,19 +191,21 @@ Generated type:

```ts
declare namespace Color {
export type Red = "Red";
export type Blue = "Blue";
export type Green = "Green";
export type Rgb = { Rgb: [number, number, number] };
export type Hsv = { Hsv: { hue: number; saturation: number; value: number } };
export type Red = "Red";
export type Blue = "Blue";
export type Green = "Green";
export type Rgb = { Rgb: [number, number, number] };
export type Hsv = {
Hsv: { hue: number; saturation: number; value: number };
};
}

export type Color =
| "Red"
| "Blue"
| "Green"
| { Rgb: [number, number, number] }
| { Hsv: { hue: number; saturation: number; value: number } };
| "Red"
| "Blue"
| "Green"
| { Rgb: [number, number, number] }
| { Hsv: { hue: number; saturation: number; value: number } };
```

## Type Aliases
Expand Down

0 comments on commit 24434dd

Please sign in to comment.