1313import { format , complementError , asyncMap , warning , deepMerge , convertFieldsError } from './util'
1414import { hasOwn , isFunction } from '../type'
1515
16- function Schema ( descriptor , translate ) {
16+ function Schema ( descriptor , translate ? ) {
1717 Schema . getSystemMessage = ( ) => Schema . getDefaultMessage ( translate )
1818 Schema . messages = Schema . getSystemMessage ( translate )
1919 Schema . systemMessages = Schema . messages
@@ -30,8 +30,8 @@ function Schema(descriptor, translate) {
3030 */
3131const getCompleteFn = ( validCallback ) => ( results ) => {
3232 let idx
33- let errors = [ ]
34- let fields = { }
33+ let errors = [ ] as any
34+ let fields = { } as any
3535
3636 function addValid ( eror ) {
3737 if ( Array . isArray ( eror ) ) {
@@ -147,7 +147,7 @@ const setDataRuleOptions = ({ data, options }) => {
147147const getValidateCallback =
148148 ( { failds, doIt } ) =>
149149 ( errs ) => {
150- const finalErrors = [ ]
150+ const finalErrors = [ ] as any [ ]
151151
152152 if ( failds && failds . length ) {
153153 finalErrors . push ( ...failds )
@@ -165,14 +165,14 @@ const getValidateCallback =
165165 */
166166const asyncCallback =
167167 ( options , rule , errorFields , doIt , data ) =>
168- ( e = [ ] ) => {
169- let failds = e
168+ ( e : any [ ] | string = [ ] ) => {
169+ let failds = e as any
170170 const deep = isDeep ( rule , data )
171171
172172 failds = arrayed ( failds )
173173
174174 if ( ! options . suppressWarning && failds . length ) {
175- Schema . warning ( 'async-validator:' , failds )
175+ Schema . warning ( )
176176 }
177177
178178 if ( failds . length && rule . message ) {
@@ -299,7 +299,7 @@ Schema.prototype = {
299299 validate ( source_ , o = { } , oc = ( ) => undefined ) {
300300 let source = source_
301301 let options = o
302- let validCallback = oc
302+ let validCallback : Function = oc
303303 if ( typeof options === 'function' ) {
304304 validCallback = options
305305 options = { }
@@ -358,7 +358,7 @@ Schema.prototype = {
358358 }
359359
360360 if ( ruleKeys . length === 1 && ruleKeys [ 0 ] === 'required' ) {
361- return Schema . validators . required
361+ return Schema . validators ? .required
362362 }
363363
364364 return Schema . validators [ this . getType ( rule ) ] || false
@@ -385,14 +385,16 @@ Schema.register = (type, validator) => {
385385 Schema . validators [ type ] = validator
386386}
387387
388- Schema . validators = { }
388+ Schema . validators = { } as any
389389
390390Schema . warning = warning
391391
392- Schema . messages = { }
392+ Schema . messages = { } as any
393393
394- Schema . systemMessages = { }
394+ Schema . systemMessages = { } as any
395395
396396Schema . getDefaultMessage = ( ) => undefined
397397
398+ Schema . getSystemMessage = ( ) => undefined
399+
398400export default Schema
0 commit comments