diff --git a/types/mongoose-paginate-v2/index.d.ts b/types/mongoose-paginate-v2/index.d.ts index 3c178c5908..dfd70cc0cb 100644 --- a/types/mongoose-paginate-v2/index.d.ts +++ b/types/mongoose-paginate-v2/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for mongoose-paginate-v2 1.0.13 +// Type definitions for mongoose-paginate-v2 1.0 // Project: https://github.com/aravindnc/mongoose-paginate-v2 // Definitions by: Linus Brolin // simonxca @@ -8,25 +8,23 @@ // // Based on type declarations for mongoose-paginate 5.0.0. -/// - declare module 'mongoose' { - export interface CustomLabels { - totalDocs?: string, - limit?: string, - page?: string, - totalPages?: string, - docs?: string, - nextPage?: string, - prevPage?: string, + interface CustomLabels { + totalDocs?: string; + limit?: string; + page?: string; + totalPages?: string; + docs?: string; + nextPage?: string; + prevPage?: string; } - export interface PaginateOptions { + interface PaginateOptions { select?: Object | string; sort?: Object | string; - customLabels?: CustomLabels, - collation?: CollationOptions, - populate?: Array | Array | Object | string; + customLabels?: CustomLabels; + collation?: CollationOptions; + populate?: Object[] | string[] | Object | string; lean?: boolean; leanWithId?: boolean; offset?: number; @@ -34,29 +32,26 @@ declare module 'mongoose' { limit?: number; } - export interface PaginateResult { - docs: Array; + interface PaginateResult { + docs: T[]; total: number; limit: number; page?: number; pages?: number; offset?: number; - [customLabel: string]: Array | number | undefined; + [customLabel: string]: T[] | number | undefined; } interface PaginateModel extends Model { - paginate(query?: Object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; + paginate(query?: object, options?: PaginateOptions, callback?: (err: any, result: PaginateResult) => void): Promise>; } - export function model( + function model( name: string, schema?: Schema, collection?: string, skipInit?: boolean): PaginateModel; } -declare module 'mongoose-paginate-v2' { - import mongoose = require('mongoose'); - var _: (schema: mongoose.Schema) => void; - export = _; -} +import mongoose = require('mongoose'); +export function _(schema: mongoose.Schema): void; diff --git a/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts index 8410c740e5..200ca4e12a 100644 --- a/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts +++ b/types/mongoose-paginate-v2/mongoose-paginate-v2-tests.ts @@ -13,7 +13,6 @@ import { import mongoosePaginate = require('mongoose-paginate'); import { Router, Request, Response } from 'express'; - //#region Test Models interface User extends Document { email: string; @@ -29,20 +28,19 @@ const UserSchema: Schema = new Schema({ UserSchema.plugin(mongoosePaginate); -interface UserModel extends PaginateModel {}; +interface UserModel extends PaginateModel {} -let UserModel: UserModel = model('User', UserSchema) as UserModel; +const UserModel: UserModel = model('User', UserSchema) as UserModel; //#endregion - //#region Test Paginate -let router: Router = Router(); +const router: Router = Router(); -router.get('/users.json', function(req: Request, res: Response) { - let descending: boolean = true; - let options: PaginateOptions = {} as PaginateOptions; +router.get('/users.json', (req: Request, res: Response) => { + const descending = true; + const options: PaginateOptions = {}; options.select = 'email username'; - options.sort = { 'username': (descending ? -1 : 1) }; + options.sort = { username: (descending ? -1 : 1) }; options.collation = { locale: 'en_US', strength: 1 }; options.populate = ''; options.lean = true; @@ -78,6 +76,5 @@ router.get('/users.json', function(req: Request, res: Response) { console.dir(value.docsCustom); return res.json(value); }); - }); //#endregion diff --git a/types/mongoose-paginate-v2/tslint.json b/types/mongoose-paginate-v2/tslint.json index a41bf5d19a..a62d0d4e68 100644 --- a/types/mongoose-paginate-v2/tslint.json +++ b/types/mongoose-paginate-v2/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "ban-types": false } }