-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Currently, ts-rs can export structs and enums, but not constants.
This leads to duplicated definitions between Rust and TypeScript for shared values (like filenames, setting keys, limits, etc.), which can easily get out of sync.
Describe the solution you'd like
Allow ts-rs to export pub const values to TypeScript.
Example:
pub const SETTINGS_FILE: &str = "settings.json";to
export const SETTINGS_FILE = "settings.json";This could also work for numeric and boolean constants:
pub const MAX_ITEMS: u32 = 100;
pub const DEBUG_MODE: bool = true;to
export const MAX_ITEMS = 100;
export const DEBUG_MODE = true;Describe alternatives you've considered
- Manually duplicating constants in Rust and TypeScript.
- Custom build scripts to generate TS files separately.
Additional context
This would improve type safety and maintainability for shared front/back-end projects (e.g., Tauri apps).
zekehuntergreen and Jacob-32587
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request