Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contextual-decorator throw some unexpectet errors #955

Closed
DerHerrGammler opened this issue Feb 12, 2020 · 4 comments
Closed

contextual-decorator throw some unexpectet errors #955

DerHerrGammler opened this issue Feb 12, 2020 · 4 comments

Comments

@DerHerrGammler
Copy link

My console is spammed with the same error in every ts file.

A clear and concise description of what the bug is.

The 'contextual-decorator' rule threw an error in 'd:/workspace/_boapi/work_bo/src/app/pages/sale/invoice/invoice.component.ts':
TypeError: Cannot read property 'kind' of undefined
    at Object.isParameterPropertyDeclaration (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:14422:83)
    at isDeclarationLike (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:61:100)
    at callbackHandler (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:51:9)
    at callback (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:83:9)
    at visitNodes (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:17635:30)
    at Object.forEachChild (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:17941:21)
    at callback (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:84:22)
    at visitNodes (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:17635:30)
    at Object.forEachChild (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:17868:24)
    at walk (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:86:18)
    at Rule.AbstractRule.applyWithFunction (d:\workspace\_boapi\work_bo\node_modules\tslint\lib\language\rule\abstractRule.js:39:9)
    at Rule.apply (d:\workspace\_boapi\work_bo\node_modules\codelyzer\contextualDecoratorRule.js:35:21)
    at Linter.applyRule (d:\workspace\_boapi\work_bo\node_modules\tslint\lib\linter.js:214:29)
    at d:\workspace\_boapi\work_bo\node_modules\tslint\lib\linter.js:155:85
    at Object.flatMap (d:\workspace\_boapi\work_bo\node_modules\tslint\lib\utils.js:160:29)
    at Linter.getAllFailures (d:\workspace\_boapi\work_bo\node_modules\tslint\lib\linter.js:155:32)
    at Linter.lint (d:\workspace\_boapi\work_bo\node_modules\tslint\lib\linter.js:110:33)
    at TsLintRunner.doRun (C:\Users\herol\.vscode\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.2.3\node_modules\typescript-tslint-plugin\out\runner\index.js:227:24)
    at TsLintRunner.runTsLint (C:\Users\herol\.vscode\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.2.3\node_modules\typescript-tslint-plugin\out\runner\index.js:80:21)
    at TSLintPlugin.getSemanticDiagnostics (C:\Users\herol\.vscode\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.2.3\node_modules\typescript-tslint-plugin\out\plugin.js:108:38)
    at Proxy.intercept.getSemanticDiagnostics (C:\Users\herol\.vscode\extensions\ms-vscode.vscode-typescript-tslint-plugin-1.2.3\node_modules\typescript-tslint-plugin\out\plugin.js:73:25)
    at IOSession.Session.semanticCheck (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139807:52)
    at c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139848:31
    at MultistepOperation.executeAction (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139001:25)
    at c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:138982:100
    at IOSession.Session.executeWithRequestId (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:140951:28)
    at Object.executeWithRequestId (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:139616:87)
    at Immediate._onImmediate (c:\Users\herol\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:138982:41)
    at processImmediate (internal/timers.js:439:21)

Please share:

  • Which rule is causing the problem
  • What's the content of your tsconfig.json
  • What's the content of ~/.codelyzer.js (if applicable)

To Reproduce

Just open ts files

Expected behavior

No errors at all.

import { Component, ViewChild } from "@angular/core";
import { InvoiceService, Invoice, Button, Customer, Address, AddressService, CustomerService, Invoicejournal, Discount, Upload } from "../../../services/classes/_classes";
import { RouterService, ToastService, ErrorService, GlobalService, ModalService, HttpService, UsersessionService } from "../../../services/_services";
import { DataRefreshComponent } from "../../data-refresh.component";
import { MatSort } from "@angular/material/sort";
import { MatPaginator } from "@angular/material/paginator";
import { MatTable } from "@angular/material/table";
import { StaticTable } from "../../../services/classes/table.class";
import { ElementModalSelectDiscountComponent } from "../../../elements/modals/select-discount/select-discount.component";
import { DiscountModalService } from "../../../services/classes/discount.service";
import { isset, arrayItemFromTo } from "../../../services/classes/_helper";
import { IDiscountPosition, IArticleListPosition } from "../../../services/classes/interfaces/_interfaces";
import { EDiscountConditionType, EDiscountConditionReference, EDiscountConditionSign, EDiscountType } from "../../../services/classes/enums/_enums";

