diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts index cf41c64241..16b1c21483 100644 --- a/types/mongoose-simple-random/index.d.ts +++ b/types/mongoose-simple-random/index.d.ts @@ -2,9 +2,17 @@ // Project: https://github.com/larryprice/mongoose-simple-random // Definitions by: My Self // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -// tslint:disable-next-line no-single-declare-module +declare module 'mongoose-simple-random' { + import mongoose = require('mongoose'); + // Dummy function allows to avoid hard to kill or fix tslint warning + // (exporting pluginFunc will make this a non-importable module) + function pluginFunc(schema: mongoose.Schema): void; + // Let allows typescript to still use ES2015 style imports + let plugin: typeof pluginFunc; + export = plugin; +} + declare module "mongoose" { interface Model extends NodeJS.EventEmitter, ModelProperties { findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) diff --git a/types/mongoose-simple-random/mongoose-simple-random-tests.ts b/types/mongoose-simple-random/mongoose-simple-random-tests.ts index 2aa9e18296..f5b26dbebb 100644 --- a/types/mongoose-simple-random/mongoose-simple-random-tests.ts +++ b/types/mongoose-simple-random/mongoose-simple-random-tests.ts @@ -1,4 +1,5 @@ import * as mongoose from 'mongoose'; +import * as mongoose_simple_random from "mongoose-simple-random"; // test compatibility with other libraries - from @types/mongoose import * as _ from 'lodash'; @@ -13,3 +14,5 @@ mongoose.Model.findRandom({ }, {}, { limit: 1 }, (error, data) => { if (error) { console.error("Error!"); } else { console.log("Success!"); } }); + +mongoose.plugin(mongoose_simple_random);