@@ -12,7 +12,7 @@ declare var $: any;
12
12
* this is used in the CSV export
13
13
* @param int nbSpaces: number of white spaces to create
14
14
*/
15
- export function addWhiteSpaces ( nbSpaces ) : string {
15
+ export function addWhiteSpaces ( nbSpaces : number ) : string {
16
16
let result = '' ;
17
17
18
18
for ( let i = 0 ; i < nbSpaces ; i ++ ) {
@@ -25,7 +25,7 @@ export function addWhiteSpaces(nbSpaces): string {
25
25
* Create a in-memory div, set it's inner text(which jQuery automatically encodes)
26
26
* then grab the encoded contents back out. The div never exists on the page.
27
27
*/
28
- export function htmlDecode ( encodedStr ) {
28
+ export function htmlDecode ( encodedStr : string ) : string {
29
29
const parser = new DOMParser ;
30
30
if ( parser && parser . parseFromString ) {
31
31
const dom = parser . parseFromString (
@@ -42,7 +42,7 @@ export function htmlDecode(encodedStr) {
42
42
* Create a in-memory div, set it's inner text(which jQuery automatically encodes)
43
43
* then grab the encoded contents back out. The div never exists on the page.
44
44
*/
45
- export function htmlEncode ( inputValue : string ) {
45
+ export function htmlEncode ( inputValue : string ) : string {
46
46
const entityMap = {
47
47
'&' : '&' ,
48
48
'<' : '<' ,
@@ -157,9 +157,9 @@ export function findOrDefault(array: any[], logic: (item: any) => boolean, defau
157
157
* @param minDecimal
158
158
* @param maxDecimal
159
159
*/
160
- export function decimalFormatted ( input : number | string , minDecimal ?: number , maxDecimal ?: number ) {
160
+ export function decimalFormatted ( input : number | string , minDecimal ?: number , maxDecimal ?: number ) : string {
161
161
if ( isNaN ( + input ) ) {
162
- return input ;
162
+ return input as string ;
163
163
}
164
164
165
165
const minDec = ( minDecimal === undefined ) ? 2 : minDecimal ;
@@ -204,12 +204,12 @@ export function formatNumber(input: number | string, minDecimal?: number, maxDec
204
204
}
205
205
206
206
/** From a dot (.) notation find and return a property within an object given a path */
207
- export function getDescendantProperty ( obj : any , path : string ) {
207
+ export function getDescendantProperty ( obj : any , path : string ) : any {
208
208
return path . split ( '.' ) . reduce ( ( acc , part ) => acc && acc [ part ] , obj ) ;
209
209
}
210
210
211
211
/** Get the browser's scrollbar width, this is different to each browser */
212
- export function getScrollBarWidth ( ) {
212
+ export function getScrollBarWidth ( ) : number {
213
213
const $outer = $ ( '<div>' ) . css ( { visibility : 'hidden' , width : 100 , overflow : 'scroll' } ) . appendTo ( 'body' ) ;
214
214
const widthWithScroll = $ ( '<div>' ) . css ( { width : '100%' } ) . appendTo ( $outer ) . outerWidth ( ) ;
215
215
$outer . remove ( ) ;
@@ -512,7 +512,7 @@ export function mapOperatorByFieldType(fieldType: FieldType | string): OperatorT
512
512
}
513
513
514
514
/** Parse any input (bool, number, string) and return a boolean or False when not possible */
515
- export function parseBoolean ( input : boolean | number | string ) {
515
+ export function parseBoolean ( input : boolean | number | string ) : boolean {
516
516
return / ( t r u e | 1 ) / i. test ( input + '' ) ;
517
517
}
518
518
@@ -553,7 +553,7 @@ export function sanitizeHtmlToText(htmlString: string) {
553
553
* @param inputStr
554
554
* @returns string
555
555
*/
556
- export function titleCase ( inputStr : string , caseEveryWords = false ) {
556
+ export function titleCase ( inputStr : string , caseEveryWords = false ) : string {
557
557
if ( typeof inputStr === 'string' ) {
558
558
if ( caseEveryWords ) {
559
559
return inputStr . replace ( / \w \S * / g, ( outputStr ) => {
0 commit comments