Official TypeScript Docs
See original GitHub issueDo you want to request a feature or report a bug?
Feature/Docs
What is the current behavior?
The current documentation site provides examples only in JavaScript. Now that TypeScript is officially supported as of v5.11 (#8108), it would be fantastic if we could have a guide on how to properly use TypeScript with Mongoose.
I have done a lot of research online and I have not been able to find good articles on this topic that cover all of the features of Mongoose. I even found an article where @vkarpov15 had to step in and provide a quick guide but this was before v5.11 was complete.
I personally need guidance on how to do the following using TypeScript with mongoose (the official way):
- Create a schema and a TypeScript interface
- Define one-to-many relationships
- Define many-to-many relationships
- Define subdocuments in a Schema
- Define Enums
- TypeScript to Mongoose Types mappings
- Interface type for a
Ref
. I think this could be aDocument
, anObjectId
, astring
ornull
but I am unsure
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
The mongoose docs should include an example written in TypeScript alongside the JavaScript example.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.
N/A
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Hey @vkarpov15, I would like to help with this.
I suggest also including how to properly type schema methods