Skip to content

Commit

Permalink
Validator - onInitialized event parameter has incorrect typing (T1269…
Browse files Browse the repository at this point in the history
…388) (#28686)
  • Loading branch information
mpreyskurantov authored Jan 21, 2025
1 parent de303f7 commit 411e1ce
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 32 deletions.
16 changes: 8 additions & 8 deletions packages/devextreme-angular/src/ui/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {


import * as CommonTypes from 'devextreme/common';
import { EventInfo } from 'devextreme/common/core/events';
import { DisposingEvent, InitializedEvent, OptionChangedEvent, ValidatedEvent } from 'devextreme/ui/validator';

import DxValidator from 'devextreme/ui/validator';

Expand Down Expand Up @@ -179,35 +179,35 @@ export class DxValidatorComponent extends DxComponentExtension implements OnDest

/**
* [descr:DOMComponentOptions.onDisposing]
* [descr:dxValidatorOptions.onDisposing]
*/
@Output() onDisposing: EventEmitter<EventInfo<any>>;
@Output() onDisposing: EventEmitter<DisposingEvent>;

/**
* [descr:ComponentOptions.onInitialized]
* [descr:dxValidatorOptions.onInitialized]
*/
@Output() onInitialized: EventEmitter<Object>;
@Output() onInitialized: EventEmitter<InitializedEvent>;

/**
* [descr:DOMComponentOptions.onOptionChanged]
* [descr:dxValidatorOptions.onOptionChanged]
*/
@Output() onOptionChanged: EventEmitter<Object>;
@Output() onOptionChanged: EventEmitter<OptionChangedEvent>;

/**
* [descr:dxValidatorOptions.onValidated]
*/
@Output() onValidated: EventEmitter<Object>;
@Output() onValidated: EventEmitter<ValidatedEvent>;

/**
Expand Down
13 changes: 12 additions & 1 deletion packages/devextreme-react/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ import { ExtensionComponent as BaseComponent } from "./core/extension-component"
import { IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
import NestedOption from "./core/nested-option";

import type { DisposingEvent, InitializedEvent, ValidatedEvent } from "devextreme/ui/validator";
import type { ValidationRuleType, ComparisonOperator } from "devextreme/common";

type IValidatorOptions = React.PropsWithChildren<Properties & IHtmlOptions>
type ReplaceFieldTypes<TSource, TReplacement> = {
[P in keyof TSource]: P extends keyof TReplacement ? TReplacement[P] : TSource[P];
}

type IValidatorOptionsNarrowedEvents = {
onDisposing?: ((e: DisposingEvent) => void);
onInitialized?: ((e: InitializedEvent) => void);
onValidated?: ((validatedInfo: ValidatedEvent) => void);
}

type IValidatorOptions = React.PropsWithChildren<ReplaceFieldTypes<Properties, IValidatorOptionsNarrowedEvents> & IHtmlOptions>

interface ValidatorRef {
instance: () => dxValidator;
Expand Down
20 changes: 9 additions & 11 deletions packages/devextreme-vue/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { PropType } from "vue";
import { defineComponent } from "vue";
import { prepareExtensionComponentConfig } from "./core/index";
import Validator, { Properties } from "devextreme/ui/validator";
import DOMComponent from "devextreme/core/dom_component";
import {
EventInfo,
} from "devextreme/common/core/events";
DisposingEvent,
InitializedEvent,
OptionChangedEvent,
ValidatedEvent,
} from "devextreme/ui/validator";
import {
Component,
} from "devextreme/core/component";
import {
ValidationStatus,
ValidationRuleType,
ComparisonOperator,
} from "devextreme/common";
Expand Down Expand Up @@ -41,10 +39,10 @@ const componentConfig = {
elementAttr: Object as PropType<Record<string, any>>,
height: [Function, Number, String] as PropType<((() => number | string)) | number | string>,
name: String,
onDisposing: Function as PropType<((e: EventInfo<any>) => void)>,
onInitialized: Function as PropType<((e: { component: Component<any>, element: any }) => void)>,
onOptionChanged: Function as PropType<((e: { component: DOMComponent, element: any, fullName: string, model: any, name: string, previousValue: any, value: any }) => void)>,
onValidated: Function as PropType<((validatedInfo: { brokenRule: CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule | CommonTypes.ValidationRule, brokenRules: Array<CommonTypes.ValidationRule>, isValid: boolean, name: string, status: ValidationStatus, validationRules: Array<CommonTypes.ValidationRule>, value: Record<string, any> }) => void)>,
onDisposing: Function as PropType<((e: DisposingEvent) => void)>,
onInitialized: Function as PropType<((e: InitializedEvent) => void)>,
onOptionChanged: Function as PropType<((e: OptionChangedEvent) => void)>,
onValidated: Function as PropType<((validatedInfo: ValidatedEvent) => void)>,
validationGroup: String,
validationRules: Array as PropType<Array<CommonTypes.ValidationRule>>,
width: [Function, Number, String] as PropType<((() => number | string)) | number | string>
Expand Down
74 changes: 63 additions & 11 deletions packages/devextreme/js/ui/validator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,52 @@ export {
ValidationStatus,
};

/** @public */
/**
* @docid _ui_validator_DisposingEvent
* @public
* @type object
* @inherits EventInfo
*/
export type DisposingEvent = EventInfo<dxValidator>;

/** @public */
/**
* @docid _ui_validator_InitializedEvent
* @public
* @type object
* @inherits InitializedEventInfo
*/
export type InitializedEvent = InitializedEventInfo<dxValidator>;

/** @public */
/**
* @docid _ui_validator_OptionChangedEvent
* @public
* @type object
* @inherits EventInfo,ChangedOptionInfo
*/
export type OptionChangedEvent = EventInfo<dxValidator> & ChangedOptionInfo;

/** @public */
/**
* @docid _ui_validator_ValidatedEvent
* @public
* @type object
*/
export type ValidatedEvent = {
/** @docid _ui_validator_ValidatedEvent.name */
name?: string;
/** @docid _ui_validator_ValidatedEvent.isValid */
isValid?: boolean;
/**
* @docid _ui_validator_ValidatedEvent.value
* @type object
*/
value?: any;
/** @docid _ui_validator_ValidatedEvent.validationRules */
validationRules?: Array<ValidationRule>;
/** @docid _ui_validator_ValidatedEvent.brokenRule */
brokenRule?: ValidationRule;
brokenRules?: ValidationRule;
/** @docid _ui_validator_ValidatedEvent.brokenRules */
brokenRules?: Array<ValidationRule>;
/** @docid _ui_validator_ValidatedEvent.status */
status?: ValidationStatus;
};

Expand Down Expand Up @@ -85,12 +114,7 @@ export interface dxValidatorOptions extends DOMComponentOptions<dxValidator> {
name?: string;
/**
* @docid
* @type_function_param1 validatedInfo:Object
* @type_function_param1_field value:Object
* @type_function_param1_field validationRules:Array<RequiredRule,NumericRule,RangeRule,StringLengthRule,CustomRule,CompareRule,PatternRule,EmailRule,AsyncRule>
* @type_function_param1_field brokenRule:RequiredRule|NumericRule|RangeRule|StringLengthRule|CustomRule|CompareRule|PatternRule|EmailRule|AsyncRule
* @type_function_param1_field brokenRules:Array<RequiredRule,NumericRule,RangeRule,StringLengthRule,CustomRule,CompareRule,PatternRule,EmailRule,AsyncRule>
* @type_function_param1_field status:Enums.ValidationStatus
* @type_function_param1 validatedInfo:{ui/validator:ValidatedEvent}
* @action
* @public
*/
Expand Down Expand Up @@ -198,3 +222,31 @@ export type Properties = dxValidatorOptions;

/** @deprecated use Properties instead */
export type Options = dxValidatorOptions;

///#DEBUG
// eslint-disable-next-line import/first
import { CheckedEvents } from '../core';

type EventsIntegrityCheckingHelper = CheckedEvents<Properties, Required<Events>, 'onValidated'>;

/**
* @hidden
*/
type Events = {
/**
* @docid dxValidatorOptions.onDisposing
* @type_function_param1 e:{ui/validator:DisposingEvent}
*/
onDisposing?: ((e: DisposingEvent) => void);
/**
* @docid dxValidatorOptions.onInitialized
* @type_function_param1 e:{ui/validator:InitializedEvent}
*/
onInitialized?: ((e: InitializedEvent) => void);
/**
* @docid dxValidatorOptions.onOptionChanged
* @type_function_param1 e:{ui/validator:OptionChangedEvent}
*/
onOptionChanged?: ((e: OptionChangedEvent) => void);
};
///#ENDDEBUG
35 changes: 34 additions & 1 deletion packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30749,21 +30749,54 @@ declare module DevExpress.ui {
validate(): DevExpress.ui.dxValidator.ValidationResult;
}
module dxValidator {
/**
* [descr:_ui_validator_DisposingEvent]
*/
export type DisposingEvent =
DevExpress.common.core.events.EventInfo<dxValidator>;
/**
* [descr:_ui_validator_InitializedEvent]
*/
export type InitializedEvent =
DevExpress.common.core.events.InitializedEventInfo<dxValidator>;
/**
* [descr:_ui_validator_OptionChangedEvent]
*/
export type OptionChangedEvent =
DevExpress.common.core.events.EventInfo<dxValidator> &
DevExpress.common.core.events.ChangedOptionInfo;
export type Properties = dxValidatorOptions;
/**
* [descr:_ui_validator_ValidatedEvent]
*/
export type ValidatedEvent = {
/**
* [descr:_ui_validator_ValidatedEvent.name]
*/
name?: string;
/**
* [descr:_ui_validator_ValidatedEvent.isValid]
*/
isValid?: boolean;
/**
* [descr:_ui_validator_ValidatedEvent.value]
*/
value?: any;
/**
* [descr:_ui_validator_ValidatedEvent.validationRules]
*/
validationRules?: Array<DevExpress.common.ValidationRule>;
/**
* [descr:_ui_validator_ValidatedEvent.brokenRule]
*/
brokenRule?: DevExpress.common.ValidationRule;
brokenRules?: DevExpress.common.ValidationRule;
/**
* [descr:_ui_validator_ValidatedEvent.brokenRules]
*/
brokenRules?: Array<DevExpress.common.ValidationRule>;
/**
* [descr:_ui_validator_ValidatedEvent.status]
*/
status?: DevExpress.common.ValidationStatus;
};
export type ValidationResult = dxValidatorResult;
Expand Down

0 comments on commit 411e1ce

Please sign in to comment.