Skip to content

DataSpecProxy

DataSpecProxy<T> = SpecBuilderMethods & T extends Record<string, unknown> ? { [K in keyof T & string]: DataSpecProxy<T[K]> } : unknown

Defined in: extract/data-spec-builder.ts:84

A Proxy-based spec builder that provides typed direct property access.

For a data type T, each key K of T becomes a navigable property that returns another DataSpecProxy for the nested type. All SpecBuilder methods (string(), number(), get(), etc.) are also available.

SpecBuilder methods take priority over data property names. If your data has a key named string or number, use $.get('string') instead.

T

The data shape being navigated

// With load({ name: 'Alice', age: 30, address: { city: 'NYC' } })
// $ is DataSpecProxy<{ name: string, age: number, address: { city: string } }>
$.name.string() // equivalent to $.get('name').string()
$.age.number() // equivalent to $.get('age').number()
$.address.city.string() // equivalent to $.get('address').get('city').string()