Skip to content

Commit

Permalink
REF: Upgrade typescript types
Browse files Browse the repository at this point in the history
  • Loading branch information
royriojas committed Oct 16, 2020
1 parent ecdffe9 commit be233df
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions mobx-form.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
declare module 'mobx-form' {

export interface IFieldsHash {
[key: string]: IField<any>;
}
Expand Down Expand Up @@ -88,7 +87,7 @@ declare module 'mobx-form' {

value: T;

setValue: ISetValueFn;
setValue: ISetValueFn<T>;

restoreInitialValue: IRestoreIntialValueFn;

Expand All @@ -100,18 +99,18 @@ declare module 'mobx-form' {

setDisabled: ISetDisabledFn;

validate(options: ForceType): Promise<void>;
validate(options?: ForceType): Promise<void>;

originalErrorMessage: string;

setRequired(value: T): void;

setErrorMessage(message: string): void;

new (model: IFormModel<any>, value: T, validatorDescriptor: IValidatorDescriptor, fieldName: string): IFilter;
new (model: IFormModel<any>, value: T, validatorDescriptor: IValidatorDescriptor<T>, fieldName: string): IField<T>;
}

export interface IvalidatorDescriptorHash {
export interface IValidatorDescriptorHash {
[key: string]: IValidatorDescriptor<any>;
}

Expand All @@ -128,11 +127,11 @@ declare module 'mobx-form' {

interacted: boolean;

restoreInitialValues(options: RestoreInitialValuesType): void;
restoreInitialValues(options?: ResetInteractedFlagType): void;

resetInteractedFlag(options: ResetInteractedFlagType): void;
resetInteractedFlag(options?: ResetInteractedFlagType): void;

updateFrom(obj: T, ResetInteractedFlagType?): void;
updateFrom(obj: T, options?: ResetInteractedFlagType): void;

enableFields(fieldNames: string[]): void;

Expand All @@ -146,17 +145,21 @@ declare module 'mobx-form' {

serializedData: T;

addFields(descriptors: IValidatorDescriptor[] | IValidatorDescriptorHash): void;
addFields(descriptors: IValidatorDescriptor<T>[] | IValidatorDescriptorHash): void;

new (descriptors: object, initialState: T);
}

export interface ICreateModelOptions<T> {
descriptors: IValidatorDescriptor[] | IValidatorDescriptorHash;
descriptors: IValidatorDescriptor<T>[] | IValidatorDescriptorHash;
initialState: T;
}

export declare function createModel<T>(options: ICreateModelOptions<T>): IFormModel;
export interface createModel<T> {
(options: ICreateModelOptions<T>): IFormModel<T>;
}

export declare function createModelFromState<T>(initialState: T, descriptors: IValidatorDescriptor[] | IValidatorDescriptorHash);
export interface createModelFromState<T> {
(initialState: T, descriptors: IValidatorDescriptor<T>[] | IValidatorDescriptorHash);
}
}

0 comments on commit be233df

Please sign in to comment.