- Sound mode parse<T>, pre-alpha
- Design record 0007, Accepted
TSR1503
'{0}' from '@ts-r.dev/guard' must be called with a type argument; it can't be used as a value.
A @ts-r.dev/guard function is used as a value instead of being called with a type argument. Call it directly, or use an instantiation like parse<User>.
Rule parse<T>: parse<T> validators. Reported by ts-r-check and ts-r-lsp in files that opt in to sound mode. See Sound mode.
What it means
Calls to @ts-r.dev/guard functions are recognised syntactically and expanded into validators. Using one as a plain value (assigning it, passing it without a type argument) can't be expanded. Instantiation expressions such as items.map(parse<User>) are supported.
Example
// parse used as a value can't be expanded.
import { parse } from "@ts-r.dev/guard";
const p = parse; // @expect TSR1503
export const v: unknown = p(1);
How to fix
- Call it with a type argument:
parse<User>(value). - To pass it as a function, use an instantiation expression:
items.map(parse<User>), orguard<User>().
Sound mode is defined in design record 0007 (accepted 2026-10-15).