-
Notifications
You must be signed in to change notification settings - Fork 53
DOCSP-25723 Updates to Mutually Recursive Schema Types #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCSP-25723 Updates to Mutually Recursive Schema Types #459
Conversation
|
||
.. _node-driver-recursive-types-dot-notation: | ||
|
||
Recursive Types and Dot Notation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. important:: Impacted Versions | ||
|
||
- 4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this admonition since this affects nested recursive types from all versions after v4.3.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: I thought v4.11 fixed this issue. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so the "fix" I meant to refer to when we met was not type safety.
For clarification, the "issue" from 4.3.0 was that, previously, just the presence of a self-referential recursive schema type at all would cause a compilation error. The "fix" in 4.3.1 is that they allowed for the code to compile with a recursive schema type present, but their solution, in doing so, couldn't guarantee type checking (which becomes a separate "issue" from the one originally mentioned).
Sorry about that confusion 😅
source/whats-new.txt
Outdated
TypeScript. | ||
The 4.11 {+driver-short+} release includes added support for **mutually | ||
recursive** collection schema types. The driver also provides type safety for | ||
dot notation queries up to a depth of eight in this release. Typescript compiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above--confirm this with devs
name: string; | ||
} | ||
|
||
The {+driver-short+} provides type safety for mutually recursive types | ||
referenced through dot notation up to a depth of eight. The following code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely worth confirming with the devs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are correct, I'll be updating the notes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job! reading through this helps me understand the subject (which i couldn't get my head around an hour ago) much better. i made some suggestions for clarity since this is weirdo technical stuff and we should be super precise. feel free to edit my suggestions as you see fit!
|
||
.. _node-driver-recursive-types-dot-notation: | ||
|
||
Recursive Types and Dot Notation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. important:: Impacted Versions | ||
|
||
- 4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: I thought v4.11 fixed this issue. What am I missing?
In versions 4.3 through 4.10 of the {+driver-short+}, you cannot specify a | ||
**mutually recursive** type as a type parameter. To specify a mutually | ||
recursive type as a type parameter, use version 4.11 or newer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: I think we can remove the version note if you're going to do a separate PR for versions 4.3-4.10. To me, it's implied that older versions of a driver might not be able to do things a new version would do.
Suggestion: Delete these lines, then make "mutually recursive" bold on line 82.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I do agree, I'm starting to skew towards keeping it. Just thinking of the case where a user using an older version (e.g. v4.3) goes to our docs site (which defaults to the current version v4.12) and sees the incorrect information without realizing they're on the incorrect version of the docs. Not sure if this is too much of an edge case, though... I'll likely bring it up as a q in #textual-dbx to get others' thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'm good with whatever the team decides.
name: string; | ||
} | ||
|
||
The {+driver-short+} provides type safety for mutually recursive types | ||
referenced through dot notation up to a depth of eight. The following code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely worth confirming with the devs
source/whats-new.txt
Outdated
dot notation queries up to a depth of eight in this release. Typescript compiles | ||
your code beyond a depth of eight, but types fall back to ``any`` at this level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Somewhat confusing
Suggestion:
dot notation queries up to a depth of eight in this release. Typescript compiles | |
your code beyond a depth of eight, but types fall back to ``any`` at this level. | |
dot notation queries up to a depth of eight in this release. At a depth greater than or equal to eight, all dot-notation properties on recursive types are assigned the ``any`` type. |
(Is "properties" the right word here?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the important thing for users to know here is that their code won't deal with a compilation error, rather than knowing the specifics of what type they'll fall back to.
The bit about the any
type assignment is more so for users to know why they won't run into a compilation error. Will try to restructure the sentence to mitigate confusion
Hi @nbbeeken and @baileympearson 👋 Whenever y'all get a chance, could I a technical review on these documentation edits referencing the changes made in NODE-3875? Mainly looking for:
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the team agrees on that admonition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one small syntax fix just to get the highlighting working
Co-authored-by: Neal Beeken <[email protected]>
* DOCSP-25723 Updates to Mutually Recursive Schema Types * edit mutually recursive pet code block * edit collection schema name * more specific limitations menu text * MW comment edits * rephrase confusing sentence * remove warning notes for v4.3-4.10 behavior * Apply suggestions from code review Co-authored-by: Neal Beeken <[email protected]> Co-authored-by: Mike Woofter <[email protected]> Co-authored-by: Neal Beeken <[email protected]> (cherry picked from commit 72be9c1)
* DOCSP-25723 Updates to Mutually Recursive Schema Types * edit mutually recursive pet code block * edit collection schema name * more specific limitations menu text * MW comment edits * rephrase confusing sentence * remove warning notes for v4.3-4.10 behavior * Apply suggestions from code review Co-authored-by: Neal Beeken <[email protected]> Co-authored-by: Mike Woofter <[email protected]> Co-authored-by: Neal Beeken <[email protected]> (cherry picked from commit 72be9c1)
Pull Request Info
PR Reviewing Guidelines
Notes
JIRA
https://jira.mongodb.org/browse/DOCSP-25723
Staging
Self-Review Checklist