@Component({
    selector: "page-sale-invoice",
    templateUrl: "./invoice.component.html",
    styles: []
})
export class PageSaleInvoiceComponent extends DataRefreshComponent {

    public oInvoice: Invoice = new Invoice();
    public oCustomer: Customer = new Customer();
    public oAddress: Address = new Address();
    public btnSubmit: Button = new Button();
    public bIsDisabled: boolean = false;
    public bIsDraft: boolean = false;
    public bIsControl: boolean = false;
    public bIsError: boolean = false;
    public bIscorrect: boolean = false;

    public aRabatte: IDiscountPosition[] = [];
    public aGutscheine: IDiscountPosition[] = [];
    public aSkontos: IDiscountPosition[] = [];
    public sINVOICEURL: string = "";
    public aFiles: any[] = [];
    public btnUpload: Button = new Button();
    public oUpload: Upload = new Upload(this.btnUpload, (response: any): void => {
        let i: number = 0;
        while (i < this.aFiles.length) {
            if (this.aFiles[i].server === "") {
                this.aFiles[i].server = response.fileid;
                i = this.aFiles.length;
            }
            i += 1;
        }
        this.oInvoice.set("updatefile", true);
    }, async (): Promise<void> => {
        this.error.handle({
                error: {
                    error: "NoFileReceived"
                }
            });
    }, (file: any): void => {
        this.aFiles.push({
            server: "",
            label: file.file.name,
            src: ""
        });
    });

    @ViewChild("tableSort", { static: true }) private readonly tableSort: MatSort;
    @ViewChild("tablePagination", { static: true }) private readonly tablePagination: MatPaginator;
    @ViewChild("tableTable", { static: true }) private readonly tableTable: MatTable<any>;
    public staticTable: StaticTable = new StaticTable(this.global);

    constructor(
        private readonly router: RouterService,
        private readonly invoice: InvoiceService,
        private readonly discountmodal: DiscountModalService,
        public readonly customer: CustomerService,
        public readonly address: AddressService,
        private readonly toast: ToastService,
        public readonly global: GlobalService,
        private readonly modal: ModalService,
        private readonly error: ErrorService,
        private readonly http: HttpService,
        public readonly user: UsersessionService
    ) {
        super(router);
        this.checkField = "oInvoice";
    }

    public trackByDiscountPosition(iIndex: number, oDiscountPosition: IDiscountPosition): number {
        if (!isset(oDiscountPosition)) {
            return null;
        }
        return iIndex;
    }

    public async initialize(): Promise<void> {
        this.sINVOICEURL = this.router.sAPI + "/invoice/";
        await this.loadInvoice();
        this.setCheckData(this.oInvoice.toJSON());
    }

    public async loadInvoice(): Promise<void> {
        try {
            if (this.router.oData.invoiceid) {
                const oInvoice: Invoice = (await this.invoice.getInvoices(this.router.oData.invoiceid))[0];
                if (!oInvoice) {
                    throw {
                        error: {
                            error: "InvoiceNotExists"
                        }
                    };
                }
                this.oInvoice.fromJSON(oInvoice.toJSON());
                this.oCustomer = (await this.customer.getCustomers(this.oInvoice.get("customerid")))[0];
                this.oAddress = (await this.address.getAddresses(this.oInvoice.get("addressid")))[0];
            } else {
                this.oInvoice.setDefault(this.global);
                this.bIsDraft = true;
                this.bIsDisabled = false;
            }
            this.loadFiles();
            this.checkStatus();
            // Artikel in Tabelle laden
            await this.staticTable.initialize(
                this.tableTable,
                this.tableSort,
                this.tablePagination,
                [
                    "position",
                    "title",
                    "notice",
                    "taxrate",
                    "pricenet",
                    "pricegross",
                    "counter",
                    "pricenetFinal",
                    "pricegrossFinal",
                    "actions"
                ],
                this.oInvoice.get("articles")
            );
        } catch (oErr) {
            this.error.handle(oErr);
        }
    }

