@@ -14,7 +14,7 @@ import { isArrayOrTypedArray } from './array.js';
1414import { isTypedArraySpec } from './array.js' ;
1515import { decodeTypedArraySpec } from './array.js' ;
1616
17- export var valObjectMeta = {
17+ export var valObjectMeta : Record < string , any > = {
1818 data_array : {
1919 // You can use *dflt=[] to force said array to exist though.
2020 description : [
@@ -45,7 +45,7 @@ export var valObjectMeta = {
4545 ] . join ( ' ' ) ,
4646 requiredOpts : [ ] ,
4747 otherOpts : [ 'dflt' ] ,
48- coerceFunction : function ( v , propOut , dflt ) {
48+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
4949 propOut . set (
5050 isArrayOrTypedArray ( v ) ? v :
5151 isTypedArraySpec ( v ) ? decodeTypedArraySpec ( v ) :
@@ -60,12 +60,12 @@ export var valObjectMeta = {
6060 ] . join ( ' ' ) ,
6161 requiredOpts : [ 'values' ] ,
6262 otherOpts : [ 'dflt' , 'coerceNumber' , 'arrayOk' ] ,
63- coerceFunction : function ( v , propOut , dflt , opts ) {
63+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
6464 if ( opts . coerceNumber ) v = + v ;
6565 if ( opts . values . indexOf ( v ) === - 1 ) propOut . set ( dflt ) ;
6666 else propOut . set ( v ) ;
6767 } ,
68- validateFunction : function ( v , opts ) {
68+ validateFunction : function ( v : any , opts : any ) : boolean {
6969 if ( opts . coerceNumber ) v = + v ;
7070
7171 var values = opts . values ;
@@ -84,8 +84,8 @@ export var valObjectMeta = {
8484 description : 'A boolean (true/false) value.' ,
8585 requiredOpts : [ ] ,
8686 otherOpts : [ 'dflt' , 'arrayOk' ] ,
87- coerceFunction : function ( v , propOut , dflt , opts ) {
88- const isBoolean = value => value === true || value === false ;
87+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
88+ const isBoolean = ( value : any ) : boolean => value === true || value === false ;
8989 if ( isBoolean ( v ) || ( opts . arrayOk && Array . isArray ( v ) && v . length > 0 && v . every ( isBoolean ) ) ) {
9090 propOut . set ( v ) ;
9191 } else {
@@ -102,7 +102,7 @@ export var valObjectMeta = {
102102 ] . join ( ' ' ) ,
103103 requiredOpts : [ ] ,
104104 otherOpts : [ 'dflt' , 'min' , 'max' , 'arrayOk' ] ,
105- coerceFunction : function ( v , propOut , dflt , opts ) {
105+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
106106 if ( isTypedArraySpec ( v ) ) v = decodeTypedArraySpec ( v ) ;
107107
108108 if ( ! isNumeric ( v ) ||
@@ -120,7 +120,7 @@ export var valObjectMeta = {
120120 ] . join ( ' ' ) ,
121121 requiredOpts : [ ] ,
122122 otherOpts : [ 'dflt' , 'min' , 'max' , 'arrayOk' , 'extras' ] ,
123- coerceFunction : function ( v , propOut , dflt , opts ) {
123+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
124124 if ( ( opts . extras || [ ] ) . indexOf ( v ) !== - 1 ) {
125125 propOut . set ( v ) ;
126126 return ;
@@ -144,7 +144,7 @@ export var valObjectMeta = {
144144 requiredOpts : [ ] ,
145145 // TODO 'values shouldn't be in there (edge case: 'dash' in Scatter)
146146 otherOpts : [ 'dflt' , 'noBlank' , 'strict' , 'arrayOk' , 'values' ] ,
147- coerceFunction : function ( v , propOut , dflt , opts ) {
147+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
148148 if ( typeof v !== 'string' ) {
149149 var okToCoerce = ( typeof v === 'number' ) ;
150150
@@ -167,7 +167,7 @@ export var valObjectMeta = {
167167 ] . join ( ' ' ) ,
168168 requiredOpts : [ ] ,
169169 otherOpts : [ 'dflt' , 'arrayOk' ] ,
170- coerceFunction : function ( v , propOut , dflt ) {
170+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
171171 if ( isTypedArraySpec ( v ) ) v = decodeTypedArraySpec ( v ) ;
172172
173173 if ( tinycolor ( v ) . isValid ( ) ) propOut . set ( v ) ;
@@ -181,8 +181,8 @@ export var valObjectMeta = {
181181 ] . join ( ' ' ) ,
182182 requiredOpts : [ ] ,
183183 otherOpts : [ 'dflt' ] ,
184- coerceFunction : function ( v , propOut , dflt ) {
185- function isColor ( color ) {
184+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
185+ function isColor ( color : any ) : boolean {
186186 return tinycolor ( color ) . isValid ( ) ;
187187 }
188188 if ( ! Array . isArray ( v ) || ! v . length ) propOut . set ( dflt ) ;
@@ -201,7 +201,7 @@ export var valObjectMeta = {
201201 ] . join ( ' ' ) ,
202202 requiredOpts : [ ] ,
203203 otherOpts : [ 'dflt' ] ,
204- coerceFunction : function ( v , propOut , dflt ) {
204+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
205205 propOut . set ( colorscales . get ( v , dflt ) ) ;
206206 }
207207 } ,
@@ -211,7 +211,7 @@ export var valObjectMeta = {
211211 ] . join ( ' ' ) ,
212212 requiredOpts : [ ] ,
213213 otherOpts : [ 'dflt' , 'arrayOk' ] ,
214- coerceFunction : function ( v , propOut , dflt ) {
214+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
215215 if ( isTypedArraySpec ( v ) ) v = decodeTypedArraySpec ( v ) ;
216216
217217 if ( v === 'auto' ) propOut . set ( 'auto' ) ;
@@ -227,16 +227,16 @@ export var valObjectMeta = {
227227 ] . join ( ' ' ) ,
228228 requiredOpts : [ 'dflt' ] ,
229229 otherOpts : [ 'regex' , 'arrayOk' ] ,
230- coerceFunction : function ( v , propOut , dflt , opts ) {
230+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
231231 var regex = opts . regex || counterRegex ( dflt ) ;
232- const isSubplotId = value => typeof value === 'string' && regex . test ( value ) ;
232+ const isSubplotId = ( value : any ) : boolean => typeof value === 'string' && regex . test ( value ) ;
233233 if ( isSubplotId ( v ) || ( opts . arrayOk && isArrayOrTypedArray ( v ) && v . length > 0 && v . every ( isSubplotId ) ) ) {
234234 propOut . set ( v ) ;
235235 } else {
236236 propOut . set ( dflt ) ;
237237 }
238238 } ,
239- validateFunction : function ( v , opts ) {
239+ validateFunction : function ( v : any , opts : any ) : boolean {
240240 var dflt = opts . dflt ;
241241
242242 if ( v === dflt ) return true ;
@@ -256,7 +256,7 @@ export var valObjectMeta = {
256256 ] . join ( ' ' ) ,
257257 requiredOpts : [ 'flags' ] ,
258258 otherOpts : [ 'dflt' , 'extras' , 'arrayOk' ] ,
259- coerceFunction : function ( v , propOut , dflt , opts ) {
259+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
260260 if ( ( opts . extras || [ ] ) . indexOf ( v ) !== - 1 ) {
261261 propOut . set ( v ) ;
262262 return ;
@@ -281,7 +281,7 @@ export var valObjectMeta = {
281281 description : 'Any type.' ,
282282 requiredOpts : [ ] ,
283283 otherOpts : [ 'dflt' , 'values' , 'arrayOk' ] ,
284- coerceFunction : function ( v , propOut , dflt ) {
284+ coerceFunction : function ( v : any , propOut : any , dflt : any ) {
285285 if ( v === undefined ) {
286286 propOut . set ( dflt ) ;
287287 } else {
@@ -303,11 +303,11 @@ export var valObjectMeta = {
303303 // if `dimensions='1-2'` and items is a 1D array, then the value can
304304 // either be a matching 1D array or an array of such matching 1D arrays
305305 otherOpts : [ 'dflt' , 'freeLength' , 'dimensions' ] ,
306- coerceFunction : function ( v , propOut , dflt , opts ) {
306+ coerceFunction : function ( v : any , propOut : any , dflt : any , opts : any ) {
307307 // simplified coerce function just for array items
308- function coercePart ( v , opts , dflt ) {
309- var out ;
310- var propPart = { set : function ( v ) { out = v ; } } ;
308+ function coercePart ( v : any , opts : any , dflt : any ) : any {
309+ var out : any ;
310+ var propPart = { set : function ( v : any ) { out = v ; } } ;
311311
312312 if ( dflt === undefined ) dflt = opts . dflt ;
313313
@@ -326,13 +326,13 @@ export var valObjectMeta = {
326326 var twoD = opts . dimensions === 2 || ( opts . dimensions === '1-2' && Array . isArray ( v ) && isArrayOrTypedArray ( v [ 0 ] ) ) ;
327327
328328 var items = opts . items ;
329- var vOut = [ ] ;
329+ var vOut : any [ ] = [ ] ;
330330 var arrayItems = Array . isArray ( items ) ;
331331 var arrayItems2D = arrayItems && twoD && isArrayOrTypedArray ( items [ 0 ] ) ;
332332 var innerItemsOnly = twoD && arrayItems && ! arrayItems2D ;
333333 var len = ( arrayItems && ! innerItemsOnly ) ? items . length : v . length ;
334334
335- var i , j , row , item , len2 , vNew ;
335+ var i : number , j : number , row : any , item : any , len2 : number , vNew : any ;
336336
337337 dflt = Array . isArray ( dflt ) ? dflt : [ ] ;
338338
@@ -362,7 +362,7 @@ export var valObjectMeta = {
362362
363363 propOut . set ( vOut ) ;
364364 } ,
365- validateFunction : function ( v , opts ) {
365+ validateFunction : function ( v : any , opts : any ) : boolean {
366366 if ( ! isArrayOrTypedArray ( v ) ) return false ;
367367
368368 var items = opts . items ;
@@ -391,7 +391,7 @@ export var valObjectMeta = {
391391 }
392392} ;
393393
394- export var coerce = function ( containerIn , containerOut , attributes , attribute , dflt ) {
394+ export var coerce = function ( containerIn : any , containerOut : any , attributes : any , attribute : string , dflt ?: any ) : any {
395395 var opts = nestedProperty ( attributes , attribute ) . get ( ) ;
396396 var propIn = nestedProperty ( containerIn , attribute ) ;
397397 var propOut = nestedProperty ( containerOut , attribute ) ;
@@ -440,20 +440,20 @@ export var coerce = function(containerIn, containerOut, attributes, attribute, d
440440 return out ;
441441} ;
442442
443- export var coerce2 = function ( containerIn , containerOut , attributes , attribute , dflt ) {
443+ export var coerce2 = function ( containerIn : any , containerOut : any , attributes : any , attribute : string , dflt ?: any ) : any {
444444 var propIn = nestedProperty ( containerIn , attribute ) ;
445445 var propOut = coerce ( containerIn , containerOut , attributes , attribute , dflt ) ;
446446 var valIn = propIn . get ( ) ;
447447
448448 return ( valIn !== undefined && valIn !== null ) ? propOut : false ;
449449} ;
450450
451- export var coerceFont = function ( coerce , attr , dfltObj , opts ) {
451+ export var coerceFont = function ( coerce : any , attr : string , dfltObj ?: any , opts ?: any ) : any {
452452 if ( ! opts ) opts = { } ;
453453 dfltObj = extendFlat ( { } , dfltObj ) ;
454454 dfltObj = extendFlat ( dfltObj , opts . overrideDflt || { } ) ;
455455
456- var out = {
456+ var out : any = {
457457 family : coerce ( attr + '.family' , dfltObj . family ) ,
458458 size : coerce ( attr + '.size' , dfltObj . size ) ,
459459 color : coerce ( attr + '.color' , dfltObj . color ) ,
@@ -475,9 +475,9 @@ export var coerceFont = function(coerce, attr, dfltObj, opts) {
475475 return out ;
476476} ;
477477
478- export var coercePattern = function ( coerce , attr , markerColor , hasMarkerColorscale ) {
478+ export var coercePattern = function ( coerce : any , attr : string , markerColor : any , hasMarkerColorscale : boolean ) : void {
479479 var shape = coerce ( attr + '.shape' ) ;
480- var path ;
480+ var path : any ;
481481 if ( ! shape ) {
482482 path = coerce ( attr + '.path' ) ;
483483 }
@@ -508,12 +508,12 @@ export var coercePattern = function(coerce, attr, markerColor, hasMarkerColorsca
508508 }
509509} ;
510510
511- export var coerceHoverinfo = function ( traceIn , traceOut , layoutOut ) {
511+ export var coerceHoverinfo = function ( traceIn : any , traceOut : any , layoutOut : any ) : any {
512512 var moduleAttrs = traceOut . _module . attributes ;
513513 var attrs = moduleAttrs . hoverinfo ? moduleAttrs : baseTraceAttrs ;
514514
515515 var valObj = attrs . hoverinfo ;
516- var dflt ;
516+ var dflt : any ;
517517
518518 if ( layoutOut . _dataLength === 1 ) {
519519 var flags = valObj . dflt === 'all' ?
@@ -527,15 +527,15 @@ export var coerceHoverinfo = function(traceIn, traceOut, layoutOut) {
527527 return coerce ( traceIn , traceOut , attrs , 'hoverinfo' , dflt ) ;
528528} ;
529529
530- export var coerceSelectionMarkerOpacity = function ( traceOut , coerce ) {
530+ export var coerceSelectionMarkerOpacity = function ( traceOut : any , coerce : any ) : void {
531531 if ( ! traceOut . marker ) return ;
532532
533533 var mo = traceOut . marker . opacity ;
534534 // you can still have a `marker` container with no markers if there's text
535535 if ( mo === undefined ) return ;
536536
537- var smoDflt ;
538- var usmoDflt ;
537+ var smoDflt : any ;
538+ var usmoDflt : any ;
539539
540540 // Don't give [un]selected.marker.opacity a default value if
541541 // marker.opacity is an array: handle this during style step.
@@ -551,7 +551,7 @@ export var coerceSelectionMarkerOpacity = function(traceOut, coerce) {
551551 coerce ( 'unselected.marker.opacity' , usmoDflt ) ;
552552} ;
553553
554- function validate ( value , opts ) {
554+ function validate ( value : any , opts : any ) : boolean {
555555 var valObjectDef = valObjectMeta [ opts . valType ] ;
556556
557557 if ( opts . arrayOk && isArrayOrTypedArray ( value ) ) return true ;
@@ -560,9 +560,9 @@ function validate(value, opts) {
560560 return valObjectDef . validateFunction ( value , opts ) ;
561561 }
562562
563- var failed = { } ;
564- var out = failed ;
565- var propMock = { set : function ( v ) { out = v ; } } ;
563+ var failed : any = { } ;
564+ var out : any = failed ;
565+ var propMock = { set : function ( v : any ) { out = v ; } } ;
566566
567567 // 'failed' just something mutable that won't be === anything else
568568
0 commit comments