Automattic / Automattic/mongoose
[Types] all used types should be exported
- Dominant language
- JavaScript
- Stars
- 27.5k
- Forks
- 4k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 35
Description
We're currently relying on types from MongoDB types, but we're not exporting them, which means as a user, I can't have the type of options in `Model.bulkSave(documents, options)` because options has the type of `mongodb.BulkWriteOptions` which I can't access from the outside without using [TS Parameters utility type](https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype).
So we need to define a local type whenever we use a type from a third party library, use it locally and export it.
So instead of
```ts
options?: mongodb.BulkWriteOptions
```
We should be doing:
```ts
export type MongoDBBulkWriteOptions = mongodb.BulkWriteOptions;
options?: MongoDBBulkWriteOptions;
```
That way I can import `MongoDBBulkWriteOptions| in my TS and use it.
What do you think?
Contributor guide
Research direction
Start by locating the TypeScript declaration for Model.bulkSave and every public signature that directly exposes a MongoDB type. Review how the package exports public types, then verify that each used third-party type has a local exported alias and is used through that alias; done means consumers can import the relevant options type without using a utility type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100