• Helper to define instance methods with properly typed this context.

    This is a zero-cost abstraction - at runtime it just returns the methods object. At compile-time, it provides TypeScript with ThisType<InferInstance & Methods> so that this inside your methods is correctly typed as the model instance.

    Type Parameters

    Parameters

    Returns Methods

    The methods object with preserved typing

    const reviewInstanceMethods = defineInstanceMethods(reviewManifest, {
    populateUserInfo(this: ReviewInstance, user: UserAccessContext) {
    // `this` is fully typed as ReviewInstance
    if (user.id === this.createdBy) {
    this.userIsAuthor = true;
    }
    }
    });