Skip to content

field

field<TYPE>(type, options?): FieldValue<TYPE>

Defined in: .work/repos/edinburgh/src/models.ts:52

Create a field definition for a model property.

This function uses TypeScript magic to return the field configuration object while appearing to return the actual field value type to the type system. This allows for both runtime introspection and compile-time type safety.

TYPE extends TypeWrapper<any>

TYPE

The type wrapper for this field.

Partial<FieldConfig<FieldValue<TYPE>>> = {}

Additional field configuration options.

FieldValue<TYPE>

The field value (typed as T, but actually returns FieldConfig).

const User = E.defineModel("User", class {
name = E.field(E.string, {description: "User's full name"});
age = E.field(E.opt(E.number), {description: "User's age", default: 25});
});