Skip to content

@vttforge/core / InferSchema

Type Alias: InferSchema<S>

InferSchema<S> = Prettify<{ [K in keyof S]: InferField<S[K]> }>

Map a defineSchema() return value to the corresponding system shape.

Type Parameters

S

S extends Record<string, FieldInstance>

Example

ts
class CharacterData extends BaseTypeDataModel() {
  static defineSchema() {
    const f = fields();
    return {
      level: new f.NumberField({ required: true, initial: 1 }),
      biography: new f.HTMLField(),
    };
  }
}
type CharacterSystem = InferSchema<ReturnType<typeof CharacterData.defineSchema>>;
// → { level: number; biography: string }

MIT licensed.