Pure-ts - Alessia Exotic -: She Loves Saving The...
// Impure: type and runtime diverge type User = id: number; name: string ; const getUser = (input: any): User => input; // Dangerous // Pure-TS: type + runtime guard (using zod or effect/schema) import z from "zod"; const UserSchema = z.object( id: z.number(), name: z.string() ); type User = z.infer<typeof UserSchema>;
Saving the architecture from what? From entropy. From null checks that don't exist. From the gradual decay of a hundred junior developers adding @ts-ignore like sacrificial incantations. Pure-TS - Alessia Exotic - she loves saving the...
const getUser = (input: unknown): User => UserSchema.parse(input); // Impure: type and runtime diverge type User