Skip to content

Commit

Permalink
Add 'ForType' suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheyan committed Apr 19, 2024
1 parent d75640e commit 2c165ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Event, EventSubscriber } from "./events";
import { replaceTokens, ObjectLookup } from "./helpers";
import { EntityRegisteredEventArgs, Entity, EntityChangeEventArgs, EntityConstructorForType } from "./entity";
import { Type, PropertyType, isEntityType, ValueConstructor, TypeOptions, TypeOfType } from "./type";
import { Type, PropertyType, isEntityType, ValueConstructor, TypeOptionsForType, TypeOfType } from "./type";
import { Format, createFormat } from "./format";
import { EntitySerializer } from "./entity-serializer";
import { LocalizedResourcesMap, setDefaultLocale, defineResources, getResource, resourceExists } from "./resource";
Expand Down Expand Up @@ -249,7 +249,7 @@ export class Model {
}
}

let typeOptions = options[typeName] as TypeOptions<unknown>;
let typeOptions = options[typeName] as TypeOptionsForType<unknown>;
let type = this.types[typeName];

typesToInitialize.push(typeName);
Expand All @@ -272,7 +272,7 @@ export class Model {

// Extend Types
for (let typeName of typesToInitialize) {
let typeOptions = options[typeName] as TypeOptions<unknown>;
let typeOptions = options[typeName] as TypeOptionsForType<unknown>;
this.types[typeName].extend(typeOptions);
}
});
Expand Down Expand Up @@ -397,7 +397,7 @@ export type ModelTypeOptions<TTypes> = {
/**
* Standard type options ($extends and $format), properties, and methods/rules
*/
[T in keyof TTypes]: (TypeOptions<TTypes[T]>) | string;
[T in keyof TTypes]: (TypeOptionsForType<TTypes[T]>) | string;
}

export type ModelLocalizationOptions = {
Expand Down
8 changes: 4 additions & 4 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Type {
readonly initExisting: EventSubscriber<Type, EntityInitExistingEventArgs>;
// readonly conditionsChanged: EventSubscriber<Type, ConditionTargetsChangedEventArgs>;

constructor(model: Model, fullName: string, baseType: Type = null, format: string | Format<Entity>, options?: TypeExtensionOptions<unknown>) {
constructor(model: Model, fullName: string, baseType: Type = null, format: string | Format<Entity>, options?: TypeExtensionOptionsForType<unknown>) {
this.model = model;
this.fullName = fullName;
this.jstype = Type$generateConstructor(this, fullName, baseType, model.settings.useGlobalObject ? getGlobalObject() : null);
Expand Down Expand Up @@ -391,7 +391,7 @@ export class Type {
* Extends the current type with the specified format, properties and methods
* @param options The options specifying how to extend the type
*/
extend(options: TypeExtensionOptions<unknown>): void {
extend(options: TypeExtensionOptionsForType<unknown>): void {
let type = this;

// Utility function to convert a path string into a resolved array of Property and PropertyChain instances
Expand Down Expand Up @@ -546,11 +546,11 @@ export interface RuleOrMethodOptions<EntityType> {

export type RuleOrMethodFunctionOrOptions<EntityType> = ((this: EntityOfType<EntityType>, ...args: any[]) => any) | RuleOrMethodOptions<EntityType>;

export type TypeExtensionOptions<EntityType> = {
export type TypeExtensionOptionsForType<EntityType> = {
[P in keyof EntityType]: ValueConstructorForType<EntityType[P]> | string | PropertyOptions<EntityType, EntityType[P]> | RuleOrMethodFunctionOrOptions<EntityType>;
}

export type TypeOptions<EntityType> = TypeBasicOptions & TypeExtensionOptions<EntityType>;
export type TypeOptionsForType<EntityType> = TypeBasicOptions & TypeExtensionOptionsForType<EntityType>;

export function isValueType(type: any): type is ValueConstructor {
return type === String || type === Number || type === Date || type === Boolean;
Expand Down

0 comments on commit 2c165ac

Please sign in to comment.