pub struct Config { /* private fields */ }Expand description
Configuration that affects the generation of TypeScript bindings and how they are exported.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a new Config with values read from environment variables.
| Variable | Description | Default |
|---|---|---|
TS_RS_EXPORT_DIR | Base directory into which bindings will be exported | ./bindings |
TS_RS_IMPORT_EXTENSION | File extension used in import statements | none |
TS_RS_LARGE_INT | Binding used for large integer types (i64, u64, i128, u128) | bigint |
Sourcepub fn with_large_int(self, ty: impl Into<String>) -> Self
pub fn with_large_int(self, ty: impl Into<String>) -> Self
Sets the TypeScript type used to represent large integers.
Here, “large” refers to integers that can not be losslessly stored using the 64-bit “binary64” IEEE 754 float format used by JavaScript.
Those include u64, i64, u128, and i128`.
Default: "bigint"
Sourcepub fn with_v11_hashmap(self) -> Self
👎Deprecated: this option is merely meant to aid migration to v12 and will be removed in a future release
pub fn with_v11_hashmap(self) -> Self
When enabled, HashMap<K, V> and similar types will always be translated to { [key in K]?: V }.
Normally, with this option disabled, { [key in K]: V } is generated instead, unless the key K is an enum.
This option is only intended to aid migration and will be removed in a future release.
Default: disabled
Sourcepub fn with_out_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_out_dir(self, dir: impl Into<PathBuf>) -> Self
Sets the output directory into which bindings will be exported.
This affects TS::export, TS::export_all, and the automatic export of types annotated with #[ts(export)] when cargo test is run.
Default: ./bindings
Sourcepub fn out_dir(&self) -> &Path
pub fn out_dir(&self) -> &Path
Returns the output directory into which bindings will be exported.
Sourcepub fn with_import_extension(self, ext: Option<impl Into<String>>) -> Self
pub fn with_import_extension(self, ext: Option<impl Into<String>>) -> Self
Sets the file extension used for import statements in generated TypeScript files.
Default: None
Sourcepub fn import_extension(&self) -> Option<&str>
pub fn import_extension(&self) -> Option<&str>
Returns the file extension used for import statements in generated TypeScript files.
Sourcepub fn with_array_tuple_limit(self, limit: usize) -> Self
pub fn with_array_tuple_limit(self, limit: usize) -> Self
Sets the maximum size of arrays ([T; N]) up to which they are treated as TypeScript tuples ([T, T, ...]).
Arrays beyond this size will instead result in a TypeScript array (Array<T>).
Default: 64
Sourcepub fn array_tuple_limit(&self) -> usize
pub fn array_tuple_limit(&self) -> usize
Returns the maximum size of arrays ([T; N]) up to which they are treated as TypeScript tuples ([T, T, ...]).