Today, we're happy to publish a small follow-up to v11.0.1!
This release fixes a nasty build failure when using the format feature.
Note: For those that use the format feature, 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 an enum, instead of a type for 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 enums
The #[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 .ts or even .js extension instead.
This is now possible by setting the TS_RS_IMPORT_EXTENSION environment 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 @NyxCode in #416 - release v11.0.1 by @NyxCode in #417
- Make
rename_allcompatible with tuple and unit structs as a no-op attribute by @gustavo-shigueo in #422 - Replace
import-esmwithTS_RS_IMPORT_EXTENSIONby @gustavo-shigueo in #423 - Updated chrono Duration emitted type by @fxf8 in #434
- Add optional_fields to enum by @gustavo-shigueo in #432
- Add
#[ts(repr(enum)]attribute by @gustavo-shigueo in #425 - Fix build with
formatfeature by @gustavo-shigueo in #438