Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit a6df5ec

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
refactor(build): add missing TS types
1 parent 3ce9849 commit a6df5ec

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/app/modules/angular-slickgrid/services/utilities.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare var $: any;
1212
* this is used in the CSV export
1313
* @param int nbSpaces: number of white spaces to create
1414
*/
15-
export function addWhiteSpaces(nbSpaces): string {
15+
export function addWhiteSpaces(nbSpaces: number): string {
1616
let result = '';
1717

1818
for (let i = 0; i < nbSpaces; i++) {
@@ -25,7 +25,7 @@ export function addWhiteSpaces(nbSpaces): string {
2525
* Create a in-memory div, set it's inner text(which jQuery automatically encodes)
2626
* then grab the encoded contents back out. The div never exists on the page.
2727
*/
28-
export function htmlDecode(encodedStr) {
28+
export function htmlDecode(encodedStr: string): string {
2929
const parser = new DOMParser;
3030
if (parser && parser.parseFromString) {
3131
const dom = parser.parseFromString(
@@ -42,7 +42,7 @@ export function htmlDecode(encodedStr) {
4242
* Create a in-memory div, set it's inner text(which jQuery automatically encodes)
4343
* then grab the encoded contents back out. The div never exists on the page.
4444
*/
45-
export function htmlEncode(inputValue: string) {
45+
export function htmlEncode(inputValue: string): string {
4646
const entityMap = {
4747
'&': '&amp;',
4848
'<': '&lt;',
@@ -157,9 +157,9 @@ export function findOrDefault(array: any[], logic: (item: any) => boolean, defau
157157
* @param minDecimal
158158
* @param maxDecimal
159159
*/
160-
export function decimalFormatted(input: number | string, minDecimal?: number, maxDecimal?: number) {
160+
export function decimalFormatted(input: number | string, minDecimal?: number, maxDecimal?: number): string {
161161
if (isNaN(+input)) {
162-
return input;
162+
return input as string;
163163
}
164164

165165
const minDec = (minDecimal === undefined) ? 2 : minDecimal;
@@ -204,12 +204,12 @@ export function formatNumber(input: number | string, minDecimal?: number, maxDec
204204
}
205205

206206
/** 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 {
208208
return path.split('.').reduce((acc, part) => acc && acc[part], obj);
209209
}
210210

211211
/** Get the browser's scrollbar width, this is different to each browser */
212-
export function getScrollBarWidth() {
212+
export function getScrollBarWidth(): number {
213213
const $outer = $('<div>').css({ visibility: 'hidden', width: 100, overflow: 'scroll' }).appendTo('body');
214214
const widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth();
215215
$outer.remove();
@@ -512,7 +512,7 @@ export function mapOperatorByFieldType(fieldType: FieldType | string): OperatorT
512512
}
513513

514514
/** 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 {
516516
return /(true|1)/i.test(input + '');
517517
}
518518

@@ -553,7 +553,7 @@ export function sanitizeHtmlToText(htmlString: string) {
553553
* @param inputStr
554554
* @returns string
555555
*/
556-
export function titleCase(inputStr: string, caseEveryWords = false) {
556+
export function titleCase(inputStr: string, caseEveryWords = false): string {
557557
if (typeof inputStr === 'string') {
558558
if (caseEveryWords) {
559559
return inputStr.replace(/\w\S*/g, (outputStr) => {

0 commit comments

Comments
 (0)