Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-3441): fix typings for createIndexes #2915

Merged
merged 2 commits into from Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 }]));
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved