Sourced from ts-rs's releases.
v11.1.0
Today, we're happy to publish a small follow-up to v11.0.1!
This release fixes a nasty build failure when using the
formatfeature. Note: For those that use theformatfeature, this release bumps the MSRV to 1.88. We'd have preferred to do this in a major release, but felt this was acceptable since the build was broken by one of the dependencies anyway.New features
TypeScript enums with
#[ts(repr(enum))
#[ts(repr(enum))instructs ts-rs to generate anenum, instead of atypefor your rust enum.#[derive(TS)] #[ts(repr(enum))] enum Role { User, Admin, } // will generate `export enum Role { "User", "Admin" }`Discriminants are preserved, and you can use the variant's name as discriminant instead using
#[ts(repr(enum = name))]
#[ts(optional_fields)]in enumsThe
#[ts(optional_fields)]attribute can now be applied directly to enums, or even to individual enum variants.Control over file extensions in imports
Normally, we generate
import { Type } from "file"statements. In some scenarios though, it might be necessary to use a.tsor even.jsextension instead.
This is now possible by setting theTS_RS_IMPORT_EXTENSIONenvironment variable.Note: With the introduction of this feature, we deprecate the
import-esmcargo feature. It will be removed in a future major release.Full changelog
- Regression:
#[ts(optional)]with#[ts(type)]by@NyxCodein Aleph-Alpha/ts-rs#416- release v11.0.1 by
@NyxCodein Aleph-Alpha/ts-rs#417- Make
rename_allcompatible with tuple and unit structs as a no-op attribute by@gustavo-shigueoin Aleph-Alpha/ts-rs#422- Replace
import-esmwithTS_RS_IMPORT_EXTENSIONby@gustavo-shigueoin Aleph-Alpha/ts-rs#423- Updated chrono Duration emitted type by
@fxf8in Aleph-Alpha/ts-rs#434- Add optional_fields to enum by
@gustavo-shigueoin Aleph-Alpha/ts-rs#432- Add
#[ts(repr(enum)]attribute by@gustavo-shigueoin Aleph-Alpha/ts-rs#425- Fix build with
formatfeature by@gustavo-shigueoin Aleph-Alpha/ts-rs#438New Contributors
@fxf8made their first contribution in Aleph-Alpha/ts-rs#434
Sourced from ts-rs's changelog.
11.1.0
Features
- Add
#[ts(repr(enum))]attribute (#425)- Add support for
#[ts(optional_fields)]in enums and enum variants (#432)- Deprecate
import-esmcargo feature in favour ofRS_RS_IMPORT_EXTENSION(#423)Fixes
- Fix bindings for
chrono::Duration(#434)