Skip to content

How to resolve angular build failure “Angular2-Notification” argument error in NotificationType class? #376

Description

@Anand2805

These are me version installed in my system node, npm and angular version

but the issue is not resolved i have even tried changing the angular versions 7.0.5 to 7.0.7 in project. and in the system i have installed angular latest and tried but same issue, below is the issue i am getting

import { NotificationsService } from 'angular2-notifications';

export class ExampleComponent implements OnInit {

constructor(private notificationsService: NotificationsService) {}

ngOnInit() {

this.notificationsService.create("Covering Letter", 'Covering Letter is required', 'error', 'yes');
this.notificationsService.create("Covering Letter", 'Covering Letter is required', 'success', 'yes');
this.notificationsService.create("Covering Letter", 'Covering Letter is required', 'warn', 'yes');

}

}

Below is the package.jason details

"dependencies": {
    "@angular/animations": "^7.0.5",
    "@angular/cdk": "^7.0.5",
    "@angular/common": "^7.0.5",
    "@angular/compiler": "^7.0.5",
    "@angular/core": "^7.0.5",
    "@angular/forms": "^7.0.5",
    "@angular/http": "^7.0.5",
    "@angular/material": "^7.0.5",
    "@angular/platform-browser": "^7.0.5",
    "@angular/platform-browser-dynamic": "^7.0.5",
    "@angular/router": "^7.0.5",
    "@kolkov/angular-editor": "^0.12.3",
    "@ng-bootstrap/ng-bootstrap": "^4.0.0",
    "@reactivex/rxjs": "^5.5.11",
    "angular-datatables": "^6.0.0",
    "angular-material-fileupload": "0.0.11",
    "angular2-notifications": "^1.0.2",
    "core-js": "^2.5.4",
    "datatables.net": "^1.10.19",
    "datatables.net-dt": "^1.10.19",
    "file-saver": "^2.0.0-rc.4",
    "google-libphonenumber": "^3.2.2",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "material-design-icons": "^3.0.1",
    "ng-treetable": "^1.3.3",
    "ng2-carouselamos": "^3.2.0",
    "ng2-charts": "^1.6.0",
    "ng2-simple-smooth-scroll": "^0.3.0",
    "ngx-dropzone-wrapper": "^6.1.0",
    "ngx-mat-select-search": "^1.4.2",
    "ngx-slimscroll": "^5.2.2",
    "rxjs": "^6.2.1",
    "rxjs-compat": "^6.2.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular-devkit/build-ng-packagr": "^0.1002.3",
    "@angular/cli": "~7.0.5",
    "@angular/compiler-cli": "^7.0.5",
    "@angular/language-service": "^7.0.5",
    "@types/datatables.net": "^1.10.12",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/jquery": "^3.3.4",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-packagr": "^3.0.0-rc.2",
    "protractor": "^5.4.0",
    "ts-node": "~5.0.1",
    "tsickle": "^0.32.0",
    "tslib": "^1.9.3",
    "tslint": "~5.9.1",
    "typescript": "~3.2.4"
  }

the Error is:

src/app/test1/test1/test1.component.ts(46,69): error TS2345: Argument of type '"error"' is not assignable to parameter of type 'NotificationType'.
src/app/test1/test1/test1.component.ts(49,82): error TS2345: Argument of type '"success"' is not assignable to parameter of type 'NotificationType'.
src/app/test1/test1/test1.component.ts(95,82): error TS2345: Argument of type '"warn"' is not assignable to parameter of type 'NotificationType'.

Below is the notification service class

import { Subject } from 'rxjs';
import { NotificationEvent } from '../interfaces/notification-event.type';
import { Notification } from '../interfaces/notification.type';
import { Icons } from '../interfaces/icons';
import { NotificationType } from '../enums/notification-type.enum';
export declare class NotificationsService {
    globalOptions: any;
    constructor(globalOptions: any);
    emitter: Subject<NotificationEvent>;
    icons: Icons;
    set(notification: Notification, to: boolean): Notification;
    success(title?: any, content?: any, override?: any): Notification;
    error(title?: any, content?: any, override?: any): Notification;
    alert(title?: any, content?: any, override?: any): Notification;
    info(title?: any, content?: any, override?: any): Notification;
    warn(title?: any, content?: any, override?: any): Notification;
    bare(title?: any, content?: any, override?: any): Notification;
    create(title?: any, content?: any, type?: NotificationType, override?: any): Notification;
    html(html: any, type?: NotificationType, override?: any, icon?: string): Notification;
    remove(id?: string): void;
}

And the NotificationType is

export declare enum NotificationType {
    Success = "success",
    Error = "error",
    Alert = "alert",
    Info = "info",
    Warn = "warn",
    Bare = "bare"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions