Search code examples
typescripttypescript-typingspouchdbdefinitelytyped

Can't use pouchdb with Typescript ? Types problem?


I am trying to install pouchdb in a typescript (ionic) application. The types don't work

npm install --save pouchdb
npm install --save-dev @types/pouchdb

When I try to use it (import Pouchdb from 'pouchdb'), I get this error

ERROR in src/app/services/pouchdb.service.ts(3,8): error TS1192: Module '"C:/Users/User/PROG/toto/node_modules/@types/pouchdb/index"' has no default export.

I tried

import * as Pouchdb from 'pouchdb'

The error disappears here, but appears after, I still can't use the pouchdb functions.

Is there a solution?


Solution

  • const PouchDB = require('pouchdb').default;
    

    This worked for me.