question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Official TypeScript Docs

See original GitHub issue

Do 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 a Document, an ObjectId, a string or null 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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
marsonyacommented, Feb 9, 2021

Hey @vkarpov15, I would like to help with this.

1reaction
ceeckocommented, Feb 10, 2021

I suggest also including how to properly type schema methods

Read more comments on GitHub >

github_iconTop Results From Across the Web

The starting point for learning TypeScript
Popular Documentation Pages. Everyday Types. All of the common types in TypeScript. Creating Types from Types. Techniques to make more elegant types.
Read more >
The TypeScript Handbook
The TypeScript Handbook is intended to be a comprehensive document that explains ...
Read more >
Documentation - TypeScript for JavaScript Programmers
By understanding how JavaScript works, TypeScript can build a type-system that ...
Read more >
TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Try TypeScript Now. Online or...
Read more >
Documentation - The Basics - TypeScript
Step one in learning TypeScript: The basic types.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found