Properties 财产';附表';不存在于类型';导入类型().ts';

Properties 财产';附表';不存在于类型';导入类型().ts';,properties,nativescript,schedule,Properties,Nativescript,Schedule,我只是一名新学员,在视频教程之后,我的代码如下所示: import { Injectable } from '@angular/core'; import { Dish } from '../shared/dish'; import { DishService } from '../services/dish.service'; import { Observable } from 'rxjs'; import {map} from 'rxjs/operators'; import {

我只是一名新学员,在视频教程之后,我的代码如下所示:

import { Injectable } from '@angular/core'; 
import { Dish } from '../shared/dish'; 
import { DishService } from '../services/dish.service'; 
import { Observable } from 'rxjs'; 
import {map} from 'rxjs/operators';
import { CouchbaseService } from '../services/couchbase.service';
import * as LocalNotifications from 'nativescript-local-notifications';


@Injectable() 
export class FavoriteService {

    favorites: Array<number>;
    docId: string = "favorites";

    constructor(private dishservice: DishService,
        private couchbaseService: CouchbaseService) { 
        this.favorites = [];

        let doc = this.couchbaseService.getDocument(this.docId);
        if( doc == null) {
            this.couchbaseService.createDocument({"favorites": []}, this.docId);
        }
        else {
            this.favorites = doc.favorites;
        }
    }

    isFavorite(id: number): boolean { 
        return this.favorites.some(el => el === id); 
    }

    addFavorite(id: number): boolean {
        if (!this.isFavorite(id)) {
            this.favorites.push(id);
            this.couchbaseService.updateDocument(this.docId, {"favorites": this.favorites});

            // Schedule a single notification
            LocalNotifications.schedule([{
                id: id,
                title: "ConFusion Favorites",
                body: 'Dish ' + id + ' added successfully'
            }])
            .then(() => console.log('Notification scheduled'),
                (error) => console.log('Error showing nofication ' + error));
        }
        return true;
    }

    getFavorites(): Observable<Dish[]> { 
        return this.dishservice.getDishes() 
        .pipe(map(dishes => dishes.filter(dish => this.favorites.some(el => el === dish.id)))); 
    }

    deleteFavorite(id: number): Observable<Dish[]> {
        let index = this.favorites.indexOf(id);
        if (index >= 0) {
          this.favorites.splice(index,1);
          this.couchbaseService.updateDocument(this.docId, {"favorites": this.favorites});
          return this.getFavorites();
        }
        else {
          console.log('Deleting non-existant favorite', id);
          return Observable.throw('Deleting non-existant favorite');
        }
    }
}
从'@angular/core'导入{Injectable};
从“../shared/Dish”导入{Dish};
从“../services/dish.service”导入{DishService};
从“rxjs”导入{Observable};
从“rxjs/operators”导入{map};
从“../services/couchbase.service”导入{CouchbaseService};
从“nativescript本地通知”导入*作为本地通知;
@可注射()
导出类收藏夹服务{
收藏夹:数组;
docId:string=“收藏夹”;
建造商(专用dishservice:dishservice,
专用couchbaseService:couchbaseService){
this.favorites=[];
让doc=this.couchbaseService.getDocument(this.docId);
如果(doc==null){
this.couchbaseService.createDocument({“收藏夹”:[]},this.docId);
}
否则{
this.favorites=doc.favorites;
}
}
isFavorite(id:number):布尔值{
返回this.favorites.some(el=>el==id);
}
addFavorite(id:number):布尔值{
如果(!this.isFavorite(id)){
这个.favorites.push(id);
this.couchbaseService.updateDocument(this.docId,{“收藏夹”:this.favorites});
//安排一次通知
LocalNotifications.schedule([{
id:id,
标题:“最爱”,
正文:“碟子”+id+“已成功添加”
}])
。然后(()=>console.log('Notification scheduled'),
(error)=>console.log('error showing nofication'+error));
}
返回true;
}
getFavorites():可观察的{
返回此.dishservice.getDishs()
.pipe(map(dish=>dish.filter(dish=>this.favorites.some(el=>el==dish.id)));
}
deleteFavorite(id:number):可观察{
让index=this.favorites.indexOf(id);
如果(索引>=0){
此.favorites.splice(索引,1);
this.couchbaseService.updateDocument(this.docId,{“收藏夹”:this.favorites});
返回这个.getFavorites();
}
否则{
log('Deleting non-existant favorite',id');
return Observable.throw('Deleting non-existant favorite');
}
}
}
我得到的错误是:

类型“typeof”上不存在属性“schedule” 导入(“c:/Users/m/Desktop/JS/mission/node_modules/nativescript local notifications/index”)。ts(2339)


我不知道问题出在哪里以及如何解决它?

如插件的read me文件所述,使用命名导入

import { LocalNotifications } from 'nativescript-local-notifications';

尝试从“nativescript本地通知”导入{LocalNotifications}如插件文档中所述。@Manoj:cool!看来成功了!