【发布时间】:2019-02-17 06:27:32
【问题描述】:
我正在尝试转换为 Angular 2 (Ionic2),而我的应用使用 pouchDB。
在 Angular1 中,我使用带有小写 pouchDB 的 var _usersDatabase = pouchDB(CouchConstants.COUCHDB_USERS_DB_NAME);,而没有使用 new。但是 TypeScript 编译器在抱怨,所以我这样做了:
import { Injectable } from '@angular/core';
import { LocalStorageService } from 'angular-2-local-storage';
import { UtilsService } from '../providers/utils-service';
import { MigrationService } from '../providers/migration-service';
import { CouchConstants } from '../couch-constants';
import PouchDB from 'pouchdb';
@Injectable()
export class UsersDatabase {
constructor(
private storageService: LocalStorageService
, private UtilsService: UtilsService
, private MigrationService: MigrationService
) {
'use strict';
var _usersDatabase = new PouchDB(CouchConstants.COUCHDB_USERS_DB_NAME);
//We attach the function if necessary
if (_usersDatabase.updateReplication == null) {
_usersDatabase.updateReplication = function (newDocsIds) {
console.info("Updating replications with: ");
console.info(newDocsIds);
...
但我收到此错误:
Typescript Error
Property 'updateReplication' does not exist on type 'Database<{}>'.
src/providers/users-database.ts
//We attach the function if necessary
if (_usersDatabase.updateReplication == null) {
【问题讨论】: