rsnext/examples/with-mongodb/util
Pier-Luc Gendreau e6c351859f
Update with-mongodb to be TypeScript-friendly (#19383)
* Update with-mongodb to be TypeScript-friendly

I slightly modified the approach so TypeScript can correctly infer types without actually having to type anything but the global:

**index.d.ts**
```ts
import { Db, MongoClient } from "mongodb";

declare global {
  namespace NodeJS {
    interface Global {
      mongoCache: {
        conn: {
          client: MongoClient | null;
          db: Db | null;
        }
        promise: Promise<MongoClient> | null;
      };
    }
  }
}
```

* lint

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-12-28 14:40:18 -05:00
..
mongodb.js Update with-mongodb to be TypeScript-friendly (#19383) 2020-12-28 14:40:18 -05:00