From 75b53205ce569cb3b9568eadc08a7a4f8a94b45a Mon Sep 17 00:00:00 2001 From: dmitryshindin Date: Wed, 10 Jan 2018 22:20:15 +0300 Subject: [PATCH 01/12] Added bar.space as an optional property to ChartConfiguration interface (#22804) * Added bar.space as an optional property to ChartConfiguration interface This property lets you to set space between bars in bar charts * Add tests for new property --- types/c3/c3-tests.ts | 3 ++- types/c3/index.d.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/c3/c3-tests.ts b/types/c3/c3-tests.ts index 509678636b..8ac8a4b93e 100644 --- a/types/c3/c3-tests.ts +++ b/types/c3/c3-tests.ts @@ -619,7 +619,8 @@ function chart_bar() { width: { ratio: 0.5, // this makes bar width 50% of length between ticks max: 50 // this limits maximum width of bar to 50px - } + }, + space: 10 // this adds space between bars in bar charts // or // width: 100 // this makes bar width 100px } diff --git a/types/c3/index.d.ts b/types/c3/index.d.ts index b06efa29f9..96ecc8c488 100644 --- a/types/c3/index.d.ts +++ b/types/c3/index.d.ts @@ -178,6 +178,10 @@ export interface ChartConfiguration { * Set if min or max value will be 0 on bar chart. */ zerobased?: boolean; + /** + * Set space between bars in bar charts + */ + space?: number; }; pie?: { From 5a4e3cece257369df1a43ac9eccf5ae240439f96 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 12:21:07 -0800 Subject: [PATCH 02/12] gzip-js: Fix test (#22812) --- types/gzip-js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/gzip-js/index.d.ts b/types/gzip-js/index.d.ts index 2807e698a8..0a5c0000ea 100644 --- a/types/gzip-js/index.d.ts +++ b/types/gzip-js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/beatgammit/gzip-js // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// From c72985cddbacc665133937a286a04aeaec807003 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 12:23:08 -0800 Subject: [PATCH 03/12] Playcanvas: Fix lint (#22808) --- types/playcanvas/index.d.ts | 4 ++-- types/playcanvas/playcanvas-tests.ts | 16 ++++++++-------- types/playcanvas/tsconfig.json | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/types/playcanvas/index.d.ts b/types/playcanvas/index.d.ts index 37509d30c9..03899cd1b9 100644 --- a/types/playcanvas/index.d.ts +++ b/types/playcanvas/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for playcanvas 0.221.0-dev -// Project: https://github.com/playcanvas/engine +// Type definitions for playcanvas 0.221 +// Project: https://github.com/playcanvas/engine // Definitions by: Philippe Vaillancourt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/playcanvas/playcanvas-tests.ts b/types/playcanvas/playcanvas-tests.ts index 1f2b06e575..95f0721dd6 100644 --- a/types/playcanvas/playcanvas-tests.ts +++ b/types/playcanvas/playcanvas-tests.ts @@ -1,6 +1,6 @@ // create a PlayCanvas application -var canvas = document.getElementById('application') as HTMLCanvasElement; -var app = new pc.Application(canvas, { }); +const canvas = document.getElementById('application') as HTMLCanvasElement; +const app = new pc.Application(canvas, { }); app.start(); // fill the available space at full resolution @@ -8,24 +8,24 @@ app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW); app.setCanvasResolution(pc.RESOLUTION_AUTO); // ensure canvas is resized when window changes size -window.addEventListener('resize', function() { +window.addEventListener('resize', () => { app.resizeCanvas(); }); // create box entity -var cube = new pc.Entity('cube'); +const cube = new pc.Entity('cube'); cube.addComponent('model', { type: 'box' }); // create camera entity -var camera = new pc.Entity('camera'); +const camera = new pc.Entity('camera'); camera.addComponent('camera', { clearColor: new pc.Color(0.1, 0.1, 0.1) }); // create directional light entity -var light = new pc.Entity('light'); +const light = new pc.Entity('light'); light.addComponent('light'); // add to hierarchy @@ -38,6 +38,6 @@ camera.setPosition(0, 0, 3); light.setEulerAngles(45, 0, 0); // register a global update event -app.on('update', function (deltaTime) { +app.on('update', deltaTime => { cube.rotate(10 * deltaTime, 20 * deltaTime, 30 * deltaTime); -}); \ No newline at end of file +}); diff --git a/types/playcanvas/tsconfig.json b/types/playcanvas/tsconfig.json index f33fcf6bbd..a2a2c895a0 100644 --- a/types/playcanvas/tsconfig.json +++ b/types/playcanvas/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, From fde9d593b1f4b22458637499d0e888a0d47c0f46 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 12:23:31 -0800 Subject: [PATCH 04/12] nightwatch: Fix lint (#22810) --- types/nightwatch/index.d.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/types/nightwatch/index.d.ts b/types/nightwatch/index.d.ts index 741f743934..6d3cc8f4a0 100644 --- a/types/nightwatch/index.d.ts +++ b/types/nightwatch/index.d.ts @@ -4,10 +4,8 @@ // Connor Schlesiger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/* tslint:disable:max-line-length */ - -export interface NightWatchCustomPageObjects { - page: {[name: string]: () => NightWatchBrowser}; +export interface NightwatchCustomPageObjects { + page: {[name: string]: () => NightwatchBrowser}; } export interface NightwatchDesiredCapabilities { From d1bc03b34c0cdfcc6208587f44ce5a8590b35042 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 12:24:10 -0800 Subject: [PATCH 05/12] webappsec-credential-management: Fix lint (#22806) --- types/webappsec-credential-management/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/webappsec-credential-management/index.d.ts b/types/webappsec-credential-management/index.d.ts index 533c26c8a2..2859e02d8a 100644 --- a/types/webappsec-credential-management/index.d.ts +++ b/types/webappsec-credential-management/index.d.ts @@ -407,7 +407,7 @@ interface PublicKeyCredentialParameters { interface PublicKeyCredentialDescriptor { type: 'public-key'; id: BufferSource; - transports?: Array; + transports?: string[]; } /** @@ -427,10 +427,10 @@ interface MakePublicKeyCredentialOptions { user: PublicKeyCredentialUserEntity; challenge: BufferSource; - pubKeyCredParams: Array; + pubKeyCredParams: PublicKeyCredentialParameters[]; timeout?: number; - excludeCredentials?: Array; + excludeCredentials?: PublicKeyCredentialDescriptor[]; authenticatorSelection?: AuthenticatorSelectionCriteria; attestation?: 'none' | 'indirect' | 'direct'; extensions?: any; From e429830e195dd24d23db785639a0d7497701d956 Mon Sep 17 00:00:00 2001 From: Tim Griesser Date: Wed, 10 Jan 2018 17:13:06 -0500 Subject: [PATCH 06/12] [graphql] allow specifying Args on GraphQLFieldResolver (#22789) --- types/graphql/index.d.ts | 1 + types/graphql/type/definition.d.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 74d9224242..4bca573210 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -9,6 +9,7 @@ // Ivan Goncharov // Hagai Cohen // Ricardo Portugal +// Tim Griesser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/graphql/type/definition.d.ts b/types/graphql/type/definition.d.ts index 52df7bd46c..4a44c5d1c6 100644 --- a/types/graphql/type/definition.d.ts +++ b/types/graphql/type/definition.d.ts @@ -262,9 +262,9 @@ export type GraphQLIsTypeOfFn = ( info: GraphQLResolveInfo ) => boolean | Promise; -export type GraphQLFieldResolver = ( +export type GraphQLFieldResolver = ( source: TSource, - args: { [argName: string]: any }, + args: TArgs, context: TContext, info: GraphQLResolveInfo ) => any; @@ -284,11 +284,11 @@ export interface GraphQLResolveInfo { export type ResponsePath = { prev: ResponsePath, key: string | number } | undefined; -export interface GraphQLFieldConfig { +export interface GraphQLFieldConfig { type: GraphQLOutputType; args?: GraphQLFieldConfigArgumentMap; - resolve?: GraphQLFieldResolver; - subscribe?: GraphQLFieldResolver; + resolve?: GraphQLFieldResolver; + subscribe?: GraphQLFieldResolver; deprecationReason?: string; description?: string; astNode?: FieldDefinitionNode; @@ -309,13 +309,13 @@ export interface GraphQLFieldConfigMap { [fieldName: string]: GraphQLFieldConfig; } -export interface GraphQLField { +export interface GraphQLField { name: string; description: string; type: GraphQLOutputType; args: GraphQLArgument[]; - resolve?: GraphQLFieldResolver; - subscribe?: GraphQLFieldResolver; + resolve?: GraphQLFieldResolver; + subscribe?: GraphQLFieldResolver; isDeprecated?: boolean; deprecationReason?: string; astNode?: FieldDefinitionNode; From 84e265d13a4e1bec238e9b22e2306318c2626818 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Wed, 10 Jan 2018 23:14:05 +0100 Subject: [PATCH 07/12] [mongodb] First update to bring the mongodb to version 3 (#22626) * First update to bring the mongodb typings to version 3 * Updated tsconfig of the older v2 version * Set mongodb version to 2 in packages with errors * MongoClient extends form EventEmitter --- types/connect-mongo/tsconfig.json | 5 + types/express-brute-mongo/tsconfig.json | 5 + types/mongodb/index.d.ts | 661 +++++----- types/mongodb/mongodb-tests.ts | 86 +- types/mongodb/v2/index.d.ts | 1435 +++++++++++++++++++++ types/mongodb/v2/mongodb-tests.ts | 101 ++ types/mongodb/v2/tsconfig.json | 28 + types/mongodb/v2/tslint.json | 80 ++ types/multer-gridfs-storage/tsconfig.json | 5 + 9 files changed, 2009 insertions(+), 397 deletions(-) create mode 100644 types/mongodb/v2/index.d.ts create mode 100644 types/mongodb/v2/mongodb-tests.ts create mode 100644 types/mongodb/v2/tsconfig.json create mode 100644 types/mongodb/v2/tslint.json diff --git a/types/connect-mongo/tsconfig.json b/types/connect-mongo/tsconfig.json index c352be5580..ca12068b57 100644 --- a/types/connect-mongo/tsconfig.json +++ b/types/connect-mongo/tsconfig.json @@ -4,6 +4,11 @@ "lib": [ "es6" ], + "paths": { + "mongodb": [ + "mongodb/v2" + ] + }, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, diff --git a/types/express-brute-mongo/tsconfig.json b/types/express-brute-mongo/tsconfig.json index 9d21f88e3c..d57cb21dd2 100644 --- a/types/express-brute-mongo/tsconfig.json +++ b/types/express-brute-mongo/tsconfig.json @@ -4,6 +4,11 @@ "lib": [ "es6" ], + "paths": { + "mongodb": [ + "mongodb/v2" + ] + }, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 6cf21c04b9..556a7ab838 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -1,5 +1,5 @@ -// Type definitions for MongoDB v2.2 -// Project: https://github.com/mongodb/node-mongodb-native/tree/2.2 +// Type definitions for MongoDB v3.0 +// Project: https://github.com/mongodb/node-mongodb-native/tree/3.0.0 // Definitions by: Federico Caselli // Alan Marcell // Gady Piazza @@ -9,7 +9,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -// Documentation : http://mongodb.github.io/node-mongodb-native/2.2/api/ +// Documentation : http://mongodb.github.io/node-mongodb-native/3.0/api/ /// /// @@ -24,31 +24,60 @@ export function connect(uri: string, options: MongoClientOptions, callback: Mong export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, Timestamp, DBRef } from 'bson'; -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html -export class MongoClient { +// Class documentation : http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html +export class MongoClient extends EventEmitter { constructor(); + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#.connect */ + static connect(uri: string, callback: MongoCallback): void; + static connect(uri: string, options?: MongoClientOptions): Promise; + static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + /** + * @deprecated + * http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#connect + */ + connect(): Promise; + connect(callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#close */ + close(callback: MongoCallback): void; + close(force?: boolean): Promise; + close(force: boolean, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#db */ + db(name: string, options?: MongoClientCommonOption): Db + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#isConnected */ + isConnected(name: string, options?: MongoClientCommonOption): boolean; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#logout */ + logout(callback: MongoCallback): void; + logout(options?: { dbName?: string }): Promise; + logout(options: { dbName?: string }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#startSession */ + startSession(options?: any): ClientSession; +} - static connect(uri: string, callback: MongoCallback): void; - static connect(uri: string, options?: MongoClientOptions): Promise; - static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; +declare class ClientSession extends EventEmitter { + endSession(callback?: MongoCallback): void; + endSession(options: any, callback?: MongoCallback): void; + equals(session: ClientSession): boolean; +} - connect(uri: string, callback: MongoCallback): void; - connect(uri: string, options?: MongoClientOptions): Promise; - connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; +export interface MongoClientCommonOption { + /** Do not make the db an event listener to the original connection. */ + noListener?: boolean; + /** Control if you want to return a cached instance or have a new one created */ + returnNonCachedInstance?: boolean; } export interface MongoCallback { (error: MongoError, result: T): void; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoError.html */ export class MongoError extends Error { constructor(message: string); static create(options: Object): MongoError; code?: number; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect +/** http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#.connect */ export interface MongoClientOptions extends DbCreateOptions, ServerOptions, @@ -97,7 +126,7 @@ export interface HighAvailabilityOptions { domainsEnabled?: boolean; } -// See http://mongodb.github.io/node-mongodb-native/2.2/api/ReadPreference.html +// See http://mongodb.github.io/node-mongodb-native/3.0/api/ReadPreference.html export class ReadPreference { constructor(mode: string, tags: Object); mode: string; @@ -112,17 +141,10 @@ export class ReadPreference { static isValid(mode: string): boolean; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html -export interface DbCreateOptions { - +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html */ +export interface DbCreateOptions extends CommonOptions { // If the database authentication is dependent on another databaseName. authSource?: string; - // Default: null;https://docs.mongodb.com/manual/reference/write-concern/#write-concern - w?: number | string; - // The write concern timeout to finish (combining with w option). - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; // Default: false; Force server to create _id fields instead of client. forceServerObjectId?: boolean; // Default: false; Use c++ bson parser. @@ -145,14 +167,14 @@ export interface DbCreateOptions { pkFactory?: Object; // ES6 compatible promise constructor promiseLibrary?: Object; - // https://docs.mongodb.com/manual/reference/read-concern/#read-concern + /** https://docs.mongodb.com/manual/reference/read-concern/#read-concern */ readConcern?: { level?: Object }; // Sets a cap on how many operations the driver will buffer up before giving up on getting a // working connection, default is -1 which is unlimited. bufferMaxEntries?: number; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Server.html */ export interface SocketOptions { // Reconnect on error. default:false autoReconnect?: boolean; @@ -166,7 +188,7 @@ export interface SocketOptions { socketTimeoutMS?: number; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Server.html */ export interface ServerOptions extends SSLOptions { // Default: 30; reconnectTries?: number; @@ -181,14 +203,14 @@ export interface ServerOptions extends SSLOptions { domainsEnabled?: boolean; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/Mongos.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Mongos.html */ export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { // Default: 15; Cutoff latency point in MS for MongoS proxy selection acceptableLatencyMS?: number; socketOptions?: SocketOptions; } -// http://mongodb.github.io/node-mongodb-native/2.2/api/ReplSet.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/ReplSet.html */ export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { // The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); maxStalenessSeconds?: number; @@ -200,7 +222,7 @@ export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { socketOptions?: SocketOptions; } -// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html +// Class documentation : http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html export class Db extends EventEmitter { constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); @@ -212,120 +234,113 @@ export class Db extends EventEmitter { slaveOk: boolean; writeConcern: any; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#addUser */ addUser(username: string, password: string, callback: MongoCallback): void; addUser(username: string, password: string, options?: DbAddUserOptions): Promise; addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#admin */ admin(): Admin; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate - authenticate(userName: string, password: string, callback: MongoCallback): void; - authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; - authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close - close(callback: MongoCallback): void; - close(forceClose?: boolean): Promise; - close(forceClose: boolean, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#collection */ collection(name: string): Collection; collection(name: string, callback: MongoCallback>): Collection; collection(name: string, options: DbCollectionOptions, callback: MongoCallback>): Collection; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#collections */ collections(): Promise[]>; collections(callback: MongoCallback[]>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#command */ command(command: Object, callback: MongoCallback): void; command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#createCollection */ createCollection(name: string, callback: MongoCallback>): void; createCollection(name: string, options?: CollectionCreateOptions): Promise>; createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#createIndex */ createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void; createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise; createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db - db(dbName: string): Db; - db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#dropCollection */ dropCollection(name: string): Promise; dropCollection(name: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#dropDatabase */ dropDatabase(): Promise; dropDatabase(callback: MongoCallback): void; - - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex - // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; - //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval - // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; - - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#executeDbAdminCommand */ executeDbAdminCommand(command: Object, callback: MongoCallback): void; executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#indexInformation */ indexInformation(name: string, callback: MongoCallback): void; indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#listCollections */ listCollections(filter?: Object, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout - logout(callback: MongoCallback): void; - logout(options?: { dbName?: string }): Promise; - logout(options: { dbName?: string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open - open(): Promise; - open(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#profilingInfo */ + profilingInfo(callback: MongoCallback): void; + profilingInfo(options?: { session?: ClientSession }): Promise; + profilingInfo(options: { session?: ClientSession }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#profilingLevel */ + profilingLevel(callback: MongoCallback): void; + profilingLevel(options?: { session?: ClientSession }): Promise; + profilingLevel(options: { session?: ClientSession }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#removeUser */ removeUser(username: string, callback: MongoCallback): void; - removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; - removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection + removeUser(username: string, options?: CommonOptions): Promise; + removeUser(username: string, options: CommonOptions, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#renameCollection */ renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback>): void; renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise>; renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#setProfilingLevel */ + profilingLevel(level: string, callback: MongoCallback): void; + profilingLevel(level: string, options?: { session?: ClientSession }): Promise; + profilingLevel(level: string, options: { session?: ClientSession }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#stats */ stats(callback: MongoCallback): void; stats(options?: { scale?: number }): Promise; stats(options: { scale?: number }, callback: MongoCallback): void; } -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html +export interface CommonOptions { + /** The write concern. */ + w?: string | number; + /** The write concern timeout. */ + wtimeout?: number; + /** Specify a journal write concern. */ + j?: boolean; + /** Session to use for this operation */ + session?: ClientSession; +} + +// Deprecated http://mongodb.github.io/node-mongodb-native/3.0/api/Server.html export class Server extends EventEmitter { constructor(host: string, port: number, options?: ServerOptions); connections(): Array; } -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html +// Deprecated http://mongodb.github.io/node-mongodb-native/3.0/api/ReplSet.html export class ReplSet extends EventEmitter { constructor(servers: Array, options?: ReplSetOptions); connections(): Array; } -// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html +// Deprecated http://mongodb.github.io/node-mongodb-native/3.0/api/ReplSet.html export class Mongos extends EventEmitter { constructor(servers: Array, options?: MongosOptions); connections(): Array; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser -export interface DbAddUserOptions { - w?: string | number; - wtimeout?: number; - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#addUser */ +export interface DbAddUserOptions extends CommonOptions { customData?: Object; roles?: Object[]; } -//http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection -export interface CollectionCreateOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#createCollection */ +export interface CollectionCreateOptions extends CommonOptions { raw?: boolean; pkFactory?: Object; readPreference?: ReadPreference | string; @@ -335,8 +350,8 @@ export interface CollectionCreateOptions { autoIndexId?: boolean; size?: number; max?: number; - flags?: number; - storageEngine?: object; + flags?: number; + storageEngine?: object; validator?: object; validationLevel?: "off" | "strict" | "moderate"; validationAction?: "error" | "warn"; @@ -346,11 +361,8 @@ export interface CollectionCreateOptions { collation?: object; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection -export interface DbCollectionOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#collection */ +export interface DbCollectionOptions extends CommonOptions { raw?: boolean; pkFactory?: Object; readPreference?: ReadPreference | string; @@ -359,14 +371,8 @@ export interface DbCollectionOptions { readConcern?: { level: Object }; } -//http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createIndex -export interface IndexOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Db.html#createIndex */ +export interface IndexOptions extends CommonOptions { // Creates an unique index. unique?: boolean; // Creates a sparse index. @@ -391,79 +397,57 @@ export interface IndexOptions { partialFilterExpression?: any; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html */ export interface Admin { - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#addUser */ addUser(username: string, password: string, callback: MongoCallback): void; addUser(username: string, password: string, options?: AddUserOptions): Promise; addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate - authenticate(username: string, callback: MongoCallback): void; - authenticate(username: string, password?: string): Promise; - authenticate(username: string, password: string, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#buildInfo */ buildInfo(): Promise; buildInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#command */ command(command: Object, callback: MongoCallback): void; command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#listDatabases */ listDatabases(): Promise; listDatabases(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout - logout(): Promise; - logout(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#ping */ ping(): Promise; ping(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo - profilingInfo(): Promise; - profilingInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel - profilingLevel(): Promise; - profilingLevel(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#removeUser */ removeUser(username: string, callback: MongoCallback): void; removeUser(username: string, options?: FSyncOptions): Promise; removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#replSetGetStatus */ replSetGetStatus(): Promise; replSetGetStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#serverInfo */ serverInfo(): Promise; serverInfo(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#serverStatus */ serverStatus(): Promise; serverStatus(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel - setProfilingLevel(level: string): Promise; - setProfilingLevel(level: string, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#validateCollection */ validateCollection(collectionNme: string, callback: MongoCallback): void; validateCollection(collectionNme: string, options?: Object): Promise; validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser -export interface AddUserOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#addUser */ +export interface AddUserOptions extends CommonOptions { fsync: boolean; customData?: Object; roles?: Object[] } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser -export interface FSyncOptions { - w?: number | string; - wtimeout?: number; - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Admin.html#removeUser */ +export interface FSyncOptions extends CommonOptions { fsync?: boolean } -// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html +// Documentation : http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html export interface Collection { // Get the collection name. collectionName: string; @@ -475,164 +459,164 @@ export interface Collection { readConcern: any; // Get current index hint for collection. hint: any; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */ aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#bulkWrite */ bulkWrite(operations: Object[], callback: MongoCallback): void; bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#count + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#count */ count(query: Object, callback: MongoCallback): void; count(query: Object, options?: MongoCountPreferences): Promise; count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#createIndex */ createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ */ createIndexes(indexSpecs: Object[]): Promise; createIndexes(indexSpecs: Object[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteMany */ deleteMany(filter: Object, callback: MongoCallback): void; - deleteMany(filter: Object, options?: CollectionOptions): Promise; - deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne + deleteMany(filter: Object, options?: CommonOptions): Promise; + deleteMany(filter: Object, options: CommonOptions, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#deleteOne */ deleteOne(filter: Object, callback: MongoCallback): void; - deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; - deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct + deleteOne(filter: Object, options?: CommonOptions & { bypassDocumentValidation?: boolean }): Promise; + deleteOne(filter: Object, options: CommonOptions & { bypassDocumentValidation?: boolean }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#distinct */ distinct(key: string, query: Object, callback: MongoCallback): void; distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#drop */ drop(): Promise; drop(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#dropIndex */ dropIndex(indexName: string, callback: MongoCallback): void; - dropIndex(indexName: string, options?: CollectionOptions): Promise; - dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes + dropIndex(indexName: string, options?: CommonOptions): Promise; + dropIndex(indexName: string, options: CommonOptions, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#dropIndexes */ dropIndexes(): Promise; dropIndexes(callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#find */ find(query?: Object): Cursor; /** @deprecated */ find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOne */ findOne(filter: Object, callback: MongoCallback): void; findOne(filter: Object, options?: FindOneOptions): Promise; findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndDelete */ findOneAndDelete(filter: Object, callback: MongoCallback>): void; findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise>; findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndReplace */ findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback>): void; findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise>; findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndUpdate */ findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback>): void; findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise>; findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoHaystackSearch */ geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoNear */ geoNear(x: number, y: number, callback: MongoCallback): void; geoNear(x: number, y: number, options?: GeoNearOptions): Promise; geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#group + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#group */ group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise; group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#indexes */ indexes(): Promise; indexes(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#indexExists */ indexExists(indexes: string | string[]): Promise; indexExists(indexes: string | string[], callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#indexInformation */ indexInformation(callback: MongoCallback): void; indexInformation(options?: { full: boolean }): Promise; indexInformation(options: { full: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp - initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp - initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#initializeOrderedBulkOp */ + initializeOrderedBulkOp(options?: CommonOptions): OrderedBulkOperation; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#initializeUnorderedBulkOp */ + initializeUnorderedBulkOp(options?: CommonOptions): UnorderedBulkOperation; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertOne */ /** @deprecated Use insertOne, insertMany or bulkWrite */ insert(docs: Object, callback: MongoCallback): void; /** @deprecated Use insertOne, insertMany or bulkWrite */ insert(docs: Object, options?: CollectionInsertOneOptions): Promise; /** @deprecated Use insertOne, insertMany or bulkWrite */ insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertMany */ insertMany(docs: Object[], callback: MongoCallback): void; insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertOne */ insertOne(docs: Object, callback: MongoCallback): void; insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#isCapped */ isCapped(): Promise; isCapped(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#listIndexes */ listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#mapReduce */ mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void; mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#options */ options(): Promise; options(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#parallelCollectionScan */ parallelCollectionScan(callback: MongoCallback[]>): void; parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>; parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#reIndex */ reIndex(): Promise; reIndex(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#remove + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#remove */ /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ remove(selector: Object, callback: MongoCallback): void; /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CollectionOptions & { single?: boolean }): Promise; + remove(selector: Object, options?: CommonOptions & { single?: boolean }): Promise; /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ - remove(selector: Object, options?: CollectionOptions & { single?: boolean }, callback?: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename + remove(selector: Object, options?: CommonOptions & { single?: boolean }, callback?: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#rename */ rename(newName: string, callback: MongoCallback>): void; rename(newName: string, options?: { dropTarget?: boolean }): Promise>; rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; - //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#replaceOne */ replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#save */ /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ save(doc: Object, callback: MongoCallback): void; /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, options?: CollectionOptions): Promise; + save(doc: Object, options?: CommonOptions): Promise; /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ - save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats + save(doc: Object, options: CommonOptions, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#stats */ stats(callback: MongoCallback): void; stats(options?: { scale: number }): Promise; stats(options: { scale: number }, callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#update */ /** @deprecated use updateOne, updateMany or bulkWrite */ update(filter: Object, update: Object, callback: MongoCallback): void; /** @deprecated use updateOne, updateMany or bulkWrite */ update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; /** @deprecated use updateOne, updateMany or bulkWrite */ update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateMany */ updateMany(filter: Object, update: Object, callback: MongoCallback): void; - updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; - updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne + updateMany(filter: Object, update: Object, options?: CommonOptions & { upsert?: boolean }): Promise; + updateMany(filter: Object, update: Object, options: CommonOptions & { upsert?: boolean }, callback: MongoCallback): void; + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#updateOne */ updateOne(filter: Object, update: Object, callback: MongoCallback): void; updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; @@ -814,7 +798,7 @@ export interface WiredTigerData { }; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate */ export interface CollectionAggregationOptions { readPreference?: ReadPreference | string; // Return the query as cursor, on 2.6 > it returns as a real cursor @@ -832,14 +816,8 @@ export interface CollectionAggregationOptions { bypassDocumentValidation?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany -export interface CollectionInsertManyOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertMany */ +export interface CollectionInsertManyOptions extends CommonOptions { // Serialize functions on any object. serializeFunctions?: boolean; //Force server to assign _id values instead of driver. @@ -850,14 +828,8 @@ export interface CollectionInsertManyOptions { ordered?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite -export interface CollectionBluckWriteOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#bulkWrite */ +export interface CollectionBluckWriteOptions extends CommonOptions { // Serialize functions on any object. serializeFunctions?: boolean; // Execute write operation in ordered or unordered fashion. @@ -866,7 +838,7 @@ export interface CollectionBluckWriteOptions { bypassDocumentValidation?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~BulkWriteOpResult */ export interface BulkWriteOpResultObject { insertedCount?: number; matchedCount?: number; @@ -878,7 +850,7 @@ export interface BulkWriteOpResultObject { result?: any; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#count */ export interface MongoCountPreferences { // The limit of documents to count. limit?: number; @@ -890,7 +862,7 @@ export interface MongoCountPreferences { readPreference?: ReadPreference | string; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~deleteWriteOpResult */ export interface DeleteWriteOpResultObject { //The raw result returned from MongoDB, field will vary depending on server version. result: { @@ -905,7 +877,7 @@ export interface DeleteWriteOpResultObject { deletedCount?: number; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~findAndModifyWriteOpResult */ export interface FindAndModifyWriteOpResultObject { //Document returned from findAndModify command. value?: TSchema; @@ -915,7 +887,7 @@ export interface FindAndModifyWriteOpResultObject { ok?: number; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOneAndReplace */ export interface FindOneAndReplaceOption { projection?: Object; sort?: Object; @@ -924,7 +896,7 @@ export interface FindOneAndReplaceOption { returnOriginal?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoHaystackSearch */ export interface GeoHaystackSearchOptions { readPreference?: ReadPreference | string; maxDistance?: number; @@ -932,7 +904,7 @@ export interface GeoHaystackSearchOptions { limit?: number; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#geoNear */ export interface GeoNearOptions { readPreference?: ReadPreference | string; num?: number; @@ -945,37 +917,27 @@ export interface GeoNearOptions { includeLocs?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Code.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Code.html */ export class Code { constructor(code: string | Function, scope?: Object) code: string | Function; scope: any; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany -export interface CollectionOptions { - //The write concern. - w?: number | string; - //The write concern timeout. - wtimeout?: number; - //Specify a journal write concern. - j?: boolean; -} - -//http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/OrderedBulkOperation.html */ export interface OrderedBulkOperation { length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute + /** http://mongodb.github.io/node-mongodb-native/3.0/api/OrderedBulkOperation.html#execute */ execute(callback: MongoCallback): void; execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find + /** http://mongodb.github.io/node-mongodb-native/3.0/api/OrderedBulkOperation.html#find */ find(selector: Object): FindOperatorsOrdered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert + /** http://mongodb.github.io/node-mongodb-native/3.0/api/OrderedBulkOperation.html#insert */ insert(doc: Object): OrderedBulkOperation; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/BulkWriteResult.html */ export interface BulkWriteResult { ok: number; nInserted: number; @@ -996,7 +958,7 @@ export interface BulkWriteResult { hasWriteErrors(): boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/WriteError.html */ export interface WriteError { //Write concern error code. code: number; @@ -1006,7 +968,7 @@ export interface WriteError { errmsg: string; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/WriteConcernError.html */ export interface WriteConcernError { //Write concern error code. code: number; @@ -1014,7 +976,7 @@ export interface WriteConcernError { errmsg: string; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/FindOperatorsOrdered.html */ export interface FindOperatorsOrdered { delete(): OrderedBulkOperation; deleteOne(): OrderedBulkOperation; @@ -1024,21 +986,21 @@ export interface FindOperatorsOrdered { upsert(): FindOperatorsOrdered; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/UnorderedBulkOperation.html */ export interface UnorderedBulkOperation { - //http://mongodb.github.io/node-mongodb-native/2.1/api/lib_bulk_unordered.js.html line 339 + /** http://mongodb.github.io/node-mongodb-native/3.0/api/lib_bulk_unordered.js.html line 339 */ length: number; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute + /** http://mongodb.github.io/node-mongodb-native/3.0/api/UnorderedBulkOperation.html#execute */ execute(callback: MongoCallback): void; execute(options?: FSyncOptions): Promise; execute(options: FSyncOptions, callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find + /** http://mongodb.github.io/node-mongodb-native/3.0/api/UnorderedBulkOperation.html#find */ find(selector: Object): FindOperatorsUnordered; - //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert + /** http://mongodb.github.io/node-mongodb-native/3.0/api/UnorderedBulkOperation.html#insert */ insert(doc: Object): UnorderedBulkOperation; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/FindOperatorsUnordered.html */ export interface FindOperatorsUnordered { length: number; remove(): UnorderedBulkOperation; @@ -1049,7 +1011,7 @@ export interface FindOperatorsUnordered { upsert(): FindOperatorsUnordered; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#findOne */ export interface FindOneOptions { limit?: number, sort?: Array | Object, @@ -1073,7 +1035,7 @@ export interface FindOneOptions { maxTimeMs?: number } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~insertWriteOpResult */ export interface InsertWriteOpResult { insertedCount: number; ops: Array; @@ -1082,14 +1044,8 @@ export interface InsertWriteOpResult { result: { ok: number, n: number } } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne -export interface CollectionInsertOneOptions { - // The write concern. - w?: number | string; - // The write concern timeout. - wtimeout?: number; - // Specify a journal write concern. - j?: boolean; +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#insertOne */ +export interface CollectionInsertOneOptions extends CommonOptions { // Serialize functions on any object. serializeFunctions?: boolean; //Force server to assign _id values instead of driver. @@ -1098,7 +1054,7 @@ export interface CollectionInsertOneOptions { bypassDocumentValidation?: boolean } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~insertOneWriteOpResult */ export interface InsertOneWriteOpResult { insertedCount: number; ops: Array; @@ -1107,7 +1063,7 @@ export interface InsertOneWriteOpResult { result: { ok: number, n: number } } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#parallelCollectionScan */ export interface ParallelCollectionScanOptions { readPreference?: ReadPreference | string; batchSize?: number; @@ -1115,16 +1071,13 @@ export interface ParallelCollectionScanOptions { raw?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne -export interface ReplaceOneOptions { +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#replaceOne */ +export interface ReplaceOneOptions extends CommonOptions { upsert?: boolean; - w?: number | string; - wtimeout?: number; - j?: boolean; bypassDocumentValidation?: boolean; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~updateWriteOpResult */ export interface UpdateWriteOpResult { result: { ok: number, n: number, nModified: number }; connection: any; @@ -1134,12 +1087,12 @@ export interface UpdateWriteOpResult { upsertedId: { _id: ObjectID }; } -// https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L957 +/** https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L957 */ export interface ReplaceWriteOpResult extends UpdateWriteOpResult { ops: Array } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#mapReduce */ export interface MapReduceOptions { readPreference?: ReadPreference | string; out?: Object; @@ -1154,104 +1107,104 @@ export interface MapReduceOptions { bypassDocumentValidation?: boolean } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#~WriteOpResult */ export interface WriteOpResult { ops: Array; connection: any; result: any; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#~resultCallback */ export type CursorResult = any | void | boolean; type Default = any; -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html */ export class Cursor extends Readable { sortValue: string; timeout: boolean; readPreference: ReadPreference; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#addCursorFlag */ addCursorFlag(flag: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#addQueryModifier */ addQueryModifier(name: string, value: boolean): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#batchSize */ batchSize(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#clone */ clone(): Cursor; // still returns the same type - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#close */ close(): Promise; close(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#comment */ comment(value: string): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#count + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#count */ count(callback: MongoCallback): void; count(applySkipLimit: boolean, callback: MongoCallback): void; count(options: CursorCommentOptions, callback: MongoCallback): void; count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; count(applySkipLimit?: boolean, options?: CursorCommentOptions): Promise; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#explain */ explain(): Promise; explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#filter */ filter(filter: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#forEach */ forEach(iterator: IteratorCallback, callback: EndCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#hasNext */ hasNext(): Promise; hasNext(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#hint */ hint(hint: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#isClosed */ isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#limit */ limit(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#map */ map(transform: Function): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#max */ max(max: number): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#maxAwaitTimeMS */ maxAwaitTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#maxScan */ maxScan(maxScan: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#maxTimeMS */ maxTimeMS(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#min */ min(min: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#next */ next(): Promise; next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#project */ project(value: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#read */ read(size: number): string | Buffer | void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#next */ returnKey(returnKey: Object): Cursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#rewind */ rewind(): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#setCursorOption */ setCursorOption(field: string, value: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#setReadPreference */ setReadPreference(readPreference: string | ReadPreference): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#showRecordId */ showRecordId(showRecordId: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#skip */ skip(value: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#snapshot */ snapshot(snapshot: Object): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#sort */ sort(keyOrList: string | Object[] | Object, direction?: number): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#stream */ stream(options?: { transform?: Function }): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#toArray */ toArray(): Promise; toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift + /** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#unshift */ unshift(stream: Buffer | string): void; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#count */ export interface CursorCommentOptions { skip?: number; limit?: number; @@ -1260,123 +1213,123 @@ export interface CursorCommentOptions { readPreference?: ReadPreference | string; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#~iteratorCallback */ export interface IteratorCallback { (doc: T): void; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback +/** http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html#~endCallback */ export interface EndCallback { (error: MongoError): void; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback +/** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#~resultCallback */ export type AggregationCursorResult = any | void; -//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html */ export class AggregationCursor extends Readable { - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#batchSize */ batchSize(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#clone */ clone(): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#close */ close(): Promise; close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#each */ each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#explain */ explain(): Promise; explain(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#geoNear */ geoNear(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#group */ group(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#isClosed */ isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#limit */ limit(value: number): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#match */ match(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#maxTimeMS */ maxTimeMS(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#next */ next(): Promise; next(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#out */ out(destination: string): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#project */ project(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#read */ read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#redact */ redact(document: Object): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#rewind */ rewind(): AggregationCursor; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#setEncoding */ skip(value: number): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#sort */ sort(document: Object): AggregationCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#toArray */ toArray(): Promise; toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#unshift */ unshift(stream: Buffer | string): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind + /** http://mongodb.github.io/node-mongodb-native/3.0/api/AggregationCursor.html#unwind */ unwind(field: string): AggregationCursor; } -//http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html */ export class CommandCursor extends Readable { - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#batchSize */ batchSize(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#clone */ clone(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#close */ close(): Promise; close(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#each */ each(callback: MongoCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#isClosed */ isClosed(): boolean; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#maxTimeMS */ maxTimeMS(value: number): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#next */ next(): Promise; next(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#read */ read(size: number): string | Buffer | void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#rewind */ rewind(): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#setReadPreference */ setReadPreference(readPreference: string | ReadPreference): CommandCursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#toArray */ toArray(): Promise; toArray(callback: MongoCallback): void; - //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift + /** http://mongodb.github.io/node-mongodb-native/3.0/api/CommandCursor.html#unshift */ unshift(stream: Buffer | string): void; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html */ export class GridFSBucket { constructor(db: Db, options?: GridFSBucketOptions); - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#delete + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#delete */ delete(id: ObjectID, callback?: GridFSBucketErrorCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#drop + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#drop */ drop(callback?: GridFSBucketErrorCallback): void; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#find */ find(filter?: Object, options?: GridFSBucketFindOptions): Cursor; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStream + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openDownloadStream */ openDownloadStream(id: ObjectID, options?: { start: number, end: number }): GridFSBucketReadStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStreamByName + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openDownloadStreamByName */ openDownloadStreamByName(filename: string, options?: { revision: number, start: number, end: number }): GridFSBucketReadStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openUploadStream */ openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStreamWithId + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openUploadStreamWithId */ openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; - // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#rename + /** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#rename */ rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html +/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html */ export interface GridFSBucketOptions { bucketName?: string; chunkSizeBytes?: number; @@ -1384,12 +1337,12 @@ export interface GridFSBucketOptions { ReadPreference?: Object; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#~errorCallback +/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#~errorCallback */ export interface GridFSBucketErrorCallback { (err?: MongoError): void; } -// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find +/** http://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#find */ export interface GridFSBucketFindOptions { batchSize?: number; limit?: number; @@ -1399,7 +1352,7 @@ export interface GridFSBucketFindOptions { sort?: Object; } -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream +/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucket.html#openUploadStream */ export interface GridFSBucketOpenUploadStreamOptions { chunkSizeBytes?: number, metadata?: Object, @@ -1407,12 +1360,12 @@ export interface GridFSBucketOpenUploadStreamOptions { aliases?: Array } -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html +/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketReadStream.html */ export class GridFSBucketReadStream extends Readable { constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions); } -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html +/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketReadStream.html */ export interface GridFSBucketReadStreamOptions { sort?: number, skip?: number, @@ -1420,12 +1373,12 @@ export interface GridFSBucketReadStreamOptions { end?: number } -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html +/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketWriteStream.html */ export class GridFSBucketWriteStream extends Writable { constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions); } -// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html +/** https://mongodb.github.io/node-mongodb-native/3.0/api/GridFSBucketWriteStream.html */ export interface GridFSBucketWriteStreamOptions { id?: string | number | Object, chunkSizeBytes?: number, diff --git a/types/mongodb/mongodb-tests.ts b/types/mongodb/mongodb-tests.ts index 52f2d6e4f8..36428d786f 100644 --- a/types/mongodb/mongodb-tests.ts +++ b/types/mongodb/mongodb-tests.ts @@ -2,72 +2,72 @@ import mongodb = require('mongodb'); var MongoClient = mongodb.MongoClient; -var format = require('util').format; +var format = require('util').format; let options: mongodb.MongoClientOptions = { - authSource : ' ', - w : 1, - wtimeout : 300, - j : true, - bufferMaxEntries : 1000, - readPreference : 'ReadPreference | string', - promoteValues : {}, - pkFactory : {}, - poolSize : 1, + authSource: ' ', + w: 1, + wtimeout: 300, + j: true, + bufferMaxEntries: 1000, + readPreference: 'ReadPreference | string', + promoteValues: {}, + pkFactory: {}, + poolSize: 1, - socketOptions : {}, + socketOptions: {}, - reconnectTries : 123456, - reconnectInterval : 123456, + reconnectTries: 123456, + reconnectInterval: 123456, - ssl : true, - sslValidate : {}, - checkServerIdentity : function (){ }, - sslCA : ['str'], - sslCert : new Buffer(999), - sslKey : new Buffer(999), - sslPass : new Buffer(999) + ssl: true, + sslValidate: {}, + checkServerIdentity: function () { }, + sslCA: ['str'], + sslCert: new Buffer(999), + sslKey: new Buffer(999), + sslPass: new Buffer(999) } - MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function(err: mongodb.MongoError, db: mongodb.Db) { +MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function (err: mongodb.MongoError, client: mongodb.MongoClient) { if (err) throw err; - + const db = client.db('test'); var collection = db.collection('test_insert'); - collection.insertOne({ a: 2 }, function(err: mongodb.MongoError, docs: any) { + collection.insertOne({ a: 2 }, function (err: mongodb.MongoError, docs: any) { - collection.count(function(err: mongodb.MongoError, count: any) { + collection.count(function (err: mongodb.MongoError, count: any) { console.log(format("count = %s", count)); }); // Locate all the entries using find - collection.find({}).toArray(function(err: mongodb.MongoError, results: any) { + collection.find({}).toArray(function (err: mongodb.MongoError, results: any) { console.dir(results); // Let's close the db - db.close(); + client.close(); }); // Get some statistics - collection.stats(function(err: mongodb.MongoError, stats: any) { + collection.stats(function (err: mongodb.MongoError, stats: any) { console.log(stats.count + " documents"); }); // - collection.stats().then(function(stats){ + collection.stats().then(function (stats) { console.log(stats.wiredTiger.cache['bytes currently in the cache']); }) - collection.createIndex({}, {partialFilterExpression: {rating: {$exists: 1}}}) + collection.createIndex({}, { partialFilterExpression: { rating: { $exists: 1 } } }) }); { - let cursor: mongodb.Cursor; + let cursor: mongodb.Cursor; cursor = collection.find(); - cursor = cursor.addCursorFlag('',true); - cursor = cursor.addQueryModifier('',true); + cursor = cursor.addCursorFlag('', true); + cursor = cursor.addQueryModifier('', true); cursor = cursor.batchSize(1); cursor = cursor.comment(''); cursor = cursor.filter(1); cursor = cursor.hint({}); cursor = cursor.limit(1); - cursor = cursor.map(function (result) {}); + cursor = cursor.map(function (result) { }); cursor = cursor.max(1); cursor = cursor.min(1); cursor = cursor.maxAwaitTimeMS(1); @@ -75,7 +75,7 @@ let options: mongodb.MongoClientOptions = { cursor = cursor.maxTimeMS(1); cursor = cursor.project({}); cursor = cursor.returnKey({}); - cursor = cursor.setCursorOption('',{}); + cursor = cursor.setCursorOption('', {}); cursor = cursor.setReadPreference(''); cursor = cursor.showRecordId({}); cursor = cursor.skip(1); @@ -85,17 +85,17 @@ let options: mongodb.MongoClientOptions = { } // Collection .findM() & .agggregate() generic tests { - let bag : {cost: number, color: string}; - type bag = typeof bag; - let cursor: mongodb.Cursor = collection.find({color: 'black'}) - cursor.toArray(function (err,r) { r[0].cost} ); - cursor.forEach(function (bag ) { bag.color }, () => {}); - collection.findOne({ color: 'white' }).then(b => { let _b:bag = b; }) + let bag: { cost: number, color: string }; + type bag = typeof bag; + let cursor: mongodb.Cursor = collection.find({ color: 'black' }) + cursor.toArray(function (err, r) { r[0].cost }); + cursor.forEach(function (bag) { bag.color }, () => { }); + collection.findOne({ color: 'white' }).then(b => { let _b: bag = b; }) collection.findOne({ color: 'white' }).then(b => { b.cost; }) } { - let payment: {total: number}; - type payment = typeof payment; - let cursor: mongodb.AggregationCursor = collection.aggregate([{}]) + let payment: { total: number }; + type payment = typeof payment; + let cursor: mongodb.AggregationCursor = collection.aggregate([{}]) } }) diff --git a/types/mongodb/v2/index.d.ts b/types/mongodb/v2/index.d.ts new file mode 100644 index 0000000000..6cf21c04b9 --- /dev/null +++ b/types/mongodb/v2/index.d.ts @@ -0,0 +1,1435 @@ +// Type definitions for MongoDB v2.2 +// Project: https://github.com/mongodb/node-mongodb-native/tree/2.2 +// Definitions by: Federico Caselli +// Alan Marcell +// Gady Piazza +// Jason Dreyzehner +// Gaurav Lahoti +// Mariano Cortesi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// Documentation : http://mongodb.github.io/node-mongodb-native/2.2/api/ + +/// +/// + +import { ObjectID } from 'bson'; +import { EventEmitter } from 'events'; +import { Readable, Writable } from "stream"; + +export function connect(uri: string, options?: MongoClientOptions): Promise; +export function connect(uri: string, callback: MongoCallback): void; +export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + +export { Binary, Double, Long, Decimal128, MaxKey, MinKey, ObjectID, ObjectId, Timestamp, DBRef } from 'bson'; + +// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/MongoClient.html +export class MongoClient { + constructor(); + + static connect(uri: string, callback: MongoCallback): void; + static connect(uri: string, options?: MongoClientOptions): Promise; + static connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; + + connect(uri: string, callback: MongoCallback): void; + connect(uri: string, options?: MongoClientOptions): Promise; + connect(uri: string, options: MongoClientOptions, callback: MongoCallback): void; +} + +export interface MongoCallback { + (error: MongoError, result: T): void; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/MongoError.html +export class MongoError extends Error { + constructor(message: string); + static create(options: Object): MongoError; + code?: number; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#.connect +export interface MongoClientOptions extends + DbCreateOptions, + ServerOptions, + MongosOptions, + ReplSetOptions, + SocketOptions, + SSLOptions, + HighAvailabilityOptions { + // The logging level (error/warn/info/debug) + loggerLevel?: string; + // Custom logger object + logger?: Object; + // Default: false; + validateOptions?: Object; +} + +export interface SSLOptions { + // Default:5; Number of connections for each server instance + poolSize?: number; + // Use ssl connection (needs to have a mongod server with ssl support) + ssl?: boolean; + // Default: true; Validate mongod server certificate against ca (mongod server >=2.4 with ssl support required) + sslValidate?: Object; + // Default: true; Server identity checking during SSL + checkServerIdentity?: boolean | Function; + // Array of valid certificates either as Buffers or Strings + sslCA?: Array; + // SSL Certificate revocation list binary buffer + sslCRL?: Buffer; + // SSL Certificate binary buffer + sslCert?: Buffer | string; + // SSL Key file binary buffer + sslKey?: Buffer | string; + // SSL Certificate pass phrase + sslPass?: Buffer | string; + // String containing the server name requested via TLS SNI. + servername?: string; +} + +export interface HighAvailabilityOptions { + // Default: true; Turn on high availability monitoring. + ha?: boolean; + // Default: 10000; The High availability period for replicaset inquiry + haInterval?: number; + // Default: false; + domainsEnabled?: boolean; +} + +// See http://mongodb.github.io/node-mongodb-native/2.2/api/ReadPreference.html +export class ReadPreference { + constructor(mode: string, tags: Object); + mode: string; + tags: any; + options: { maxStalenessSeconds?: number }; // Max Secondary Read Stalleness in Seconds + static PRIMARY: string; + static PRIMARY_PREFERRED: string; + static SECONDARY: string; + static SECONDARY_PREFERRED: string; + static NEAREST: string; + isValid(mode: string): boolean; + static isValid(mode: string): boolean; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html +export interface DbCreateOptions { + + // If the database authentication is dependent on another databaseName. + authSource?: string; + // Default: null;https://docs.mongodb.com/manual/reference/write-concern/#write-concern + w?: number | string; + // The write concern timeout to finish (combining with w option). + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Default: false; Force server to create _id fields instead of client. + forceServerObjectId?: boolean; + // Default: false; Use c++ bson parser. + native_parser?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + // Specify if the BSON serializer should ignore undefined fields. + ignoreUndefined?: boolean; + // Return document results as raw BSON buffers. + raw?: boolean; + // Default: true; Promotes Long values to number if they fit inside the 53 bits resolution. + promoteLongs?: boolean; + // Default: -1 (unlimited); Amount of operations the driver buffers up untill discard any new ones + promoteBuffers?: number; + // the prefered read preference. use 'ReadPreference' class. + readPreference?: ReadPreference | string; + // Default: true; Promotes BSON values to native types where possible, set to false to only receive wrapper types. + promoteValues?: Object; + // Custom primary key factory to generate _id values (see Custom primary keys). + pkFactory?: Object; + // ES6 compatible promise constructor + promiseLibrary?: Object; + // https://docs.mongodb.com/manual/reference/read-concern/#read-concern + readConcern?: { level?: Object }; + // Sets a cap on how many operations the driver will buffer up before giving up on getting a + // working connection, default is -1 which is unlimited. + bufferMaxEntries?: number; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html +export interface SocketOptions { + // Reconnect on error. default:false + autoReconnect?: boolean; + // TCP Socket NoDelay option. default:true + noDelay?: boolean; + // TCP KeepAlive on the socket with a X ms delay before start. default:0 + keepAlive?: number; + // TCP Connection timeout setting. default 0 + connectTimeoutMS?: number; + // TCP Socket timeout setting. default 0 + socketTimeoutMS?: number; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/Server.html +export interface ServerOptions extends SSLOptions { + // Default: 30; + reconnectTries?: number; + // Default: 1000; + reconnectInterval?: number; + // Default: true; + monitoring?: boolean + socketOptions?: SocketOptions; + // Default: 10000; The High availability period for replicaset inquiry + haInterval?: number; + // Default: false; + domainsEnabled?: boolean; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/Mongos.html +export interface MongosOptions extends SSLOptions, HighAvailabilityOptions { + // Default: 15; Cutoff latency point in MS for MongoS proxy selection + acceptableLatencyMS?: number; + socketOptions?: SocketOptions; +} + +// http://mongodb.github.io/node-mongodb-native/2.2/api/ReplSet.html +export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions { + // The max staleness to secondary reads (values under 10 seconds cannot be guaranteed); + maxStalenessSeconds?: number; + // The name of the replicaset to connect to. + replicaSet?: string; + // Default: 15 ; Range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms) + secondaryAcceptableLatencyMS?: number; + connectWithNoPrimary?: boolean; + socketOptions?: SocketOptions; +} + +// Class documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html +export class Db extends EventEmitter { + constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions); + + serverConfig: Server | ReplSet | Mongos; + bufferMaxEntries: number; + databaseName: string; + options: any; + native_parser: boolean; + slaveOk: boolean; + writeConcern: any; + + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser + addUser(username: string, password: string, callback: MongoCallback): void; + addUser(username: string, password: string, options?: DbAddUserOptions): Promise; + addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#admin + admin(): Admin; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#authenticate + authenticate(userName: string, password: string, callback: MongoCallback): void; + authenticate(userName: string, password: string, options?: { authMechanism: string }): Promise; + authenticate(userName: string, password: string, options: { authMechanism: string }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#close + close(callback: MongoCallback): void; + close(forceClose?: boolean): Promise; + close(forceClose: boolean, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection + collection(name: string): Collection; + collection(name: string, callback: MongoCallback>): Collection; + collection(name: string, options: DbCollectionOptions, callback: MongoCallback>): Collection; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collections + collections(): Promise[]>; + collections(callback: MongoCallback[]>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#command + command(command: Object, callback: MongoCallback): void; + command(command: Object, options?: { readPreference: ReadPreference | string }): Promise; + command(command: Object, options: { readPreference: ReadPreference | string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createCollection + createCollection(name: string, callback: MongoCallback>): void; + createCollection(name: string, options?: CollectionCreateOptions): Promise>; + createCollection(name: string, options: CollectionCreateOptions, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#createIndex + createIndex(name: string, fieldOrSpec: string | Object, callback: MongoCallback): void; + createIndex(name: string, fieldOrSpec: string | Object, options?: IndexOptions): Promise; + createIndex(name: string, fieldOrSpec: string | Object, options: IndexOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#db + db(dbName: string): Db; + db(dbName: string, options: { noListener?: boolean, returnNonCachedInstance?: boolean }): Db; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropCollection + dropCollection(name: string): Promise; + dropCollection(name: string, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#dropDatabase + dropDatabase(): Promise; + dropDatabase(callback: MongoCallback): void; + + //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#ensureIndex + // ensureIndex(collectionName: any, fieldOrSpec: any, options: IndexOptions, callback: Function): void; + //deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#eval + // eval(code: any, parameters: any[], options?: any, callback?: MongoCallback): void; + + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#executeDbAdminCommand + executeDbAdminCommand(command: Object, callback: MongoCallback): void; + executeDbAdminCommand(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; + executeDbAdminCommand(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#indexInformation + indexInformation(name: string, callback: MongoCallback): void; + indexInformation(name: string, options?: { full?: boolean, readPreference?: ReadPreference | string }): Promise; + indexInformation(name: string, options: { full?: boolean, readPreference?: ReadPreference | string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#listCollections + listCollections(filter?: Object, options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#logout + logout(callback: MongoCallback): void; + logout(options?: { dbName?: string }): Promise; + logout(options: { dbName?: string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#open + open(): Promise; + open(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#removeUser + removeUser(username: string, callback: MongoCallback): void; + removeUser(username: string, options?: { w?: number | string, wtimeout?: number, j?: boolean }): Promise; + removeUser(username: string, options: { w?: number | string, wtimeout?: number, j?: boolean }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#renameCollection + renameCollection(fromCollection: string, toCollection: string, callback: MongoCallback>): void; + renameCollection(fromCollection: string, toCollection: string, options?: { dropTarget?: boolean }): Promise>; + renameCollection(fromCollection: string, toCollection: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#stats + stats(callback: MongoCallback): void; + stats(options?: { scale?: number }): Promise; + stats(options: { scale?: number }, callback: MongoCallback): void; +} + +// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html +export class Server extends EventEmitter { + constructor(host: string, port: number, options?: ServerOptions); + + connections(): Array; +} + +// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html +export class ReplSet extends EventEmitter { + constructor(servers: Array, options?: ReplSetOptions); + + connections(): Array; +} + +// Deprecated http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html +export class Mongos extends EventEmitter { + constructor(servers: Array, options?: MongosOptions); + + connections(): Array; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#addUser +export interface DbAddUserOptions { + w?: string | number; + wtimeout?: number; + j?: boolean; + customData?: Object; + roles?: Object[]; +} + +//http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection +export interface CollectionCreateOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + raw?: boolean; + pkFactory?: Object; + readPreference?: ReadPreference | string; + serializeFunctions?: boolean; + strict?: boolean; + capped?: boolean; + autoIndexId?: boolean; + size?: number; + max?: number; + flags?: number; + storageEngine?: object; + validator?: object; + validationLevel?: "off" | "strict" | "moderate"; + validationAction?: "error" | "warn"; + indexOptionDefaults?: object; + viewOn?: string; + pipeline?: any[]; + collation?: object; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html#collection +export interface DbCollectionOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + raw?: boolean; + pkFactory?: Object; + readPreference?: ReadPreference | string; + serializeFunctions?: boolean; + strict?: boolean; + readConcern?: { level: Object }; +} + +//http://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createIndex +export interface IndexOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Creates an unique index. + unique?: boolean; + // Creates a sparse index. + sparse?: boolean; + // Creates the index in the background, yielding whenever possible. + background?: boolean; + // A unique index cannot be created on a key that has pre-existing duplicate values. + // If you would like to create the index anyway, keeping the first document the database indexes and + // deleting all subsequent documents that have duplicate value + dropDups?: boolean; + // For geo spatial indexes set the lower bound for the co-ordinates. + min?: number; + // For geo spatial indexes set the high bound for the co-ordinates. + max?: number; + // Specify the format version of the indexes. + v?: number; + // Allows you to expire data on indexes applied to a data (MongoDB 2.2 or higher) + expireAfterSeconds?: number; + // Override the auto generated index name (useful if the resulting name is larger than 128 bytes) + name?: string; + // Creates a partial index based on the given filter object (MongoDB 3.2 or higher) + partialFilterExpression?: any; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html +export interface Admin { + // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser + addUser(username: string, password: string, callback: MongoCallback): void; + addUser(username: string, password: string, options?: AddUserOptions): Promise; + addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#authenticate + authenticate(username: string, callback: MongoCallback): void; + authenticate(username: string, password?: string): Promise; + authenticate(username: string, password: string, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#buildInfo + buildInfo(): Promise; + buildInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#command + command(command: Object, callback: MongoCallback): void; + command(command: Object, options?: { readPreference?: ReadPreference | string, maxTimeMS?: number }): Promise; + command(command: Object, options: { readPreference?: ReadPreference | string, maxTimeMS?: number }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#listDatabases + listDatabases(): Promise; + listDatabases(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#logout + logout(): Promise; + logout(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#ping + ping(): Promise; + ping(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingInfo + profilingInfo(): Promise; + profilingInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#profilingLevel + profilingLevel(): Promise; + profilingLevel(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser + removeUser(username: string, callback: MongoCallback): void; + removeUser(username: string, options?: FSyncOptions): Promise; + removeUser(username: string, options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#replSetGetStatus + replSetGetStatus(): Promise; + replSetGetStatus(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverInfo + serverInfo(): Promise; + serverInfo(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#serverStatus + serverStatus(): Promise; + serverStatus(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#setProfilingLevel + setProfilingLevel(level: string): Promise; + setProfilingLevel(level: string, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#validateCollection + validateCollection(collectionNme: string, callback: MongoCallback): void; + validateCollection(collectionNme: string, options?: Object): Promise; + validateCollection(collectionNme: string, options: Object, callback: MongoCallback): void; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#addUser +export interface AddUserOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + fsync: boolean; + customData?: Object; + roles?: Object[] +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Admin.html#removeUser +export interface FSyncOptions { + w?: number | string; + wtimeout?: number; + j?: boolean; + fsync?: boolean +} + +// Documentation : http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html +export interface Collection { + // Get the collection name. + collectionName: string; + // Get the full collection namespace. + namespace: string; + // The current write concern values. + writeConcern: any; + // The current read concern values. + readConcern: any; + // Get current index hint for collection. + hint: any; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate + aggregate(pipeline: Object[], callback: MongoCallback): AggregationCursor; + aggregate(pipeline: Object[], options?: CollectionAggregationOptions, callback?: MongoCallback): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite + bulkWrite(operations: Object[], callback: MongoCallback): void; + bulkWrite(operations: Object[], options?: CollectionBluckWriteOptions): Promise; + bulkWrite(operations: Object[], options: CollectionBluckWriteOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#count + count(query: Object, callback: MongoCallback): void; + count(query: Object, options?: MongoCountPreferences): Promise; + count(query: Object, options: MongoCountPreferences, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndex + createIndex(fieldOrSpec: string | any, callback: MongoCallback): void; + createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise; + createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes and http://docs.mongodb.org/manual/reference/command/createIndexes/ + createIndexes(indexSpecs: Object[]): Promise; + createIndexes(indexSpecs: Object[], callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany + deleteMany(filter: Object, callback: MongoCallback): void; + deleteMany(filter: Object, options?: CollectionOptions): Promise; + deleteMany(filter: Object, options: CollectionOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteOne + deleteOne(filter: Object, callback: MongoCallback): void; + deleteOne(filter: Object, options?: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }): Promise; + deleteOne(filter: Object, options: { w?: number | string, wtimmeout?: number, j?: boolean, bypassDocumentValidation?: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#distinct + distinct(key: string, query: Object, callback: MongoCallback): void; + distinct(key: string, query: Object, options?: { readPreference?: ReadPreference | string }): Promise; + distinct(key: string, query: Object, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#drop + drop(): Promise; + drop(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndex + dropIndex(indexName: string, callback: MongoCallback): void; + dropIndex(indexName: string, options?: CollectionOptions): Promise; + dropIndex(indexName: string, options: CollectionOptions, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#dropIndexes + dropIndexes(): Promise; + dropIndexes(callback?: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#find + find(query?: Object): Cursor; + /** @deprecated */ + find(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne + findOne(filter: Object, callback: MongoCallback): void; + findOne(filter: Object, options?: FindOneOptions): Promise; + findOne(filter: Object, options: FindOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete + findOneAndDelete(filter: Object, callback: MongoCallback>): void; + findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise>; + findOneAndDelete(filter: Object, options: { projection?: Object, sort?: Object, maxTimeMS?: number }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace + findOneAndReplace(filter: Object, replacement: Object, callback: MongoCallback>): void; + findOneAndReplace(filter: Object, replacement: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndReplace(filter: Object, replacement: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndUpdate + findOneAndUpdate(filter: Object, update: Object, callback: MongoCallback>): void; + findOneAndUpdate(filter: Object, update: Object, options?: FindOneAndReplaceOption): Promise>; + findOneAndUpdate(filter: Object, update: Object, options: FindOneAndReplaceOption, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch + geoHaystackSearch(x: number, y: number, callback: MongoCallback): void; + geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise; + geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear + geoNear(x: number, y: number, callback: MongoCallback): void; + geoNear(x: number, y: number, options?: GeoNearOptions): Promise; + geoNear(x: number, y: number, options: GeoNearOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#group + group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, callback: MongoCallback): void; + group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string }): Promise; + group(keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options: { readPreference?: ReadPreference | string }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexes + indexes(): Promise; + indexes(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexExists + indexExists(indexes: string | string[]): Promise; + indexExists(indexes: string | string[], callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#indexInformation + indexInformation(callback: MongoCallback): void; + indexInformation(options?: { full: boolean }): Promise; + indexInformation(options: { full: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp + initializeOrderedBulkOp(options?: CollectionOptions): OrderedBulkOperation; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp + initializeUnorderedBulkOp(options?: CollectionOptions): UnorderedBulkOperation; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, callback: MongoCallback): void; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options?: CollectionInsertOneOptions): Promise; + /** @deprecated Use insertOne, insertMany or bulkWrite */ + insert(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany + insertMany(docs: Object[], callback: MongoCallback): void; + insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise; + insertMany(docs: Object[], options: CollectionInsertManyOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne + insertOne(docs: Object, callback: MongoCallback): void; + insertOne(docs: Object, options?: CollectionInsertOneOptions): Promise; + insertOne(docs: Object, options: CollectionInsertOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#isCapped + isCapped(): Promise; + isCapped(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#listIndexes + listIndexes(options?: { batchSize?: number, readPreference?: ReadPreference | string }): CommandCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce + mapReduce(map: Function | string, reduce: Function | string, callback: MongoCallback): void; + mapReduce(map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; + mapReduce(map: Function | string, reduce: Function | string, options: MapReduceOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#options + options(): Promise; + options(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan + parallelCollectionScan(callback: MongoCallback[]>): void; + parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise[]>; + parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback[]>): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#reIndex + reIndex(): Promise; + reIndex(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#remove + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, callback: MongoCallback): void; + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, options?: CollectionOptions & { single?: boolean }): Promise; + /** @deprecated Use use deleteOne, deleteMany or bulkWrite */ + remove(selector: Object, options?: CollectionOptions & { single?: boolean }, callback?: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#rename + rename(newName: string, callback: MongoCallback>): void; + rename(newName: string, options?: { dropTarget?: boolean }): Promise>; + rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; + //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne + replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; + replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; + replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, callback: MongoCallback): void; + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, options?: CollectionOptions): Promise; + /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ + save(doc: Object, options: CollectionOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#stats + stats(callback: MongoCallback): void; + stats(options?: { scale: number }): Promise; + stats(options: { scale: number }, callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#update + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, callback: MongoCallback): void; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options?: ReplaceOneOptions & { multi?: boolean }): Promise; + /** @deprecated use updateOne, updateMany or bulkWrite */ + update(filter: Object, update: Object, options: ReplaceOneOptions & { multi?: boolean }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateMany + updateMany(filter: Object, update: Object, callback: MongoCallback): void; + updateMany(filter: Object, update: Object, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; + updateMany(filter: Object, update: Object, options: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#updateOne + updateOne(filter: Object, update: Object, callback: MongoCallback): void; + updateOne(filter: Object, update: Object, options?: ReplaceOneOptions): Promise; + updateOne(filter: Object, update: Object, options: ReplaceOneOptions, callback: MongoCallback): void; +} + +// Documentation: http://docs.mongodb.org/manual/reference/command/collStats/ +export interface CollStats { + // Namespace. + ns: string; + // Number of documents. + count: number; + // Collection size in bytes. + size: number; + // Average object size in bytes. + avgObjSize: number; + // (Pre)allocated space for the collection in bytes. + storageSize: number; + // Number of extents (contiguously allocated chunks of datafile space). + numExtents: number; + // Number of indexes. + nindexes: number; + // Size of the most recently created extent in bytes. + lastExtentSize: number; + // Padding can speed up updates if documents grow. + paddingFactor: number; + // A number that indicates the user-set flags on the collection. userFlags only appears when using the mmapv1 storage engine. + userFlags?: number; + // Total index size in bytes. + totalIndexSize: number; + // Size of specific indexes in bytes. + indexSizes: { + _id_: number; + [index: string]: number; + }; + // `true` if the collection is capped. + capped: boolean; + // The maximum number of documents that may be present in a capped collection. + max: number; + // The maximum size of a capped collection. + maxSize: number; + wiredTiger?: WiredTigerData; + indexDetails?: any; + ok: number; +} + +export interface WiredTigerData { + LSM: { + 'bloom filter false positives': number, + 'bloom filter hits': number; + 'bloom filter misses': number; + 'bloom filter pages evicted from cache': number; + 'bloom filter pages read into cache': number; + 'bloom filters in the LSM tree': number; + 'chunks in the LSM tree': number; + 'highest merge generation in the LSM tree': number; + 'queries that could have benefited from a Bloom filter that did not exist': number; + 'sleep for LSM checkpoint throttle': number; + 'sleep for LSM merge throttle': number; + 'total size of bloom filters': number; + }; + 'block-manager': { + 'allocations requiring file extension': number; + 'blocks allocated': number; + 'blocks freed': number; + 'checkpoint size': number; + 'file allocation unit size': number; + 'file bytes available for reuse': number; + 'file magic number': number; + 'file major version number': number; + 'file size in bytes': number; + 'minor version number': number; + }; + btree: { + 'btree checkpoint generation': number; + 'column-store fixed-size leaf pages': number; + 'column-store internal pages': number; + 'column-store variable-size RLE encoded values': number; + 'column-store variable-size deleted values': number; + 'column-store variable-size leaf pages': number; + 'fixed-record size': number; + 'maximum internal page key size': number; + 'maximum internal page size': number; + 'maximum leaf page key size': number; + 'maximum leaf page size': number; + 'maximum leaf page value size': number; + 'maximum tree depth': number; + 'number of key/value pairs': number; + 'overflow pages': number; + 'pages rewritten by compaction': number; + 'row-store internal pages': number; + 'row-store leaf pages': number; + }; + cache: { + 'bytes currently in the cache': number; + 'bytes read into cache': number; + 'bytes written from cache': number; + 'checkpoint blocked page eviction': number; + 'data source pages selected for eviction unable to be evicted': number; + 'hazard pointer blocked page eviction': number; + 'in-memory page passed criteria to be split': number; + 'in-memory page splits': number; + 'internal pages evicted': number; + 'internal pages split during eviction': number; + 'leaf pages split during eviction': number; + 'modified pages evicted': number; + 'overflow pages read into cache': number; + 'overflow values cached in memory': number; + 'page split during eviction deepened the tree': number; + 'page written requiring lookaside records': number; + 'pages read into cache': number; + 'pages read into cache requiring lookaside entries': number; + 'pages requested from the cache': number; + 'pages written from cache': number; + 'pages written requiring in-memory restoration': number; + 'tracked dirty bytes in the cache': number; + 'unmodified pages evicted': number; + }; + cache_walk: { + 'Average difference between current eviction generation when the page was last considered': number; + 'Average on-disk page image size seen': number; + 'Clean pages currently in cache': number; + 'Current eviction generation': number; + 'Dirty pages currently in cache': number; + 'Entries in the root page': number; + 'Internal pages currently in cache': number; + 'Leaf pages currently in cache': number; + 'Maximum difference between current eviction generation when the page was last considered': number; + 'Maximum page size seen': number; + 'Minimum on-disk page image size seen': number; + 'On-disk page image sizes smaller than a single allocation unit': number; + 'Pages created in memory and never written': number; + 'Pages currently queued for eviction': number; + 'Pages that could not be queued for eviction': number; + 'Refs skipped during cache traversal': number; + 'Size of the root page': number; + 'Total number of pages currently in cache': number; + }; + compression: { + 'compressed pages read': number; + 'compressed pages written': number; + 'page written failed to compress': number; + 'page written was too small to compress': number; + 'raw compression call failed, additional data available': number; + 'raw compression call failed, no additional data available': number; + 'raw compression call succeeded': number; + }; + cursor: { + 'bulk-loaded cursor-insert calls': number; + 'create calls': number; + 'cursor-insert key and value bytes inserted': number; + 'cursor-remove key bytes removed': number; + 'cursor-update value bytes updated': number; + 'insert calls': number; + 'next calls': number; + 'prev calls': number; + 'remove calls': number; + 'reset calls': number; + 'restarted searches': number; + 'search calls': number; + 'search near calls': number; + 'truncate calls': number; + 'update calls': number; + }; + reconciliation: { + 'dictionary matches': number; + 'fast-path pages deleted': number; + 'internal page key bytes discarded using suffix compression': number; + 'internal page multi-block writes': number; + 'internal-page overflow keys': number; + 'leaf page key bytes discarded using prefix compression': number; + 'leaf page multi-block writes': number; + 'leaf-page overflow keys': number; + 'maximum blocks required for a page': number; + 'overflow values written': number; + 'page checksum matches': number; + 'page reconciliation calls': number; + 'page reconciliation calls for eviction': number; + 'pages deleted': number; + }; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#aggregate +export interface CollectionAggregationOptions { + readPreference?: ReadPreference | string; + // Return the query as cursor, on 2.6 > it returns as a real cursor + // on pre 2.6 it returns as an emulated cursor. + cursor?: { batchSize: number }; + // Explain returns the aggregation execution plan (requires mongodb 2.6 >). + explain?: boolean; + // lets the server know if it can use disk to store + // temporary results for the aggregation (requires mongodb 2.6 >). + allowDiskUse?: boolean; + // specifies a cumulative time limit in milliseconds for processing operations + // on the cursor. MongoDB interrupts the operation at the earliest following interrupt point. + maxTimeMS?: number; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany +export interface CollectionInsertManyOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + //Force server to assign _id values instead of driver. + forceServerObjectId?: boolean; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; + // If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. + ordered?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#bulkWrite +export interface CollectionBluckWriteOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + // Execute write operation in ordered or unordered fashion. + ordered?: boolean; + // Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~BulkWriteOpResult +export interface BulkWriteOpResultObject { + insertedCount?: number; + matchedCount?: number; + modifiedCount?: number; + deletedCount?: number; + upsertedCount?: number; + insertedIds?: any; + upsertedIds?: any; + result?: any; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#count +export interface MongoCountPreferences { + // The limit of documents to count. + limit?: number; + // The number of documents to skip for the count. + skip?: boolean; + // An index name hint for the query. + hint?: string; + // The preferred read preference + readPreference?: ReadPreference | string; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~deleteWriteOpResult +export interface DeleteWriteOpResultObject { + //The raw result returned from MongoDB, field will vary depending on server version. + result: { + //Is 1 if the command executed correctly. + ok?: number; + //The total count of documents deleted. + n?: number; + } + //The connection object used for the operation. + connection?: any; + //The number of documents deleted. + deletedCount?: number; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~findAndModifyWriteOpResult +export interface FindAndModifyWriteOpResultObject { + //Document returned from findAndModify command. + value?: TSchema; + //The raw lastErrorObject returned from the command. + lastErrorObject?: any; + //Is 1 if the command executed correctly. + ok?: number; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndReplace +export interface FindOneAndReplaceOption { + projection?: Object; + sort?: Object; + maxTimeMS?: number; + upsert?: boolean; + returnOriginal?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoHaystackSearch +export interface GeoHaystackSearchOptions { + readPreference?: ReadPreference | string; + maxDistance?: number; + search?: Object; + limit?: number; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#geoNear +export interface GeoNearOptions { + readPreference?: ReadPreference | string; + num?: number; + minDistance?: number; + maxDistance?: number; + distanceMultiplier?: number; + query?: Object; + spherical?: boolean; + uniqueDocs?: boolean; + includeLocs?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Code.html +export class Code { + constructor(code: string | Function, scope?: Object) + code: string | Function; + scope: any; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#deleteMany +export interface CollectionOptions { + //The write concern. + w?: number | string; + //The write concern timeout. + wtimeout?: number; + //Specify a journal write concern. + j?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html +export interface OrderedBulkOperation { + length: number; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#execute + execute(callback: MongoCallback): void; + execute(options?: FSyncOptions): Promise; + execute(options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#find + find(selector: Object): FindOperatorsOrdered; + //http://mongodb.github.io/node-mongodb-native/2.1/api/OrderedBulkOperation.html#insert + insert(doc: Object): OrderedBulkOperation; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/BulkWriteResult.html +export interface BulkWriteResult { + ok: number; + nInserted: number; + nUpdated: number; + nUpserted: number; + nModified: number; + nRemoved: number; + + getInsertedIds(): Array; + getLastOp(): Object; + getRawResponse(): Object; + getUpsertedIdAt(index: number): Object; + getUpsertedIds(): Array; + getWriteConcernError(): WriteConcernError; + getWriteErrorAt(index: number): WriteError; + getWriteErrorCount(): number; + getWriteErrors(): Array; + hasWriteErrors(): boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteError.html +export interface WriteError { + //Write concern error code. + code: number; + //Write concern error original bulk operation index. + index: number; + //Write concern error message. + errmsg: string; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/WriteConcernError.html +export interface WriteConcernError { + //Write concern error code. + code: number; + //Write concern error message. + errmsg: string; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsOrdered.html +export interface FindOperatorsOrdered { + delete(): OrderedBulkOperation; + deleteOne(): OrderedBulkOperation; + replaceOne(doc: Object): OrderedBulkOperation; + update(doc: Object): OrderedBulkOperation; + updateOne(doc: Object): OrderedBulkOperation; + upsert(): FindOperatorsOrdered; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html +export interface UnorderedBulkOperation { + //http://mongodb.github.io/node-mongodb-native/2.1/api/lib_bulk_unordered.js.html line 339 + length: number; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#execute + execute(callback: MongoCallback): void; + execute(options?: FSyncOptions): Promise; + execute(options: FSyncOptions, callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#find + find(selector: Object): FindOperatorsUnordered; + //http://mongodb.github.io/node-mongodb-native/2.1/api/UnorderedBulkOperation.html#insert + insert(doc: Object): UnorderedBulkOperation; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/FindOperatorsUnordered.html +export interface FindOperatorsUnordered { + length: number; + remove(): UnorderedBulkOperation; + removeOne(): UnorderedBulkOperation; + replaceOne(doc: Object): UnorderedBulkOperation; + update(doc: Object): UnorderedBulkOperation; + updateOne(doc: Object): UnorderedBulkOperation; + upsert(): FindOperatorsUnordered; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne +export interface FindOneOptions { + limit?: number, + sort?: Array | Object, + fields?: Object, + skip?: number, + hint?: Object, + explain?: boolean, + snapshot?: boolean, + timeout?: boolean, + tailable?: boolean, + batchSize?: number, + returnKey?: boolean, + maxScan?: number, + min?: number, + max?: number, + showDiskLoc?: boolean, + comment?: string, + raw?: boolean, + readPreference?: ReadPreference | string, + partial?: boolean, + maxTimeMs?: number +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertWriteOpResult +export interface InsertWriteOpResult { + insertedCount: number; + ops: Array; + insertedIds: Array; + connection: any; + result: { ok: number, n: number } +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertOne +export interface CollectionInsertOneOptions { + // The write concern. + w?: number | string; + // The write concern timeout. + wtimeout?: number; + // Specify a journal write concern. + j?: boolean; + // Serialize functions on any object. + serializeFunctions?: boolean; + //Force server to assign _id values instead of driver. + forceServerObjectId?: boolean; + //Allow driver to bypass schema validation in MongoDB 3.2 or higher. + bypassDocumentValidation?: boolean +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~insertOneWriteOpResult +export interface InsertOneWriteOpResult { + insertedCount: number; + ops: Array; + insertedId: ObjectID; + connection: any; + result: { ok: number, n: number } +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#parallelCollectionScan +export interface ParallelCollectionScanOptions { + readPreference?: ReadPreference | string; + batchSize?: number; + numCursors?: number; + raw?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#replaceOne +export interface ReplaceOneOptions { + upsert?: boolean; + w?: number | string; + wtimeout?: number; + j?: boolean; + bypassDocumentValidation?: boolean; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~updateWriteOpResult +export interface UpdateWriteOpResult { + result: { ok: number, n: number, nModified: number }; + connection: any; + matchedCount: number; + modifiedCount: number; + upsertedCount: number; + upsertedId: { _id: ObjectID }; +} + +// https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L957 +export interface ReplaceWriteOpResult extends UpdateWriteOpResult { + ops: Array +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce +export interface MapReduceOptions { + readPreference?: ReadPreference | string; + out?: Object; + query?: Object; + sort?: Object; + limit?: number; + keeptemp?: boolean; + finalize?: Function | string; + scope?: Object; + jsMode?: boolean; + verbose?: boolean; + bypassDocumentValidation?: boolean +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#~WriteOpResult +export interface WriteOpResult { + ops: Array; + connection: any; + result: any; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~resultCallback +export type CursorResult = any | void | boolean; + +type Default = any; + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html +export class Cursor extends Readable { + + sortValue: string; + timeout: boolean; + readPreference: ReadPreference; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addCursorFlag + addCursorFlag(flag: string, value: boolean): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#addQueryModifier + addQueryModifier(name: string, value: boolean): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#batchSize + batchSize(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#clone + clone(): Cursor; // still returns the same type + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#comment + comment(value: string): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.2/api/Cursor.html#count + count(callback: MongoCallback): void; + count(applySkipLimit: boolean, callback: MongoCallback): void; + count(options: CursorCommentOptions, callback: MongoCallback): void; + count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback): void; + count(applySkipLimit?: boolean, options?: CursorCommentOptions): Promise; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#explain + explain(): Promise; + explain(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#filter + filter(filter: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#forEach + forEach(iterator: IteratorCallback, callback: EndCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hasNext + hasNext(): Promise; + hasNext(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#hint + hint(hint: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#limit + limit(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#map + map(transform: Function): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#max + max(max: number): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxAwaitTimeMS + maxAwaitTimeMS(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxScan + maxScan(maxScan: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#maxTimeMS + maxTimeMS(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#min + min(min: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#project + project(value: Object): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#read + read(size: number): string | Buffer | void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#next + returnKey(returnKey: Object): Cursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#rewind + rewind(): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setCursorOption + setCursorOption(field: string, value: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#setReadPreference + setReadPreference(readPreference: string | ReadPreference): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#showRecordId + showRecordId(showRecordId: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#skip + skip(value: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#snapshot + snapshot(snapshot: Object): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#sort + sort(keyOrList: string | Object[] | Object, direction?: number): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#stream + stream(options?: { transform?: Function }): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift + unshift(stream: Buffer | string): void; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#count +export interface CursorCommentOptions { + skip?: number; + limit?: number; + maxTimeMS?: number; + hint?: string; + readPreference?: ReadPreference | string; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~iteratorCallback +export interface IteratorCallback { + (doc: T): void; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#~endCallback +export interface EndCallback { + (error: MongoError): void; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#~resultCallback +export type AggregationCursorResult = any | void; +//http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html +export class AggregationCursor extends Readable { + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#batchSize + batchSize(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#clone + clone(): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#each + each(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#explain + explain(): Promise; + explain(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#geoNear + geoNear(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#group + group(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#limit + limit(value: number): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#match + match(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#maxTimeMS + maxTimeMS(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#out + out(destination: string): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#project + project(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#read + read(size: number): string | Buffer | void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#redact + redact(document: Object): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#rewind + rewind(): AggregationCursor; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#setEncoding + skip(value: number): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort + sort(document: Object): AggregationCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unshift + unshift(stream: Buffer | string): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unwind + unwind(field: string): AggregationCursor; +} + +//http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html +export class CommandCursor extends Readable { + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#batchSize + batchSize(value: number): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#clone + clone(): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#close + close(): Promise; + close(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#each + each(callback: MongoCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#isClosed + isClosed(): boolean; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#maxTimeMS + maxTimeMS(value: number): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#next + next(): Promise; + next(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#read + read(size: number): string | Buffer | void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#rewind + rewind(): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#setReadPreference + setReadPreference(readPreference: string | ReadPreference): CommandCursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#toArray + toArray(): Promise; + toArray(callback: MongoCallback): void; + //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift + unshift(stream: Buffer | string): void; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html +export class GridFSBucket { + constructor(db: Db, options?: GridFSBucketOptions); + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#delete + delete(id: ObjectID, callback?: GridFSBucketErrorCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#drop + drop(callback?: GridFSBucketErrorCallback): void; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find + find(filter?: Object, options?: GridFSBucketFindOptions): Cursor; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStream + openDownloadStream(id: ObjectID, options?: { start: number, end: number }): GridFSBucketReadStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openDownloadStreamByName + openDownloadStreamByName(filename: string, options?: { revision: number, start: number, end: number }): GridFSBucketReadStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream + openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStreamWithId + openUploadStreamWithId(id: string | number | Object, filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream; + // http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#rename + rename(id: ObjectID, filename: string, callback?: GridFSBucketErrorCallback): void; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html +export interface GridFSBucketOptions { + bucketName?: string; + chunkSizeBytes?: number; + writeConcern?: Object; + ReadPreference?: Object; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#~errorCallback +export interface GridFSBucketErrorCallback { + (err?: MongoError): void; +} + +// http://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#find +export interface GridFSBucketFindOptions { + batchSize?: number; + limit?: number; + maxTimeMS?: number; + noCursorTimeout?: boolean; + skip?: number; + sort?: Object; +} + +// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucket.html#openUploadStream +export interface GridFSBucketOpenUploadStreamOptions { + chunkSizeBytes?: number, + metadata?: Object, + contentType?: string, + aliases?: Array +} + +// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html +export class GridFSBucketReadStream extends Readable { + constructor(chunks: Collection, files: Collection, readPreference: Object, filter: Object, options?: GridFSBucketReadStreamOptions); +} + +// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketReadStream.html +export interface GridFSBucketReadStreamOptions { + sort?: number, + skip?: number, + start?: number, + end?: number +} + +// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html +export class GridFSBucketWriteStream extends Writable { + constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions); +} + +// https://mongodb.github.io/node-mongodb-native/2.1/api/GridFSBucketWriteStream.html +export interface GridFSBucketWriteStreamOptions { + id?: string | number | Object, + chunkSizeBytes?: number, + w?: number, + wtimeout?: number, + j?: number +} diff --git a/types/mongodb/v2/mongodb-tests.ts b/types/mongodb/v2/mongodb-tests.ts new file mode 100644 index 0000000000..52f2d6e4f8 --- /dev/null +++ b/types/mongodb/v2/mongodb-tests.ts @@ -0,0 +1,101 @@ +// Test source : https://github.com/mongodb/node-mongodb-native +import mongodb = require('mongodb'); +var MongoClient = mongodb.MongoClient; + +var format = require('util').format; +let options: mongodb.MongoClientOptions = { + authSource : ' ', + w : 1, + wtimeout : 300, + j : true, + bufferMaxEntries : 1000, + readPreference : 'ReadPreference | string', + promoteValues : {}, + pkFactory : {}, + poolSize : 1, + + socketOptions : {}, + + reconnectTries : 123456, + reconnectInterval : 123456, + + ssl : true, + sslValidate : {}, + checkServerIdentity : function (){ }, + sslCA : ['str'], + sslCert : new Buffer(999), + sslKey : new Buffer(999), + sslPass : new Buffer(999) +} + MongoClient.connect('mongodb://127.0.0.1:27017/test', options, function(err: mongodb.MongoError, db: mongodb.Db) { + if (err) throw err; + + var collection = db.collection('test_insert'); + collection.insertOne({ a: 2 }, function(err: mongodb.MongoError, docs: any) { + + collection.count(function(err: mongodb.MongoError, count: any) { + console.log(format("count = %s", count)); + }); + + // Locate all the entries using find + collection.find({}).toArray(function(err: mongodb.MongoError, results: any) { + console.dir(results); + // Let's close the db + db.close(); + }); + + // Get some statistics + collection.stats(function(err: mongodb.MongoError, stats: any) { + console.log(stats.count + " documents"); + }); + + // + collection.stats().then(function(stats){ + console.log(stats.wiredTiger.cache['bytes currently in the cache']); + }) + + collection.createIndex({}, {partialFilterExpression: {rating: {$exists: 1}}}) + }); + + { + let cursor: mongodb.Cursor; + cursor = collection.find(); + cursor = cursor.addCursorFlag('',true); + cursor = cursor.addQueryModifier('',true); + cursor = cursor.batchSize(1); + cursor = cursor.comment(''); + cursor = cursor.filter(1); + cursor = cursor.hint({}); + cursor = cursor.limit(1); + cursor = cursor.map(function (result) {}); + cursor = cursor.max(1); + cursor = cursor.min(1); + cursor = cursor.maxAwaitTimeMS(1); + cursor = cursor.maxScan({}); + cursor = cursor.maxTimeMS(1); + cursor = cursor.project({}); + cursor = cursor.returnKey({}); + cursor = cursor.setCursorOption('',{}); + cursor = cursor.setReadPreference(''); + cursor = cursor.showRecordId({}); + cursor = cursor.skip(1); + cursor = cursor.snapshot({}); + cursor = cursor.sort({}); + cursor = cursor.stream(); + } + // Collection .findM() & .agggregate() generic tests + { + let bag : {cost: number, color: string}; + type bag = typeof bag; + let cursor: mongodb.Cursor = collection.find({color: 'black'}) + cursor.toArray(function (err,r) { r[0].cost} ); + cursor.forEach(function (bag ) { bag.color }, () => {}); + collection.findOne({ color: 'white' }).then(b => { let _b:bag = b; }) + collection.findOne({ color: 'white' }).then(b => { b.cost; }) + } + { + let payment: {total: number}; + type payment = typeof payment; + let cursor: mongodb.AggregationCursor = collection.aggregate([{}]) + } +}) diff --git a/types/mongodb/v2/tsconfig.json b/types/mongodb/v2/tsconfig.json new file mode 100644 index 0000000000..7bfc92fc32 --- /dev/null +++ b/types/mongodb/v2/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "paths": { + "mongodb": [ + "mongodb/v2" + ] + }, + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mongodb-tests.ts" + ] +} \ No newline at end of file diff --git a/types/mongodb/v2/tslint.json b/types/mongodb/v2/tslint.json new file mode 100644 index 0000000000..e3610fefae --- /dev/null +++ b/types/mongodb/v2/tslint.json @@ -0,0 +1,80 @@ +{ + "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, + "use-default-type-parameter": false, + "void-return": false, + "whitespace": false + } +} diff --git a/types/multer-gridfs-storage/tsconfig.json b/types/multer-gridfs-storage/tsconfig.json index 4729416ff1..1daa734d97 100644 --- a/types/multer-gridfs-storage/tsconfig.json +++ b/types/multer-gridfs-storage/tsconfig.json @@ -4,6 +4,11 @@ "lib": [ "es6" ], + "paths": { + "mongodb": [ + "mongodb/v2" + ] + }, "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From 219dd6df82e7ee9023e8602e58102e22781fb12f Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 14:59:37 -0800 Subject: [PATCH 08/12] Fix 'prefer-readonly' lint failures (#22819) --- .../angular-material-tests.ts | 2 +- types/angular-scroll/angular-scroll-tests.ts | 4 ++-- .../angular-signalr-hub-tests.ts | 2 +- .../angular-ui-router-tests.ts | 8 +++---- types/angular/angular-tests.ts | 2 +- .../angularlocalstorage-tests.ts | 2 +- types/bardjs/bardjs-tests.ts | 2 +- types/braft-editor/braft-editor-tests.tsx | 4 ++-- types/camo/camo-tests.ts | 8 +++---- types/css-modules/css-modules-tests.ts | 2 +- types/d3-geo/d3-geo-tests.ts | 6 ++--- types/d3-shape/d3-shape-tests.ts | 20 ++++++++-------- .../google-cloud__storage-tests.ts | 3 --- .../google-drive-realtime-api-tests.ts | 2 +- types/jest/jest-tests.ts | 4 ++-- types/jest/v16/jest-tests.ts | 2 +- types/knockout/test/index.ts | 2 +- .../knuddels-userapps-api-tests.ts | 22 ++++++++--------- types/meteor/meteor-tests.ts | 8 +------ types/nedb/nedb-tests.ts | 2 +- types/ng-cordova/test/appAvailability.ts | 4 ++-- types/ng-cordova/test/deviceMotion.ts | 2 +- types/ng-cordova/test/deviceOrientation.ts | 4 ++-- types/ng-cordova/test/dialogs.ts | 2 +- types/ng-cordova/test/geolocation.ts | 2 +- types/ng-cordova/test/network.ts | 2 +- types/ng-cordova/test/toast.ts | 2 +- types/ng-file-upload/ng-file-upload-tests.ts | 2 +- types/ng-stomp/ng-stomp-tests.ts | 2 +- types/ngbootbox/ngbootbox-tests.ts | 8 +++---- types/openui5/openui5-tests.ts | 2 +- types/p-queue/p-queue-tests.ts | 2 +- types/pixi.js/tslint.json | 1 + types/q/q-tests.ts | 2 +- types/q/v0/q-tests.ts | 2 +- types/rc-select/rc-select-tests.ts | 6 ++--- .../react-dnd-html5-backend-tests.ts | 6 ++--- types/react-dnd/react-dnd-tests.tsx | 6 ++--- .../react-hamburger-menu-tests.tsx | 2 +- types/react-intl/v1/react-intl-tests.tsx | 6 ++--- .../react-native-drawer-layout-tests.tsx | 6 ++--- .../react-native-drawer-tests.tsx | 4 ++-- .../react-native-snap-carousel-tests.tsx | 6 ++--- .../react-navigation-tests.tsx | 2 +- .../react-router/test/NavigateWithContext.tsx | 2 +- types/react-select/react-select-tests.tsx | 20 ++++++++-------- .../react-sortable-hoc-tests.tsx | 2 +- types/react-swipe/react-swipe-tests.tsx | 8 +++---- .../react-swipeable/react-swipeable-tests.tsx | 24 +++++++++---------- types/react-touch/react-touch-tests.tsx | 8 +++---- types/react/test/index.ts | 2 +- types/react/v15/test/index.ts | 2 +- types/reactstrap/reactstrap-tests.tsx | 2 +- types/rot-js/rot-js-tests.ts | 4 ++-- types/rrc/rrc-tests.tsx | 6 ++--- .../screeps-profiler-tests.ts | 2 +- types/sharepoint/sharepoint-tests.ts | 2 +- types/slickgrid/test/index.ts | 2 +- types/wallabyjs/wallabyjs-tests.ts | 2 +- types/whatwg-streams/whatwg-streams-tests.ts | 4 ++-- types/when/when-tests.ts | 2 +- types/yfiles/yfiles-tests.ts | 4 ++-- 62 files changed, 140 insertions(+), 148 deletions(-) diff --git a/types/angular-material/angular-material-tests.ts b/types/angular-material/angular-material-tests.ts index ac4a1386cd..8d6955c697 100644 --- a/types/angular-material/angular-material-tests.ts +++ b/types/angular-material/angular-material-tests.ts @@ -196,7 +196,7 @@ myApp.controller('DialogController', ($scope: TestScope, $mdDialog: ng.material. }); class IconDirective implements ng.IDirective { - private $mdIcon: ng.material.IIcon; + private readonly $mdIcon: ng.material.IIcon; constructor($mdIcon: ng.material.IIcon) { this.$mdIcon = $mdIcon; } diff --git a/types/angular-scroll/angular-scroll-tests.ts b/types/angular-scroll/angular-scroll-tests.ts index fbc1c01642..84491706bc 100644 --- a/types/angular-scroll/angular-scroll-tests.ts +++ b/types/angular-scroll/angular-scroll-tests.ts @@ -50,11 +50,11 @@ namespace TestApp { var horixontalPosition: number = $document.duScrollLeft(); } - private invertedEasingFn = (x: number): number => { + private readonly invertedEasingFn = (x: number): number => { return 1 - x; } - private onScrollCompleted = (): void => { + private readonly onScrollCompleted = (): void => { console.log('Done scrolling'); } } diff --git a/types/angular-signalr-hub/angular-signalr-hub-tests.ts b/types/angular-signalr-hub/angular-signalr-hub-tests.ts index 14d202e171..62ea189787 100644 --- a/types/angular-signalr-hub/angular-signalr-hub-tests.ts +++ b/types/angular-signalr-hub/angular-signalr-hub-tests.ts @@ -1,6 +1,6 @@ class EmployeesFactory { static $inject = ['$rootScope', 'Hub', '$timeout']; - private hub: ngSignalr.Hub; + private readonly hub: ngSignalr.Hub; public all: Array; constructor($rootScope: ng.IRootScopeService, Hub: ngSignalr.HubFactory, $timeout: ng.ITimeoutService) { diff --git a/types/angular-ui-router/angular-ui-router-tests.ts b/types/angular-ui-router/angular-ui-router-tests.ts index 406e94a1eb..889e92bfc9 100644 --- a/types/angular-ui-router/angular-ui-router-tests.ts +++ b/types/angular-ui-router/angular-ui-router-tests.ts @@ -137,10 +137,10 @@ class UrlLocatorTestService implements IUrlLocatorTestService { static $inject = ["$http", "$rootScope", "$urlRouter", "$state"]; constructor( - private $http: ng.IHttpService, - private $rootScope: ng.IRootScopeService, - private $urlRouter: ng.ui.IUrlRouterService, - private $state: ng.ui.IStateService + private readonly $http: ng.IHttpService, + private readonly $rootScope: ng.IRootScopeService, + private readonly $urlRouter: ng.ui.IUrlRouterService, + private readonly $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 15d4d6a137..795e74a058 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -161,7 +161,7 @@ namespace My.Namespace { } class TestProvider implements ng.IServiceProvider { - constructor(private $scope: ng.IScope) {} + constructor(private readonly $scope: ng.IScope) {} $get() {} } diff --git a/types/angularlocalstorage/angularlocalstorage-tests.ts b/types/angularlocalstorage/angularlocalstorage-tests.ts index 22d71f8b5d..df50c6694a 100644 --- a/types/angularlocalstorage/angularlocalstorage-tests.ts +++ b/types/angularlocalstorage/angularlocalstorage-tests.ts @@ -3,7 +3,7 @@ interface TestScope extends ng.IScope { } class TestController { - constructor(private $scope: TestScope, private storage: ng.localStorage.ILocalStorageService) { + constructor(private readonly $scope: TestScope, private readonly storage: ng.localStorage.ILocalStorageService) { storage.bind($scope, 'varName'); storage.bind($scope,'varName', { defaultValue: 'randomValue123', storeName: 'customStoreKey' }); $scope.viewType = 'ANYTHING'; diff --git a/types/bardjs/bardjs-tests.ts b/types/bardjs/bardjs-tests.ts index 52f5ab1d3f..de656bc22e 100644 --- a/types/bardjs/bardjs-tests.ts +++ b/types/bardjs/bardjs-tests.ts @@ -5,7 +5,7 @@ var expect = chai.expect, assert = chai.assert; class MyService { - constructor(private $q: angular.IQService) {} + constructor(private readonly $q: angular.IQService) {} remoteCall(): angular.IPromise { return new this.$q((resolve, reject) => { diff --git a/types/braft-editor/braft-editor-tests.tsx b/types/braft-editor/braft-editor-tests.tsx index 354c4cbb5b..584927e0bd 100644 --- a/types/braft-editor/braft-editor-tests.tsx +++ b/types/braft-editor/braft-editor-tests.tsx @@ -22,10 +22,10 @@ class BraftEditorTest extends React.Component { ); } - private handleChange = (content: RawDraftContentState) => { + private readonly handleChange = (content: RawDraftContentState) => { console.log(content); } - private handleHTMLChange = (html: string) => { + private readonly handleHTMLChange = (html: string) => { console.log(html); } } diff --git a/types/camo/camo-tests.ts b/types/camo/camo-tests.ts index 6830133f8f..b88f7007f6 100644 --- a/types/camo/camo-tests.ts +++ b/types/camo/camo-tests.ts @@ -16,10 +16,10 @@ connect("mongodb://user:password@localhost:27017/database?authSource=admin").the } class User extends CamoDocument { - private name: SchemaTypeExtended = String; - private password: SchemaTypeExtended = String; - private friends: SchemaTypeExtended = [String]; - private dateCreated: SchemaTypeExtended = { + private readonly name: SchemaTypeExtended = String; + private readonly password: SchemaTypeExtended = String; + private readonly friends: SchemaTypeExtended = [String]; + private readonly dateCreated: SchemaTypeExtended = { type: Date, default: Date.now }; diff --git a/types/css-modules/css-modules-tests.ts b/types/css-modules/css-modules-tests.ts index e6479ba2d5..685e322703 100644 --- a/types/css-modules/css-modules-tests.ts +++ b/types/css-modules/css-modules-tests.ts @@ -2,7 +2,7 @@ import styles from './main.sass'; import * as classNames from 'classnames'; class App { - private theme: string; + private readonly theme: string; constructor(theme: string) { this.theme = theme; } diff --git a/types/d3-geo/d3-geo-tests.ts b/types/d3-geo/d3-geo-tests.ts index 876461e3e9..c4508351a0 100644 --- a/types/d3-geo/d3-geo-tests.ts +++ b/types/d3-geo/d3-geo-tests.ts @@ -205,9 +205,9 @@ class Circulator { return d ? d : [0, 0]; }); } - private r: number; - private p: number; - private circleGenerator: d3Geo.GeoCircleGenerator; + private readonly r: number; + private readonly p: number; + private readonly circleGenerator: d3Geo.GeoCircleGenerator; getCirclePolygon(center?: [number, number]): GeoJSON.Polygon { if (center && center.length === 2 && typeof center[0] === 'number' && typeof center[1] === 'number') { diff --git a/types/d3-shape/d3-shape-tests.ts b/types/d3-shape/d3-shape-tests.ts index 4199d2f170..687da79188 100644 --- a/types/d3-shape/d3-shape-tests.ts +++ b/types/d3-shape/d3-shape-tests.ts @@ -200,14 +200,14 @@ class Arcer { .endAngle(this.endAngle) .padAngle(this.padAngle); } - private startAngle: number; - private endAngle: number; - private padAngle: number; - private innerRadius: number; - private outerRadius: number; - private cornerRadius: number; + private readonly startAngle: number; + private readonly endAngle: number; + private readonly padAngle: number; + private readonly innerRadius: number; + private readonly outerRadius: number; + private readonly cornerRadius: number; - private arc: d3Shape.Arc; + private readonly arc: d3Shape.Arc; getPathString(d?: ArcerDatum) { return d ? this.arc(d) : this.arc({ innerRadius: this.innerRadius, outerRadius: this.outerRadius }); @@ -1292,9 +1292,9 @@ class Symbolizer { return type; }); } - private size: number; - private type: d3Shape.SymbolType; - private symbol: d3Shape.Symbol; + private readonly size: number; + private readonly type: d3Shape.SymbolType; + private readonly symbol: d3Shape.Symbol; getPathString(d?: SymbolDatum) { return d ? this.symbol(d) : this.symbol(); diff --git a/types/google-cloud__storage/google-cloud__storage-tests.ts b/types/google-cloud__storage/google-cloud__storage-tests.ts index b277343bdb..24d300b8e6 100644 --- a/types/google-cloud__storage/google-cloud__storage-tests.ts +++ b/types/google-cloud__storage/google-cloud__storage-tests.ts @@ -40,9 +40,6 @@ export class TestStorage { // import Storage class static gcs = CloudStorage(); - // the bucket - private buckets: Bucket[] = []; - constructor() { // nothing to do } diff --git a/types/google-drive-realtime-api/google-drive-realtime-api-tests.ts b/types/google-drive-realtime-api/google-drive-realtime-api-tests.ts index af2313f147..7eb8708768 100644 --- a/types/google-drive-realtime-api/google-drive-realtime-api-tests.ts +++ b/types/google-drive-realtime-api/google-drive-realtime-api-tests.ts @@ -94,7 +94,7 @@ namespace GRealtime { export class MyRealtimeDoc { protected rtmodel: CollabModel; protected rtdoc: CollabDoc; - private myRTLoader = new GRealtime.MyRTLoader(); + private readonly myRTLoader = new GRealtime.MyRTLoader(); newFile(title: string, initializeModel: (x:CollabModel) => void, diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 88f72f3f1a..4d8ae05e1c 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -288,7 +288,7 @@ describe('missing tests', () => { class Closure { private arg: T; - constructor(private fn: (arg: T) => void) { + constructor(private readonly fn: (arg: T) => void) { this.fn = fn; } @@ -522,7 +522,7 @@ describe('beforeEach with timeout', () => { class TestApi { constructor() { } testProp: boolean; - private anotherProp: string; + private readonly anotherProp: string; testMethod(a: number): string { return ""; } } diff --git a/types/jest/v16/jest-tests.ts b/types/jest/v16/jest-tests.ts index 7a58d6e9b1..6acfa77fa8 100644 --- a/types/jest/v16/jest-tests.ts +++ b/types/jest/v16/jest-tests.ts @@ -183,7 +183,7 @@ describe('missing tests', function () { class Closure { private arg: T; - public constructor(private fn: (arg: T) => void) { + public constructor(private readonly fn: (arg: T) => void) { this.fn = fn; } diff --git a/types/knockout/test/index.ts b/types/knockout/test/index.ts index 9913b64fa8..36db7657ed 100644 --- a/types/knockout/test/index.ts +++ b/types/knockout/test/index.ts @@ -90,7 +90,7 @@ function test_computed() { } class GetterViewModel { - private _selectedRange: KnockoutObservable; + private readonly _selectedRange: KnockoutObservable; constructor() { this._selectedRange = ko.observable(); diff --git a/types/knuddels-userapps-api/knuddels-userapps-api-tests.ts b/types/knuddels-userapps-api/knuddels-userapps-api-tests.ts index bf0933a5e1..4ee25c84ec 100644 --- a/types/knuddels-userapps-api/knuddels-userapps-api-tests.ts +++ b/types/knuddels-userapps-api/knuddels-userapps-api-tests.ts @@ -1,9 +1,9 @@ class Server implements App { - private usersPlaying: { [nick: string]: number } = {}; + private readonly usersPlaying = new Map(); private isShuttingDown = false; - private htmlFile: HTMLFile = new HTMLFile('start.html'); - private appContent: AppContent = AppContent.overlayContent(this.htmlFile, 243, 266); + private readonly htmlFile: HTMLFile = new HTMLFile('start.html'); + private readonly appContent: AppContent = AppContent.overlayContent(this.htmlFile, 243, 266); onAppStart() { KnuddelsServer.getChannel() @@ -21,11 +21,11 @@ class Server implements App { } onUserLeft(user: User) { - if (this.usersPlaying[user.getNick()] === 1) { + if (this.usersPlaying.get(user.getNick()) === 1) { KnuddelsServer.getDefaultBotUser() .transferKnuddel(user, new KnuddelAmount(1), 'Du hast den Channel verlassen.'); - delete this.usersPlaying[user.getNick()]; + this.usersPlaying.delete(user.getNick()); } } @@ -46,7 +46,7 @@ class Server implements App { session.remove(); }); - delete this.usersPlaying[key]; + this.usersPlaying.delete(key); } } } @@ -61,7 +61,7 @@ class Server implements App { knuddelTransfer.accept(); } else if (this.isShuttingDown) { knuddelTransfer.reject('Du App nimmt gerade keine neuen Spieler an.'); - } else if (this.usersPlaying[sender.getNick()]) { + } else if (this.usersPlaying.get(sender.getNick())) { knuddelTransfer.reject('Du spielst bereits.'); } else if (knuddelTransfer.getKnuddelAmount().asNumber() !== 1) { const botNick = KnuddelsServer.getDefaultBotUser() @@ -75,7 +75,7 @@ class Server implements App { onKnuddelReceived(user: User, receiver: User, knuddelAmount: KnuddelAmount) { if (knuddelAmount.asNumber() === 1) { - this.usersPlaying[user.getNick()] = 1; + this.usersPlaying.set(user.getNick(), 1); user.sendAppContent(this.appContent); } else { user.sendPrivateMessage('Vielen Dank für die Einzahlung.'); @@ -83,8 +83,8 @@ class Server implements App { } onEventReceived(user: User, key: string, data: string) { - if (key === 'selectedEntry' && this.usersPlaying[user.getNick()] === 1) { - this.usersPlaying[user.getNick()] = 2; + if (key === 'selectedEntry' && this.usersPlaying.get(user.getNick()) === 1) { + this.usersPlaying.set(user.getNick(), 2); setTimeout(() => { const doorNumber = parseInt(data[data.length - 1], 10); @@ -116,7 +116,7 @@ class Server implements App { .forEach((session: AppContentSession) => { session.remove(); }); - delete this.usersPlaying[user.getNick()]; + this.usersPlaying.delete(user.getNick()); }, 4000); }, 1500); } diff --git a/types/meteor/meteor-tests.ts b/types/meteor/meteor-tests.ts index 6c71fef438..0e457b9fc5 100644 --- a/types/meteor/meteor-tests.ts +++ b/types/meteor/meteor-tests.ts @@ -206,13 +206,7 @@ Posts.insert({ title: "Hello world", body: "First post" }); **/ class Animal { - private sound: string; - constructor(doc: any) { - - } - makeNoise() { - console.log(this.sound) - } + constructor(doc: any) {} } interface AnimalDAO { diff --git a/types/nedb/nedb-tests.ts b/types/nedb/nedb-tests.ts index 96c5e9f154..c1ba5459cd 100644 --- a/types/nedb/nedb-tests.ts +++ b/types/nedb/nedb-tests.ts @@ -7,7 +7,7 @@ import * as es6styleimport from 'nedb'; import nedb = require('nedb'); class BaseCollection { - private dataStore: nedb; + private readonly dataStore: nedb; constructor(dataStore: nedb) { this.dataStore = dataStore; diff --git a/types/ng-cordova/test/appAvailability.ts b/types/ng-cordova/test/appAvailability.ts index 6c0391792b..aabd90ab9c 100644 --- a/types/ng-cordova/test/appAvailability.ts +++ b/types/ng-cordova/test/appAvailability.ts @@ -17,8 +17,8 @@ namespace demo.appavailability { static $inject:Array = ["$ionicPlatform", "$cordovaDevice", "$cordovaAppAvailability"]; constructor($ionicPlatform:ionic.platform.IonicPlatformService, - private $cordovaDevice:ngCordova.IDeviceService, - private $cordovaAppAvailability:ngCordova.IAppAvailabilityService) { + private readonly $cordovaDevice:ngCordova.IDeviceService, + private readonly $cordovaAppAvailability:ngCordova.IAppAvailabilityService) { this.isAvailable = false; diff --git a/types/ng-cordova/test/deviceMotion.ts b/types/ng-cordova/test/deviceMotion.ts index a93f42152b..31b825525d 100644 --- a/types/ng-cordova/test/deviceMotion.ts +++ b/types/ng-cordova/test/deviceMotion.ts @@ -11,7 +11,7 @@ namespace demo.devicemotion { msg:string; static $inject:Array = ["$ionicPlatform", "$cordovaDeviceMotion"]; - constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDeviceMotion:ngCordova.IDeviceMotionService) { + constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaDeviceMotion:ngCordova.IDeviceMotionService) { $ionicPlatform.ready(() => { this.getAcceleration(); }); diff --git a/types/ng-cordova/test/deviceOrientation.ts b/types/ng-cordova/test/deviceOrientation.ts index eadcdcb234..56a8efee88 100644 --- a/types/ng-cordova/test/deviceOrientation.ts +++ b/types/ng-cordova/test/deviceOrientation.ts @@ -12,8 +12,8 @@ namespace demo.deviceorientation { static $inject:Array = ["$ionicPlatform", "$timeout", "$cordovaDeviceOrientation"]; constructor($ionicPlatform:ionic.platform.IonicPlatformService, - private $timeout:ng.ITimeoutService, - private $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) { + private readonly $timeout:ng.ITimeoutService, + private readonly $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) { $ionicPlatform.ready(() => { this.getHeading(); diff --git a/types/ng-cordova/test/dialogs.ts b/types/ng-cordova/test/dialogs.ts index fe56cc3bc1..578d995724 100644 --- a/types/ng-cordova/test/dialogs.ts +++ b/types/ng-cordova/test/dialogs.ts @@ -9,7 +9,7 @@ namespace demo.dialog { action:string; static $inject:Array = ["$ionicPlatform", "$cordovaDialogs"]; - constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDialogs:ngCordova.IDialogsService) { + constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaDialogs:ngCordova.IDialogsService) { this.action = "Press any button !"; } diff --git a/types/ng-cordova/test/geolocation.ts b/types/ng-cordova/test/geolocation.ts index 34a67c9b00..63879867ac 100644 --- a/types/ng-cordova/test/geolocation.ts +++ b/types/ng-cordova/test/geolocation.ts @@ -10,7 +10,7 @@ namespace demo.geolocation { position:ngCordova.IGeoPosition; static $inject:Array = ["$ionicPlatform", "$cordovaGeolocation"]; - constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaGeolocation:ngCordova.IGeolocationService) { + constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaGeolocation:ngCordova.IGeolocationService) { } diff --git a/types/ng-cordova/test/network.ts b/types/ng-cordova/test/network.ts index dde727237b..e7bb18f6ac 100644 --- a/types/ng-cordova/test/network.ts +++ b/types/ng-cordova/test/network.ts @@ -12,7 +12,7 @@ namespace demo.network { static $inject:Array = ["$ionicPlatform", "$cordovaNetwork"]; - constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaNetwork:ngCordova.INetworkInformationService) { + constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaNetwork:ngCordova.INetworkInformationService) { $ionicPlatform.ready(() => { this.refresh(); diff --git a/types/ng-cordova/test/toast.ts b/types/ng-cordova/test/toast.ts index 2601ad577a..a1dc1d0a6d 100644 --- a/types/ng-cordova/test/toast.ts +++ b/types/ng-cordova/test/toast.ts @@ -10,7 +10,7 @@ namespace demo.toast { msg:string; static $inject:Array = ["$cordovaToast"]; - constructor(private $cordovaToast:ngCordova.IToastService) { + constructor(private readonly $cordovaToast:ngCordova.IToastService) { } diff --git a/types/ng-file-upload/ng-file-upload-tests.ts b/types/ng-file-upload/ng-file-upload-tests.ts index 8ed2d0d115..49a62e290e 100644 --- a/types/ng-file-upload/ng-file-upload-tests.ts +++ b/types/ng-file-upload/ng-file-upload-tests.ts @@ -7,7 +7,7 @@ let controllerId = "upload"; class UploadController { static $inject = ["Upload"]; - constructor(private Upload: angular.angularFileUpload.IUploadService) { + constructor(private readonly Upload: angular.angularFileUpload.IUploadService) { this.Upload.setDefaults({ ngfAccept: "image/*", ngfAllowDir: true, diff --git a/types/ng-stomp/ng-stomp-tests.ts b/types/ng-stomp/ng-stomp-tests.ts index 436fe901ea..dd5cdafa24 100644 --- a/types/ng-stomp/ng-stomp-tests.ts +++ b/types/ng-stomp/ng-stomp-tests.ts @@ -1,5 +1,5 @@ class test { - constructor(private ngstomp: ngStomp) { + constructor(private readonly ngstomp: ngStomp) { const connectHeaders = { Auth: "user", Accept: "lol" diff --git a/types/ngbootbox/ngbootbox-tests.ts b/types/ngbootbox/ngbootbox-tests.ts index e38995bcd7..4e40e7438c 100644 --- a/types/ngbootbox/ngbootbox-tests.ts +++ b/types/ngbootbox/ngbootbox-tests.ts @@ -3,7 +3,7 @@ class TestBootboxController { - constructor(private $scope: angular.IScope, $ngBootbox: BootboxService) { + constructor(private readonly $scope: angular.IScope, $ngBootbox: BootboxService) { $ngBootbox.alert('An important message!').then(function() { console.log('Alert closed'); @@ -29,15 +29,15 @@ class TestBootboxController { warning: { label: "Cancel", className: "btn-warning", - callback: function() { + callback: function() { console.log('warning callback'); } }, success: { label: "Ok", className: "btn-success", - callback: function() { - console.log('sucess callback'); + callback: function() { + console.log('sucess callback'); } } } diff --git a/types/openui5/openui5-tests.ts b/types/openui5/openui5-tests.ts index bb411a9a1e..495a2a8ed5 100644 --- a/types/openui5/openui5-tests.ts +++ b/types/openui5/openui5-tests.ts @@ -11,7 +11,7 @@ sap.ui.getCore().attachInit(function () { }); class Ctrl extends sap.ui.core.mvc.Controller { - constructor(private JSONModel: typeof sap.ui.model.json.JSONModel) { + constructor(private readonly JSONModel: typeof sap.ui.model.json.JSONModel) { super(undefined); } diff --git a/types/p-queue/p-queue-tests.ts b/types/p-queue/p-queue-tests.ts index 6a63e9e607..8c54953a73 100644 --- a/types/p-queue/p-queue-tests.ts +++ b/types/p-queue/p-queue-tests.ts @@ -21,7 +21,7 @@ num = queue.size; num = queue.pending; class QueueClass implements PQueue.QueueClass<{ any: string }> { - private queue: Array<() => void>; + private readonly queue: Array<() => void>; size = 0; diff --git a/types/pixi.js/tslint.json b/types/pixi.js/tslint.json index 590b9da845..01be0cd9ee 100644 --- a/types/pixi.js/tslint.json +++ b/types/pixi.js/tslint.json @@ -17,6 +17,7 @@ "no-unnecessary-qualifier": false, "one-line": false, "prefer-conditional-expression": false, + "prefer-readonly": false, "unified-signatures": false, "class-name": true, diff --git a/types/q/q-tests.ts b/types/q/q-tests.ts index aedacef09c..8489625736 100644 --- a/types/q/q-tests.ts +++ b/types/q/q-tests.ts @@ -153,7 +153,7 @@ Q.nfbind(nodeStyle)('foo').done((result: string) => { }); class Repo { - private items: any[] = [ + private readonly items: any[] = [ {name: 'Max', cute: false}, {name: 'Annie', cute: true} ]; diff --git a/types/q/v0/q-tests.ts b/types/q/v0/q-tests.ts index 9bd95a77c8..7fb1e7e88d 100644 --- a/types/q/v0/q-tests.ts +++ b/types/q/v0/q-tests.ts @@ -144,7 +144,7 @@ Q.nfbind(nodeStyle)('foo').done((result: string) => {}); class Repo { - private items: any[] = [ + private readonly items: any[] = [ { name: 'Max', cute: false }, { name: 'Annie', cute: true } ]; diff --git a/types/rc-select/rc-select-tests.ts b/types/rc-select/rc-select-tests.ts index 5416919a6f..990c04639a 100644 --- a/types/rc-select/rc-select-tests.ts +++ b/types/rc-select/rc-select-tests.ts @@ -16,7 +16,7 @@ class Component extends React.Component { console.log('input changed'); } - private defaultSelectProps = { + private readonly defaultSelectProps = { className: "my-select", prefixCls: "prefix", animation: "slide-up", @@ -41,13 +41,13 @@ class Component extends React.Component { defaultActiveFirstOption: false }; - private defaultOptGroupProps = { + private readonly defaultOptGroupProps = { label: "Option group", key: "option-group-0", value: "option-group-0" }; - private defaultOptionProps = { + private readonly defaultOptionProps = { className: "option", disabled: true, key: "option-0", diff --git a/types/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts b/types/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts index 14463a0440..71a0d06039 100644 --- a/types/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts +++ b/types/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts @@ -154,7 +154,7 @@ namespace BoardSquare { export class BoardSquare extends React.Component { static defaultProps: BoardSquareP; - private _renderOverlay = (color: string) => { + private readonly _renderOverlay = (color: string) => { return r.div({ style: { position: 'absolute', @@ -231,7 +231,7 @@ namespace Board { } export class Board extends React.Component { - private _renderPiece = (x: number, y: number) => { + private readonly _renderPiece = (x: number, y: number) => { const knightX = this.props.knightPosition[0]; const knightY = this.props.knightPosition[1]; return x === knightX && y === knightY ? @@ -239,7 +239,7 @@ namespace Board { null; } - private _renderSquare = (i: number) => { + private readonly _renderSquare = (i: number) => { const x = i % 8; const y = Math.floor(i / 8); diff --git a/types/react-dnd/react-dnd-tests.tsx b/types/react-dnd/react-dnd-tests.tsx index 76d732f268..3016a3f523 100644 --- a/types/react-dnd/react-dnd-tests.tsx +++ b/types/react-dnd/react-dnd-tests.tsx @@ -167,7 +167,7 @@ namespace BoardSquare { export class BoardSquare extends React.Component { static defaultProps: BoardSquareP; - private _renderOverlay = (color: string) => { + private readonly _renderOverlay = (color: string) => { return r.div({ style: { position: 'absolute', @@ -247,7 +247,7 @@ namespace Board { } export class Board extends React.Component { - private _renderPiece = (x: number, y: number) => { + private readonly _renderPiece = (x: number, y: number) => { var knightX = this.props.knightPosition[0]; var knightY = this.props.knightPosition[1]; return x === knightX && y === knightY ? @@ -255,7 +255,7 @@ namespace Board { null; }; - private _renderSquare = (i: number) => { + private readonly _renderSquare = (i: number) => { var x = i % 8; var y = Math.floor(i / 8); diff --git a/types/react-hamburger-menu/react-hamburger-menu-tests.tsx b/types/react-hamburger-menu/react-hamburger-menu-tests.tsx index d9a6b34463..dd0f6e20d3 100644 --- a/types/react-hamburger-menu/react-hamburger-menu-tests.tsx +++ b/types/react-hamburger-menu/react-hamburger-menu-tests.tsx @@ -19,7 +19,7 @@ export class ReactHamburgerMenuTest extends React.PureComponent<{}, State> { return ; } - private menuClicked = (): void => this.setState({isOpen: !this.state.isOpen}); + private readonly menuClicked = (): void => this.setState({isOpen: !this.state.isOpen}); } interface State { diff --git a/types/react-intl/v1/react-intl-tests.tsx b/types/react-intl/v1/react-intl-tests.tsx index 298f05f6ed..a75b95c202 100644 --- a/types/react-intl/v1/react-intl-tests.tsx +++ b/types/react-intl/v1/react-intl-tests.tsx @@ -33,7 +33,7 @@ namespace I18nDirect { class I18nDirect extends React.Component { - private _currentLocale: string + private readonly _currentLocale: string private _messages: {[key: string]: string} constructor( props: I18nDirect.Props ) { @@ -69,7 +69,7 @@ class I18nDirect extends React.Component { } - private compileMessages = (props: I18nDirect.Props): void => { + private readonly compileMessages = (props: I18nDirect.Props): void => { let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US' @@ -104,7 +104,7 @@ namespace I18nMixin { @reactMixin.decorate( IntlMixin ) class I18nMixin extends React.Component implements IntlComponent { - private _currentLocale: string + private readonly _currentLocale: string constructor( props: I18nMixin.Props ) { super( props ) diff --git a/types/react-native-drawer-layout/react-native-drawer-layout-tests.tsx b/types/react-native-drawer-layout/react-native-drawer-layout-tests.tsx index d1a8c31168..c194756333 100644 --- a/types/react-native-drawer-layout/react-native-drawer-layout-tests.tsx +++ b/types/react-native-drawer-layout/react-native-drawer-layout-tests.tsx @@ -11,11 +11,11 @@ class DrawerTest extends React.Component<{}, DrawerTestState> { open: false }; - private onOpen = () => this.setState({ open: true }); + private readonly onOpen = () => this.setState({ open: true }); - private onClose = () => this.setState({ open: false }); + private readonly onClose = () => this.setState({ open: false }); - private renderNavigationView = () => ( + private readonly renderNavigationView = () => ( Drawer content diff --git a/types/react-native-drawer/react-native-drawer-tests.tsx b/types/react-native-drawer/react-native-drawer-tests.tsx index dbc1d06b0e..10aa1991bd 100644 --- a/types/react-native-drawer/react-native-drawer-tests.tsx +++ b/types/react-native-drawer/react-native-drawer-tests.tsx @@ -30,11 +30,11 @@ class DrawerTest extends React.Component<{}, {open: boolean}> { ); } - private onOpen = () => { + private readonly onOpen = () => { this.setState({open: true}); } - private onClose = () => { + private readonly onClose = () => { this.setState({open: false}); } } diff --git a/types/react-native-snap-carousel/react-native-snap-carousel-tests.tsx b/types/react-native-snap-carousel/react-native-snap-carousel-tests.tsx index b89129fd93..5edbd84389 100644 --- a/types/react-native-snap-carousel/react-native-snap-carousel-tests.tsx +++ b/types/react-native-snap-carousel/react-native-snap-carousel-tests.tsx @@ -46,15 +46,15 @@ class SnapCarouselTest extends React.Component { ); } - private onSnapToItem = (index: number) => { + private readonly onSnapToItem = (index: number) => { console.log("Snapped to: ", index); } - private onScroll = (event: NativeSyntheticEvent) => { + private readonly onScroll = (event: NativeSyntheticEvent) => { console.log("Scrolled: ", event); } - private onLayout = (event: LayoutChangeEvent) => { + private readonly onLayout = (event: LayoutChangeEvent) => { console.log("Layout: ", event); } } diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 619c07c545..aca3f1bcf6 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -62,7 +62,7 @@ class StartScreen extends React.Component ); } - private navigateToNextScreen = (): void => { + private readonly navigateToNextScreen = (): void => { const params: NextScreenNavigationParams = { id: this.props.navigation.state.params.id, name: this.props.navigation.state.params.s, diff --git a/types/react-router/test/NavigateWithContext.tsx b/types/react-router/test/NavigateWithContext.tsx index cd6f45d232..7ab89b2e0d 100644 --- a/types/react-router/test/NavigateWithContext.tsx +++ b/types/react-router/test/NavigateWithContext.tsx @@ -19,7 +19,7 @@ class ComponentThatUsesContext extends React.Component { router: PropTypes.object.isRequired }; context: RouterChildContext; - private onClick = () => { + private readonly onClick = () => { const { history, route: { diff --git a/types/react-select/react-select-tests.tsx b/types/react-select/react-select-tests.tsx index 000042c1d0..f53f905c9b 100644 --- a/types/react-select/react-select-tests.tsx +++ b/types/react-select/react-select-tests.tsx @@ -114,7 +114,7 @@ describe("react-select", () => { it("Focus method", () => { class Component extends React.PureComponent { - private selectRef = (component: ReactSelect) => { + private readonly selectRef = (component: ReactSelect) => { component.focus(); } @@ -171,7 +171,7 @@ describe("Focus events", () => { describe("Examples", () => { it("Simple example", () => { class Component extends React.Component { - private onSelectChange: ReactSelectModule.OnChangeSingleHandler = (option) => { + private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler = (option) => { const optionValue: string = option.value; } @@ -187,7 +187,7 @@ describe("Examples", () => { it("onValueClick", () => { class Component extends React.Component { - private onValueClick: ReactSelectModule.OnValueClickHandler = (option) => { + private readonly onValueClick: ReactSelectModule.OnValueClickHandler = (option) => { const optionValue: number = option.value; } @@ -208,7 +208,7 @@ describe("Examples", () => { it("Custom value onValueClick", () => { class Component extends React.Component { - private onValueClick: ReactSelectModule.OnValueClickHandler = (option) => { + private readonly onValueClick: ReactSelectModule.OnValueClickHandler = (option) => { const optionValue: CustomValueType = option.value; } @@ -224,7 +224,7 @@ describe("Examples", () => { it("Custom value onChange", () => { class Component extends React.Component { - private onSelectChange: ReactSelectModule.OnChangeSingleHandler = (option) => { + private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler = (option) => { const optionValue: CustomValueType = option.value; } @@ -240,11 +240,11 @@ describe("Examples", () => { it("Menu renderer example", () => { class Component extends React.Component { - private onSelectChange: ReactSelectModule.OnChangeSingleHandler = option => { + private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler = option => { const optionValue: string = option.value; } - private menuRenderer: ReactSelectModule.MenuRendererHandler = props => { + private readonly menuRenderer: ReactSelectModule.MenuRendererHandler = props => { const options = props.options.map(option => { return
{option.label}
; }); @@ -265,7 +265,7 @@ describe("Examples", () => { it("Menu renderer with custom value type example", () => { class Component extends React.Component { - private menuRenderer: ReactSelectModule.MenuRendererHandler = props => { + private readonly menuRenderer: ReactSelectModule.MenuRendererHandler = props => { const options = props.options.map(option => { return (
{ it("Input render example", () => { class Component extends React.Component { - private onSelectChange: ReactSelectModule.OnChangeSingleHandler = option => { + private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler = option => { const optionValue: string = option.value; } - private inputRenderer: ReactSelectModule.InputRendererHandler = props => { + private readonly inputRenderer: ReactSelectModule.InputRendererHandler = props => { return ; } diff --git a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx index 1d3b3d5da7..236f39b77a 100644 --- a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx +++ b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx @@ -33,7 +33,7 @@ const SortableList = ReactSortableHOC.SortableContainer((props: SortableListProp }); class SortableComponent extends React.Component<{}, SortableComponentState> { - private _onSortEnd: ReactSortableHOC.SortEndHandler; + private readonly _onSortEnd: ReactSortableHOC.SortEndHandler; private _handleSortEnd(sort: ReactSortableHOC.SortEnd, event: ReactSortableHOC.SortEvent): void { this.setState({items: ReactSortableHOC.arrayMove(this.state.items, sort.oldIndex, sort.newIndex)}); diff --git a/types/react-swipe/react-swipe-tests.tsx b/types/react-swipe/react-swipe-tests.tsx index c8873c8aa6..2a2f0ffc90 100644 --- a/types/react-swipe/react-swipe-tests.tsx +++ b/types/react-swipe/react-swipe-tests.tsx @@ -4,26 +4,26 @@ import * as ReactSwipe from "react-swipe"; class ReactSwipeTest extends React.PureComponent { private swipeComponent: ReactSwipe | null = null; - private onPrev: React.MouseEventHandler = () => { + private readonly onPrev: React.MouseEventHandler = () => { if (this.swipeComponent != null) { this.swipeComponent.prev(); } } - private onNext: React.MouseEventHandler = () => { + private readonly onNext: React.MouseEventHandler = () => { if (this.swipeComponent != null) { this.swipeComponent.next(); } } - private onSlideToStart: React.MouseEventHandler = () => { + private readonly onSlideToStart: React.MouseEventHandler = () => { if (this.swipeComponent != null) { const lastSlide = this.swipeComponent.getNumSlides() - 1; this.swipeComponent.slide(lastSlide, 1000); } } - private onGetCurrentPosition: React.MouseEventHandler = () => { + private readonly onGetCurrentPosition: React.MouseEventHandler = () => { const currentPosition = this.swipeComponent != null ? this.swipeComponent.getPos() : 0; alert(currentPosition); } diff --git a/types/react-swipeable/react-swipeable-tests.tsx b/types/react-swipeable/react-swipeable-tests.tsx index ed5df52e54..b31011d63d 100644 --- a/types/react-swipeable/react-swipeable-tests.tsx +++ b/types/react-swipeable/react-swipeable-tests.tsx @@ -2,18 +2,18 @@ import * as React from 'react'; import * as Swipeable from 'react-swipeable'; class SampleComponent extends React.PureComponent { - private handleSwiped: Swipeable.OnSwipedCallback = () => {}; - private handleSwiping: Swipeable.OnSwipingCallback = () => {}; - private handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {}; - private handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {}; - private handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {}; - private handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {}; - private handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {}; - private handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {}; - private handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {}; - private handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {}; - private handleTap: Swipeable.OnTapCallback = () => {}; - private handleClick = () => {}; + private readonly handleSwiped: Swipeable.OnSwipedCallback = () => {}; + private readonly handleSwiping: Swipeable.OnSwipingCallback = () => {}; + private readonly handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {}; + private readonly handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {}; + private readonly handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {}; + private readonly handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {}; + private readonly handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {}; + private readonly handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {}; + private readonly handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {}; + private readonly handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {}; + private readonly handleTap: Swipeable.OnTapCallback = () => {}; + private readonly handleClick = () => {}; render() { return ( diff --git a/types/react-touch/react-touch-tests.tsx b/types/react-touch/react-touch-tests.tsx index 4ba1f3e1ef..3a0703bb7c 100644 --- a/types/react-touch/react-touch-tests.tsx +++ b/types/react-touch/react-touch-tests.tsx @@ -25,7 +25,7 @@ export class DraggableTest extends React.PureComponent { return ; } - private callback = (argument: DraggableCallbackArgument): JSX.Element => { + private readonly callback = (argument: DraggableCallbackArgument): JSX.Element => { return
; } } @@ -44,19 +44,19 @@ export class SwipeableTest extends React.PureComponent { ; } - private swipeHandler = () => { + private readonly swipeHandler = () => { return; } } export class CustomGestureTest extends React.PureComponent { - private move: moves[] = [moves.UPLEFT, moves.RIGHT, moves.DOWNRIGHT]; + private readonly move: moves[] = [moves.UPLEFT, moves.RIGHT, moves.DOWNRIGHT]; render() { return ; } - private handler = () => { + private readonly handler = () => { return; } } diff --git a/types/react/test/index.ts b/types/react/test/index.ts index e8aabfa35c..16141fabb4 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -85,7 +85,7 @@ class ModernComponent extends React.Component }); } - private _myComponent: MyComponent; + private readonly _myComponent: MyComponent; private _input: HTMLInputElement | null; render() { diff --git a/types/react/v15/test/index.ts b/types/react/v15/test/index.ts index 340ea94ec2..be6d27b659 100644 --- a/types/react/v15/test/index.ts +++ b/types/react/v15/test/index.ts @@ -110,7 +110,7 @@ class ModernComponent extends React.Component }); } - private _myComponent: MyComponent; + private readonly _myComponent: MyComponent; private _input: HTMLInputElement | null; render() { diff --git a/types/reactstrap/reactstrap-tests.tsx b/types/reactstrap/reactstrap-tests.tsx index 36625681dc..2a67844f9f 100644 --- a/types/reactstrap/reactstrap-tests.tsx +++ b/types/reactstrap/reactstrap-tests.tsx @@ -3529,7 +3529,7 @@ render() { class Example115 extends React.Component { // https://reactstrap.github.io/components/carousel/ - private items = [ + private readonly items = [ { src: 'data:image/svg+xml...', altText: 'Slide 1', diff --git a/types/rot-js/rot-js-tests.ts b/types/rot-js/rot-js-tests.ts index 9a07511dce..50ec56b947 100644 --- a/types/rot-js/rot-js-tests.ts +++ b/types/rot-js/rot-js-tests.ts @@ -59,7 +59,7 @@ SHOW("%f".format(myObj)); // ---- class Item { - constructor(private name: string) { } + constructor(private readonly name: string) { } a() { const first = self.name.charAt(0); @@ -83,7 +83,7 @@ SHOW(template.format(banana, banana)); // ---- class Animal { - constructor(private name: string) { } + constructor(private readonly name: string) { } adjective(x: string) { return `${x} ${this.name}`; } diff --git a/types/rrc/rrc-tests.tsx b/types/rrc/rrc-tests.tsx index 5356cb21a6..74f15045f4 100644 --- a/types/rrc/rrc-tests.tsx +++ b/types/rrc/rrc-tests.tsx @@ -30,7 +30,7 @@ class RouteOne extends React.Component> { } class RouteTwo extends React.Component> { - private onUpdate: OnUpdateCall = (location) => { console.log("update"); }; + private readonly onUpdate: OnUpdateCall = (location) => { console.log("update"); }; render() { return
@@ -65,11 +65,11 @@ interface Params { } class RouteFour extends React.Component> { - private routes: RouteConfiguration[] = [ + private readonly routes: RouteConfiguration[] = [ { path: "/four/something/:page", component: RouteTwo } ]; - private getKey: GetKeyFunction = (match, route, location) => { + private readonly getKey: GetKeyFunction = (match, route, location) => { return "my-key-" + match.url; } diff --git a/types/screeps-profiler/screeps-profiler-tests.ts b/types/screeps-profiler/screeps-profiler-tests.ts index 009f36f256..aab28c7ad9 100644 --- a/types/screeps-profiler/screeps-profiler-tests.ts +++ b/types/screeps-profiler/screeps-profiler-tests.ts @@ -4,7 +4,7 @@ function testFunction() { } class TestClass { - private dummy: string; + private readonly dummy: string; } const testObj = { diff --git a/types/sharepoint/sharepoint-tests.ts b/types/sharepoint/sharepoint-tests.ts index 2b9bba7943..e76536cd18 100644 --- a/types/sharepoint/sharepoint-tests.ts +++ b/types/sharepoint/sharepoint-tests.ts @@ -2355,7 +2355,7 @@ namespace App { static $inject: string[] = ["$SharePoint", "$spnotify"]; - constructor(private $SharePoint: App.SharePoint, private $n: App.SpNotify) { + constructor(private readonly $SharePoint: App.SharePoint, private readonly $n: App.SpNotify) { this.activate(); } diff --git a/types/slickgrid/test/index.ts b/types/slickgrid/test/index.ts index d0ee85a23c..a0b5f178c5 100644 --- a/types/slickgrid/test/index.ts +++ b/types/slickgrid/test/index.ts @@ -62,7 +62,7 @@ $('.newSelection'); grid.setSelectedRows([0, 1, 2]); class SingleCellSelectionModel extends Slick.SelectionModel { - private self: SingleCellSelectionModel = null; + private readonly self: SingleCellSelectionModel = null; private _grid: Slick.Grid; constructor() { diff --git a/types/wallabyjs/wallabyjs-tests.ts b/types/wallabyjs/wallabyjs-tests.ts index 141e55d708..b4120d74ba 100644 --- a/types/wallabyjs/wallabyjs-tests.ts +++ b/types/wallabyjs/wallabyjs-tests.ts @@ -37,5 +37,5 @@ export class WallabyConfig implements wallabyjs.IWallabyConfig { } }; - constructor(private wallaby: wallabyjs.IWallaby) { } + constructor(private readonly wallaby: wallabyjs.IWallaby) { } } diff --git a/types/whatwg-streams/whatwg-streams-tests.ts b/types/whatwg-streams/whatwg-streams-tests.ts index 528c2f1f01..9456ff2983 100644 --- a/types/whatwg-streams/whatwg-streams-tests.ts +++ b/types/whatwg-streams/whatwg-streams-tests.ts @@ -295,7 +295,7 @@ function streamifyWebSocket(url: string, protocol: string) { } class WebSocketSource implements ReadableStreamSource { - private _ws: WebSocket; + private readonly _ws: WebSocket; constructor(ws: WebSocket) { this._ws = ws; @@ -316,7 +316,7 @@ class WebSocketSource implements ReadableStreamSource { } class WebSocketSink implements WritableStreamSink { - private _ws: WebSocket; + private readonly _ws: WebSocket; constructor(ws: WebSocket) { this._ws = ws; diff --git a/types/when/when-tests.ts b/types/when/when-tests.ts index 57523b00ac..63fbba2234 100644 --- a/types/when/when-tests.ts +++ b/types/when/when-tests.ts @@ -7,7 +7,7 @@ import dns = require('dns'); import when = require("when"); class ForeignPromise { - constructor(private value: T) { + constructor(private readonly value: T) { } then(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U) { return new ForeignPromise(onFulfilled(this.value)); } diff --git a/types/yfiles/yfiles-tests.ts b/types/yfiles/yfiles-tests.ts index f05acba4a4..5d13f4de75 100644 --- a/types/yfiles/yfiles-tests.ts +++ b/types/yfiles/yfiles-tests.ts @@ -1,5 +1,5 @@ class BasicTest { - private graphComponent:yfiles.view.GraphComponent; + private readonly graphComponent:yfiles.view.GraphComponent; constructor() { this.graphComponent = new yfiles.view.GraphComponent("graphControl"); @@ -129,7 +129,7 @@ class BasicTest { var args = new yfiles.lang.EventArgs(); yfiles.input.KeyEventRecognizers.META_PRESSED(null, args); } - + testsForVersion2012() { //isInstance type-guard let r : any; From 01d4dcdcd2e1ce6b8073b9491e722132b307a04e Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 15:01:26 -0800 Subject: [PATCH 09/12] Fix 'no-dynamic-delete' lint failures (#22822) --- .../documentdb-server-tests.ts | 4 +-- types/domurl/domurl-tests.ts | 2 -- types/jsurl/jsurl-tests.ts | 2 -- types/mongoose/v3/mongoose-tests.ts | 4 +-- .../react-virtualized-tests.tsx | 12 +++----- types/screeps/screeps-tests.ts | 2 +- types/sizzle/sizzle-tests.ts | 6 ++-- types/ssh2/ssh2-tests.ts | 10 +++---- types/viewporter/viewporter-tests.ts | 29 ++++++++++--------- 9 files changed, 33 insertions(+), 38 deletions(-) diff --git a/types/documentdb-server/documentdb-server-tests.ts b/types/documentdb-server/documentdb-server-tests.ts index d4e8e7f40c..cc7c97e07c 100644 --- a/types/documentdb-server/documentdb-server-tests.ts +++ b/types/documentdb-server/documentdb-server-tests.ts @@ -614,7 +614,7 @@ function updateSproc(id: string, update: Object) { } else if (document[existingFieldName]) { // If the field exists, set/overwrite the new field name and unset the existing field name. document[newFieldName] = document[existingFieldName]; - delete document[existingFieldName]; + delete document[existingFieldName]; // tslint:disable-line no-dynamic-delete } else { // Otherwise this is a noop. } @@ -641,7 +641,7 @@ function updateSproc(id: string, update: Object) { if (update.$unset) { fields = Object.keys(update.$unset); for (i = 0; i < fields.length; i++) { - delete document[fields[i]]; + delete document[fields[i]]; // tslint:disable-line no-dynamic-delete } } } diff --git a/types/domurl/domurl-tests.ts b/types/domurl/domurl-tests.ts index ff7f3c11c6..2de93bcc20 100644 --- a/types/domurl/domurl-tests.ts +++ b/types/domurl/domurl-tests.ts @@ -38,8 +38,6 @@ else { // if not an array but scalar value here is a way how to convert to array // The way to remove the parameter: delete u.query.a; -// or: -delete u.query["a"]; // If you need to remove all query string params: console.log(u.clearQuery()); diff --git a/types/jsurl/jsurl-tests.ts b/types/jsurl/jsurl-tests.ts index abdbb45851..a8adcfa90c 100644 --- a/types/jsurl/jsurl-tests.ts +++ b/types/jsurl/jsurl-tests.ts @@ -40,8 +40,6 @@ else { // if not an array but scalar value here is a way how to convert to array // The way to remove the parameter: delete u.query.a -// or: -delete u.query["a"] // If you need to remove all query string params: u.query.clear(); diff --git a/types/mongoose/v3/mongoose-tests.ts b/types/mongoose/v3/mongoose-tests.ts index 8a0f4896d4..ee56b9cc1b 100644 --- a/types/mongoose/v3/mongoose-tests.ts +++ b/types/mongoose/v3/mongoose-tests.ts @@ -143,8 +143,8 @@ Model.findOne({ name: 'john' }, (err: any, doc: mongoose.Document) => { doc.toJSON({ getters: true, virtuals: false }); var data: any = doc.toObject(); - delete data['age']; - delete data['weight']; + delete data['age']; // tslint:disable-line no-dynamic-delete + delete data['weight']; // tslint:disable-line no-dynamic-delete data['isAwesome'] = true; }); diff --git a/types/react-virtualized/react-virtualized-tests.tsx b/types/react-virtualized/react-virtualized-tests.tsx index e0bd1d50ed..c5958ab96c 100644 --- a/types/react-virtualized/react-virtualized-tests.tsx +++ b/types/react-virtualized/react-virtualized-tests.tsx @@ -654,13 +654,11 @@ const STATUS_LOADING = 1 const STATUS_LOADED = 2 export class InfiniteLoaderExample extends PureComponent { - _timeoutIdMap: any; + _timeoutIds = new Set(); constructor(props) { super(props) - this._timeoutIdMap = {} - this._clearData = this._clearData.bind(this) this._isRowLoaded = this._isRowLoaded.bind(this) this._loadMoreRows = this._loadMoreRows.bind(this) @@ -668,9 +666,7 @@ export class InfiniteLoaderExample extends PureComponent { } componentWillUnmount() { - Object.keys(this._timeoutIdMap).forEach(timeoutId => { - clearTimeout(timeoutId as any) - }) + this._timeoutIds.forEach(clearTimeout); } render() { @@ -731,7 +727,7 @@ export class InfiniteLoaderExample extends PureComponent { const timeoutId = setTimeout(() => { const { loadedRowCount, loadingRowCount } = this.state - delete this._timeoutIdMap[timeoutId] + this._timeoutIds.delete(timeoutId); for (let i = startIndex; i <= stopIndex; i++) { loadedRowsMap[i] = STATUS_LOADED @@ -745,7 +741,7 @@ export class InfiniteLoaderExample extends PureComponent { promiseResolver() }, 1000 + Math.round(Math.random() * 2000)) - this._timeoutIdMap[timeoutId] = true + this._timeoutIds.add(timeoutId); let promiseResolver diff --git a/types/screeps/screeps-tests.ts b/types/screeps/screeps-tests.ts index a308ebeb0b..5b518c8336 100644 --- a/types/screeps/screeps-tests.ts +++ b/types/screeps/screeps-tests.ts @@ -354,7 +354,7 @@ interface CreepMemory { const interShardData = JSON.parse(RawMemory.interShardSegment); if (interShardData.creeps[creep.name]) { creep.memory = interShardData[creep.name]; - delete interShardData.creeps[creep.name]; + delete interShardData.creeps[creep.name]; // tslint:disable-line no-dynamic-delete } RawMemory.interShardSegment = JSON.stringify(interShardData); diff --git a/types/sizzle/sizzle-tests.ts b/types/sizzle/sizzle-tests.ts index 3c6d17dc64..0662380942 100644 --- a/types/sizzle/sizzle-tests.ts +++ b/types/sizzle/sizzle-tests.ts @@ -47,8 +47,8 @@ function setFilters_0() { } function setFilters_1(oldPOS: RegExp) { - Sizzle.selectors.match['POS'] = new RegExp(oldPOS.source.replace('first', 'uno'), 'gi'); - Sizzle.selectors.setFilters['uno'] = Sizzle.selectors.setFilters['first']; - delete Sizzle.selectors.setFilters['first']; + Sizzle.selectors.match.POS = new RegExp(oldPOS.source.replace('first', 'uno'), 'gi'); + Sizzle.selectors.setFilters.uno = Sizzle.selectors.setFilters.first; + delete Sizzle.selectors.setFilters.first; Sizzle('div:uno'); // ==> [
] } diff --git a/types/ssh2/ssh2-tests.ts b/types/ssh2/ssh2-tests.ts index 1244ccb3fa..e6d03e939f 100644 --- a/types/ssh2/ssh2-tests.ts +++ b/types/ssh2/ssh2-tests.ts @@ -388,7 +388,7 @@ new ssh2.Server({ var session = accept(); session.on('sftp', (accept: any, reject: any) => { console.log('Client SFTP session'); - var openFiles: any = {}; + var openFiles = new Set(); var handleCount = 0; // `sftpStream` is an `SFTPStream` instance in server mode // see: https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md @@ -401,12 +401,12 @@ new ssh2.Server({ // be a real file descriptor number for example if actually opening // the file on the disk var handle = new Buffer(4); - openFiles[handleCount] = true; + openFiles.add(handleCount); handle.writeUInt32BE(handleCount++, 0, true); sftpStream.handle(reqid, handle); console.log('Opening file for write') }).on('WRITE', (reqid: any, handle: any, offset: any, data: any) => { - if (handle.length !== 4 || !openFiles[handle.readUInt32BE(0, true)]) + if (handle.length !== 4 || !openFiles.has(handle.readUInt32BE(0, true))) return sftpStream.status(reqid, STATUS_CODE.FAILURE); // fake the write sftpStream.status(reqid, STATUS_CODE.OK); @@ -414,9 +414,9 @@ new ssh2.Server({ console.log('Write to file at offset %d: %s', offset, inspected); }).on('CLOSE', (reqid: any, handle: any) => { var fnum: any; - if (handle.length !== 4 || !openFiles[(fnum = handle.readUInt32BE(0, true))]) + if (handle.length !== 4 || !openFiles.has((fnum = handle.readUInt32BE(0, true)))) return sftpStream.status(reqid, STATUS_CODE.FAILURE); - delete openFiles[fnum]; + openFiles.delete(fnum); sftpStream.status(reqid, STATUS_CODE.OK); console.log('Closing file'); }); diff --git a/types/viewporter/viewporter-tests.ts b/types/viewporter/viewporter-tests.ts index 15997f9425..94df0749fa 100644 --- a/types/viewporter/viewporter-tests.ts +++ b/types/viewporter/viewporter-tests.ts @@ -109,7 +109,7 @@ function test_swipey() { var canvas = $('canvas')[0]; var context = canvas.getContext('2d'); var iOS = (/iphone|ipad/i).test(navigator.userAgent); - var pointers = {}; + var pointers = new Map(); // handle resizing / rotating of the viewport var width, height; $(window).bind(viewporter.ACTIVE ? 'viewportchange' : 'resize', function () { @@ -123,11 +123,12 @@ function test_swipey() { for (var i = 0; i < touches.length; i++) { identifier = touches[i].identifier || 'mouse'; // if no pointer has been created for this finger yet, do it - if (!pointers[identifier]) { - pointers[identifier] = new drawingPointer(context, rainbow(8, Object.keys(pointers).length)); + let pointer = pointers.get(identifier); + if (!pointer) { + pointers.set(identifier, pointer = new drawingPointer(context, rainbow(8, Object.keys(pointers).length))); } - pointers[identifier].start(); - pointers[identifier].addPoint(touches[i].pageX, touches[i].pageY); + pointer.start(); + pointer.addPoint(touches[i].pageX, touches[i].pageY); } }); @@ -136,8 +137,9 @@ function test_swipey() { var identifier; for (var i = 0; i < touches.length; i++) { identifier = touches[i].identifier || 'mouse'; - if (pointers[identifier] && pointers[identifier].painting) { - pointers[identifier].addPoint(touches[i].pageX, touches[i].pageY, true); + const pointer = pointers.get(identifier); + if (pointer && pointer.painting) { + pointer.addPoint(touches[i].pageX, touches[i].pageY, true); } } }); @@ -147,11 +149,12 @@ function test_swipey() { var identifier; for (var i = 0; i < touches.length; i++) { identifier = touches[i].identifier || 'mouse'; - if (pointers[identifier]) { - pointers[identifier].stop(); + const pointer = pointers.get(identifier); + if (pointer) { + pointer.stop(); (function (identifier) { setTimeout(function () { - delete pointers[identifier]; + pointers.delete(identifier); }, 300); })(identifier); } @@ -161,10 +164,10 @@ function test_swipey() { window.setInterval(function () { context.clearRect(0, 0, width, height); var counter = 0, ratio = (window).devicePixelRatio || 1; - for (var identifier in pointers) { - pointers[identifier].redraw(); + pointers.forEach(pointer => { + pointer.redraw(); counter++; - } + }); context.font = (10 * ratio) + 'pt Arial'; context.fillText(counter + ' active pointers', 15 * ratio, 25 * ratio); From 516533240959f66f8410e68a67ea6e98d6c1a0f6 Mon Sep 17 00:00:00 2001 From: Cassey Lottman Date: Wed, 10 Jan 2018 17:25:41 -0600 Subject: [PATCH 10/12] Chartist - add another possible series type to IChartistData (#22803) * missing comment * missing comment * add iteratee property shorthand for uniq in underscore * undo bad commit * can also pass array of array of data to chartist --- types/chartist/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/chartist/index.d.ts b/types/chartist/index.d.ts index 6bdb7ebfe3..93918a5eeb 100644 --- a/types/chartist/index.d.ts +++ b/types/chartist/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Chartist v0.9.8 +// Type definitions for Chartist v0.9.81 // Project: https://github.com/gionkunz/chartist-js // Definitions by: Matt Gibbs , Simon Pfeifer , Cassey Lottman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -78,7 +78,7 @@ declare namespace Chartist { // TODO: come in and tidy this up and make it fit better interface IChartistData { labels?: Array | Array | Array; - series: Array | Array | Array>; + series: Array | Array> | Array | Array>; } interface IChartistSeriesData { From b0fee33bf0010dcc37fe165d5d26e94dbc549100 Mon Sep 17 00:00:00 2001 From: Flarna Date: Thu, 11 Jan 2018 00:26:30 +0100 Subject: [PATCH 11/12] [sinon] add spy.resetHistory() (#22807) --- types/sinon/index.d.ts | 2 ++ types/sinon/sinon-tests.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 90e352f1cb..f0433a694e 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -87,7 +87,9 @@ declare namespace Sinon { invokeCallback(...args: any[]): void; getCall(n: number): SinonSpyCall; getCalls(): SinonSpyCall[]; + /// @deprecated Use resetHistory() instead reset(): void; + resetHistory(): void; printf(format: string, ...args: any[]): string; restore(): void; } diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 846edd45d5..2e2286e538 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -157,6 +157,7 @@ function testSymbolMatch() { function testResetHistory() { sinon.stub().resetHistory(); + sinon.spy().resetHistory(); } function testUsingPromises() { From 2c2794aae48f3eea59940d9abd7b67ebd0db49ab Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 10 Jan 2018 15:27:01 -0800 Subject: [PATCH 12/12] flatbuffers: Fix lint (#22820) --- types/flatbuffers/flatbuffers-tests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/flatbuffers/flatbuffers-tests.ts b/types/flatbuffers/flatbuffers-tests.ts index 493773fdcf..13f8453224 100644 --- a/types/flatbuffers/flatbuffers-tests.ts +++ b/types/flatbuffers/flatbuffers-tests.ts @@ -14,7 +14,7 @@ enum Any { } class Monster2 { - bb: flatbuffers.ByteBuffer= null; + bb: flatbuffers.ByteBuffer = null; bb_pos = 0; @@ -89,7 +89,7 @@ class Test { } class TestSimpleTableWithEnum { - bb: flatbuffers.ByteBuffer= null; + bb: flatbuffers.ByteBuffer = null; bb_pos = 0; @@ -134,7 +134,7 @@ class TestSimpleTableWithEnum { } class Vec3 { - bb: flatbuffers.ByteBuffer= null; + bb: flatbuffers.ByteBuffer = null; bb_pos = 0; @@ -242,7 +242,7 @@ class Vec3 { } class Stat { - bb: flatbuffers.ByteBuffer= null; + bb: flatbuffers.ByteBuffer = null; bb_pos = 0; @@ -305,7 +305,7 @@ class Stat { } class Monster { - bb: flatbuffers.ByteBuffer= null; + bb: flatbuffers.ByteBuffer = null; bb_pos = 0;