Skip to content

Commit

Permalink
docs: explain the need for new variable is for TS
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Aug 23, 2021
1 parent 32ca27d commit b75d242
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/cursor/abstract_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,12 @@ export abstract class AbstractCursor<
* Map all documents using the provided function
* If there is a transform set on the cursor, that will be called first and the result passed to
* this function's transform.
* @remarks
*
* **NOTE:** adding a transform changes the return type of the iteration of this cursor, it **does not** return
* a new instance of a cursor. This means when calling map, you should always assign the result to a new
* variable. Take note of the following example:
* @remarks
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
* it **does not** return a new instance of a cursor. This means when calling map,
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
* Take note of the following example:
*
* @example
* ```typescript
Expand Down
5 changes: 3 additions & 2 deletions src/cursor/aggregation_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ export class AggregationCursor<TSchema = Document> extends AbstractCursor<TSchem
* In order to strictly type this function you must provide an interface
* that represents the effect of your projection on the result documents.
*
* Adding a projection changes the return type of the iteration of this cursor,
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
* it **does not** return a new instance of a cursor. This means when calling project,
* you should always assign the result to a new variable. Take note of the following example:
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
* Take note of the following example:
*
* @example
* ```typescript
Expand Down
5 changes: 3 additions & 2 deletions src/cursor/find_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ export class FindCursor<TSchema = Document> extends AbstractCursor<TSchema> {
*
* @remarks
*
* Adding a projection changes the return type of the iteration of this cursor,
* **Note for Typescript Users:** adding a transform changes the return type of the iteration of this cursor,
* it **does not** return a new instance of a cursor. This means when calling project,
* you should always assign the result to a new variable. Take note of the following example:
* you should always assign the result to a new variable in order to get a correctly typed cursor variable.
* Take note of the following example:
*
* @example
* ```typescript
Expand Down

0 comments on commit b75d242

Please sign in to comment.