diff --git a/src/operations/indexes.ts b/src/operations/indexes.ts index 6d9bd2fa15..a3a2b91d33 100644 --- a/src/operations/indexes.ts +++ b/src/operations/indexes.ts @@ -70,7 +70,7 @@ export type IndexSpecification = OneOrMore< >; /** @public */ -export interface IndexDescription { +export interface IndexDescription extends CreateIndexesOptions { collation?: CollationOptions; name?: string; key: Document; diff --git a/test/types/mongodb.test-d.ts b/test/types/mongodb.test-d.ts index 9bd8c54e70..bd2f5eb019 100644 --- a/test/types/mongodb.test-d.ts +++ b/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'; @@ -32,3 +32,8 @@ const composedMap = mappedAgg.map(x => x.toString()); expectType>(composedMap); expectType(await composedMap.next()); expectType(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 }]));