    public refreshData(): void {
        // Artikel
        this.staticTable.refreshData(this.oInvoice.get("articles"));
        // Discounts
        const aDiscounts: IDiscountPosition[] = this.oInvoice.get("discounts");
        this.aRabatte = aDiscounts.filter(
            (oRabatt: IDiscountPosition): boolean => oRabatt.discounttype === EDiscountType.Rabatt
        );
        this.aGutscheine = aDiscounts.filter(
            (oRabatt: IDiscountPosition): boolean => oRabatt.discounttype === EDiscountType.Gutschein
        );
        this.aSkontos = aDiscounts.filter(
            (oRabatt: IDiscountPosition): boolean => oRabatt.discounttype === EDiscountType.Skonto
        );
    }

    public checkStatus(): void {
        this.bIsDisabled = false;
        this.bIsDraft = false;
        this.bIsControl = false;
        this.bIsError = false;
        this.bIscorrect = false;
        switch (parseInt(this.oInvoice.get("status"), 10)) {
            case parseInt(this.global.settings.invoice.draftstatus.value, 10):
                this.bIsDraft = true;
                break;
            case parseInt(this.global.settings.invoice.controlstatus.value, 10):
                this.bIsDisabled = true;
                this.bIsControl = true;
                break;
            case parseInt(this.global.settings.invoice.errorstatus.value, 10):
                this.bIsError = true;
                break;
            case parseInt(this.global.settings.invoice.correctstatus.value, 10):
                this.bIsDisabled = true;
                this.bIscorrect = true;
        }
        this.refreshData();
    }

    public async customerSelected(oCustomer: Customer): Promise<void> {
        this.oCustomer = oCustomer;
        this.oInvoice.set("customerid", this.oCustomer.get("customerid"));
        this.oInvoice.set("delivery", this.oCustomer.get("contactpreference"));
        this.oInvoice.set("notificationsetting", oCustomer.getNotificationsetting("invoicesendingaddress", this.global));
        if (this.oCustomer.get("addresses").length > 0) {
            this.changeAddress(this.oCustomer.get("addresses")[0].id);
        }
    }

    public changeAddress(addressid: number): void {
        this.oInvoice.set("addressid", addressid);
    }

    public async resetCustomer(): Promise<void> {
        if (await this.modal.confirmDelete()) {
            this.oCustomer = new Customer();
            this.oInvoice.set("customerid", this.oCustomer.get("customerid"));
            this.changeAddress(0);
        }
    }

    public async removeArticle(iIndex: number): Promise<void> {
        if (await this.modal.confirmDelete()) {
            this.oInvoice.removeArticle(this.global, iIndex);
            this.refreshData();
        }
    }

    public async removeDiscount(iIndex: number): Promise<void> {
        if (await this.modal.confirmDelete()) {
            this.oInvoice.removeDiscount(this.global, iIndex);
        }
    }

