Skip to content

Commit b35c0d9

Browse files
CC - edits part 1
1 parent ea95abc commit b35c0d9

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

source/fundamentals/typescript.txt

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ For more information on object types, see the
4444
Extend Document
4545
~~~~~~~~~~~~~~~
4646

47-
The following classes accept any :ref:`non-recursive <node-driver-recursive-type>`
48-
type that extends the ``Document`` interface:
47+
The following classes accept all :ref:`non-recursive <node-driver-limitations>`
48+
types that extends the ``Document`` interface:
4949

5050
- `Collection <{+api+}/classes/Collection.html>`__
5151
- `ChangeStream <{+api+}/classes/ChangeStream.html>`__
@@ -70,7 +70,7 @@ You can pass a type parameter that extends the ``Document`` interface like this:
7070
Any Type
7171
~~~~~~~~
7272

73-
The following classes accept any :ref:`non-recursive <node-driver-recursive-type>`
73+
The following classes accept any :ref:`non-recursive <node-driver-limitations>`
7474
type parameter:
7575

7676
- `FindCursor <{+api+}/classes/FindCursor.html>`__
@@ -85,46 +85,35 @@ class in the
8585
Limitations
8686
-----------
8787

88-
.. _node-driver-recursive-type:
89-
9088
You cannot specify a recursive type as a type parameter for {+driver-long+}
91-
classes. Click the following tabs to see a recursive type and a code snippet that
92-
uses the recursive type and raises an error:
93-
94-
.. tabs::
95-
96-
.. tab:: Recursive Type
97-
:tabid: recursive-type
98-
99-
.. code-block:: typescript
89+
classes. The following code snippet defines a recursive type:
10090

101-
interface RecursiveType {
102-
r: RecursiveType | BaseCase;
103-
i: number;
104-
}
91+
.. code-block:: typescript
10592

106-
type BaseCase = "done";
93+
interface RecursiveType {
94+
r: RecursiveType | BaseCase;
95+
i: number;
96+
}
10797

108-
.. tab:: Code Snippet
109-
:tabid: code-snippet
98+
type BaseCase = "done";
11099

111-
The following code snippet uses a recursive type:
100+
The following code snippet uses the preceding recursive type:
112101

113-
.. code-block:: typescript
102+
.. code-block:: typescript
114103

115-
const database = client.db("test-db");
116-
const col = database.collection<RecursiveType>("test-collection");
117-
const document = await col.findOne({ i: 1 });
104+
const database = client.db("<your db>");
105+
const col = database.collection<RecursiveType>("<your collection>");
106+
const document = await col.findOne({ i: 1 });
118107

119-
The preceding code snippet raises the following error at compile time:
108+
The preceding code snippet raises the following error at compile time:
120109

121-
.. code-block:: text
110+
.. code-block:: text
122111

123-
error TS2615: Type of property 'r' circularly references itself in mapped type '{ [Key in keyof RecursiveType]: [Key, ...NestedPaths<RecursiveType[Key]>]; }'.
112+
error TS2615: Type of property 'r' circularly references itself in mapped type '{ [Key in keyof RecursiveType]: [Key, ...NestedPaths<RecursiveType[Key]>]; }'.
124113

125-
If you must use a recursive type to specify a schema for your documents,
126-
use version 4.2 of the {+driver-long+}.
114+
If you must use a recursive type as your document schema, use version 4.2 of
115+
the {+driver-long+}.
127116

128-
To track the progress of mitigating this limitation in version {+version+} of
129-
the driver, see `this ticket <https://jira.mongodb.org/browse/NODE-3852>`__
130-
in the {+driver-short+}'s JIRA project.
117+
To track the fix for this limitation, see
118+
`NODE-3852 <https://jira.mongodb.org/browse/NODE-3852>`__
119+
in JIRA.

0 commit comments

Comments
 (0)