Skip to content

Type Alias: InferredVueReActiveObjectMap

ts
type InferredVueReActiveObjectMap =
  VueReActiveRecordTypes["ObjectMap"] extends DefaultObjectMap
    ? VueReActiveRecordTypes["ObjectMap"]
    : DefaultObjectMap;

A utility type that intelligently infers the model object map for your Vue ReActiveRecord application.

This type uses TypeScript's module augmentation pattern to provide type safety for your models. It checks if you've extended the VueReActiveRecordTypes interface in your application, and if so, uses your custom model definitions. Otherwise, it falls back to the default object map from the underlying @nhtio/web-re-active-record library.

Remarks

This type enables the plugin to work with both:

  • Augmented types: When you define custom model schemas via module augmentation
  • Default types: When no custom models are defined, providing basic functionality

The @ts-expect-error comments are intentional and suppress TypeScript errors that occur when the VueReActiveRecordTypes['ObjectMap'] property doesn't exist (before augmentation).

Example

ts
// Without augmentation - uses DefaultObjectMap
type Models = InferredVueReActiveObjectMap; // DefaultObjectMap

// With augmentation in your app
declare module "@nhtio/vue-re-active-record" {
  interface VueReActiveRecordTypes {
    ObjectMap: {
      User: { id: number; name: string; email: string };
      Post: { id: number; title: string; content: string };
    };
  }
}
type Models = InferredVueReActiveObjectMap; // { User: {...}, Post: {...} }

See

VueReActiveRecordTypes - The interface to augment with your model definitions