pub struct Any<T = ()>(/* private fields */);Expand description
Cast a Rust type to a Typescript any type.
WARNING: When used with Option<Any<T>>, Typescript will not prompt you about nullability checks as any | null is coalesced to any in Typescript.
§Examples
This can be used as a type override.
use serde::Serialize;
use specta::Type;
use specta_typescript::Any;
#[derive(Serialize, Type)]
pub struct Demo {
#[specta(type = Any)]
pub field: String,
}Or it can be used as a wrapper type.
use serde::Serialize;
use specta::Type;
use specta_typescript::Any;
#[derive(Serialize, Type)]
pub struct Demo {
pub field: Any<String>,
}Trait Implementations§
Source§impl<T> Type for Any<T>
impl<T> Type for Any<T>
Source§fn definition(_: &mut TypeCollection) -> DataType
fn definition(_: &mut TypeCollection) -> DataType
returns a
DataType that represents the type.
This will also register this and any dependent types into the TypeCollection.Auto Trait Implementations§
impl<T> Freeze for Any<T>where
T: Freeze,
impl<T> RefUnwindSafe for Any<T>where
T: RefUnwindSafe,
impl<T> Send for Any<T>where
T: Send,
impl<T> Sync for Any<T>where
T: Sync,
impl<T> Unpin for Any<T>where
T: Unpin,
impl<T> UnsafeUnpin for Any<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Any<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more