apache / apache/pouchdb

Buffer type declaration from Node conflicts with the PouchDB one

Open
#8,544 8 comments 7 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Hi guys! I am new to both TypeScript (I have some JS background) and PouchDB. I found your site and the API exciting, managed to draft a few of examples in JS and thought I'd kick-start an experimental project using PouchDB and TypeScript. Unfortunately, I have run into the issue below while trying to compile a very simple script.

### Issue
When using the TypeScript compiler, I get an error saying that a Node (sic!) type declaration tries to export a non-local type (indeed, it's defined in the `@types/pouchdb-core`):

Screenshot 2022-09-15 at 13 11 27

### Info
- Environment: Node 16.17.0
- Platform: not applicable
- Adapter: leveldb (really, not applicable)
- Server: not applicable

### Reproduce
I have created an [SSCCE repo](https://github.com/szubtsovskiy/pouchdb-typescript-issue-sscce). Just clone it, and run:
```
npm install
npx tsc
```

I was able to work around this by monkey-patching the type declarations, namely, wrapping `interface Buffer extends Uint8Array` in `@types/pouchdb-core/index.d.ts` in `declare module 'pouchdb-override' { ... }` . This resolved the compilation issue for me. I am not sure if it is the best way to address this, although I kinda see why it helped. If this solution is good, I am happy to raise a pull request, please guide me where to do it.

I do apologise if this repo was a wrong place to report this issue. If possible, please guide me to a proper repo then. Thank you very much.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.