Skip to content

Commit a9864c3

Browse files
Validator - onInitialized event parameter has incorrect typing (T1269388) (DevExpress#28793)
1 parent 1e97eaf commit a9864c3

File tree

5 files changed

+126
-32
lines changed

5 files changed

+126
-32
lines changed

packages/devextreme-angular/src/ui/validator/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626

2727

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

3131
import DxValidator from 'devextreme/ui/validator';
3232

@@ -179,35 +179,35 @@ export class DxValidatorComponent extends DxComponentExtension implements OnDest
179179

180180
/**
181181
182-
* [descr:DOMComponentOptions.onDisposing]
182+
* [descr:dxValidatorOptions.onDisposing]
183183
184184
185185
*/
186-
@Output() onDisposing: EventEmitter<EventInfo<any>>;
186+
@Output() onDisposing: EventEmitter<DisposingEvent>;
187187

188188
/**
189189
190-
* [descr:ComponentOptions.onInitialized]
190+
* [descr:dxValidatorOptions.onInitialized]
191191
192192
193193
*/
194-
@Output() onInitialized: EventEmitter<Object>;
194+
@Output() onInitialized: EventEmitter<InitializedEvent>;
195195

196196
/**
197197
198-
* [descr:DOMComponentOptions.onOptionChanged]
198+
* [descr:dxValidatorOptions.onOptionChanged]
199199
200200
201201
*/
202-
@Output() onOptionChanged: EventEmitter<Object>;
202+
@Output() onOptionChanged: EventEmitter<OptionChangedEvent>;
203203

204204
/**
205205
206206
* [descr:dxValidatorOptions.onValidated]
207207
208208
209209
*/
210-
@Output() onValidated: EventEmitter<Object>;
210+
@Output() onValidated: EventEmitter<ValidatedEvent>;
211211

212212
/**
213213

packages/devextreme-react/src/validator.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@ import { ExtensionComponent as BaseComponent } from "./core/extension-component"
99
import { IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
1010
import NestedOption from "./core/nested-option";
1111

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

14-
type IValidatorOptions = React.PropsWithChildren<Properties & IHtmlOptions>
15+
type ReplaceFieldTypes<TSource, TReplacement> = {
16+
[P in keyof TSource]: P extends keyof TReplacement ? TReplacement[P] : TSource[P];
17+
}
18+
19+
type IValidatorOptionsNarrowedEvents = {
20+
onDisposing?: ((e: DisposingEvent) => void);
21+
onInitialized?: ((e: InitializedEvent) => void);
22+
onValidated?: ((validatedInfo: ValidatedEvent) => void);
23+
}
24+
25+
type IValidatorOptions = React.PropsWithChildren<ReplaceFieldTypes<Properties, IValidatorOptionsNarrowedEvents> & IHtmlOptions>
1526

1627
interface ValidatorRef {
1728
instance: () => dxValidator;

packages/devextreme-vue/src/validator.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import { PropType } from "vue";
22
import { defineComponent } from "vue";
33
import { prepareExtensionComponentConfig } from "./core/index";
44
import Validator, { Properties } from "devextreme/ui/validator";
5-
import DOMComponent from "devextreme/core/dom_component";
65
import {
7-
EventInfo,
8-
} from "devextreme/common/core/events";
6+
DisposingEvent,
7+
InitializedEvent,
8+
OptionChangedEvent,
9+
ValidatedEvent,
10+
} from "devextreme/ui/validator";
911
import {
10-
Component,
11-
} from "devextreme/core/component";
12-
import {
13-
ValidationStatus,
1412
ValidationRuleType,
1513
ComparisonOperator,
1614
} from "devextreme/common";
@@ -41,10 +39,10 @@ const componentConfig = {
4139
elementAttr: Object as PropType<Record<string, any>>,
4240
height: [Function, Number, String] as PropType<((() => number | string)) | number | string>,
4341
name: String,
44-
onDisposing: Function as PropType<((e: EventInfo<any>) => void)>,
45-
onInitialized: Function as PropType<((e: { component: Component<any>, element: any }) => void)>,
46-
onOptionChanged: Function as PropType<((e: { component: DOMComponent, element: any, fullName: string, model: any, name: string, previousValue: any, value: any }) => void)>,
47-
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)>,
42+
onDisposing: Function as PropType<((e: DisposingEvent) => void)>,
43+
onInitialized: Function as PropType<((e: InitializedEvent) => void)>,
44+
onOptionChanged: Function as PropType<((e: OptionChangedEvent) => void)>,
45+
onValidated: Function as PropType<((validatedInfo: ValidatedEvent) => void)>,
4846
validationGroup: String,
4947
validationRules: Array as PropType<Array<CommonTypes.ValidationRule>>,
5048
width: [Function, Number, String] as PropType<((() => number | string)) | number | string>

packages/devextreme/js/ui/validator.d.ts

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,52 @@ export {
2222
ValidationStatus,
2323
};
2424

25-
/** @public */
25+
/**
26+
* @docid _ui_validator_DisposingEvent
27+
* @public
28+
* @type object
29+
* @inherits EventInfo
30+
*/
2631
export type DisposingEvent = EventInfo<dxValidator>;
2732

28-
/** @public */
33+
/**
34+
* @docid _ui_validator_InitializedEvent
35+
* @public
36+
* @type object
37+
* @inherits InitializedEventInfo
38+
*/
2939
export type InitializedEvent = InitializedEventInfo<dxValidator>;
3040

31-
/** @public */
41+
/**
42+
* @docid _ui_validator_OptionChangedEvent
43+
* @public
44+
* @type object
45+
* @inherits EventInfo,ChangedOptionInfo
46+
*/
3247
export type OptionChangedEvent = EventInfo<dxValidator> & ChangedOptionInfo;
3348

34-
/** @public */
49+
/**
50+
* @docid _ui_validator_ValidatedEvent
51+
* @public
52+
* @type object
53+
*/
3554
export type ValidatedEvent = {
55+
/** @docid _ui_validator_ValidatedEvent.name */
3656
name?: string;
57+
/** @docid _ui_validator_ValidatedEvent.isValid */
3758
isValid?: boolean;
59+
/**
60+
* @docid _ui_validator_ValidatedEvent.value
61+
* @type object
62+
*/
3863
value?: any;
64+
/** @docid _ui_validator_ValidatedEvent.validationRules */
3965
validationRules?: Array<ValidationRule>;
66+
/** @docid _ui_validator_ValidatedEvent.brokenRule */
4067
brokenRule?: ValidationRule;
41-
brokenRules?: ValidationRule;
68+
/** @docid _ui_validator_ValidatedEvent.brokenRules */
69+
brokenRules?: Array<ValidationRule>;
70+
/** @docid _ui_validator_ValidatedEvent.status */
4271
status?: ValidationStatus;
4372
};
4473

@@ -85,12 +114,7 @@ export interface dxValidatorOptions extends DOMComponentOptions<dxValidator> {
85114
name?: string;
86115
/**
87116
* @docid
88-
* @type_function_param1 validatedInfo:Object
89-
* @type_function_param1_field value:Object
90-
* @type_function_param1_field validationRules:Array<RequiredRule,NumericRule,RangeRule,StringLengthRule,CustomRule,CompareRule,PatternRule,EmailRule,AsyncRule>
91-
* @type_function_param1_field brokenRule:RequiredRule|NumericRule|RangeRule|StringLengthRule|CustomRule|CompareRule|PatternRule|EmailRule|AsyncRule
92-
* @type_function_param1_field brokenRules:Array<RequiredRule,NumericRule,RangeRule,StringLengthRule,CustomRule,CompareRule,PatternRule,EmailRule,AsyncRule>
93-
* @type_function_param1_field status:Enums.ValidationStatus
117+
* @type_function_param1 validatedInfo:{ui/validator:ValidatedEvent}
94118
* @action
95119
* @public
96120
*/
@@ -198,3 +222,31 @@ export type Properties = dxValidatorOptions;
198222

199223
/** @deprecated use Properties instead */
200224
export type Options = dxValidatorOptions;
225+
226+
///#DEBUG
227+
// eslint-disable-next-line import/first
228+
import { CheckedEvents } from '../core';
229+
230+
type EventsIntegrityCheckingHelper = CheckedEvents<Properties, Required<Events>, 'onValidated'>;
231+
232+
/**
233+
* @hidden
234+
*/
235+
type Events = {
236+
/**
237+
* @docid dxValidatorOptions.onDisposing
238+
* @type_function_param1 e:{ui/validator:DisposingEvent}
239+
*/
240+
onDisposing?: ((e: DisposingEvent) => void);
241+
/**
242+
* @docid dxValidatorOptions.onInitialized
243+
* @type_function_param1 e:{ui/validator:InitializedEvent}
244+
*/
245+
onInitialized?: ((e: InitializedEvent) => void);
246+
/**
247+
* @docid dxValidatorOptions.onOptionChanged
248+
* @type_function_param1 e:{ui/validator:OptionChangedEvent}
249+
*/
250+
onOptionChanged?: ((e: OptionChangedEvent) => void);
251+
};
252+
///#ENDDEBUG

packages/devextreme/ts/dx.all.d.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30749,21 +30749,54 @@ declare module DevExpress.ui {
3074930749
validate(): DevExpress.ui.dxValidator.ValidationResult;
3075030750
}
3075130751
module dxValidator {
30752+
/**
30753+
* [descr:_ui_validator_DisposingEvent]
30754+
*/
3075230755
export type DisposingEvent =
3075330756
DevExpress.common.core.events.EventInfo<dxValidator>;
30757+
/**
30758+
* [descr:_ui_validator_InitializedEvent]
30759+
*/
3075430760
export type InitializedEvent =
3075530761
DevExpress.common.core.events.InitializedEventInfo<dxValidator>;
30762+
/**
30763+
* [descr:_ui_validator_OptionChangedEvent]
30764+
*/
3075630765
export type OptionChangedEvent =
3075730766
DevExpress.common.core.events.EventInfo<dxValidator> &
3075830767
DevExpress.common.core.events.ChangedOptionInfo;
3075930768
export type Properties = dxValidatorOptions;
30769+
/**
30770+
* [descr:_ui_validator_ValidatedEvent]
30771+
*/
3076030772
export type ValidatedEvent = {
30773+
/**
30774+
* [descr:_ui_validator_ValidatedEvent.name]
30775+
*/
3076130776
name?: string;
30777+
/**
30778+
* [descr:_ui_validator_ValidatedEvent.isValid]
30779+
*/
3076230780
isValid?: boolean;
30781+
/**
30782+
* [descr:_ui_validator_ValidatedEvent.value]
30783+
*/
3076330784
value?: any;
30785+
/**
30786+
* [descr:_ui_validator_ValidatedEvent.validationRules]
30787+
*/
3076430788
validationRules?: Array<DevExpress.common.ValidationRule>;
30789+
/**
30790+
* [descr:_ui_validator_ValidatedEvent.brokenRule]
30791+
*/
3076530792
brokenRule?: DevExpress.common.ValidationRule;
30766-
brokenRules?: DevExpress.common.ValidationRule;
30793+
/**
30794+
* [descr:_ui_validator_ValidatedEvent.brokenRules]
30795+
*/
30796+
brokenRules?: Array<DevExpress.common.ValidationRule>;
30797+
/**
30798+
* [descr:_ui_validator_ValidatedEvent.status]
30799+
*/
3076730800
status?: DevExpress.common.ValidationStatus;
3076830801
};
3076930802
export type ValidationResult = dxValidatorResult;

0 commit comments

Comments
 (0)