Using TypeScript
Narrowing Types
import { is, number, object, string } from 'superstruct'
const User = object({
id: number(),
email: string(),
name: string(),
})
if (is(data, User)) {
// In this block TypeScript knows the shape of `data` is guaranteed to match
// the `User` struct, so you can access properties like `data.name`.
}Describing Types
Inferring Types
Last updated