TS-Pattern
V3 includes the TS-Pattern library, useful for safely pattern-matching. Below is an example of a tRPC query response being pattern-matched against.
const createUser = async (input: User) => { const { type, error, data } = await $client.user.createUser.mutate(input) match(type) .with( 'error', () => { throw new Error(error?.message) }, ) .with( 'ok', () => { user.value = data! }, ) .exhaustive()}