Skip to content

Commit 94194c2

Browse files
committed
feat: make callback types more general
1 parent 766e7e9 commit 94194c2

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

packages/form-js-viewer/src/core/FormCore.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import { clone } from '../util';
2222
* @typedef { ('submit' | 'changed') } Events
2323
* @typedef { { data: Data, schema: Schema, properties?: PropertyOptions } } FormCoreOptions
2424
* @typedef { { data: Data, errors: Errors, schema: Schema, properties: PropertyOptions } } State
25-
*
26-
* @callback EventHandler
27-
* @param { { data: Data, errors: Errors} } state
28-
* @returns { void }
2925
*/
3026

3127
/**
@@ -133,7 +129,7 @@ export default class FormCore {
133129

134130
/**
135131
* @param { Data } data
136-
* @return Errors
132+
* @returns Errors
137133
*/
138134
validateAll(data) {
139135
const errors = Array.from(this.fields.values()).reduce((errors, field) => {
@@ -185,16 +181,14 @@ export default class FormCore {
185181
}
186182

187183
/**
188-
* @param { Events } event
189-
* @param { EventHandler } callback
184+
* @type { (event: Events, callback: (state: any) => void) => void }
190185
*/
191186
on(event, callback) {
192187
this.emitter.on(event, callback);
193188
}
194189

195190
/**
196-
* @param { Events } event
197-
* @param { EventHandler } callback
191+
* @type { (event: Events, callback: (state: any) => void) => void }
198192
*/
199193
off(event, callback) {
200194
this.emitter.off(event, callback);

0 commit comments

Comments
 (0)