Skip to content

Commit 6552a79

Browse files
options overloading
1 parent 8af2884 commit 6552a79

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/cursor/aggregation_cursor.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ export class AggregationCursor<TSchema = any> extends AbstractCursor<TSchema> {
111111
explain =
112112
typeof verbosity !== 'object'
113113
? verbosity
114-
: 'timeoutMS' in verbosity
115-
? undefined
116-
: (verbosity as ExplainCommandOptions);
114+
: 'verbosity' in verbosity
115+
? verbosity
116+
: undefined;
117+
117118
timeout = typeof verbosity === 'object' && 'timeoutMS' in verbosity ? verbosity : undefined;
118119
} else {
119-
explain = verbosity as ExplainCommandOptions;
120+
// @ts-expect-error TS isn't smart enough to determine that if both options are provided, the first is explain options
121+
explain = verbosity;
120122
timeout = options;
121123
}
122124

src/cursor/find_cursor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ export class FindCursor<TSchema = any> extends AbstractCursor<TSchema> {
168168
explain =
169169
typeof verbosity !== 'object'
170170
? verbosity
171-
: 'timeoutMS' in verbosity
172-
? undefined
173-
: (verbosity as ExplainCommandOptions);
171+
: 'verbosity' in verbosity
172+
? verbosity
173+
: undefined;
174174
timeout = typeof verbosity === 'object' && 'timeoutMS' in verbosity ? verbosity : undefined;
175175
} else {
176-
explain = verbosity as ExplainCommandOptions;
176+
// @ts-expect-error TS isn't smart enough to determine that if both options are provided, the first is explain options
177+
explain = verbosity;
177178
timeout = options;
178179
}
179180

0 commit comments

Comments
 (0)