Skip to content

Commit

Permalink
fix(NODE-3441): fix typings for createIndexes
Browse files Browse the repository at this point in the history
  • Loading branch information
emadum committed Jul 20, 2021
1 parent 9e48bbd commit 3e45d6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/operations/indexes.ts
Expand Up @@ -70,7 +70,7 @@ export type IndexSpecification = OneOrMore<
>;

/** @public */
export interface IndexDescription {
export interface IndexDescription extends CreateIndexesOptions {
collation?: CollationOptions;
name?: string;
key: Document;
Expand Down
7 changes: 6 additions & 1 deletion test/types/mongodb.test-d.ts
@@ -1,4 +1,4 @@
import { expectType, expectDeprecated } from 'tsd';
import { expectType, expectDeprecated, expectError } from 'tsd';

import { MongoClient } from '../../src/mongo_client';
import { Collection } from '../../src/collection';
Expand Down Expand Up @@ -32,3 +32,8 @@ const composedMap = mappedAgg.map<string>(x => x.toString());
expectType<AggregationCursor<string>>(composedMap);
expectType<string | null>(await composedMap.next());
expectType<string[]>(await composedMap.toArray());

// test that VALID_INDEX_OPTIONS like expireAfterSeconds are allowed in IndexDefinitions
coll.createIndexes([{ key: { event: 1 }, name: 'event', expireAfterSeconds: 2400 }]);
// test that invalid options are not allowed
expectError(coll.createIndexes([{ key: { event: 1 }, name: 'event', invalidOption: 2400 }]));

0 comments on commit 3e45d6c

Please sign in to comment.