Skip to content

Commit 3e45d6c

Browse files
committed
fix(NODE-3441): fix typings for createIndexes
1 parent 9e48bbd commit 3e45d6c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/operations/indexes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export type IndexSpecification = OneOrMore<
7070
>;
7171

7272
/** @public */
73-
export interface IndexDescription {
73+
export interface IndexDescription extends CreateIndexesOptions {
7474
collation?: CollationOptions;
7575
name?: string;
7676
key: Document;

test/types/mongodb.test-d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectType, expectDeprecated } from 'tsd';
1+
import { expectType, expectDeprecated, expectError } from 'tsd';
22

33
import { MongoClient } from '../../src/mongo_client';
44
import { Collection } from '../../src/collection';
@@ -32,3 +32,8 @@ const composedMap = mappedAgg.map<string>(x => x.toString());
3232
expectType<AggregationCursor<string>>(composedMap);
3333
expectType<string | null>(await composedMap.next());
3434
expectType<string[]>(await composedMap.toArray());
35+
36+
// test that VALID_INDEX_OPTIONS like expireAfterSeconds are allowed in IndexDefinitions
37+
coll.createIndexes([{ key: { event: 1 }, name: 'event', expireAfterSeconds: 2400 }]);
38+
// test that invalid options are not allowed
39+
expectError(coll.createIndexes([{ key: { event: 1 }, name: 'event', invalidOption: 2400 }]));

0 commit comments

Comments
 (0)