    public async printpreview(): Promise<void> {
        this.btnSubmit.startLoading();
        try {
            const sOutput: string = await this.invoice.getPreview(this.oInvoice.get("invoiceid"));
            const sURL: string = this.router.sAPI + "/invoice/" + sOutput;
            await this.modal.printPreview(sURL, sOutput);
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async export(): Promise<void> {
        this.btnSubmit.startLoading();
        try {
            const sOutput: string = await this.invoice.getExport(this.oInvoice.get("invoiceid"));
            const sURL: string = this.router.sAPI + "/invoice/" + sOutput;
            await this.http.download(sURL, sOutput);
            this.toast.success("Export abgeschlossen", "Datei/en wurde/n erfolgreich exportiert");
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async submit(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            // Den Dateiarray zum senden vorbereiten
            const aFiles: any[] = [];
            let i: number = 0;
            while (i < this.aFiles.length) {
                if (this.aFiles[i].server) {
                    aFiles.push({
                        src: this.aFiles[i].server,
                        label: this.aFiles[i].label
                    });
                } else {
                    aFiles.push({
                        src: this.aFiles[i].src,
                        label: this.aFiles[i].label
                    });
                }
                i += 1;
            }
            this.oInvoice.set("newfile", aFiles);
            // Prüfen ob es eine neue Rechnung ist
            if (this.oInvoice.get("invoiceid") === "0") {
                this.oInvoice = await this.invoice.postInvoice(this.oInvoice);
                await this.router.go("/sale/invoice/" + String(this.oInvoice.get("invoiceid")));
            } else {
                this.oInvoice = await this.invoice.putInvoice(this.oInvoice);
            }
            this.refreshData();
            this.loadFiles();
            this.setCheckData(this.oInvoice.toJSON());
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich gespeichert");
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async control(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            this.oInvoice = await this.invoice.controlInvoice(this.oInvoice);
            this.checkStatus();
            this.refreshData();
            this.setCheckData(this.oInvoice.toJSON());
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich zur kontrolle gespeichert");
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async incorrect(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            this.oInvoice = await this.invoice.incorrectInvoice(this.oInvoice);
            this.checkStatus();
            this.refreshData();
            this.setCheckData(this.oInvoice.toJSON());
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich als Fehlerhaft gespeichert");
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async correct(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            this.oInvoice = await this.invoice.correctInvoice(this.oInvoice);
            this.checkStatus();
            this.refreshData();
            this.setCheckData(this.oInvoice.toJSON());
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich als Korrekt gespeichert");
            this.btnSubmit.stopLoading();
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async book(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            const oInvoicejournal: Invoicejournal = await this.invoice.bookInvoice(this.oInvoice);
            this.btnSubmit.stopLoading();
            this.refreshData();
            this.setCheckData(this.oInvoice.toJSON());
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich verbucht");
            await this.router.go("/sale/invoicejournal/" + String(oInvoicejournal.get("invoicejournalid")));
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public async showProtocol(): Promise<void> {
        await this.modal.protocol(this.oInvoice.get("protocol"), {
            "SALE_INVOICE_BOOK": "Verbucht",
            "SALE_INVOICE_CONTROL": "Zur Kontrolle gegeben",
            "SALE_INVOICE_CORRECT": "Als Korrekt markiert",
            "SALE_INVOICE_INCORRECT": "Als Inkorrekt markiert",
            "SALE_INVOICE_CREATE": "Erstellt",
            "SALE_INVOICE_MODIFY": "Bearbeitet",
            "SALE_INVOICE_CANCEL": "Storno Rechnung erstellt",
            "SALE_INVOICEJOURNAL_PAYED": "Als Bezahlt markiert",
            "SALE_INVOICEJOURNAL_SEND": "Als gesendet markiert"
        });
    }

    public updatePaymenttarget(): void {
        this.oInvoice.calculatePaymenttarget(this.global);
    }

    public async sumupInvoice(): Promise<void> {
        try {
            this.btnSubmit.startLoading();
            const oInvoice: Invoice = await this.invoice.sumupInvoice(this.oInvoice.get("invoiceid"));
            await this.router.go("/sale/invoice/" + String(oInvoice.get("invoiceid")));
            this.btnSubmit.stopLoading();
            this.toast.success("Speichern erfolgreich", "Rechnung wurde erfolgreich neuberechnet");
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            await this.router.go("/sale/invoices");
            this.error.handle(oErr);
        }
    }

    public canMove(oPosition: IArticleListPosition, sDirection: string): boolean {
        // Bei einer position, sowieso nicht
        if (this.tablePagination.length < 2) {
            return false;
        }
        // Die erste position kann nicht weiter nach oben bewegt werden
        if (oPosition.position === 1 && sDirection === "up") {
            return false;
        }
        // Die letzte position kann nicht weiter nach unten bewegt werden
        if (oPosition.position === this.tablePagination.length && sDirection === "down") {
            return false;
        }
        return true;
    }

    public movePosition(oPosition: IArticleListPosition, sDirection: string): void {
        const aArticlepositions: IArticleListPosition[] = this.oInvoice.get("articles");
        // Verschieben
        switch (sDirection) {
            case "up":
                arrayItemFromTo(aArticlepositions, oPosition.position - 1, oPosition.position - 2);
                break;
            case "down":
                arrayItemFromTo(aArticlepositions, oPosition.position - 1, oPosition.position);
        }
        // Position neu durchzählen
        aArticlepositions.map((oPos: IArticleListPosition, iIndex: number): void => {
            oPos.position = iIndex + 1;
        });
        this.oInvoice.set("articles", aArticlepositions);
        this.refreshData();
    }

    public async addDiscount(): Promise<void> {
        try {
            const oDiscount: Discount = await this.discountmodal.addDiscount(
                ElementModalSelectDiscountComponent
            );
            if (isset(oDiscount)) {
                // Prüfen ob der Discount überhaupt gültig ist
                const iToday: number = this.global.currentTimestamp();
                if (
                    (oDiscount.get("from") > 0 && oDiscount.get("from") > iToday) ||
                    (oDiscount.get("to") > 0 && oDiscount.get("to") < iToday)
                ) {
                    this.toast.error("Nachlass nicht möglich", "Gültigkeitszeitram ist ungültig");
                    return;
                }
                // Prüfen ob der discount schon drin ist
                const aDiscounts: IDiscountPosition[] = this.oInvoice.get("discounts");
                if (isset(aDiscounts.find((oPosition: IDiscountPosition): boolean => oPosition.id === oDiscount.get("discountid")))) {
                    this.toast.error("Nachlass nicht möglich", "Nachlass bereits vorhanden");
                    return;
                }
                // Prüfen ob Discount gültig ist (andere anforderung)
                switch (oDiscount.get("conditiontype")) {
                    case EDiscountConditionType.AnzahlArtikel: {
                        let iCount: number = 0;
                        switch (oDiscount.get("reference")) {
                            case EDiscountConditionReference.AlleArtikel: {
                                iCount = this.oInvoice.get("articles").length;
                                break;
                            }
                            case EDiscountConditionReference.BestimmteArtikel: {
                                iCount = this.oInvoice.get("articles").filter(
                                    (oArticle: IArticleListPosition): boolean => oArticle.articleid === oDiscount.get("referenceid")
                                ).length;
                                break;
                            }
                            case EDiscountConditionReference.BestimmteWarengruppe: {
                                iCount = this.oInvoice.get("articles").filter(
                                    (oArticle: IArticleListPosition): boolean => oArticle.productgroupid === oDiscount.get("referenceid")
                                ).length;
                            }
                        }
                        switch (oDiscount.get("conditionsign")) {
                            case EDiscountConditionSign.IstGleich: {
                                if (iCount !== oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserAls: {
                                if (iCount <= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerAls: {
                                if (iCount >= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserGleich: {
                                if (iCount < oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerGleich: {
                                if (iCount > oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                            }
                        }
                        break;
                    }
                    case EDiscountConditionType.SummeNetto: {
                        let iSum: number = 0;
                        switch (oDiscount.get("reference")) {
                            case EDiscountConditionReference.AlleArtikel: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    iSum += oPosition.sumnet;
                                });
                                break;
                            }
                            case EDiscountConditionReference.BestimmteArtikel: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    if (oPosition.articleid === oDiscount.get("referenceid")) {
                                        iSum += oPosition.sumnet;
                                    }
                                });
                                break;
                            }
                            case EDiscountConditionReference.BestimmteWarengruppe: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    if (oPosition.productgroupid === oDiscount.get("referenceid")) {
                                        iSum += oPosition.sumnet;
                                    }
                                });
                            }
                        }
                        switch (oDiscount.get("conditionsign")) {
                            case EDiscountConditionSign.IstGleich: {
                                if (iSum !== oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserAls: {
                                if (iSum <= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerAls: {
                                if (iSum >= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserGleich: {
                                if (iSum < oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerGleich: {
                                if (iSum > oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                            }
                        }
                        break;
                    }
                    case EDiscountConditionType.SummeBrutto: {
                        let iSum: number = 0;
                        switch (oDiscount.get("reference")) {
                            case EDiscountConditionReference.AlleArtikel: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    iSum += oPosition.sumgross;
                                });
                                break;
                            }
                            case EDiscountConditionReference.BestimmteArtikel: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    if (oPosition.articleid === oDiscount.get("referenceid")) {
                                        iSum += oPosition.sumgross;
                                    }
                                });
                                break;
                            }
                            case EDiscountConditionReference.BestimmteWarengruppe: {
                                this.oInvoice.get("articles").map((oPosition: IArticleListPosition): void => {
                                    if (oPosition.productgroupid === oDiscount.get("referenceid")) {
                                        iSum += oPosition.sumgross;
                                    }
                                });
                            }
                        }
                        switch (oDiscount.get("conditionsign")) {
                            case EDiscountConditionSign.IstGleich: {
                                if (iSum !== oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserAls: {
                                if (iSum <= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerAls: {
                                if (iSum >= oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstGroesserGleich: {
                                if (iSum < oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                                break;
                            }
                            case EDiscountConditionSign.IstKleinerGleich: {
                                if (iSum > oDiscount.get("conditioncount")) {
                                    this.toast.error("Nachlass nicht möglich", "Nachlassbedingung nicht erfüllt");
                                    return;
                                }
                            }
                        }
                    }
                }
                // Discount hinzufügen
                this.oInvoice.addDiscount(this.global, oDiscount);
            }
        } catch (oErr) {
            this.btnSubmit.stopLoading();
            this.error.handle(oErr);
        }
    }

    public loadFiles(): void {
        const aFiles: any[] = this.oInvoice.get("files");
        this.aFiles = [];
        aFiles.forEach((oFile: any): void => {
            this.aFiles.push(oFile);
        });
    }

    public async removeFile(iIndex: number): Promise<void> {
        if (await this.modal.confirmDelete()) {
            this.aFiles.splice(iIndex, 1);
            this.oInvoice.set("updatefile", true);
        }
    }
}

Share the code which will let us reproduce the problem

Environment

  • Version 5.2.1
  • OS: Windows 10
  • Node.js version 13.8.0
  • Package manager (yarn/npm) version: npm 6.13.7
  • Angular version 9.0.1
  • tslint version 6.0.0

Additional context

Add any other context about the problem here.

@piotrl
Copy link

piotrl commented Feb 19, 2020

I'm encountering the same after update to Angular 9.0.1 (no-ivy) and TypeScript 3.6.5.

  • It happens both node 12.16.0 and 10.15.0
  • It happens both MacOs and Linux
  • Package manager: Yarn 1.22
  • tslint: 5.18.0 (no difference after update to 6.0.0)
  • codelyzer: 5.1.0 (no difference after update)

Exception for every fileL

The 'contextual-decorator' rule threw an error in '/path-to-project/util/src/lib/element-stylist.ts':
TypeError: Cannot read property 'kind' of undefined
    at Object.isParameterPropertyDeclaration (/path-to-project/node_modules/typescript/lib/typescript.js:13412:83)
    at isDeclarationLike (/path-to-project/node_modules/codelyzer/contextualDecoratorRule.js:61:100)
    at callbackHandler (/path-to-project/node_modules/codelyzer/contextualDecoratorRule.js:51:9)
    at callback (/path-to-project/node_modules/codelyzer/contextualDecoratorRule.js:83:9)
    at visitNodes (/path-to-project/node_modules/typescript/lib/typescript.js:17016:30)
    at Object.forEachChild (/path-to-project/node_modules/typescript/lib/typescript.js:17134:21)
    at callback (/path-to-project/node_modules/codelyzer/contextualDecoratorRule.js:84:22)
    at visitNodes (/path-to-project/node_modules/typescript/lib/typescript.js:17016:30)
    at Object.forEachChild (/path-to-project/node_modules/typescript/lib/typescript.js:17317:21)
    at callback (/path-to-project/node_modules/codelyzer/contextualDecoratorRule.js:84:22)

After update to 5.2.0 there is no error :)

The 'no-redundant-jsdoc' rule threw an error in '/src/lib/dashboard.component.ts':
Error: Unexpected tag kind: JSDocAuthorTag

at checkTag (/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:106:23)
at cb (/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:62:25)
at Array.forEach (<anonymous>)
at walk (/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:55:34)
at Rule.AbstractRule.applyWithFunction (/node_modules/tslint/lib/language/rule/abstractRule.js:39:9)
at Rule.apply (/node_modules/tslint/lib/rules/noRedundantJsdocRule.js:35:21)
at Linter.applyRule (/node_modules/tslint/lib/linter.js:214:29)
at /node_modules/tslint/lib/linter.js:155:85
at Object.flatMap (/node_modules/tslint/lib/utils.js:160:29)
at Linter.getAllFailures (/node_modules/tslint/lib/linter.js:155:32)

@rafaelss95
Copy link
Collaborator

@DerHerrGammler @piotrl can you confirm that it's still an issue? I wasn't able to reproduce it with the latest version.

@piotrl
Copy link

piotrl commented Jun 4, 2020

hey @rafaelss95 - I consider it as fixed in v5.2.

After update there was different error in no-redundant-jsdoc that happened to be issue of tslint, not codelyzer.

@rafaelss95
Copy link
Collaborator

hey @rafaelss95 - I consider it as fixed in v5.2.

After update there was different error in no-redundant-jsdoc that happened to be issue of tslint, not codelyzer.

Nice, I'm closing this then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants