Fully working with the rule no explicit any

This commit is contained in:
2020-11-25 09:27:42 +05:30
parent 84535ca9bb
commit b583b90756
27 changed files with 223 additions and 155 deletions

View File

@ -4,7 +4,8 @@ import { Pipe, PipeTransform } from '@angular/core';
name: 'clear',
})
export class ClearPipe implements PipeTransform {
transform(value: any): any {
transform(value: string | null): string {
if (value === null) return '';
return value === '₹ 0.00' || value === '0.00' ? '' : value;
}
}

View File

@ -9,6 +9,6 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
export class ConfirmDialogComponent {
constructor(
public dialogRef: MatDialogRef<ConfirmDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: { title: string; content: string },
) {}
}

View File

@ -9,7 +9,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
export class ImageDialogComponent {
constructor(
public dialogRef: MatDialogRef<ImageDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public data: string,
) {}
close(): void {

View File

@ -5,16 +5,6 @@ import { evaluate, round } from 'mathjs';
providedIn: 'root',
})
export class MathService {
// eslint-disable-next-line class-methods-use-this
journalAmount(amount: string = '', debit: number): any {
const val = this.parseAmount(amount, 2);
let newDebit = debit;
if (val < 0) {
newDebit *= -1;
}
return { debit: newDebit, amount: Math.abs(val) };
}
// eslint-disable-next-line class-methods-use-this
parseAmount(amount: string = '', rounding: number = 2): number {
const cleaned = `${amount}`.replace(new RegExp('(₹[s]*)|(,)|(s)', 'g'), '');

View File

@ -0,0 +1,3 @@
export interface ToCsvType {
[column: string]: string | number | boolean | null;
}

View File

@ -1,15 +1,19 @@
import { Injectable } from '@angular/core';
import { ToCsvType } from './to-csv-type';
@Injectable({
providedIn: 'root',
})
export class ToCsvService {
// eslint-disable-next-line class-methods-use-this
toCsv(headers: any, data: any[]): string {
toCsv(headers: { [display: string]: string }, data: unknown[]): string {
const header = Object.keys(headers);
const replacer = (key: string, value: string | number | null) => (value === null ? '' : value);
const csv = data.map((row) =>
header.map((fieldName) => JSON.stringify(row[headers[fieldName]], replacer)).join(','),
header
.map((fieldName) => JSON.stringify((row as ToCsvType)[headers[fieldName]], replacer))
.join(','),
);
csv.unshift(header.join(','));
return csv.join('\r\n');