From 16b909b10fbaed9f6d8cd7e145a8d33201cf0d97 Mon Sep 17 00:00:00 2001 From: Hinell Date: Sat, 7 Jan 2017 02:54:53 +0300 Subject: [PATCH 001/248] Node api fix according to official API --- node/index.d.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index a52b0424de..e9b120cc2b 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -281,9 +281,9 @@ declare namespace NodeJS { readable: boolean; isTTY?: boolean; read(size?: number): string | Buffer; - setEncoding(encoding: string | null): void; - pause(): ReadableStream; - resume(): ReadableStream; + setEncoding(encoding: string | null): this; + pause(): this; + resume(): this; pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; @@ -302,10 +302,7 @@ declare namespace NodeJS { end(str: string, encoding?: string, cb?: Function): void; } - export interface ReadWriteStream extends ReadableStream, WritableStream { - pause(): ReadWriteStream; - resume(): ReadWriteStream; - } + export interface ReadWriteStream extends ReadableStream, WritableStream { } export interface Events extends EventEmitter { } @@ -1845,11 +1842,11 @@ declare module "net" { connect(port: number, host?: string, connectionListener?: Function): void; connect(path: string, connectionListener?: Function): void; bufferSize: number; - setEncoding(encoding?: string): void; + setEncoding(encoding?: string): this; write(data: any, encoding?: string, callback?: Function): void; destroy(): void; - pause(): Socket; - resume(): Socket; + pause(): this; + resume(): this; setTimeout(timeout: number, callback?: Function): void; setNoDelay(noDelay?: boolean): void; setKeepAlive(enable?: boolean, initialDelay?: number): void; @@ -3339,9 +3336,9 @@ declare module "stream" { constructor(opts?: ReadableOptions); protected _read(size: number): void; read(size?: number): any; - setEncoding(encoding: string): void; - pause(): Readable; - resume(): Readable; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: any): void; @@ -3502,8 +3499,8 @@ declare module "stream" { // Note: Duplex extends both Readable and Writable. export class Duplex extends Readable implements NodeJS.ReadWriteStream { // Readable - pause(): Duplex; - resume(): Duplex; + pause(): this; + resume(): this; // Writeable writable: boolean; constructor(opts?: DuplexOptions); @@ -3528,9 +3525,9 @@ declare module "stream" { protected _transform(chunk: any, encoding: string, callback: Function): void; protected _flush(callback: Function): void; read(size?: number): any; - setEncoding(encoding: string): void; - pause(): Transform; - resume(): Transform; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: any): void; From bbc7449794201aaa4a8c34363068e2a2e70c5321 Mon Sep 17 00:00:00 2001 From: Hinell Date: Sat, 7 Jan 2017 19:57:33 +0300 Subject: [PATCH 002/248] Mongodb-node reconciliation --- mongodb/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mongodb/index.d.ts b/mongodb/index.d.ts index 82f8f0dcce..26d1656baf 100644 --- a/mongodb/index.d.ts +++ b/mongodb/index.d.ts @@ -1185,7 +1185,7 @@ export interface Cursor extends Readable { // 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#setEncoding - setEncoding(encoding: string): void; + setEncoding(encoding: string): this; // 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 @@ -1271,7 +1271,7 @@ export interface AggregationCursor extends Readable { //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 - setEncoding(encoding: string): void; + setEncoding(encoding: string): this; // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#skip skip(value: number): AggregationCursor; // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#sort @@ -1312,7 +1312,7 @@ export interface CommandCursor extends Readable { //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#setEncoding - setEncoding(encoding: string): void; + setEncoding(encoding: string): this; // 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 From 6c25f377ff8bbaf1cf1f9d39b22f5350b8eca55e Mon Sep 17 00:00:00 2001 From: Hinell Date: Sat, 7 Jan 2017 23:13:39 +0300 Subject: [PATCH 003/248] Fixed @node/node interface accroding to official NodeJS API. Closing #13782 --- node/index.d.ts | 7243 ++++++++++++++++++++++------------------------- 1 file changed, 3445 insertions(+), 3798 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index e9b120cc2b..e6333dd7d1 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -8,37 +8,162 @@ * Node.js v6.x API * * * ************************************************/ +interface NodeError { + /** + * Returns a string describing the point in the code at which the Error was instantiated. + * + * For example: + * + * ``` + * Error: Things keep happening! + * at /home/gbusey/file.js:525:2 + * at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21) + * at Actor. (/home/gbusey/actors.js:400:8) + * at increaseSynergy (/home/gbusey/actors.js:701:6) + * ``` + * + * The first line is formatted as : , and is followed by a series of stack frames (each line beginning with "at "). Each frame describes a call site within the code that lead to the error being generated. V8 attempts to display a name for each function (by variable name, function name, or object method name), but occasionally it will not be able to find a suitable name. If V8 cannot determine a name for the function, only location information will be displayed for that frame. Otherwise, the determined function name will be displayed with location information appended in parentheses. + */ + stack?: string; -// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build -interface Console { - Console: typeof NodeJS.Console; - assert(value: any, message?: string, ...optionalParams: any[]): void; - dir(obj: any, options?: {showHidden?: boolean, depth?: number, colors?: boolean}): void; - error(message?: any, ...optionalParams: any[]): void; - info(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - time(label: string): void; - timeEnd(label: string): void; - trace(message?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; + /** + * Returns the string description of error as set by calling new Error(message). The message passed to the constructor will also appear in the first line of the stack trace of the Error, however changing this property after the Error object is created may not change the first line of the stack trace. + * + * ``` + * const err = new Error('The message'); + * console.log(err.message); + * // Prints: The message + * ``` + */ + message: string; } -interface Error { - stack?: string; -} +interface Error extends NodeError { } interface ErrorConstructor { - captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - stackTraceLimit: number; + /** + * Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()`` was called. + * + * ```js + * const myObject = {}; + * Error.captureStackTrace(myObject); + * myObject.stack // similar to `new Error().stack` + * ``` + * + * The first line of the trace, instead of being prefixed with `ErrorType : message`, will be the result of calling `targetObject.toString()``. + * + * The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. + * + * The constructorOpt argument is useful for hiding implementation details of error generation from an end user. For instance: + * + * ```js + * function MyError() { + * Error.captureStackTrace(this, MyError); + * } + * + * // Without passing MyError to captureStackTrace, the MyError + * // frame would should up in the .stack property. by passing + * // the constructor, we omit that frame and all frames above it. + * new MyError().stack + * ``` + */ + captureStackTrace(targetObject: T, constructorOpt?: new () => T): void; + + /** + * The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj))``. + * + * The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. + * + * If set to a non-number value, or set to a negative number, stack traces will not capture any frames. + */ + stackTraceLimit: number; } -// compat for TypeScript 1.8 -// if you use with --target es3 or --target es5 and use below definitions, -// use the lib.es6.d.ts that is bundled with TypeScript 1.8. -interface MapConstructor { } -interface WeakMapConstructor { } -interface SetConstructor { } -interface WeakSetConstructor { } +// ES2015 collection types +interface NodeCollection { + size: number; +} + +interface NodeWeakCollection {} + +interface IterableIterator {} + +interface NodeCollectionConstructor { + prototype: T; +} + +interface Map extends NodeCollection { + clear(): void; + delete(key: K): boolean; + entries(): Array<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; + get(key: K): V; + has(key: K): boolean; + keys(): Array; + set(key: K, value?: V): Map; + values(): Array; + // [Symbol.iterator]():Array<[K,V]>; + // [Symbol.toStringTag]: "Map"; +} + +interface MapConstructor extends NodeCollectionConstructor> { + new (): Map; + new (): Map; +} + +declare var Map: MapConstructor; + +interface WeakMap extends NodeWeakCollection { + clear(): void; + delete(key: K): boolean; + get(key: K): V | void; + has(key: K): boolean; + set(key: K, value?: V): WeakMap; +} + +interface WeakMapConstructor extends NodeCollectionConstructor> { + new (): WeakMap; + new (): WeakMap; +} + +declare var WeakMap: WeakMapConstructor; + +interface Set extends NodeCollection { + add(value: T): Set; + clear(): void; + delete(value: T): boolean; + entries(): Array<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; + keys(): Array; + values(): Array; + // [Symbol.iterator]():Array; + // [Symbol.toStringTag]: "Set"; +} + +interface SetConstructor extends NodeCollectionConstructor> { + new (): Set; + new (): Set; + new (iterable: Array): Set; +} + +declare var Set: SetConstructor; + +interface WeakSet extends NodeWeakCollection { + add(value: T): WeakSet; + clear(): void; + delete(value: T): boolean; + has(value: T): boolean; + // [Symbol.toStringTag]: "WeakSet"; +} + +interface WeakSetConstructor extends NodeCollectionConstructor> { + new (): WeakSet; + new (): WeakSet; + new (iterable: Array): WeakSet; +} + +declare var WeakSet: WeakSetConstructor; /************************************************ * * @@ -47,7 +172,6 @@ interface WeakSetConstructor { } ************************************************/ declare var process: NodeJS.Process; declare var global: NodeJS.Global; -declare var console: Console; declare var __filename: string; declare var __dirname: string; @@ -60,26 +184,44 @@ declare function setImmediate(callback: (...args: any[]) => void, ...args: any[] declare function clearImmediate(immediateId: any): void; interface NodeRequireFunction { - (id: string): any; + (id: string): any; } interface NodeRequire extends NodeRequireFunction { - resolve(id: string): string; - cache: any; - extensions: any; - main: NodeModule | undefined; + resolve(id: string): string; + cache: { [filename: string]: NodeModule }; + extensions: NodeExtensions; + main: any; +} + +interface NodeExtensions { + '.js': (m: NodeModule, filename: string) => any; + '.json': (m: NodeModule, filename: string) => any; + '.node': (m: NodeModule, filename: string) => any; + [ext: string]: (m: NodeModule, filename: string) => any; } declare var require: NodeRequire; -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: NodeModule | null; - children: NodeModule[]; +declare class NodeModule { + static runMain(): void; + static wrap(code: string): string; + static _nodeModulePaths(path: string): string[]; + static _load(request: string, parent?: NodeModule, isMain?: boolean): any; + static _resolveFilename(request: string, parent?: NodeModule, isMain?: boolean): string; + static _extensions: NodeExtensions; + + constructor(filename: string); + _compile(code: string, filename: string): string; + + id: string; + parent: NodeModule; + filename: string; + paths: string[]; + children: NodeModule[]; + exports: any; + loaded: boolean; + require: NodeRequireFunction; } declare var module: NodeModule; @@ -87,159 +229,209 @@ declare var module: NodeModule; // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (size: Uint8Array): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; }; +// Console class (compatible with TypeScript `lib.d.ts`). +declare interface Console { + log(msg: any, ...params: any[]): void; + info(msg: any, ...params: any[]): void; + warn(msg: any, ...params: any[]): void; + error(msg: any, ...params: any[]): void; + dir(value: any, ...params: any[]): void; + time(timerName?: string): void; + timeEnd(timerName?: string): void; + trace(msg: any, ...params: any[]): void; + assert(test?: boolean, msg?: string, ...params: any[]): void; -// Buffer class -type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex"; -interface Buffer extends NodeBuffer { } + Console: new (stdout: NodeJS.WritableStream) => Console; +} -/** - * Raw data is stored in instances of the Buffer class. - * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. - * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - */ -declare var Buffer: { - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - new (str: string, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - new (size: number): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: Uint8Array): Buffer; - /** - * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. - * - * - * @param arrayBuffer The ArrayBuffer with which to share memory. - */ - new (arrayBuffer: ArrayBuffer): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: any[]): Buffer; - /** - * Copies the passed {buffer} data onto a new {Buffer} instance. - * - * @param buffer The buffer to copy. - */ - new (buffer: Buffer): Buffer; - prototype: Buffer; - /** - * Allocates a new Buffer using an {array} of octets. - * - * @param array - */ - from(array: any[]): Buffer; - /** - * When passed a reference to the .buffer property of a TypedArray instance, - * the newly created Buffer will share the same allocated memory as the TypedArray. - * The optional {byteOffset} and {length} arguments specify a memory range - * within the {arrayBuffer} that will be shared by the Buffer. - * - * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() - * @param byteOffset - * @param length - */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - /** - * Copies the passed {buffer} data onto a new Buffer instance. - * - * @param buffer - */ - from(buffer: Buffer): Buffer; - /** - * Creates a new Buffer containing the given JavaScript string {str}. - * If provided, the {encoding} parameter identifies the character encoding. - * If not provided, {encoding} defaults to 'utf8'. - * - * @param str - */ - from(str: string, encoding?: string): Buffer; - /** - * Returns true if {obj} is a Buffer - * - * @param obj object to test. - */ - isBuffer(obj: any): obj is Buffer; - /** - * Returns true if {encoding} is a valid encoding argument. - * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - * - * @param encoding string to test. - */ - isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - * @param fill if specified, buffer will be initialized by calling buf.fill(fill). - * If parameter is omitted, buffer will be filled with zeros. - * @param encoding encoding used for call to buf.fill while initalizing - */ - alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafe(size: number): Buffer; - /** - * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents - * of the newly created Buffer are unknown and may contain sensitive data. - * - * @param size count of octets to allocate - */ - allocUnsafeSlow(size: number): Buffer; -}; +declare var console: Console; + +declare class Buffer extends Uint8Array { + [index: number]: number; + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + constructor(str: string, encoding?: string); + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + constructor(size: number); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor(array: Uint8Array); + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}. + * + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + */ + constructor(arrayBuffer: ArrayBuffer); + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + constructor(array: any[]); + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + constructor(buffer: Buffer); + /** + * Allocates a new Buffer using an {array} of octets. + * + * @param array + */ + static from(array: any[]): Buffer; + /** + * When passed a reference to the .buffer property of a TypedArray instance, + * the newly created Buffer will share the same allocated memory as the TypedArray. + * The optional {byteOffset} and {length} arguments specify a memory range + * within the {arrayBuffer} that will be shared by the Buffer. + * + * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() + * @param byteOffset + * @param length + */ + static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * Copies the passed {buffer} data onto a new Buffer instance. + * + * @param buffer + */ + static from(buffer: Buffer): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + * + * @param str + */ + static from(str: string, encoding?: string): Buffer; + /** + * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be _zero-filled_. + * + * @param size The desired length of the new `Buffer` + * @param fill A value to pre-fill the new `Buffer` with. Default: `0` + * @param encoding If `fill` is a string, this is its encoding. Default: `'utf8'` + */ + static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new _non-zero-filled_ `Buffer` of `size` bytes. The `size` must be less than or equal to the value of `buffer.kMaxLength`. Otherwise, a `RangeError` is thrown. A zero-length `Buffer` will be created if `size <= 0`. + * + * The underlying memory for `Buffer` instances created in this way is not initialized. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize such `Buffer` instances to zeroes. + * + * @param size The desired length of the new `Buffer` + */ + static allocUnsafe(size: number): Buffer; + /** + * Returns `true` if `obj` is a Buffer, `false` otherwise. + */ + static isBuffer(obj: any): obj is Buffer; + /** + * Returns `true` if `encoding` contains a supported character encoding, or `false` otherwise. + * + * @param encoding A character encoding name to check. + */ + static isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + static byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + static concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + compare(buf1: Buffer, buf2: Buffer): number; + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): any; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAssert?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): this; + indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + swap16(): this; + swap32(): this; + swap64(): this; + includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; + entries(): IterableIterator<[number, number]>; + keys(): IterableIterator; + values(): IterableIterator; +} /************************************************ * * @@ -247,301 +439,244 @@ declare var Buffer: { * * ************************************************/ declare namespace NodeJS { - export var Console: { - prototype: Console; - new(stdout: WritableStream, stderr?: WritableStream): Console; - } + export interface ErrnoException extends Error { + errno?: number; + code?: string; + path?: string; + syscall?: string; + stack?: string; + } - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } + export interface EventEmitter { + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + prependListener(event: string, listener: Function): this; + prependOnceListener(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + eventNames(): string[]; + listenerCount(type: string): number; + } - export class EventEmitter { - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - listenerCount(type: string | symbol): number; - // Added in Node 6... - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - eventNames(): (string | symbol)[]; - } + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string | Buffer; + setEncoding(encoding: string): this; + isPaused(): boolean; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } - export interface ReadableStream extends EventEmitter { - readable: boolean; - isTTY?: boolean; - read(size?: number): string | Buffer; - setEncoding(encoding: string | null): this; - pause(): this; - resume(): this; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } + export interface WritableStream extends EventEmitter { + writable: boolean; + setDefaultEncoding(encoding: string): this; + write(buffer: Buffer | string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } - export interface WritableStream extends EventEmitter { - writable: boolean; - isTTY?: boolean; - write(buffer: Buffer | string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } + export interface ReadWriteStream extends ReadableStream, WritableStream { } - export interface ReadWriteStream extends ReadableStream, WritableStream { } + export interface Events extends EventEmitter { } - export interface Events extends EventEmitter { } + export interface Domain extends Events { + run(fn: Function): void; + add(emitter: Events): void; + remove(emitter: Events): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; - export interface Domain extends Events { - run(fn: Function): void; - add(emitter: Events): void; - remove(emitter: Events): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + } - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - } + export interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + } - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - } + export interface Env { + PATH: string; + [key: string]: string; + } - export interface CpuUsage { - user: number; - system: number; - } + export interface Versions { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + modules: string; + openssl: string; + } - export interface ProcessVersions { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - modules: string; - openssl: string; - } + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + argv0: string; + /** + * The process.execArgv property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the process.argv property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent. + */ + execArgv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: Env; + exit(code?: number): void; + exitCode?: number; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: Versions; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string | number): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): MemoryUsage; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?: [number, number]): [number, number]; + domain: Domain; - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - argv0: string; - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - exitCode: number; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: ProcessVersions; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string | number): void; - pid: number; - title: string; - arch: string; - platform: string; - mainModule?: NodeModule; - memoryUsage(): MemoryUsage; - cpuUsage(previousValue?: CpuUsage): CpuUsage; - nextTick(callback: Function, ...args: any[]): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?: [number, number]): [number, number]; - domain: Domain; + // Worker + send?(message: any, sendHandle?: any): void; + disconnect(): void; + connected: boolean; + } - // Worker - send?(message: any, sendHandle?: any): void; - disconnect(): void; - connected: boolean; - } + export interface Global { + Array: typeof Array; + ArrayBuffer: typeof ArrayBuffer; + Boolean: typeof Boolean; + Buffer: typeof Buffer; + DataView: typeof DataView; + Date: typeof Date; + Error: typeof Error; + EvalError: typeof EvalError; + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Function: typeof Function; + GLOBAL: Global; + Infinity: typeof Infinity; + Int16Array: typeof Int16Array; + Int32Array: typeof Int32Array; + Int8Array: typeof Int8Array; + Intl: typeof Intl; + JSON: typeof JSON; + Map: MapConstructor; + Math: typeof Math; + NaN: typeof NaN; + Number: typeof Number; + Object: typeof Object; + Promise: Function; + RangeError: typeof RangeError; + ReferenceError: typeof ReferenceError; + RegExp: typeof RegExp; + Set: SetConstructor; + String: typeof String; + Symbol: Function; + SyntaxError: typeof SyntaxError; + TypeError: typeof TypeError; + URIError: typeof URIError; + Uint16Array: typeof Uint16Array; + Uint32Array: typeof Uint32Array; + Uint8Array: typeof Uint8Array; + Uint8ClampedArray: Function; + WeakMap: WeakMapConstructor; + WeakSet: WeakSetConstructor; + clearImmediate: (immediateId: any) => void; + clearInterval: (intervalId: NodeJS.Timer) => void; + clearTimeout: (timeoutId: NodeJS.Timer) => void; + console: typeof console; + decodeURI: typeof decodeURI; + decodeURIComponent: typeof decodeURIComponent; + encodeURI: typeof encodeURI; + encodeURIComponent: typeof encodeURIComponent; + escape: (str: string) => string; + eval: typeof eval; + global: Global; + isFinite: typeof isFinite; + isNaN: typeof isNaN; + parseFloat: typeof parseFloat; + parseInt: typeof parseInt; + process: Process; + root: Global; + setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; + setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + undefined: typeof undefined; + unescape: (str: string) => string; + gc: () => void; + v8debug?: any; + } - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } + export interface Timer { + ref(): void; + unref(): void; + _called: boolean; + _onTimeout: Function; + _timerArgs?: any[]; + } - export interface Timer { - ref(): void; - unref(): void; - } -} - -interface IterableIterator { } - -/** - * @deprecated - */ -interface NodeBuffer extends Uint8Array { - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): { type: 'Buffer', data: any[] }; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - swap16(): Buffer; - swap32(): Buffer; - swap64(): Buffer; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): this; - indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - entries(): IterableIterator<[number, number]>; - includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; - keys(): IterableIterator; - values(): IterableIterator; + export interface Immediate { + _argv?: any[]; + _callback: Function; + _onImmediate: Function; + } } /************************************************ @@ -550,3566 +685,3078 @@ interface NodeBuffer extends Uint8Array { * * ************************************************/ declare module "buffer" { - export var INSPECT_MAX_BYTES: number; - var BuffType: typeof Buffer; - var SlowBuffType: typeof SlowBuffer; - export { BuffType as Buffer, SlowBuffType as SlowBuffer }; + export var INSPECT_MAX_BYTES: number; + export var kMaxLength: number; + + export type Encoding = "ascii" | "latin1" | "binary" | "utf8" | "utf-8" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "hex" | "base64"; + + var BuffType: typeof Buffer; + var SlowBuffType: typeof SlowBuffer; + + export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } declare module "querystring" { - export interface StringifyOptions { - encodeURIComponent?: Function; - } + export interface StringifyOptions { + encodeURIComponent?: Function; + } - export interface ParseOptions { - maxKeys?: number; - decodeURIComponent?: Function; - } + export interface ParseOptions { + maxKeys?: number; + decodeURIComponent?: Function; + } - export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; - export function escape(str: string): string; - export function unescape(str: string): string; + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; + export function escape(str: string): string; + export function unescape(str: string): string; } declare module "events" { - class internal extends NodeJS.EventEmitter { } + export class EventEmitter implements NodeJS.EventEmitter { + static EventEmitter: EventEmitter; + static listenerCount(emitter: EventEmitter, event: string): number; // deprecated + static defaultMaxListeners: number; - namespace internal { - export class EventEmitter extends internal { - static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated - static defaultMaxListeners: number; + addListener(event: string, listener: (...args: any[]) => void): this; + on(event: string, listener: (...args: any[]) => void): this; + once(event: string, listener: (...args: any[]) => void): this; + prependListener(event: string, listener: (...args: any[]) => void): this; + prependOnceListener(event: string, listener: (...args: any[]) => void): this; + removeListener(event: string, listener: (...args: any[]) => void): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Array<(...args: any[]) => void>; + listenerCount(event: string): number; + emit(event: string, ...args: any[]): boolean; + eventNames(): string[]; + } - addListener(event: string | symbol, listener: Function): this; - on(event: string | symbol, listener: Function): this; - once(event: string | symbol, listener: Function): this; - prependListener(event: string | symbol, listener: Function): this; - prependOnceListener(event: string | symbol, listener: Function): this; - removeListener(event: string | symbol, listener: Function): this; - removeAllListeners(event?: string | symbol): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string | symbol): Function[]; - emit(event: string | symbol, ...args: any[]): boolean; - eventNames(): (string | symbol)[]; - listenerCount(type: string | symbol): number; - } - } - - export = internal; + export interface Listener { + on(event: E, listener: L): this; + once(event: E, listener: L): this; + addListener(event: E, listener: L): this; + removeListener(event: E, listener: L): this; + listeners(event: E): L[]; + } } declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; + import * as events from "events"; + import * as net from "net"; + import * as stream from "stream"; - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number; - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: { [key: string]: any }; - auth?: string; - agent?: Agent | boolean; - } + export interface OutgoingHeaders { + [header: string]: number | string | string[]; + } - export interface Server extends net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - listening: boolean; - } + export interface IncomingHeaders { + [header: string]: string | string[]; + } + + export interface RequestOptions { + protocol?: string; + host?: string; + hostname?: string; + family?: number; + port?: number | string; + localAddress?: string; + socketPath?: string; + method?: string; + path?: string; + headers?: OutgoingHeaders; + auth?: string; + agent?: Agent | boolean; + } + + export class Server extends net.Server { + setTimeout(msecs: number, callback: Function): void; + maxHeadersCount: number; + timeout: number; + listening: boolean; + } + + export class ServerResponse extends stream.Writable { + finished: boolean; + headersSent: boolean; + statusCode: number; + statusMessage: string; + sendDate: boolean; + + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + writeContinue(): void; + writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHeaders): void; + setHeader(name: string, value: string | string[]): void; + setTimeout(msecs: number, callback: () => void): this; + getHeader(name: string): string; + removeHeader(name: string): void; + write(chunk: any, encoding?: string): any; + addTrailers(headers: OutgoingHeaders): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export class ClientRequest extends stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + write(chunk: any, encoding?: string): void; + abort(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + setHeader(name: string, value: string | string[]): void; + getHeader(name: string): string; + removeHeader(name: string): void; + addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + + export class IncomingMessage extends stream.Readable { + httpVersion: string; + headers: IncomingHeaders; + rawHeaders: string[]; + trailers: IncomingHeaders; + rawTrailers: string[]; + setTimeout(msecs: number, callback: Function): NodeJS.Timer; + destroy(error?: Error): void; /** - * @deprecated Use IncomingMessage + * Only valid for request obtained from http.Server. */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; - statusCode: number; - statusMessage: string; - headersSent: boolean; - setHeader(name: string, value: string | string[]): void; - setTimeout(msecs: number, callback: Function): ServerResponse; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - finished: boolean; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface ClientRequest extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - setHeader(name: string, value: string | string[]): void; - getHeader(name: string): string; - removeHeader(name: string): void; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface IncomingMessage extends stream.Readable { - httpVersion: string; - httpVersionMajor: number; - httpVersionMinor: number; - connection: net.Socket; - headers: any; - rawHeaders: string[]; - trailers: any; - rawTrailers: any; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - /** - * Only valid for request obtained from http.Server. - */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - destroy(error?: Error): void; - } + method?: string; /** - * @deprecated Use IncomingMessage + * Only valid for request obtained from http.Server. */ - export interface ClientResponse extends IncomingMessage { } + url?: string; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusCode?: number; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusMessage?: string; + socket: net.Socket; + } - export interface AgentOptions { - /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false - */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } - export class Agent { - maxSockets: number; - sockets: any; - requests: any; + export class Agent { + maxSockets: number; + sockets: any; + requests: any; - constructor(opts?: AgentOptions); + constructor(opts?: AgentOptions); - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } - export var METHODS: string[]; + export var METHODS: string[]; - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; + + export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export var globalAgent: Agent; } declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; - import * as net from "net"; + import * as child from "child_process"; + import * as events from "events"; - // interfaces - export interface ClusterSettings { - execArgv?: string[]; // default: process.execArgv - exec?: string; - args?: string[]; - silent?: boolean; - stdio?: any[]; - uid?: number; - gid?: number; - } + export interface ClusterSettings { + exec?: string; + args?: string[]; + silent?: boolean; + } - export interface ClusterSetupMasterSettings { - exec?: string; // default: process.argv[1] - args?: string[]; // default: process.argv.slice(2) - silent?: boolean; // default: false - stdio?: any[]; - } + export interface Address { + address: string; + port: number; + addressType: string; + } - export interface Address { - address: string; - port: number; - addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" - } + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): boolean; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + isConnected(): boolean; + isDead(): boolean; + } - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): boolean; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - exitedAfterDisconnect: boolean; + export var settings: ClusterSettings; + export var isMaster: boolean; + export var isWorker: boolean; + export function setupMaster(settings?: ClusterSettings): void; + export function fork(env?: any): Worker; + export function disconnect(callback?: Function): void; + export var worker: Worker; + export var workers: { + [index: string]: Worker + }; - /** - * events.EventEmitter - * 1. disconnect - * 2. error - * 3. exit - * 4. listening - * 5. message - * 6. online - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: () => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "listening", listener: (address: Address) => void): this; - addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: () => void): this; - - emit(event: string, listener: Function): boolean - emit(event: "disconnect", listener: () => void): boolean - emit(event: "error", listener: (code: number, signal: string) => void): boolean - emit(event: "exit", listener: (code: number, signal: string) => void): boolean - emit(event: "listening", listener: (address: Address) => void): boolean - emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean - emit(event: "online", listener: () => void): boolean - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: () => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "listening", listener: (address: Address) => void): this; - on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: () => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "listening", listener: (address: Address) => void): this; - once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: () => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "listening", listener: (address: Address) => void): this; - prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: () => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "listening", listener: (address: Address) => void): this; - prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: () => void): this; - } - - export interface Cluster extends events.EventEmitter { - Worker: Worker; - disconnect(callback?: Function): void; - fork(env?: any): Worker; - isMaster: boolean; - isWorker: boolean; - // TODO: cluster.schedulingPolicy - settings: ClusterSettings; - setupMaster(settings?: ClusterSetupMasterSettings): void; - worker: Worker; - workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - addListener(event: string, listener: Function): this; - addListener(event: "disconnect", listener: (worker: Worker) => void): this; - addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - addListener(event: "fork", listener: (worker: Worker) => void): this; - addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - addListener(event: "online", listener: (worker: Worker) => void): this; - addListener(event: "setup", listener: (settings: any) => void): this; - - emit(event: string, listener: Function): boolean; - emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - emit(event: "fork", listener: (worker: Worker) => void): boolean; - emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - emit(event: "online", listener: (worker: Worker) => void): boolean; - emit(event: "setup", listener: (settings: any) => void): boolean; - - on(event: string, listener: Function): this; - on(event: "disconnect", listener: (worker: Worker) => void): this; - on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - on(event: "fork", listener: (worker: Worker) => void): this; - on(event: "listening", listener: (worker: Worker, address: Address) => void): this; - on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - on(event: "online", listener: (worker: Worker) => void): this; - on(event: "setup", listener: (settings: any) => void): this; - - once(event: string, listener: Function): this; - once(event: "disconnect", listener: (worker: Worker) => void): this; - once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - once(event: "fork", listener: (worker: Worker) => void): this; - once(event: "listening", listener: (worker: Worker, address: Address) => void): this; - once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - once(event: "online", listener: (worker: Worker) => void): this; - once(event: "setup", listener: (settings: any) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependListener(event: "fork", listener: (worker: Worker) => void): this; - prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependListener(event: "online", listener: (worker: Worker) => void): this; - prependListener(event: "setup", listener: (settings: any) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; - prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; - prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; - prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; - prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. - prependOnceListener(event: "online", listener: (worker: Worker) => void): this; - prependOnceListener(event: "setup", listener: (settings: any) => void): this; - - } - - export function disconnect(callback?: Function): void; - export function fork(env?: any): Worker; - export var isMaster: boolean; - export var isWorker: boolean; - // TODO: cluster.schedulingPolicy - export var settings: ClusterSettings; - export function setupMaster(settings?: ClusterSetupMasterSettings): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; - - /** - * events.EventEmitter - * 1. disconnect - * 2. exit - * 3. fork - * 4. listening - * 5. message - * 6. online - * 7. setup - */ - export function addListener(event: string, listener: Function): Cluster; - export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function addListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function emit(event: string, listener: Function): boolean; - export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; - export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; - export function emit(event: "fork", listener: (worker: Worker) => void): boolean; - export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; - export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; - export function emit(event: "online", listener: (worker: Worker) => void): boolean; - export function emit(event: "setup", listener: (settings: any) => void): boolean; - - export function on(event: string, listener: Function): Cluster; - export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function on(event: "fork", listener: (worker: Worker) => void): Cluster; - export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function on(event: "online", listener: (worker: Worker) => void): Cluster; - export function on(event: "setup", listener: (settings: any) => void): Cluster; - - export function once(event: string, listener: Function): Cluster; - export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function once(event: "fork", listener: (worker: Worker) => void): Cluster; - export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function once(event: "online", listener: (worker: Worker) => void): Cluster; - export function once(event: "setup", listener: (settings: any) => void): Cluster; - - export function removeListener(event: string, listener: Function): Cluster; - export function removeAllListeners(event?: string): Cluster; - export function setMaxListeners(n: number): Cluster; - export function getMaxListeners(): number; - export function listeners(event: string): Function[]; - export function listenerCount(type: string): number; - - export function prependListener(event: string, listener: Function): Cluster; - export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function prependOnceListener(event: string, listener: Function): Cluster; - export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; - export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; - export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. - export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster; - export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster; - - export function eventNames(): string[]; + // Event emitter + export function addListener(event: string, listener: Function): void; + export function on(event: "disconnect", listener: (worker: Worker) => void): void; + export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void; + export function on(event: "fork", listener: (worker: Worker) => void): void; + export function on(event: "listening", listener: (worker: Worker, address: any) => void): void; + export function on(event: "message", listener: (worker: Worker, message: any) => void): void; + export function on(event: "online", listener: (worker: Worker) => void): void; + export function on(event: "setup", listener: (settings: any) => void): void; + export function on(event: string, listener: Function): any; + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListeners(event?: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; } declare module "zlib" { - import * as stream from "stream"; - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; finishFlush?: number } + import * as stream from "stream"; - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } + export interface ZlibCallback { (error: Error, result: any): void } - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } - export function deflate(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function deflateRaw(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; - export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer; - export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; - export var Z_NULL: number; + export function deflate(buf: Buffer | string, callback?: ZlibCallback): void; + export function deflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function deflateSync(buf: Buffer | string, options?: ZlibOptions): any; + export function deflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; + export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; + export function gzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function gzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function gzipSync(buf: Buffer | string, options?: ZlibOptions): any; + export function gunzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function gunzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function gunzipSync(buf: Buffer | string, options?: ZlibOptions): any; + export function inflate(buf: Buffer | string, callback?: ZlibCallback): void; + export function inflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function inflateSync(buf: Buffer | string, options?: ZlibOptions): any; + export function inflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; + export function inflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function inflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; + export function unzip(buf: Buffer | string, callback?: ZlibCallback): void; + export function unzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; + export function unzipSync(buf: Buffer | string, options?: ZlibOptions): any; + + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; } declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; - }; - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function hostname(): string; - export function loadavg(): number[]; - export function uptime(): number; - export function freemem(): number; - export function totalmem(): number; - export function cpus(): CpuInfo[]; - export function type(): string; - export function release(): string; - export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; - export function homedir(): string; - export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string } - export var constants: { - UV_UDP_REUSEADDR: number, - errno: { - SIGHUP: number; - SIGINT: number; - SIGQUIT: number; - SIGILL: number; - SIGTRAP: number; - SIGABRT: number; - SIGIOT: number; - SIGBUS: number; - SIGFPE: number; - SIGKILL: number; - SIGUSR1: number; - SIGSEGV: number; - SIGUSR2: number; - SIGPIPE: number; - SIGALRM: number; - SIGTERM: number; - SIGCHLD: number; - SIGSTKFLT: number; - SIGCONT: number; - SIGSTOP: number; - SIGTSTP: number; - SIGTTIN: number; - SIGTTOU: number; - SIGURG: number; - SIGXCPU: number; - SIGXFSZ: number; - SIGVTALRM: number; - SIGPROF: number; - SIGWINCH: number; - SIGIO: number; - SIGPOLL: number; - SIGPWR: number; - SIGSYS: number; - SIGUNUSED: number; - }, - signals: { - E2BIG: number; - EACCES: number; - EADDRINUSE: number; - EADDRNOTAVAIL: number; - EAFNOSUPPORT: number; - EAGAIN: number; - EALREADY: number; - EBADF: number; - EBADMSG: number; - EBUSY: number; - ECANCELED: number; - ECHILD: number; - ECONNABORTED: number; - ECONNREFUSED: number; - ECONNRESET: number; - EDEADLK: number; - EDESTADDRREQ: number; - EDOM: number; - EDQUOT: number; - EEXIST: number; - EFAULT: number; - EFBIG: number; - EHOSTUNREACH: number; - EIDRM: number; - EILSEQ: number; - EINPROGRESS: number; - EINTR: number; - EINVAL: number; - EIO: number; - EISCONN: number; - EISDIR: number; - ELOOP: number; - EMFILE: number; - EMLINK: number; - EMSGSIZE: number; - EMULTIHOP: number; - ENAMETOOLONG: number; - ENETDOWN: number; - ENETRESET: number; - ENETUNREACH: number; - ENFILE: number; - ENOBUFS: number; - ENODATA: number; - ENODEV: number; - ENOENT: number; - ENOEXEC: number; - ENOLCK: number; - ENOLINK: number; - ENOMEM: number; - ENOMSG: number; - ENOPROTOOPT: number; - ENOSPC: number; - ENOSR: number; - ENOSTR: number; - ENOSYS: number; - ENOTCONN: number; - ENOTDIR: number; - ENOTEMPTY: number; - ENOTSOCK: number; - ENOTSUP: number; - ENOTTY: number; - ENXIO: number; - EOPNOTSUPP: number; - EOVERFLOW: number; - EPERM: number; - EPIPE: number; - EPROTO: number; - EPROTONOSUPPORT: number; - EPROTOTYPE: number; - ERANGE: number; - EROFS: number; - ESPIPE: number; - ESRCH: number; - ESTALE: number; - ETIME: number; - ETIMEDOUT: number; - ETXTBSY: number; - EWOULDBLOCK: number; - EXDEV: number; - }, + export interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; }; - export function arch(): string; - export function platform(): string; - export function tmpdir(): string; - export var EOL: string; - export function endianness(): "BE" | "LE"; + } + + export interface NetworkInterfaceInfo { + address: string; + netmask: string; + family: string; + mac: string; + internal: boolean; + } + + export function tmpdir(): string; + export function homedir(): string; + export function endianness(): "BE" | "LE"; + export function hostname(): string; + export function type(): string; + export function platform(): string; + export function arch(): string; + export function release(): string; + export function uptime(): number; + export function loadavg(): number[]; + export function totalmem(): number; + export function freemem(): number; + export function cpus(): CpuInfo[]; + export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; + export function userInfo(options?: { encoding: 'buffer' }): { username: Buffer, uid: number, gid: number, shell: Buffer | null, homedir: Buffer } + export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: string | null, homedir: string } + export var EOL: string; } declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; + import * as tls from "tls"; + import * as events from "events"; + import * as http from "http"; - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any; - } + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string) => any; + } - export interface RequestOptions extends http.RequestOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } + export interface RequestOptions extends http.RequestOptions { + pfx?: string | Buffer; + key?: string | Buffer; + passphrase?: string; + cert?: string | Buffer; + ca?: string | Buffer | string[] | Buffer[]; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + } - export interface Agent extends http.Agent { } + export interface AgentOptions extends http.AgentOptions { + /** + * Certificate, Private key and CA certificates to use for SSL. Default `null`. + */ + pfx?: string | Buffer; + /** + * Private key to use for SSL. Default `null`. + */ + key?: string | Buffer | string[] | Buffer[]; + /** + * A string of passphrase for the private key or pfx. Default `null`. + */ + passphrase?: string; + /** + * Public x509 certificate to use. Default `null`. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. + */ + ciphers?: string; + /** + * If `true`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default `true`. + */ + rejectUnauthorized?: boolean; + /** + * Servername for SNI (Server Name Indication) TLS extension. + */ + servername?: string; + /** + * The SSL method to use, e.g. `SSLv3_method` to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + maxCachedSessions?: number; + } - export interface AgentOptions extends http.AgentOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - maxCachedSessions?: number; - } + export class Agent extends http.Agent { + constructor(options?: AgentOptions); + } - export var Agent: { - new (options?: AgentOptions): Agent; - }; - export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export var globalAgent: Agent; + export class Server extends tls.Server { } + + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function get(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export var globalAgent: Agent; } declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): number[]; + encode(codePoints: number[]): string; + } + export var version: any; } declare module "repl" { - import * as stream from "stream"; - import * as readline from "readline"; + import { EventEmitter } from "events"; + import { Interface } from "readline"; - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - completer?: Function; - replMode?: any; - breakEvalOnSigint?: any; - } + export interface ReplOptions { + prompt?: string; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + completer?: Function; + replMode?: symbol; + breakEvalOnSigint?: boolean; + } - export interface REPLServer extends readline.ReadLine { - defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; - displayPrompt(preserveCursor?: boolean): void; + export function start(options: ReplOptions): REPLServer; - /** - * events.EventEmitter - * 1. exit - * 2. reset - **/ + export type REPLCommand = (this: REPLServer, rest: string) => void; - addListener(event: string, listener: Function): this; - addListener(event: "exit", listener: () => void): this; - addListener(event: "reset", listener: Function): this; + export class REPLServer extends Interface { + inputStream: NodeJS.ReadableStream; + outputStream: NodeJS.WritableStream; + useColors: boolean; + commands: { + [command: string]: REPLCommand; + }; + defineCommand(keyword: string, cmd: REPLCommand | { help: string, action: REPLCommand }): void; + displayPrompt(preserveCursor?: boolean): void; + setPrompt(prompt: string): void; + turnOffEditorMode(): void; + } - emit(event: string, ...args: any[]): boolean; - emit(event: "exit"): boolean; - emit(event: "reset", context: any): boolean; - - on(event: string, listener: Function): this; - on(event: "exit", listener: () => void): this; - on(event: "reset", listener: Function): this; - - once(event: string, listener: Function): this; - once(event: "exit", listener: () => void): this; - once(event: "reset", listener: Function): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "exit", listener: () => void): this; - prependListener(event: "reset", listener: Function): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "exit", listener: () => void): this; - prependOnceListener(event: "reset", listener: Function): this; - } - - export function start(options: ReplOptions): REPLServer; + export class Recoverable extends SyntaxError { + err: Error; + constructor(err: Error); + } } declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; + import * as events from "events"; + import * as stream from "stream"; - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - pause(): ReadLine; - resume(): ReadLine; - close(): void; - write(data: string | Buffer, key?: Key): void; + export class Interface extends events.EventEmitter { + setPrompt(prompt: string): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: (answer: string) => void): void; + pause(): this; + resume(): this; + close(): void; + write(data: string | Buffer, key?: Key): void; + } - /** - * events.EventEmitter - * 1. close - * 2. line - * 3. pause - * 4. resume - * 5. SIGCONT - * 6. SIGINT - * 7. SIGTSTP - **/ + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "line", listener: (input: any) => void): this; - addListener(event: "pause", listener: () => void): this; - addListener(event: "resume", listener: () => void): this; - addListener(event: "SIGCONT", listener: () => void): this; - addListener(event: "SIGINT", listener: () => void): this; - addListener(event: "SIGTSTP", listener: () => void): this; + export interface CompleterResult { + completions: string[]; + line: string; + } - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "line", input: any): boolean; - emit(event: "pause"): boolean; - emit(event: "resume"): boolean; - emit(event: "SIGCONT"): boolean; - emit(event: "SIGINT"): boolean; - emit(event: "SIGTSTP"): boolean; + export interface InterfaceOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + completer?: Completer; + terminal?: boolean; + historySize?: number; + } - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "line", listener: (input: any) => void): this; - on(event: "pause", listener: () => void): this; - on(event: "resume", listener: () => void): this; - on(event: "SIGCONT", listener: () => void): this; - on(event: "SIGINT", listener: () => void): this; - on(event: "SIGTSTP", listener: () => void): this; + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): Interface; + export function createInterface(options: InterfaceOptions): Interface; - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "line", listener: (input: any) => void): this; - once(event: "pause", listener: () => void): this; - once(event: "resume", listener: () => void): this; - once(event: "SIGCONT", listener: () => void): this; - once(event: "SIGINT", listener: () => void): this; - once(event: "SIGTSTP", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "line", listener: (input: any) => void): this; - prependListener(event: "pause", listener: () => void): this; - prependListener(event: "resume", listener: () => void): this; - prependListener(event: "SIGCONT", listener: () => void): this; - prependListener(event: "SIGINT", listener: () => void): this; - prependListener(event: "SIGTSTP", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "line", listener: (input: any) => void): this; - prependOnceListener(event: "pause", listener: () => void): this; - prependOnceListener(event: "resume", listener: () => void): this; - prependOnceListener(event: "SIGCONT", listener: () => void): this; - prependOnceListener(event: "SIGINT", listener: () => void): this; - prependOnceListener(event: "SIGTSTP", listener: () => void): this; - } - - export interface Completer { - (line: string): CompleterResult; - (line: string, callback: (err: any, result: CompleterResult) => void): any; - } - - export type CompleterResult = [string[], string]; - - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer; - terminal?: boolean; - historySize?: number; - } - - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; - export function createInterface(options: ReadLineOptions): ReadLine; - - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; } declare module "vm" { - export interface Context { } - export interface ScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - cachedData?: Buffer; - produceCachedData?: boolean; - } - export interface RunningScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - } - export class Script { - constructor(code: string, options?: ScriptOptions); - runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any; - runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any; - runInThisContext(options?: RunningScriptOptions): any; - } - export function createContext(sandbox?: Context): Context; - export function isContext(sandbox: Context): boolean; - export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any; - export function runInDebugContext(code: string): any; - export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any; - export function runInThisContext(code: string, options?: RunningScriptOptions): any; + export interface Context { } + + export interface ScriptOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + cachedData?: Buffer; + produceCachedData?: boolean; + } + + export interface RunInNewContextOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + } + + export interface RunInContextOptions extends RunInNewContextOptions { + breakOnSigint?: boolean; + } + + export class Script { + constructor(code: string, options?: string | ScriptOptions); + runInContext(contextifiedSandbox: Context, options?: RunInContextOptions): any; + runInNewContext(sandbox?: Context, options?: RunInNewContextOptions): any; + runInThisContext(options?: RunInNewContextOptions): any; + } + + export function createContext(sandbox?: Context): Context; + export function isContext(sandbox: Context): boolean; + export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunInNewContextOptions): any; + export function runInDebugContext(code: string): any; + export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInNewContextOptions): any; + export function runInThisContext(code: string, options?: string | RunInNewContextOptions): any; + /** + * @deprecated + */ + export function createScript(code: string, options?: string | ScriptOptions): Script; } declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - import * as net from "net"; + import * as events from "events"; + import * as stream from "stream"; + import * as buffer from "buffer"; + import * as net from "net"; - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): boolean; - connected: boolean; - disconnect(): void; - unref(): void; - ref(): void; + export class ChildProcess extends events.EventEmitter implements + events.Listener<'close', (code: number, signal: string) => void>, + events.Listener<'error', (error: Error) => void>, + events.Listener<'exit', ((code: number, signal: string | null) => void) | ((code: number | null, signal: string) => void)>, + events.Listener<'message', (message: any, sendHandle?: net.Socket | net.Server) => void>, + events.Listener<'disconnect', () => void> { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + stdio: [stream.Writable, stream.Readable, stream.Readable]; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle?: any): boolean; + connected: boolean; + disconnect(): void; + unref(): void; + } - /** - * events.EventEmitter - * 1. close - * 2. disconnet - * 3. error - * 4. exit - * 5. message - **/ + export interface SpawnOptions { + cwd?: string; + env?: any; + stdio?: any; + detached?: boolean; + uid?: number; + gid?: number; + shell?: boolean | string; + } - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (code: number, signal: string) => void): this; - addListener(event: "disconnet", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "exit", listener: (code: number, signal: string) => void): this; - addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; + export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; - emit(event: string, ...args: any[]): boolean; - emit(event: "close", code: number, signal: string): boolean; - emit(event: "disconnet"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "exit", code: number, signal: string): boolean; - emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; + export interface ExecOptions { + cwd?: string; + env?: any; + shell?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + encoding?: buffer.Encoding | 'buffer'; + } - on(event: string, listener: Function): this; - on(event: "close", listener: (code: number, signal: string) => void): this; - on(event: "disconnet", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; + export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function exec(command: string, options: ExecOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - once(event: string, listener: Function): this; - once(event: "close", listener: (code: number, signal: string) => void): this; - once(event: "disconnet", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "exit", listener: (code: number, signal: string) => void): this; - once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; + export interface ExecFileOptions { + cwd?: string; + env?: any; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + encoding?: buffer.Encoding | 'buffer'; + } - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (code: number, signal: string) => void): this; - prependListener(event: "disconnet", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; + export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "disconnet", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; - prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - } + export interface ForkOptions { + cwd?: string; + env?: any; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; + } - export interface SpawnOptions { - cwd?: string; - env?: any; - stdio?: any; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - } - export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; + export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; - export interface ExecOptions { - cwd?: string; - env?: any; - shell?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecOptionsWithStringEncoding extends ExecOptions { - encoding: BufferEncoding; - } - export interface ExecOptionsWithBufferEncoding extends ExecOptions { - encoding: string; // specify `null`. - } - export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {}); - export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export interface SpawnSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + shell?: boolean | string; + encoding?: buffer.Encoding | 'buffer'; + } - export interface ExecFileOptions { - cwd?: string; - env?: any; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - } - export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { - encoding: BufferEncoding; - } - export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { - encoding: string; // specify `null`. - } - export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {}); - export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export interface SpawnSyncReturns { + pid: number; + output: string[]; + stdout: T; + stderr: T; + status: number; + signal: string; + error: Error; + } + export function spawnSync(command: string): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; - export interface ForkOptions { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - } - export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; + export interface ExecSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + shell?: string; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: buffer.Encoding | 'buffer'; + } - export interface SpawnSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - shell?: boolean | string; - } - export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { - encoding: BufferEncoding; - } - export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { - encoding: string; // specify `null`. - } - export interface SpawnSyncReturns { - pid: number; - output: string[]; - stdout: T; - stderr: T; - status: number; - signal: string; - error: Error; - } - export function spawnSync(command: string): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; + export function execSync(command: string): Buffer; + export function execSync(command: string, options?: ExecSyncOptions & { encoding: 'buffer' }): Buffer; + export function execSync(command: string, options?: ExecSyncOptions): Buffer; - export interface ExecSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - shell?: string; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { - encoding: BufferEncoding; - } - export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { - encoding: string; // specify `null`. - } - export function execSync(command: string): Buffer; - export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string; - export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer; - export function execSync(command: string, options?: ExecSyncOptions): Buffer; + export interface ExecFileSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: buffer.Encoding | 'buffer'; + } - export interface ExecFileSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: string; - } - export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { - encoding: BufferEncoding; - } - export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { - encoding: string; // specify `null`. - } - export function execFileSync(command: string): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; + export function execFileSync(command: string): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; } declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: string | any; - slashes?: boolean; - hash?: string; - path?: string; - } + export interface Url { + href?: string; + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: string | any; + slashes?: boolean; + hash?: string; + path?: string; + } - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; - export function format(url: Url): string; - export function resolve(from: string, to: string): string; + export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; + export function format(url: Url | string): string; + export function resolve(from: string, to: string): string; } declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; - export function setServers(servers: string[]): void; - - //Error codes - export var NODATA: string; - export var FORMERR: string; - export var SERVFAIL: string; - export var NOTFOUND: string; - export var NOTIMP: string; - export var REFUSED: string; - export var BADQUERY: string; - export var BADNAME: string; - export var BADFAMILY: string; - export var BADRESP: string; - export var CONNREFUSED: string; - export var TIMEOUT: string; - export var EOF: string; - export var FILE: string; - export var NOMEM: string; - export var DESTRUCTION: string; - export var BADSTR: string; - export var BADFLAGS: string; - export var NONAME: string; - export var BADHINTS: string; - export var NOTINITIALIZED: string; - export var LOADIPHLPAPI: string; - export var ADDRGETNETWORKPARAMS: string; - export var CANCELLED: string; + export const NODATA: 'ENODATA'; + export const FORMERR: 'EFORMERR'; + export const SERVFAIL: 'ESERVFAIL'; + export const NOTFOUND: 'ENOTFOUND'; + export const NOTIMP: 'ENOTIMP'; + export const REFUSED: 'EREFUSED'; + export const BADQUERY: 'EBADQUERY'; + export const BADNAME: 'EBADNAME'; + export const BADFAMILY: 'EBADFAMILY'; + export const BADRESP: 'EBADRESP'; + export const CONNREFUSED: 'ECONNREFUSED'; + export const TIMEOUT: 'ETIMEOUT'; + export const EOF: 'EOF'; + export const FILE: 'EFILE'; + export const NOMEM: 'ENOMEM'; + export const DESTRUCTION: 'EDESTRUCTION'; + export const BADSTR: 'EBADSTR'; + export const BADFLAGS: 'EBADFLAGS'; + export const NONAME: 'ENONAME'; + export const BADHINTS: 'EBADHINTS'; + export const NOTINITIALIZED: 'ENOTINITIALIZED'; + export const LOADIPHLPAPI: 'ELOADIPHLPAPI'; + export const ADDRGETNETWORKPARAMS: 'EADDRGETNETWORKPARAMS'; + export const CANCELLED: 'ECANCELLED'; } declare module "net" { - import * as stream from "stream"; - import * as events from "events"; + import * as stream from "stream"; - export interface Socket extends stream.Duplex { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; + export class Socket extends stream.Duplex { + constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }); - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - setEncoding(encoding?: string): this; - write(data: any, encoding?: string, callback?: Function): void; - destroy(): void; - pause(): this; - resume(): this; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; - destroyed: boolean; + connect(port: number, host?: string, connectionListener?: Function): void; + connect(path: string, connectionListener?: Function): void; + bufferSize: number; + write(data: any, encoding?: string, callback?: Function): void; + destroy(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + unref(): void; + ref(): void; - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; + remoteAddress: string; + remoteFamily: string; + remotePort: number; + localAddress: string; + localPort: number; + bytesRead: number; + bytesWritten: number; - /** - * events.EventEmitter - * 1. close - * 2. connect - * 3. data - * 4. drain - * 5. end - * 6. error - * 7. lookup - * 8. timeout - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: (had_error: boolean) => void): this; - addListener(event: "connect", listener: () => void): this; - addListener(event: "data", listener: (data: Buffer) => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - addListener(event: "timeout", listener: () => void): this; + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } - emit(event: string, ...args: any[]): boolean; - emit(event: "close", had_error: boolean): boolean; - emit(event: "connect"): boolean; - emit(event: "data", data: Buffer): boolean; - emit(event: "drain"): boolean; - emit(event: "end"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; - emit(event: "timeout"): boolean; + export interface ListenOptions { + port?: number; + host?: string; + backlog?: number; + path?: string; + exclusive?: boolean; + } - on(event: string, listener: Function): this; - on(event: "close", listener: (had_error: boolean) => void): this; - on(event: "connect", listener: () => void): this; - on(event: "data", listener: (data: Buffer) => void): this; - on(event: "drain", listener: () => void): this; - on(event: "end", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - on(event: "timeout", listener: () => void): this; + export class Server extends Socket { + listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): this; + listen(port: number, hostname?: string, listeningListener?: Function): this; + listen(port: number, backlog?: number, listeningListener?: Function): this; + listen(port: number, listeningListener?: Function): this; + listen(path: string, backlog?: number, listeningListener?: Function): this; + listen(path: string, listeningListener?: Function): this; + listen(handle: any, backlog?: number, listeningListener?: Function): this; + listen(handle: any, listeningListener?: Function): this; + listen(options: ListenOptions, listeningListener?: Function): this; + close(callback?: () => void): this; + address(): { port: number; family: string; address: string; }; + getConnections(cb: (error: Error, count: number) => void): void; + ref(): this; + unref(): this; + maxConnections: number; + connections: number; + } - once(event: string, listener: Function): this; - once(event: "close", listener: (had_error: boolean) => void): this; - once(event: "connect", listener: () => void): this; - once(event: "data", listener: (data: Buffer) => void): this; - once(event: "drain", listener: () => void): this; - once(event: "end", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - once(event: "timeout", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: (had_error: boolean) => void): this; - prependListener(event: "connect", listener: () => void): this; - prependListener(event: "data", listener: (data: Buffer) => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependListener(event: "timeout", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; - prependOnceListener(event: "connect", listener: () => void): this; - prependOnceListener(event: "data", listener: (data: Buffer) => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; - prependOnceListener(event: "timeout", listener: () => void): this; - } - - export var Socket: { - new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; - }; - - export interface ListenOptions { - port?: number; - host?: string; - backlog?: number; - path?: string; - exclusive?: boolean; - } - - export interface Server extends events.EventEmitter { - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server; - listen(port: number, hostname?: string, listeningListener?: Function): Server; - listen(port: number, backlog?: number, listeningListener?: Function): Server; - listen(port: number, listeningListener?: Function): Server; - listen(path: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(options: ListenOptions, listeningListener?: Function): Server; - listen(handle: any, backlog?: number, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - getConnections(cb: (error: Error, count: number) => void): void; - ref(): Server; - unref(): Server; - maxConnections: number; - connections: number; - - /** - * events.EventEmitter - * 1. close - * 2. connection - * 3. error - * 4. listening - */ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "connection", listener: (socket: Socket) => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "connection", socket: Socket): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "connection", listener: (socket: Socket) => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "connection", listener: (socket: Socket) => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "connection", listener: (socket: Socket) => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - } - export function createServer(connectionListener?: (socket: Socket) => void): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; + export function createServer(connectionListener?: (socket: Socket) => void): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; + export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(port: number, host?: string, connectionListener?: Function): Socket; + export function connect(path: string, connectionListener?: Function): Socket; + export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; + export function createConnection(path: string, connectionListener?: Function): Socket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; } declare module "dgram" { - import * as events from "events"; + import * as events from "events"; - interface RemoteInfo { - address: string; - family: string; - port: number; - } + export interface RemoteInfo { + address: string; + port: number; + size: number; + } - interface AddressInfo { - address: string; - family: string; - port: number; - } + export interface AddressInfo { + address: string; + family: string; + port: number; + } - interface BindOptions { - port: number; - address?: string; - exclusive?: boolean; - } + export interface BindOptions { + port: number; + address?: string; + exclusive?: boolean; + } - interface SocketOptions { - type: "udp4" | "udp6"; - reuseAddr?: boolean; - } + export interface SocketOptions { + type: string; + reuseAddr?: boolean; + } - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + export function createSocket(type: string | SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export interface Socket extends events.EventEmitter { - send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port?: number, address?: string, callback?: () => void): void; - bind(options: BindOptions, callback?: Function): void; - close(callback?: any): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setTTL(ttl: number): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - ref(): this; - unref(): this; - - /** - * events.EventEmitter - * 1. close - * 2. error - * 3. listening - * 4. message - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "listening", listener: () => void): this; - addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "listening"): boolean; - emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "listening", listener: () => void): this; - on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "listening", listener: () => void): this; - once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "listening", listener: () => void): this; - prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "listening", listener: () => void): this; - prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; - } + export class Socket extends events.EventEmitter { + send(msg: Buffer | string | Array, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + send(msg: Buffer | string | Array, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + bind(port: number, address?: string, callback?: () => void): void; + bind(options: BindOptions, callback?: () => void): void; + close(callback?: () => void): void; + setTTL(ttl: number): void; + address(): AddressInfo; + setBroadcast(flag: boolean): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + ref(): void; + unref(): void; + } } declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - - /** - * events.EventEmitter - * 1. change - * 2. error - */ - addListener(event: string, listener: Function): this; - addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - addListener(event: "error", listener: (code: number, signal: string) => void): this; - - on(event: string, listener: Function): this; - on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - on(event: "error", listener: (code: number, signal: string) => void): this; - - once(event: string, listener: Function): this; - once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - once(event: "error", listener: (code: number, signal: string) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependListener(event: "error", listener: (code: number, signal: string) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; - prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; - } - - export interface ReadStream extends stream.Readable { - close(): void; - destroy(): void; - bytesRead: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } - - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - path: string | Buffer; - - /** - * events.EventEmitter - * 1. open - * 2. close - */ - addListener(event: string, listener: Function): this; - addListener(event: "open", listener: (fd: number) => void): this; - addListener(event: "close", listener: () => void): this; - - on(event: string, listener: Function): this; - on(event: "open", listener: (fd: number) => void): this; - on(event: "close", listener: () => void): this; - - once(event: string, listener: Function): this; - once(event: "open", listener: (fd: number) => void): this; - once(event: "close", listener: () => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "open", listener: (fd: number) => void): this; - prependListener(event: "close", listener: () => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "open", listener: (fd: number) => void): this; - prependOnceListener(event: "close", listener: () => void): this; - } + import * as stream from "stream"; + import * as events from "events"; + import * as buffer from "buffer"; + /** + * Objects returned from `fs.stat()`, `fs.lstat()` and `fs.fstat()` and their synchronous counterparts are of this type. + */ + export class Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. + * "Access Time" - Time when file data last accessed. Changed by the `mknod(2)`, `utimes(2)`, and `read(2)` system calls. */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + atime: Date; /** - * Synchronous rename - * @param oldPath - * @param newPath + * "Modified Time" - Time when file data last modified. Changed by the `mknod(2)`, `utimes(2)`, and `write(2)` system calls. */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string | Buffer, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string | Buffer, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string | Buffer, uid: number, gid: number): void; - export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string | Buffer, mode: number): void; - export function chmodSync(path: string | Buffer, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string | Buffer, mode: number): void; - export function lchmodSync(path: string | Buffer, mode: string): void; - export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string | Buffer): Stats; - export function lstatSync(path: string | Buffer): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void; - export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void; - export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string | Buffer): string; - export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string; - /* - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. + mtime: Date; + /** + * "Change Time" - Time when file status was last changed (inode data modification). Changed by the `chmod(2)`, `chown(2)`, `link(2)`, `mknod(2)`, `rename(2)`, `unlink(2)`,` utimes(2)`, `read(2)`, and `write(2)` system calls. */ - export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous unlink - deletes the file specified in {path} - * - * @param path + ctime: Date; + /** + * "Birth Time" - Time of file creation. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the `ctime` or `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). Note that this value may be greater than `atime` or `mtime` in this case. On Darwin and other FreeBSD variants, also set if the `atime` is explicitly set to an earlier value than the current `birthtime` using the `utimes(2)` system call. */ - export function unlinkSync(path: string | Buffer): void; - /* - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. + birthtime: Date; + } + + export type WatchListener = (eventType: string, filename?: string | Buffer) => void; + + /** + * Objects returned from fs.watch() are of this type. + */ + export class FSWatcher extends events.EventEmitter implements + events.Listener<'change', WatchListener> { + close(): void; + } + + export class ReadStream extends stream.Readable implements + events.Listener<'open', (fd: number) => void>, + events.Listener<'close', () => void> { + bytesRead: number; + path: string | Buffer; + close(): void; + destroy(): void; + } + + export class WriteStream extends stream.Writable implements + events.Listener<'open', (fd: number) => void>, + events.Listener<'close', () => void> { + close(): void; + bytesWritten: number; + path: string | Buffer; + } + + export const F_OK: number; + export const R_OK: number; + export const W_OK: number; + export const X_OK: number; + + export const constants: { + O_RDONLY: number; + O_WRONLY: number; + O_RDWR: number; + S_IFMT: number; + S_IFREG: number; + S_IFDIR: number; + S_IFCHR: number; + S_IFBLK: number; + S_IFIFO: number; + S_IFLNK: number; + S_IFSOCK: number; + O_CREAT: number; + O_EXCL: number; + O_NOCTTY: number; + O_TRUNC: number; + O_APPEND: number; + O_DIRECTORY: number; + O_NOFOLLOW: number; + O_SYNC: number; + O_SYMLINK: number; + O_NONBLOCK: number; + S_IRWXU: number; + S_IRUSR: number; + S_IWUSR: number; + S_IXUSR: number; + S_IRWXG: number; + S_IRGRP: number; + S_IWGRP: number; + S_IXGRP: number; + S_IRWXO: number; + S_IROTH: number; + S_IWOTH: number; + S_IXOTH: number; + F_OK: number; + R_OK: number; + W_OK: number; + X_OK: number; + [key: string]: number; + } + + /** + * Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values. + */ + export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.access()`. This throws if any accessibility checks fail, and does nothing otherwise. + */ + export function accessSync(path: string | Buffer, mode?: number): void; + + export interface AppendFileOptions { + encoding?: buffer.Encoding; + mode?: number; + flag?: string; + } + + /** + * Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a buffer. + */ + export function appendFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function appendFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * The synchronous version of `fs.appendFile()`. + */ + export function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions | null): void; + + /** + * Asynchronous chmod(2). + */ + export function chmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous chmod(2). + */ + export function chmodSync(path: string | Buffer, mode: number): void; + + /** + * Asynchronous chown(2). + */ + export function chown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous chown(2). + */ + export function chownSync(path: string | Buffer, uid: number, gid: number): void; + + /** + * Asynchronous close(2). + */ + export function close(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous close(2). + */ + export function closeSync(fd: number): void; + + export interface ReadStreamOptions { + flags?: string; + encoding?: buffer.Encoding; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + end?: number; + } + + /** + * Returns a new ReadStream object. + * + * Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter. + */ + export function createReadStream(path: string | Buffer, options?: ReadStreamOptions | null): ReadStream; + + export interface WriteStreamOptions { + flags?: string; + defaultEncoding?: buffer.Encoding; + fd?: number; + mode?: number; + autoClose?: boolean; + start: number; + end: number; + } + + /** + * Returns a new WriteStream object. + */ + export function createWriteStream(path: string | Buffer, options?: WriteStreamOptions | null): WriteStream; + + /** + * Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false. + * + * @deprecated + */ + export function exists(path: string | Buffer, callback: (exists: boolean) => void): void; + + /** + * Synchronous version of `fs.exists()`. Returns true if the file exists, false otherwise. + */ + export function existsSync(path: string | Buffer): boolean; + + /** + * Asynchronous fchmod(2). + */ + export function fchmod(fd: number, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fchmod(2). + */ + export function fchmodSync(fd: number, mode: number): void; + + /** + * Asynchronous fchown(2). + */ + export function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fchown(2). + */ + export function fchownSync(fd: number, uid: number, gid: number): void; + + /** + * Asynchronous fdatasync(2). + */ + export function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fdatasync(2). + */ + export function fdatasyncSync(fd: number): void; + + /** + * Asynchronous fstat(2). + */ + export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous fstat(2). + */ + export function fstatSync(fd: number): Stats; + + /** + * Asynchronous fsync(2). + */ + export function fsync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous fsync(2). + */ + export function fsyncSync(fd: number): void; + + /** + * Asynchronous ftruncate(2). + * + * If the file referred to by the file descriptor was larger than `len` bytes, only the first `len` bytes will be retained in the file. + * + * If the file previously was shorter than `len` bytes, it is extended, and the extended part is filled with null bytes ('\0'). + */ + export function ftruncate(fd: number, len: number | null | undefined, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous ftruncate(2). + */ + export function ftruncateSync(fd: number, len?: number | null): void; + + /** + * Change the file timestamps of a file referenced by the supplied file descriptor. + */ + export function futimes(fd: number, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.futimes()`. + */ + export function futimesSync(fd: number, atime: number, mtime: number): void; + + /** + * Asynchronous lchmod(2). + * + * Only available on Mac OS X. + * + * @deprecated + */ + export function lchmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous lchmod(2). + * + * @deprecated + */ + export function lchmodSync(path: string | Buffer, mode: number): void; + + /** + * Asynchronous lchown(2). + * + * @deprecated + */ + export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous lchown(2). + * + * @deprecated + */ + export function lchownSync(path: string | Buffer, uid: number, gid: number): void; + + /** + * Asynchronous link(2). + */ + export function link(existingPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous link(2). + */ + export function linkSync(existingPath: string | Buffer, newPath: string | Buffer): void; + + /** + * Asynchronous lstat(2). `lstat()` is identical to `stat()`, except that if `path` is a symbolic link, then the link itself is stat-ed, not the file that it refers to. + */ + export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous lstat(2). + */ + export function lstatSync(path: string | Buffer): Stats; + + /** + * Asynchronous mkdir(2). `mode` defaults to `0o777`. + */ + export function mkdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function mkdir(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous mkdir(2). + */ + export function mkdirSync(path: string | Buffer, mode?: number): void; + + export interface MkdtempOptions { + encoding: buffer.Encoding; + } + + /** + * Creates a unique temporary directory. + * + * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * + * The created folder path is passed as a string to the callback's second parameter. + */ + export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; + export function mkdtemp(prefix: string, options: buffer.Encoding | MkdtempOptions | null, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; + + /** + * The synchronous version of fs.mkdtemp(). Returns the created folder path. + */ + export function mkdtempSync(prefix: string, options?: buffer.Encoding | MkdtempOptions | null): string; + + /** + * Asynchronous file open. See open(2). `flags` can be: + * + * 'r' - Open file for reading. An exception occurs if the file does not exist. + * + * 'r+' - Open file for reading and writing. An exception occurs if the file does not exist. + * + * 'rs+' - Open file for reading and writing in synchronous mode. Instructs the operating system to bypass the local file system cache. + * + * This is primarily useful for opening files on NFS mounts as it allows you to skip the potentially stale local cache. It has a very real impact on I/O performance so don't use this flag unless you need it. + * + * Note that this doesn't turn `fs.open()` into a synchronous blocking call. If that's what you want then you should be using `fs.openSync()` + * + * 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists). + * + * 'wx' - Like `'w'` but fails if `path` exists. + * + * 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). + * + * 'wx+' - Like `'w+'` but fails if `path` exists. + * + * 'a' - Open file for appending. The file is created if it does not exist. + * + * 'ax' - Like 'a' but fails if `path` exists. + * + * 'a+' - Open file for reading and appending. The file is created if it does not exist. + * + * 'ax+' - Like 'a+' but fails if `path` exists. + * + * `mode` sets the file mode (permission and sticky bits), but only if the file was created. It defaults to `0666`, readable and writable. + */ + export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; + + /** + * Synchronous version of `fs.open()`. + */ + export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; + + /** + * Read data from the file specified by fd. + * + * @param buffer is the buffer that the data will be written to. + * @param offset is the offset in the buffer to start writing at. + * @param length is an integer specifying the number of bytes to read. + * @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position. + */ + export function read(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Buffer) => void): void; + + export interface ReaddirOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous readdir(3). Reads the contents of a directory. + * + * @param files is an array of the names of the files in the directory excluding '.' and '..'. + */ + export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; + export function readdir(path: string | Buffer, options: 'buffer' | (ReadFileOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void; + export function readdir(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; + + /** + * Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'. + */ + export function readdirSync(path: string | Buffer): string[]; + export function readdirSync(path: string | Buffer, options: 'buffer' | (ReaddirOptions & { encoding: 'buffer' })): Buffer[]; + export function readdirSync(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null): string[]; + + export interface ReadFileOptions { + encoding?: buffer.Encoding | 'buffer'; + flag?: string; + } + + /** + * Asynchronously reads the entire contents of a file. + */ + export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; + export function readFile(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding }), callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; + export function readFile(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; + + /** + * Synchronous version of `fs.readFile`. + */ + export function readFileSync(file: string | Buffer | number): Buffer; + export function readFileSync(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding })): string; + export function readFileSync(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null): Buffer; + + export interface ReadlinkOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous readlink(2). + */ + export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void; + export function readlink(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; + export function readlink(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; + + /** + * Synchronous readlink(2). + */ + export function readlinkSync(path: string | Buffer): string; + export function readlinkSync(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' })): Buffer; + export function readlinkSync(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null): string; + + /** + * Synchronous version of `fs.read()`. + */ + export function readSync(fd: number, buffer: string | Buffer, offset: number, length: number, position: number): number; + + export interface RealpathOptions { + encoding?: buffer.Encoding | 'buffer'; + } + + /** + * Asynchronous realpath(3). May use `process.cwd` to resolve relative paths. + * + * Only paths that can be converted to UTF8 strings are supported. + */ + export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void; + export function realpath(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; + export function realpath(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; + + /** + * Synchronous realpath(3). Returns the resolved path. + * + * Only paths that can be converted to UTF8 strings are supported. + */ + export function realpathSync(path: string | Buffer): string; + export function realpathSync(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' })): Buffer; + export function realpathSync(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null): string; + + /** + * Asynchronous rename(2). + */ + export function rename(oldPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous rename(2). + */ + export function renameSync(oldPath: string | Buffer, newPath: string | Buffer): void; + + /** + * Asynchronous rmdir(2). + */ + export function rmdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous rmdir(2). + */ + export function rmdirSync(path: string | Buffer): void; + + /** + * Asynchronous stat(2). + * + * In case of an error, the `err.code` will be one of Common System Errors. + * + * Using `fs.stat()` to check for the existence of a file before calling `fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Instead, user code should open/read/write the file directly and handle the error raised if the file is not available. + * + * To check if a file exists without manipulating it afterwards, `fs.access()` is recommended. + */ + export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; + + /** + * Synchronous stat(2). + */ + export function statSync(path: string | Buffer): Stats; + + /** + * Asynchronous symlink(2). The type argument is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using `'junction'`, the target argument will automatically be normalized to absolute path. + */ + export function symlink(target: string | Buffer, path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function symlink(target: string | Buffer, path: string | Buffer, type: 'dir' | 'file' | 'junction', callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous symlink(2). + */ + export function symlinkSync(target: string | Buffer, path: string | Buffer, type?: 'dir' | 'file' | 'junction'): void; + + /** + * Asynchronous truncate(2). + */ + export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous truncate(2). + */ + export function truncateSync(path: string | Buffer, len?: number): void; + + /** + * Asynchronous unlink(2). + */ + export function unlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous unlink(2). + */ + export function unlinkSync(path: string | Buffer): void; + + /** + * Stop watching for changes on `filename`. If `listener` is specified, only that particular listener is removed. Otherwise, _all_ listeners are removed and you have effectively stopped watching `filename`. + * + * Calling `fs.unwatchFile()` with a filename that is not being watched is a no-op, not an error. + * + * Note: `fs.watch()` is more efficient than `fs.watchFile()` and `fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()` when possible. + */ + export function unwatchFile(filename: string | Buffer, listener?: WatchListener): void; + + /** + * Change file timestamps of the file referenced by the supplied path. + * + * Note: the arguments `atime` and `mtime` of the following related functions follow these rules: + * + * - The value should be a Unix timestamp in seconds. For example, `Date.now()` returns milliseconds, so it should be divided by 1000 before passing it in. + * If the value is a numeric string like `'123456789'`, the value will get converted to the corresponding number. + * If the value is `NaN` or `Infinity`, the value will get converted to `Date.now() / 1000`. + */ + export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; + + /** + * Synchronous version of `fs.utimes()`. + */ + export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; + + export interface WatchOptions { + /** + * Indicates whether the process should continue to run as long as files are being watched. default = `true`. */ - export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path + persistent?: boolean; + /** + * Indicates whether all subdirectories should be watched, or only the current directory. The applies when a directory is specified, and only on supported platforms (See Caveats). default = `false`. */ - export function rmdirSync(path: string | Buffer): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. + recursive?: boolean; + /** + * Specifies the character encoding to be used for the filename passed to the listener. default = `'utf8'`. */ - export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. + encoding?: buffer.Encoding; + } + + /** + * Watch for changes on `filename`, where `filename` is either a file or a directory. The returned object is a `fs.FSWatcher`. + * + * Please note the listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but they are not the same thing. + */ + export function watch(filename: string | Buffer): FSWatcher; + export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null): FSWatcher; + export function watch(filename: string | Buffer, listener: WatchListener): FSWatcher; + export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null, listener: WatchListener): FSWatcher; + + export interface WatchFileOptions { + /** + * Indicates whether the process should continue to run as long as files are being watched */ - export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. + persistent: boolean; + /** + * Indicates how often the target should be polled in milliseconds. The default is `5007`. */ - export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: number): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string | Buffer, mode?: string): void; - /* - * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @param callback The created folder path is passed as a string to the callback's second parameter. - */ - export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void; - /* - * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * @param prefix - * @returns Returns the created folder path. - */ - export function mkdtempSync(prefix: string): string; - export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string | Buffer): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; - export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; - export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; - export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number; - export function writeSync(fd: number, data: any, position?: number, enconding?: string): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; - export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void; - export function existsSync(path: string | Buffer): boolean; + interval: number; + } - export namespace constants { - // File Access Constants + /** + * Watch for changes on filename. The callback listener will be called each time the file is accessed. + * + * Note: when an `fs.watchFile` operation results in an `ENOENT` error, it will invoke the listener once, with all the fields zeroed (or, for dates, the Unix Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`, instead of zero. If the file is created later on, the listener will be called again, with the latest stat objects. + * + * Note: `fs.watch()` is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible. + */ + export function watchFile(filename: string | Buffer, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string | Buffer, options: WatchFileOptions | null, listener: (curr: Stats, prev: Stats) => void): void; - /** Constant for fs.access(). File is visible to the calling process. */ - export const F_OK: number; + /** + * Write `buffer` to the file specified by `fd`. + * + * `offset` and `length` determine the part of the buffer to be written. + * + * `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'number'`, the data will be written at the current position. See pwrite(2). + * + * Note that it is unsafe to use `fs.write` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. + * + * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file. + */ + export function write(fd: number, buffer: string | Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; + export function write(fd: number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + export function write(fd: number, data: string | Buffer, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + export function write(fd: number, data: string | Buffer, position: number, encoding: buffer.Encoding, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; - /** Constant for fs.access(). File can be read by the calling process. */ - export const R_OK: number; + export interface WriteFileOptions { + encoding?: buffer.Encoding; + mode?: number; + flag?: string; + } - /** Constant for fs.access(). File can be written by the calling process. */ - export const W_OK: number; + /** + * Asynchronously writes data to a file, replacing the file if it already exists. + * + * Note that it is unsafe to use `fs.writeFile` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. + * + * Note: If a file descriptor is specified as the `file`, it will not be closed automatically. + */ + export function writeFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; + export function writeFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void; - /** Constant for fs.access(). File can be executed by the calling process. */ - export const X_OK: number; + /** + * The synchronous version of `fs.writeFile()`. + */ + export function writeFileSync(file: string | Buffer | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions | null): void; - // File Open Constants - - /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ - export const O_RDONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ - export const O_WRONLY: number; - - /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ - export const O_RDWR: number; - - /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ - export const O_CREAT: number; - - /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ - export const O_EXCL: number; - - /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */ - export const O_NOCTTY: number; - - /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ - export const O_TRUNC: number; - - /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ - export const O_APPEND: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ - export const O_DIRECTORY: number; - - /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */ - export const O_NOATIME: number; - - /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ - export const O_NOFOLLOW: number; - - /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ - export const O_SYNC: number; - - /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ - export const O_SYMLINK: number; - - /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ - export const O_DIRECT: number; - - /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ - export const O_NONBLOCK: number; - - // File Type Constants - - /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ - export const S_IFMT: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ - export const S_IFREG: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ - export const S_IFDIR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ - export const S_IFCHR: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ - export const S_IFBLK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ - export const S_IFIFO: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ - export const S_IFLNK: number; - - /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ - export const S_IFSOCK: number; - - // File Mode Constants - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ - export const S_IRWXU: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ - export const S_IRUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ - export const S_IWUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ - export const S_IXUSR: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ - export const S_IRWXG: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ - export const S_IRGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ - export const S_IWGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ - export const S_IXGRP: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ - export const S_IRWXO: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ - export const S_IROTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ - export const S_IWOTH: number; - - /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ - export const S_IXOTH: number; - } - - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string | Buffer, mode?: number): void; - export function createReadStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - }): ReadStream; - export function createWriteStream(path: string | Buffer, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - }): WriteStream; - export function fdatasync(fd: number, callback: Function): void; - export function fdatasyncSync(fd: number): void; + /** + * Synchronous `fs.write`. + */ + export function writeSync(fd: number, buffer: string | Buffer, offset: number, length: number, position?: number): void; + export function writeSync(fd: number, data: string | Buffer, position?: number, encoding?: buffer.Encoding): void; } declare module "path" { + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + export interface ParsedPath { /** - * A parsed path object generated by path.parse() or consumed by path.format(). + * The root of the path such as '/' or 'c:\' */ - export interface ParsedPath { - /** - * The root of the path such as '/' or 'c:\' - */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ + export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: string[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ + export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ + export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ + export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ + export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + export var delimiter: string; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; + + export module posix { export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths paths to join. - */ export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: any[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ + export function resolve(...pathSegments: string[]): string; + export function isAbsolute(p: string): boolean; export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } - export module posix { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } - - export module win32 { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } + export module win32 { + export function normalize(p: string): string; + export function join(...paths: string[]): string; + export function resolve(...pathSegments: string[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } } declare module "string_decoder" { - export interface NodeStringDecoder { - write(buffer: Buffer): string; - end(buffer?: Buffer): string; - } - export var StringDecoder: { - new (encoding?: string): NodeStringDecoder; - }; + import * as buffer from "buffer"; + + export class StringDecoder { + /** + * @param encoding The character encoding the `StringDecoder` will use. Defaults to `'utf8'`. + */ + constructor(encoding?: buffer.Encoding); + /** + * Returns a decoded string, ensuring that any incomplete multibyte characters at the end of the `Buffer` are omitted from the returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`. + * + * @param buffer A `Buffer` containing the bytes to decode. + */ + write(buffer: Buffer): string; + /** + * Returns any remaining input stored in the internal buffer as a string. Bytes representing incomplete UTF-8 and UTF-16 characters will be replaced with substitution characters appropriate for the character encoding. + * + * If the `buffer` argument is provided, one final call to `stringDecoder.write()` is performed before returning the remaining input. + * + * @param buffer A `Buffer` containing the bytes to decode. + */ + end(buffer?: Buffer): string; + } } declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; + import * as crypto from "crypto"; + import * as net from "net"; + import * as stream from "stream"; - var CLIENT_RENEG_LIMIT: number; - var CLIENT_RENEG_WINDOW: number; + export var CLIENT_RENEG_LIMIT: number; + export var CLIENT_RENEG_WINDOW: number; + export var SLAB_BUFFER_SIZE: number; + export var DEFAULT_CIPHERS: string; + export var DEFAULT_ECDH_CURVE: string; - export interface Certificate { - /** - * Country code. - */ - C: string; - /** - * Street. - */ - ST: string; - /** - * Locality. - */ - L: string; - /** - * Organization. - */ - O: string; - /** - * Organizational unit. - */ - OU: string; - /** - * Common name. - */ - CN: string; - } + export class Server extends net.Server { + /** + * The `server.addContext()` method adds a secure context that will be used if the client request's SNS hostname matches the supplied `hostname` (or wildcard). + * + * @param hostname A SNI hostname or wildcard (e.g. `'*'`) + * @param options An object containing any of the possible properties from the `tls.createSecureContext()` options arguments + */ + addContext(hostName: string, options: SecureContextOptions): void; + /** + * Returns a `Buffer` instance holding the keys currently used for encryption/decryption of the TLS Session Tickets. + */ + getTicketKeys(): Buffer; + /** + * Updates the keys for encryption/decryption of the TLS Session Tickets. + * + * Note: The key's Buffer should be 48 bytes long. See ticketKeys option in tls.createServer for more information on how it is used. + * + * Note: Changes to the ticket keys are effective only for future server connections. Existing or currently pending server connections will use the previous keys. + */ + setTicketKeys(keys: Buffer): void; + /** + * Returns the current number of concurrent connections on the server. + */ + connections: number; + } - export interface CipherNameAndProtocol { - /** - * The cipher name. - */ - name: string; - /** - * SSL/TLS protocol version. - */ - version: string; - } + export interface Certificate { + /** + * Country code. + */ + C: string; + /** + * Street. + */ + ST: string; + /** + * Locality. + */ + L: string; + /** + * Organization. + */ + O: string; + /** + * Organizational unit. + */ + OU: string; + /** + * Common name. + */ + CN: string; + } - export class TLSSocket extends stream.Duplex { - /** - * Construct a new tls.TLSSocket object from an existing TCP socket. - */ - constructor(socket:net.Socket, options?: { - /** - * An optional TLS context object from tls.createSecureContext() - */ - secureContext?: SecureContext, - /** - * If true the TLS socket will be instantiated in server-mode. - * Defaults to false. - */ - isServer?: boolean, - /** - * An optional net.Server instance. - */ - server?: net.Server, - /** - * If true the server will request a certificate from clients that - * connect and attempt to verify that certificate. Defaults to - * false. - */ - requestCert?: boolean, - /** - * If true the server will reject any connection which is not - * authorized with the list of supplied CAs. This option only has an - * effect if requestCert is true. Defaults to false. - */ - rejectUnauthorized?: boolean, - /** - * An array of strings or a Buffer naming possible NPN protocols. - * (Protocols should be ordered by their priority.) - */ - NPNProtocols?: string[] | Buffer, - /** - * An array of strings or a Buffer naming possible ALPN protocols. - * (Protocols should be ordered by their priority.) When the server - * receives both NPN and ALPN extensions from the client, ALPN takes - * precedence over NPN and the server does not send an NPN extension - * to the client. - */ - ALPNProtocols?: string[] | Buffer, - /** - * SNICallback(servername, cb) A function that will be - * called if the client supports SNI TLS extension. Two arguments - * will be passed when called: servername and cb. SNICallback should - * invoke cb(null, ctx), where ctx is a SecureContext instance. - * (tls.createSecureContext(...) can be used to get a proper - * SecureContext.) If SNICallback wasn't provided the default callback - * with high-level API will be used (see below). - */ - SNICallback?: Function, - /** - * An optional Buffer instance containing a TLS session. - */ - session?: Buffer, - /** - * If true, specifies that the OCSP status request extension will be - * added to the client hello and an 'OCSPResponse' event will be - * emitted on the socket before establishing a secure communication - */ - requestOCSP?: boolean - }); - /** - * Returns the bound address, the address family name and port of the underlying socket as reported by - * the operating system. - * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. - */ - address(): { port: number; family: string; address: string }; - /** - * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false. - */ - authorized: boolean; - /** - * The reason why the peer's certificate has not been verified. - * This property becomes available only when tlsSocket.authorized === false. - */ - authorizationError: Error; - /** - * Static boolean value, always true. - * May be used to distinguish TLS sockets from regular ones. - */ - encrypted: boolean; - /** - * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection. - * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name - * and the SSL/TLS protocol version of the current connection. - */ - getCipher(): CipherNameAndProtocol; - /** - * Returns an object representing the peer's certificate. - * The returned object has some properties corresponding to the field of the certificate. - * If detailed argument is true the full chain with issuer property will be returned, - * if false only the top certificate without issuer property. - * If the peer does not provide a certificate, it returns null or an empty object. - * @param {boolean} detailed - If true; the full chain with issuer property will be returned. - * @returns {any} - An object representing the peer's certificate. - */ - getPeerCertificate(detailed?: boolean): { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: any; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - }; - /** - * Could be used to speed up handshake establishment when reconnecting to the server. - * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated. - */ - getSession(): any; - /** - * NOTE: Works only with client TLS sockets. - * Useful only for debugging, for session reuse provide session option to tls.connect(). - * @returns {any} - TLS session ticket or undefined if none was negotiated. - */ - getTLSTicket(): any; - /** - * The string representation of the local IP address. - */ - localAddress: string; - /** - * The numeric representation of the local port. - */ - localPort: string; - /** - * The string representation of the remote IP address. - * For example, '74.125.127.100' or '2001:4860:a005::68'. - */ - remoteAddress: string; - /** - * The string representation of the remote IP family. 'IPv4' or 'IPv6'. - */ - remoteFamily: string; - /** - * The numeric representation of the remote port. For example, 443. - */ - remotePort: number; - /** - * Initiate TLS renegotiation process. - * - * NOTE: Can be used to request peer's certificate after the secure connection has been established. - * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout. - * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized, - * requestCert (See tls.createServer() for details). - * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation - * is successfully completed. - */ - renegotiate(options: TlsOptions, callback: (err: Error) => any): any; - /** - * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by - * the TLS layer until the entire fragment is received and its integrity is verified; - * large fragments can span multiple roundtrips, and their processing can be delayed due to packet - * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, - * which may decrease overall server throughput. - * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). - * @returns {boolean} - Returns true on success, false otherwise. - */ - setMaxSendFragment(size: number): boolean; + export interface Cipher { + /** + * The cipher name. + */ + name: string; + /** + * SSL/TLS protocol version. + */ + version: string; + } - /** - * events.EventEmitter - * 1. OCSPResponse - * 2. secureConnect - **/ - addListener(event: string, listener: Function): this; - addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - addListener(event: "secureConnect", listener: () => void): this; + export interface EphemeralKeyInfo { + type: 'DH' | 'ECDH'; + name?: string; + size: number; + } - emit(event: string, ...args: any[]): boolean; - emit(event: "OCSPResponse", response: Buffer): boolean; - emit(event: "secureConnect"): boolean; + export interface PeerCertificate { + subject: Certificate; + issuerInfo: Certificate; + issuer: Certificate; + raw: Buffer; + valid_from: string; + valid_to: string; + fingerprint: string; + serialNumber: string; + } - on(event: string, listener: Function): this; - on(event: "OCSPResponse", listener: (response: Buffer) => void): this; - on(event: "secureConnect", listener: () => void): this; + export interface TLSSocketOptions { + /** + * An optional TLS context object from `tls.createSecureContext()`. + */ + secureContext?: SecureContext; + /** + * If true the TLS socket will be instantiated in server-mode. Defaults to `false`. + */ + isServer?: boolean; + /** + * An optional net.Server instance. + */ + server?: net.Server; + /** + * Optional, see `tls.createServer()`. + */ + requestCert?: boolean; + /** + * Optional, see `tls.createServer()`. + */ + rejectUnauthorized?: boolean; + /** + * Optional, see `tls.createServer()`. + */ + NPNProtocols?: string[] | Buffer; + /** + * Optional, see `tls.createServer()`. + */ + ALPNProtocols?: string[] | Buffer; + /** + * Optional, see `tls.createServer()`. + */ + SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; + /** + * An optional Buffer instance containing a TLS session. + */ + session?: Buffer; + /** + * If `true`, specifies that the OCSP status request extension will be added to the client hello and an 'OCSPResponse' event will be emitted on the socket before establishing a secure communication + */ + requestOCSP?: boolean; + } - once(event: string, listener: Function): this; - once(event: "OCSPResponse", listener: (response: Buffer) => void): this; - once(event: "secureConnect", listener: () => void): this; + export interface RenegotiateOptions { + rejectUnauthorized?: boolean; + requestCert?: boolean; + } - prependListener(event: string, listener: Function): this; - prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependListener(event: "secureConnect", listener: () => void): this; + export class TLSSocket extends net.Socket { + /** + * Construct a new `tls.TLSSocket` object from an existing TCP socket. + */ + constructor(socket: net.Socket, options?: TLSSocketOptions); + /** + * Returns `true` if the peer certificate was signed by one of the CAs specified when creating the `tls.TLSSocket` instance, otherwise `false`. + */ + authorized: boolean; + /** + * Returns the reason why the peer's certificate was not been verified. This property is set only when `tlsSocket.authorized === false`. + */ + authorizationError?: Error; + /** + * Always returns `true`. This may be used to distinguish TLS sockets from regular `net.Socket` instances. + */ + encrypted: true; + /** + * Returns an object representing the cipher name and the SSL/TLS protocol version that first defined the cipher. + */ + getCipher(): Cipher; + /** + * Returns an object representing the type, name, and size of parameter of an ephemeral key exchange in Perfect Forward Secrecy on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; `null` is returned if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The `name` property is available only when type is `'ECDH'`. + */ + getEphemeralKeyInfo(): EphemeralKeyInfo; + /** + * Returns an object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. + * + * @param detailed Specify `true` to request that the full certificate chain with the `issuer` property be returned; false to return only the top certificate without the `issuer` property. + */ + getPeerCertificate(detailed?: boolean): PeerCertificate; + /** + * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process. The value `null` will be returned for server sockets or disconnected client sockets. + */ + getProtocol(): string | null; + /** + * Returns the ASN.1 encoded TLS session or `undefined` if no session was negotiated. Can be used to speed up handshake establishment when reconnecting to the server. + */ + getSession(): Buffer | undefined; + /** + * Returns the TLS session ticket or `undefined` if no session was negotiated. + * + * Note: This only works with client TLS sockets. Useful only for debugging, for session reuse `provide` session option to `tls.connect()`. + */ + getTLSTicket(): Buffer | undefined; + /** + * Returns the string representation of the local IP address. + */ + localAddress: string; + /** + * Returns the numeric representation of the local port. + */ + localPort: number; + /** + * Returns the string representation of the remote IP address. For example, `'74.125.127.100'` or `'2001:4860:a005::68'`. + */ + remoteAddress: string; + /** + * Returns the string representation of the remote IP family. `'IPv4'` or `'IPv6'`. + */ + remoteFamily: string; + /** + * The numeric representation of the remote port. For example, 443. + */ + remotePort: number; + /** + * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process. + * + * Note: This method can be used to request a peer's certificate after the secure connection has been established. + * + * Note: When running as the server, the socket will be destroyed with an error after `handshakeTimeout` timeout. + */ + renegotiate(options: RenegotiateOptions, callback: (err: Error | null) => any): any; + /** + * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size. Returns `true` if setting the limit succeeded; false otherwise. + * + * Smaller fragment sizes decrease the buffering latency on the client: larger fragments are buffered by the TLS layer until the entire fragment is received and its integrity is verified; large fragments can span multiple roundtrips and their processing can be delayed due to packet loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, which may decrease overall server throughput. + * + * @param size The maximum TLS fragment size. Defaults to `16384`. The maximum value is `16384`. + */ + setMaxSendFragment(size: number): boolean; + } - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; - prependOnceListener(event: "secureConnect", listener: () => void): this; - } + export interface ConnectOptions { + /** + * Host the client should connect to. + */ + host?: string; + /** + * Port the client should connect to. + */ + port?: number | string; + /** + * Establish secure connection on a given socket rather than creating a new socket. If this option is specified, `host` and `port` are ignored. + */ + socket?: net.Socket; + /** + * Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored. + */ + path?: string; + /** + * A `string` or `Buffer` containing the private key, certificate, and CA certs of the client in PFX or PKCS12 format. + */ + pfx?: string | Buffer; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s containing the private key of the client in PEM format. + */ + key?: string | Buffer | string[] | Buffer[]; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s containing the certificate key of the client in PEM format. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * A string describing the ciphers to use or exclude, separated by `:`. Uses the same default cipher suite as `tls.createServer()`. + */ + ciphers?: string; + /** + * If true, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code. Defaults to `true`. + */ + rejectUnauthorized?: boolean; + /** + * An array of strings or `Buffer`s containing supported NPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['hello', 'world']`. + */ + NPNProtocols?: string[] | Buffer[]; + /** + * An array of strings or `Buffer`s containing the supported ALPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler: `['hello', 'world']`.) + */ + ALPNProtocols?: string[] | Buffer[]; + /** + * Server name for the SNI (Server Name Indication) TLS extension. + */ + servername?: string; + /** + * A callback function to be used when checking the server's hostname against the certificate. This should throw an error if verification fails. The method should return `undefined` if the `servername` and `cert` are verified. + */ + checkServerIdentity?: (servername: string, cert: Buffer) => void; + /** + * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + /** + * An optional TLS context object as returned by from `tls.createSecureContext( ... )`. It can be used for caching client certificates, keys, and CA certificates. + */ + secureContext?: SecureContext; + /** + * A `Buffer` instance, containing TLS session. + */ + session?: Buffer; + /** + * Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown. Defaults to `1024`. + */ + minDHSize?: number; + } - export interface TlsOptions { - host?: string; - port?: number; - pfx?: string | Buffer[]; - key?: string | string[] | Buffer | any[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | string[] | Buffer | Buffer[]; - crl?: string | string[]; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: string[] | Buffer; - SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any; - ecdhCurve?: string; - dhparam?: string | Buffer; - handshakeTimeout?: number; - ALPNProtocols?: string[] | Buffer; - sessionTimeout?: number; - ticketKeys?: any; - sessionIdContext?: string; - secureProtocol?: string; - } + export interface SecureContextOptions { + /** + * A string or `Buffer` holding the PFX or PKCS12 encoded private key, certificate, and CA certificates. + */ + pfx?: string | Buffer; + /** + * The private key of the server in PEM format. To support multiple keys using different algorithms, an array can be provided either as an array of key strings or as an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. + */ + key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string containing the PEM encoded certificate. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). + */ + crl?: string | string[]; + /** + * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. + */ + ciphers?: string; + /** + * If `true`, when a cipher is being selected, the server's preferences will be used instead of the client preferences. + */ + honorCipherOrder?: boolean; + } - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: string | Buffer - key?: string | string[] | Buffer | Buffer[]; - passphrase?: string; - cert?: string | string[] | Buffer | Buffer[]; - ca?: string | Buffer | (string | Buffer)[]; - rejectUnauthorized?: boolean; - NPNProtocols?: (string | Buffer)[]; - servername?: string; - path?: string; - ALPNProtocols?: (string | Buffer)[]; - checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any; - secureProtocol?: string; - secureContext?: Object; - session?: Buffer; - minDHSize?: number; - } + export interface CreateServerOptions { + /** + * A `string` or `Buffer` containing the private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the `key`, `cert`, and `ca` options.) + */ + pfx?: string | Buffer; + /** + * The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. + */ + key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; + /** + * A string containing the passphrase for the private key or pfx. + */ + passphrase?: string; + /** + * A string containing the PEM encoded certificate. + */ + cert?: string | Buffer | string[] | Buffer[]; + /** + * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. + */ + ca?: string | Buffer | string[] | Buffer[]; + /** + * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). + */ + crl?: string | string[]; + /** + * A string describing the ciphers to use or exclude, separated by `:`. + */ + ciphers?: string; + /** + * A string describing a named curve to use for ECDH key agreement or false to disable ECDH. Defaults to `prime256v1` (NIST P-256). Use crypto.getCurves() to obtain a list of available curve names. On recent releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve. + */ + ecdhCurve?: string; + /** + * A string or `Buffer` containing Diffie Hellman parameters, required for Perfect Forward Secrecy. Use `openssl dhparam` to create the parameters. The key length must be greater than or equal to 1024 bits, otherwise an error will be thrown. It is strongly recommended to use 2048 bits or larger for stronger security. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. + */ + dhparam?: string | Buffer; + /** + * Abort the connection if the SSL/TLS handshake does not finish in the specified number of milliseconds. Defaults to `120` seconds. A `'clientError'` is emitted on the `tls.Server` object whenever a handshake times out. + */ + handshakeTimeout?: number; + /** + * When choosing a cipher, use the server's preferences instead of the client preferences. Defaults to `true`. + */ + honorCipherOrder?: boolean; + /** + * If `true` the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to `false`. + */ + requestCert?: boolean; + /** + * If `true` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if `requestCert` is `true`. Defaults to `false`. + */ + rejectUnauthorized?: boolean; + /** + * An array of strings or a `Buffer` naming possible NPN protocols. (Protocols should be ordered by their priority.) + */ + NPNProtocols?: string[] | Buffer; + /** + * An array of strings or a `Buffer` naming possible ALPN protocols. (Protocols should be ordered by their priority.) When the server receives both NPN and ALPN extensions from the client, ALPN takes precedence over NPN and the server does not send an NPN extension to the client. + */ + ALPNProtocols?: string[] | Buffer; + /** + * A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `cb`. `SNICallback` should invoke `cb(null, ctx)`, where `ctx` is a SecureContext instance. (`tls.createSecureContext(...)` can be used to get a proper SecureContext.) If `SNICallback` wasn't provided the default callback with high-level API will be used (see below). + */ + SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; + /** + * An integer specifying the number of seconds after which the TLS session identifiers and TLS session tickets created by the server will time out. See SSL_CTX_set_timeout for more details. + */ + sessionTimeout?: number; + /** + * A 48-byte `Buffer` instance consisting of a 16-byte prefix, a 16-byte HMAC key, and a 16-byte AES key. This can be used to accept TLS session tickets on multiple instances of the TLS server. Note that this is automatically shared between `cluster` module workers. + */ + ticketKeys?: Buffer; + /** + * A string containing an opaque identifier for session resumption. If `requestCert` is true, the default is a 128 bit truncated SHA1 hash value generated from the command-line. Otherwise, a default is not provided. + */ + sessionIdContext?: string; + /** + * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. + */ + secureProtocol?: string; + } - export interface Server extends net.Server { - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - addContext(hostName: string, credentials: { - key: string; - cert: string; - ca: string; - }): void; - maxConnections: number; - connections: number; + export interface SecureContext { + context: any; + } - /** - * events.EventEmitter - * 1. tlsClientError - * 2. newSession - * 3. OCSPRequest - * 4. resumeSession - * 5. secureConnection - **/ - addListener(event: string, listener: Function): this; - addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + /** + * Creates a new tls.Server. The secureConnectionListener, if provided, is automatically set as a listener for the `'secureConnection'` event. + */ + export function createServer(options: CreateServerOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; - emit(event: string, ...args: any[]): boolean; - emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; - emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean; - emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean; - emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; - emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; + /** + * Creates a new client connection to the given `port` and `host` or `options.port` and `options.host`. (If `host` is omitted, it defaults to `localhost`.) + */ + export function connect(options: ConnectOptions, callback?: () => void): TLSSocket; + export function connect(port: number, options?: ConnectOptions, callback?: () => void): TLSSocket; + export function connect(port: number, host?: string, options?: ConnectOptions, callback?: () => void): TLSSocket; - on(event: string, listener: Function): this; - on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + /** + * The `tls.createSecureContext()` method creates a credentials object. + * + * If the `'ca'` option is not given, then Node.js will use the default publicly trusted list of CAs as given in http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt. + */ + export function createSecureContext(options: SecureContextOptions): SecureContext; - once(event: string, listener: Function): this; - once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; - prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; - prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; - prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; - prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - } - - export interface ClearTextStream extends stream.Duplex { - authorized: boolean; - authorizationError: Error; - getPeerCertificate(): any; - getCipher: { - name: string; - version: string; - }; - address: { - port: number; - family: string; - address: string; - }; - remoteAddress: string; - remotePort: number; - } - - export interface SecurePair { - encrypted: any; - cleartext: any; - } - - export interface SecureContextOptions { - pfx?: string | Buffer; - key?: string | Buffer; - passphrase?: string; - cert?: string | Buffer; - ca?: string | Buffer; - crl?: string | string[] - ciphers?: string; - honorCipherOrder?: boolean; - } - - export interface SecureContext { - context: any; - } - - export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) => void): Server; - export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): ClearTextStream; - export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream; - export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream; - export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; - export function createSecureContext(details: SecureContextOptions): SecureContext; + /** + * Returns an array with the names of the supported SSL ciphers. + */ + export function getCiphers(): string[]; } declare module "crypto" { - export interface Certificate { - exportChallenge(spkac: string | Buffer): Buffer; - exportPublicKey(spkac: string | Buffer): Buffer; - verifySpkac(spkac: Buffer): boolean; - } - export var Certificate: { - new (): Certificate; - (): Certificate; - } + import * as stream from "stream"; - export var fips: boolean; + export var constants: { + defaultCipherList: string; + defaultCoreCipherList: string; + [key: string]: string | number; + } - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: string | string[]; - crl: string | string[]; - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string | Buffer): Hmac; + export function getCiphers(): string[]; + export function getCurves(): string[]; + export function getHashes(): string[]; - type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1"; - type HexBase64Latin1Encoding = "latin1" | "hex" | "base64"; - type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary"; - type HexBase64BinaryEncoding = "binary" | "base64" | "hex"; - type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; + export class Certificate { + constructor(); + exportChallenge(spkac: string | Buffer, encoding?: string): string; + exportPublicKey(spkac: string | Buffer, encoding?: string): Buffer; + verifySpkac(spkac: Buffer): boolean; + } - export interface Hash extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hash; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export interface Hmac extends NodeJS.ReadWriteStream { - update(data: string | Buffer): Hmac; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; - digest(): Buffer; - digest(encoding: HexBase64Latin1Encoding): string; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - export interface Cipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; - update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - getAuthTag(): Buffer; - setAAD(buffer: Buffer): void; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - export interface Decipher extends NodeJS.ReadWriteStream { - update(data: Buffer): Buffer; - update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; - update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding?: boolean): void; - setAuthTag(tag: Buffer): void; - setAAD(buffer: Buffer): void; - } - export function createSign(algorithm: string): Signer; - export interface Signer extends NodeJS.WritableStream { - update(data: string | Buffer): Signer; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; - sign(private_key: string | { key: string; passphrase: string }): Buffer; - sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; - } - export function createVerify(algorith: string): Verify; - export interface Verify extends NodeJS.WritableStream { - update(data: string | Buffer): Verify; - update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; - verify(object: string, signature: Buffer): boolean; - verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; - } - export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; - export function createDiffieHellman(prime: Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman; - export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman; - export interface DiffieHellman { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrime(): Buffer; - getPrime(encoding: HexBase64Latin1Encoding): string; - getGenerator(): Buffer; - getGenerator(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - setPublicKey(public_key: Buffer): void; - setPublicKey(public_key: string, encoding: string): void; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: string): void; - verifyError: number; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - export interface RsaPublicKey { - key: string; - padding?: number; - } - export interface RsaPrivateKey { - key: string; - passphrase?: string, - padding?: number; - } - export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer - export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer - export function getCiphers(): string[]; - export function getCurves(): string[]; - export function getHashes(): string[]; - export interface ECDH { - generateKeys(): Buffer; - generateKeys(encoding: HexBase64Latin1Encoding): string; - generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - computeSecret(other_public_key: Buffer): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; - computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; - getPrivateKey(): Buffer; - getPrivateKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(): Buffer; - getPublicKey(encoding: HexBase64Latin1Encoding): string; - getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; - setPrivateKey(private_key: Buffer): void; - setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void; - } - export function createECDH(curve_name: string): ECDH; - export function timingSafeEqual(a: Buffer, b: Buffer): boolean; - export var DEFAULT_ENCODING: string; + export function createHash(algorithm: string): Hash; + + export class Hash extends stream.Transform { + update(data: string | Buffer, input_encoding?: string): Hash; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): string; + digest(): Buffer; + } + + export function createHmac(algorithm: string, key: string | Buffer): Hmac; + + export class Hmac extends stream.Transform { + update(data: string | Buffer, input_encoding?: string): Hmac; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): string; + digest(): Buffer; + } + + export function createCipher(algorithm: string, password: string | Buffer): Cipher; + export function createCipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Cipher; + + export class Cipher extends stream.Transform { + update(data: Buffer): Buffer; + update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1"): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: "binary" | "latin1" | "base64" | "hex"): string; + update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1", output_encoding: "binary" | "latin1" | "base64" | "hex"): string; + final(): Buffer; + final(output_encoding: string): string; + setAAD(buffer: Buffer): void; + setAutoPadding(auto_padding: boolean): void; + getAuthTag(): Buffer; + } + + export function createDecipher(algorithm: string, password: string | Buffer): Decipher; + export function createDecipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Decipher; + + export class Decipher extends stream.Transform { + update(data: Buffer): Buffer; + update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex"): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; + update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex", output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; + final(): Buffer; + final(output_encoding: string): string; + setAAD(buffer: Buffer): void; + setAutoPadding(auto_padding: boolean): void; + setAuthTag(tag: Buffer): void; + } + + export function createSign(algorithm: string): Signer; + + export class Signer extends stream.Writable { + update(data: string | Buffer): void; + sign(private_key: string): Buffer; + sign(private_key: string, output_format: string): string; + } + + export function createVerify(algorith: string): Verify; + + export class Verify extends stream.Writable { + update(data: string | Buffer): void; + verify(object: string, signature: string, signature_format?: string): boolean; + } + + export function createDiffieHellman(prime: number, prime_encoding?: string, generator?: number | string | Buffer, generator_encoding?: string): DiffieHellman; + export function createDiffieHellman(prime_length: number, generator?: number | string | Buffer): DiffieHellman; + export function getDiffieHellman(group_name: string): DiffieHellman; + + export class DiffieHellman { + verifyError: number; + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + generateKeys(encoding?: string): string; + getPrime(encoding?: string): string; + getGenerator(encoding?: string): string; + getPublicKey(encoding?: string): string; + getPrivateKey(encoding?: string): string; + setPublicKey(public_key: string, encoding?: string): void; + setPrivateKey(public_key: string, encoding?: string): void; + } + + export function createECDH(curve_name: string): ECDH; + + export class ECDH { + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + generateKeys(encoding?: string, format?: string): string; + getPrivateKey(encoding?: string): string; + getPublicKey(encoding?: string, format?: string): string; + setPrivateKey(private_key: string, encoding?: string): void; + } + + export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => void): void; + export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => void): void; + + export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number): Buffer; + export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; + + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + + export interface RsaKey { + key: string; + passphrase?: string, + padding?: number; + } + + export function timingSafeEqual(a: Buffer, b: Buffer): boolean; + export function publicEncrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; + export function privateEncrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; + export function publicDecrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; + export function privateDecrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; + + export function setEngine(engine: string, flags?: number): void; } declare module "stream" { - import * as events from "events"; + import * as events from "events"; - class internal extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - namespace internal { + export class Stream extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } - export class Stream extends internal { } + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + read?: (this: Readable, size?: number) => any; + } - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - read?: (size?: number) => any; - } + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; + isPaused(): boolean; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + } - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - protected _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + objectMode?: boolean; + write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + } - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. data - * 3. end - * 4. readable - * 5. error - **/ - addListener(event: string, listener: Function): this; - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "data", listener: (chunk: Buffer | string) => void): this; - addListener(event: "end", listener: () => void): this; - addListener(event: "readable", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + setDefaultEncoding(encoding: string): this; + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "data", chunk: Buffer | string): boolean; - emit(event: "end"): boolean; - emit(event: "readable"): boolean; - emit(event: "error", err: Error): boolean; + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + readableObjectMode?: boolean; + writableObjectMode?: boolean; + } - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "data", listener: (chunk: Buffer | string) => void): this; - on(event: "end", listener: () => void): this; - on(event: "readable", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements Writable { + writable: boolean; + constructor(opts?: DuplexOptions); + setDefaultEncoding(encoding: string): this; + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "data", listener: (chunk: Buffer | string) => void): this; - once(event: "end", listener: () => void): this; - once(event: "readable", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; + export interface TransformOptions extends ReadableOptions, WritableOptions { + write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + } - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependListener(event: "end", listener: () => void): this; - prependListener(event: "readable", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; + export class Transform extends Duplex { + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: string, callback: Function): void; + } - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; - prependOnceListener(event: "end", listener: () => void): this; - prependOnceListener(event: "readable", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; - removeListener(event: "end", listener: () => void): this; - removeListener(event: "readable", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - - /** - * Event emitter - * The defined events on documents including: - * 1. close - * 2. drain - * 3. error - * 4. finish - * 5. pipe - * 6. unpipe - **/ - addListener(event: string, listener: Function): this; - addListener(event: "close", listener: () => void): this; - addListener(event: "drain", listener: () => void): this; - addListener(event: "error", listener: (err: Error) => void): this; - addListener(event: "finish", listener: () => void): this; - addListener(event: "pipe", listener: (src: Readable) => void): this; - addListener(event: "unpipe", listener: (src: Readable) => void): this; - - emit(event: string, ...args: any[]): boolean; - emit(event: "close"): boolean; - emit(event: "drain", chunk: Buffer | string): boolean; - emit(event: "error", err: Error): boolean; - emit(event: "finish"): boolean; - emit(event: "pipe", src: Readable): boolean; - emit(event: "unpipe", src: Readable): boolean; - - on(event: string, listener: Function): this; - on(event: "close", listener: () => void): this; - on(event: "drain", listener: () => void): this; - on(event: "error", listener: (err: Error) => void): this; - on(event: "finish", listener: () => void): this; - on(event: "pipe", listener: (src: Readable) => void): this; - on(event: "unpipe", listener: (src: Readable) => void): this; - - once(event: string, listener: Function): this; - once(event: "close", listener: () => void): this; - once(event: "drain", listener: () => void): this; - once(event: "error", listener: (err: Error) => void): this; - once(event: "finish", listener: () => void): this; - once(event: "pipe", listener: (src: Readable) => void): this; - once(event: "unpipe", listener: (src: Readable) => void): this; - - prependListener(event: string, listener: Function): this; - prependListener(event: "close", listener: () => void): this; - prependListener(event: "drain", listener: () => void): this; - prependListener(event: "error", listener: (err: Error) => void): this; - prependListener(event: "finish", listener: () => void): this; - prependListener(event: "pipe", listener: (src: Readable) => void): this; - prependListener(event: "unpipe", listener: (src: Readable) => void): this; - - prependOnceListener(event: string, listener: Function): this; - prependOnceListener(event: "close", listener: () => void): this; - prependOnceListener(event: "drain", listener: () => void): this; - prependOnceListener(event: "error", listener: (err: Error) => void): this; - prependOnceListener(event: "finish", listener: () => void): this; - prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; - prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; - - removeListener(event: string, listener: Function): this; - removeListener(event: "close", listener: () => void): this; - removeListener(event: "drain", listener: () => void): this; - removeListener(event: "error", listener: (err: Error) => void): this; - removeListener(event: "finish", listener: () => void): this; - removeListener(event: "pipe", listener: (src: Readable) => void): this; - removeListener(event: "unpipe", listener: (src: Readable) => void): this; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - readableObjectMode?: boolean; - writableObjectMode?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - // Readable - pause(): this; - resume(): this; - // Writeable - writable: boolean; - constructor(opts?: DuplexOptions); - protected _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface TransformOptions extends DuplexOptions { - transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - flush?: (callback: Function) => any; - } - - // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { - readable: boolean; - writable: boolean; - constructor(opts?: TransformOptions); - protected _transform(chunk: any, encoding: string, callback: Function): void; - protected _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export class PassThrough extends Transform { } - } - - export = internal; + export class PassThrough extends Transform { } } declare module "util" { - export interface InspectOptions { - showHidden?: boolean; - depth?: number; - colors?: boolean; - customInspect?: boolean; + /** + * The `util.debuglog()` method is used to create a function that conditionally writes debug messages to `stderr` based on the existence of the `NODE_DEBUG` environment variable. If the `section` name appears within the value of that environment variable, then the returned function operates similar to console.error(). If not, then the returned function is a no-op. + */ + export function debuglog(section: string): (msg: any, ...args: any[]) => void; + + export interface InspectOptions { + /** + * If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`. + */ + showHidden?: boolean; + /** + * Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`. + */ + depth?: number | null; + /** + * If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see "Customizing util.inspect colors". + */ + colors?: boolean; + /** + * If `false`, then custom `inspect(depth, opts)` functions exported on the object being inspected will not be called. Defaults to `true`. + */ + customInspect?: boolean; + /** + * If `true`, then objects and functions that are `Proxy` objects will be introspected to show their `target` and `handler` objects. Defaults to `false`. + */ + showProxy?: boolean; + /** + * Specifies the maximum number of array and `TypedArray` elements to include when formatting. Defaults to `100`. Set to `null` to show all array elements. Set to `0` or negative to show no array elements. + */ + maxArrayLength?: number | null; + /** + * The length at which an object's keys are split across multiple lines. Set to `Infinity` to format an object as a single line. Defaults to `60` for legacy compatibility. + */ + breakLength?: number; + } + + /** + * The `util.inspect()` method returns a string representation of object that is primarily useful for debugging. + */ + export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + + export namespace inspect { + export var colors: { + bold: [number, number]; + italic: [number, number]; + underline: [number, number]; + inverse: [number, number]; + white: [number, number]; + grey: [number, number]; + black: [number, number]; + blue: [number, number]; + cyan: [number, number]; + green: [number, number]; + magenta: [number, number]; + red: [number, number]; + yellow: [number, number]; } - export function format(format: any, ...param: any[]): string; - export function debug(string: string): void; - export function error(...param: any[]): void; - export function puts(...param: any[]): void; - export function print(...param: any[]): void; - export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - export function isArray(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isDate(object: any): boolean; - export function isError(object: any): boolean; - export function inherits(constructor: any, superConstructor: any): void; - export function debuglog(key: string): (msg: string, ...param: any[]) => void; - export function isBoolean(object: any): boolean; - export function isBuffer(object: any): boolean; - export function isFunction(object: any): boolean; - export function isNull(object: any): boolean; - export function isNullOrUndefined(object: any): boolean; - export function isNumber(object: any): boolean; - export function isObject(object: any): boolean; - export function isPrimitive(object: any): boolean; - export function isString(object: any): boolean; - export function isSymbol(object: any): boolean; - export function isUndefined(object: any): boolean; - export function deprecate(fn: Function, message: string): Function; + export var styles: { + special: string; + number: string; + boolean: string; + undefined: string; + null: string; + string: string; + symbol: string; + date: string; + regexp: string; + }; + + export var custom: symbol; + } + + /** + * The `util.deprecate()` method wraps the given function or class in such a way that it is marked as deprecated. + */ + export function deprecate(fn: T, string: string): T; + + /** + * The `util.format()` method returns a formatted string using the first argument as a printf-like format. + */ + export function format(format: any, ...param: any[]): string; + + /** + * Inherit the prototype methods from one constructor into another. The prototype of constructor will be set to a new object created from superConstructor. + */ + export function inherits(constructor: any, superConstructor: any): void; + + /** + * Deprecated predecessor of `console.error`. + * + * @deprecated + */ + export function debug(string: string): void; + + /** + * Deprecated predecessor of `console.error`. + * + * @deprecated + */ + export function error(...strings: string[]): void; + + /** + * Internal alias for `Array.isArray`. + * + * @deprecated + */ + export function isArray(object: any): object is any[]; + + /** + * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isBoolean(object: any): object is boolean; + + /** + * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isBuffer(object: any): object is Buffer; + + /** + * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isDate(object: any): object is Date; + + /** + * Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isError(object: any): object is Error; + + /** + * Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isFunction(object: any): object is Function; + + /** + * Returns `true` if the given `object` is strictly `null`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNull(object: any): object is null; + + /** + * Returns `true` if the given `object` is `null` or `undefined`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNullOrUndefined(object: any): object is null | undefined; + + /** + * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isNumber(object: any): object is number; + + /** + * Returns true if the given `object` is strictly an `Object` and not a `Function`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isObject(object: any): object is Object; + + /** + * Returns true if the given `object` is a primitive type. Otherwise, returns `false`. + * + * @deprecated + */ + export function isPrimitive(object: any): object is string | number | boolean | null | undefined; + + /** + * Returns true if the given `object` is a `RegExp`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isRegExp(object: any): object is RegExp; + + /** + * Returns true if the given `object` is a `String`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isString(object: any): object is string; + + /** + * Returns true if the given `object` is a `Symbol`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isSymbol(object: any): object is symbol; + + /** + * Returns true if the given `object` is `undefined`. Otherwise, returns `false`. + * + * @deprecated + */ + export function isUndefined(object: any): object is symbol; + + /** + * The `util.log()` method prints the given `string` to `stdout` with an included timestamp. + * + * @deprecated + */ + export function log(string: string): void; + + /** + * Deprecated predecessor of `console.log`. + * + * @deprecated + */ + export function print(strings: string[]): void; + + /** + * Deprecated predecessor of `console.log`. + * + * @deprecated + */ + export function puts(strings: string[]): void; + + /** + * The `util._extend()` method was never intended to be used outside of internal Node.js modules. The community found and used it anyway. + * + * It is deprecated and should not be used in new code. JavaScript comes with very similar built-in functionality through `Object.assign()`. + * + * @deprecated + */ + export function _extend(target: T, source: U): T & U; } declare module "assert" { - function internal(value: any, message?: string): void; - namespace internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; + function internal(value: any, message?: string): void; + namespace internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; - constructor(options?: { - message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function - }); - } - - export function fail(actual: any, expected: any, message: string, operator: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; + constructor(options?: { + message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function + }); } - export = internal; + export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export function deepStrictEqual(actual: any, expected: any, message?: string): void; + export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export function ifError(value: any): void; + } + + export = internal; } declare module "tty" { - import * as net from "net"; + import * as net from "net"; - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - isTTY: boolean; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - isTTY: boolean; - } + export function isatty(fd: number): boolean; + export interface ReadStream extends net.Socket { + isRaw: boolean; + setRawMode(mode: boolean): void; + isTTY: boolean; + } + export interface WriteStream extends net.Socket { + columns: number; + rows: number; + isTTY: boolean; + } } declare module "domain" { - import * as events from "events"; + import * as events from "events"; - export class Domain extends events.EventEmitter implements NodeJS.Domain { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - members: any[]; - enter(): void; - exit(): void; - } + export class Domain extends events.EventEmitter implements NodeJS.Domain { + run(fn: Function): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + members: any[]; + enter(): void; + exit(): void; + } - export function create(): Domain; + export function create(): Domain; } declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFBLK: number; - export var S_IFIFO: number; - export var S_IFSOCK: number; - export var S_IRWXU: number; - export var S_IRUSR: number; - export var S_IWUSR: number; - export var S_IXUSR: number; - export var S_IRWXG: number; - export var S_IRGRP: number; - export var S_IWGRP: number; - export var S_IXGRP: number; - export var S_IRWXO: number; - export var S_IROTH: number; - export var S_IWOTH: number; - export var S_IXOTH: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_NOCTTY: number; - export var O_DIRECTORY: number; - export var O_NOATIME: number; - export var O_NOFOLLOW: number; - export var O_SYNC: number; - export var O_SYMLINK: number; - export var O_DIRECT: number; - export var O_NONBLOCK: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; - export var SIGQUIT: number; - export var SIGTRAP: number; - export var SIGIOT: number; - export var SIGBUS: number; - export var SIGUSR1: number; - export var SIGUSR2: number; - export var SIGPIPE: number; - export var SIGALRM: number; - export var SIGCHLD: number; - export var SIGSTKFLT: number; - export var SIGCONT: number; - export var SIGSTOP: number; - export var SIGTSTP: number; - export var SIGTTIN: number; - export var SIGTTOU: number; - export var SIGURG: number; - export var SIGXCPU: number; - export var SIGXFSZ: number; - export var SIGVTALRM: number; - export var SIGPROF: number; - export var SIGIO: number; - export var SIGPOLL: number; - export var SIGPWR: number; - export var SIGSYS: number; - export var SIGUNUSED: number; - export var defaultCoreCipherList: string; - export var defaultCipherList: string; - export var ENGINE_METHOD_RSA: number; - export var ALPN_ENABLED: number; + export var E2BIG: number; + export var EACCES: number; + export var EADDRINUSE: number; + export var EADDRNOTAVAIL: number; + export var EAFNOSUPPORT: number; + export var EAGAIN: number; + export var EALREADY: number; + export var EBADF: number; + export var EBADMSG: number; + export var EBUSY: number; + export var ECANCELED: number; + export var ECHILD: number; + export var ECONNABORTED: number; + export var ECONNREFUSED: number; + export var ECONNRESET: number; + export var EDEADLK: number; + export var EDESTADDRREQ: number; + export var EDOM: number; + export var EEXIST: number; + export var EFAULT: number; + export var EFBIG: number; + export var EHOSTUNREACH: number; + export var EIDRM: number; + export var EILSEQ: number; + export var EINPROGRESS: number; + export var EINTR: number; + export var EINVAL: number; + export var EIO: number; + export var EISCONN: number; + export var EISDIR: number; + export var ELOOP: number; + export var EMFILE: number; + export var EMLINK: number; + export var EMSGSIZE: number; + export var ENAMETOOLONG: number; + export var ENETDOWN: number; + export var ENETRESET: number; + export var ENETUNREACH: number; + export var ENFILE: number; + export var ENOBUFS: number; + export var ENODATA: number; + export var ENODEV: number; + export var ENOENT: number; + export var ENOEXEC: number; + export var ENOLCK: number; + export var ENOLINK: number; + export var ENOMEM: number; + export var ENOMSG: number; + export var ENOPROTOOPT: number; + export var ENOSPC: number; + export var ENOSR: number; + export var ENOSTR: number; + export var ENOSYS: number; + export var ENOTCONN: number; + export var ENOTDIR: number; + export var ENOTEMPTY: number; + export var ENOTSOCK: number; + export var ENOTSUP: number; + export var ENOTTY: number; + export var ENXIO: number; + export var EOPNOTSUPP: number; + export var EOVERFLOW: number; + export var EPERM: number; + export var EPIPE: number; + export var EPROTO: number; + export var EPROTONOSUPPORT: number; + export var EPROTOTYPE: number; + export var ERANGE: number; + export var EROFS: number; + export var ESPIPE: number; + export var ESRCH: number; + export var ETIME: number; + export var ETIMEDOUT: number; + export var ETXTBSY: number; + export var EWOULDBLOCK: number; + export var EXDEV: number; + export var WSAEINTR: number; + export var WSAEBADF: number; + export var WSAEACCES: number; + export var WSAEFAULT: number; + export var WSAEINVAL: number; + export var WSAEMFILE: number; + export var WSAEWOULDBLOCK: number; + export var WSAEINPROGRESS: number; + export var WSAEALREADY: number; + export var WSAENOTSOCK: number; + export var WSAEDESTADDRREQ: number; + export var WSAEMSGSIZE: number; + export var WSAEPROTOTYPE: number; + export var WSAENOPROTOOPT: number; + export var WSAEPROTONOSUPPORT: number; + export var WSAESOCKTNOSUPPORT: number; + export var WSAEOPNOTSUPP: number; + export var WSAEPFNOSUPPORT: number; + export var WSAEAFNOSUPPORT: number; + export var WSAEADDRINUSE: number; + export var WSAEADDRNOTAVAIL: number; + export var WSAENETDOWN: number; + export var WSAENETUNREACH: number; + export var WSAENETRESET: number; + export var WSAECONNABORTED: number; + export var WSAECONNRESET: number; + export var WSAENOBUFS: number; + export var WSAEISCONN: number; + export var WSAENOTCONN: number; + export var WSAESHUTDOWN: number; + export var WSAETOOMANYREFS: number; + export var WSAETIMEDOUT: number; + export var WSAECONNREFUSED: number; + export var WSAELOOP: number; + export var WSAENAMETOOLONG: number; + export var WSAEHOSTDOWN: number; + export var WSAEHOSTUNREACH: number; + export var WSAENOTEMPTY: number; + export var WSAEPROCLIM: number; + export var WSAEUSERS: number; + export var WSAEDQUOT: number; + export var WSAESTALE: number; + export var WSAEREMOTE: number; + export var WSASYSNOTREADY: number; + export var WSAVERNOTSUPPORTED: number; + export var WSANOTINITIALISED: number; + export var WSAEDISCON: number; + export var WSAENOMORE: number; + export var WSAECANCELLED: number; + export var WSAEINVALIDPROCTABLE: number; + export var WSAEINVALIDPROVIDER: number; + export var WSAEPROVIDERFAILEDINIT: number; + export var WSASYSCALLFAILURE: number; + export var WSASERVICE_NOT_FOUND: number; + export var WSATYPE_NOT_FOUND: number; + export var WSA_E_NO_MORE: number; + export var WSA_E_CANCELLED: number; + export var WSAEREFUSED: number; + export var SIGHUP: number; + export var SIGINT: number; + export var SIGILL: number; + export var SIGABRT: number; + export var SIGFPE: number; + export var SIGKILL: number; + export var SIGSEGV: number; + export var SIGTERM: number; + export var SIGBREAK: number; + export var SIGWINCH: number; + export var SSL_OP_ALL: number; + export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; + export var SSL_OP_CISCO_ANYCONNECT: number; + export var SSL_OP_COOKIE_EXCHANGE: number; + export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + export var SSL_OP_EPHEMERAL_RSA: number; + export var SSL_OP_LEGACY_SERVER_CONNECT: number; + export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; + export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; + export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; + export var SSL_OP_NETSCAPE_CA_DN_BUG: number; + export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; + export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NO_COMPRESSION: number; + export var SSL_OP_NO_QUERY_MTU: number; + export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + export var SSL_OP_NO_SSLv2: number; + export var SSL_OP_NO_SSLv3: number; + export var SSL_OP_NO_TICKET: number; + export var SSL_OP_NO_TLSv1: number; + export var SSL_OP_NO_TLSv1_1: number; + export var SSL_OP_NO_TLSv1_2: number; + export var SSL_OP_PKCS1_CHECK_1: number; + export var SSL_OP_PKCS1_CHECK_2: number; + export var SSL_OP_SINGLE_DH_USE: number; + export var SSL_OP_SINGLE_ECDH_USE: number; + export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; + export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; + export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; + export var SSL_OP_TLS_D5_BUG: number; + export var SSL_OP_TLS_ROLLBACK_BUG: number; + export var ENGINE_METHOD_DSA: number; + export var ENGINE_METHOD_DH: number; + export var ENGINE_METHOD_RAND: number; + export var ENGINE_METHOD_ECDH: number; + export var ENGINE_METHOD_ECDSA: number; + export var ENGINE_METHOD_CIPHERS: number; + export var ENGINE_METHOD_DIGESTS: number; + export var ENGINE_METHOD_STORE: number; + export var ENGINE_METHOD_PKEY_METHS: number; + export var ENGINE_METHOD_PKEY_ASN1_METHS: number; + export var ENGINE_METHOD_ALL: number; + export var ENGINE_METHOD_NONE: number; + export var DH_CHECK_P_NOT_SAFE_PRIME: number; + export var DH_CHECK_P_NOT_PRIME: number; + export var DH_UNABLE_TO_CHECK_GENERATOR: number; + export var DH_NOT_SUITABLE_GENERATOR: number; + export var NPN_ENABLED: number; + export var RSA_PKCS1_PADDING: number; + export var RSA_SSLV23_PADDING: number; + export var RSA_NO_PADDING: number; + export var RSA_PKCS1_OAEP_PADDING: number; + export var RSA_X931_PADDING: number; + export var RSA_PKCS1_PSS_PADDING: number; + export var POINT_CONVERSION_COMPRESSED: number; + export var POINT_CONVERSION_UNCOMPRESSED: number; + export var POINT_CONVERSION_HYBRID: number; + export var O_RDONLY: number; + export var O_WRONLY: number; + export var O_RDWR: number; + export var S_IFMT: number; + export var S_IFREG: number; + export var S_IFDIR: number; + export var S_IFCHR: number; + export var S_IFBLK: number; + export var S_IFIFO: number; + export var S_IFSOCK: number; + export var S_IRWXU: number; + export var S_IRUSR: number; + export var S_IWUSR: number; + export var S_IXUSR: number; + export var S_IRWXG: number; + export var S_IRGRP: number; + export var S_IWGRP: number; + export var S_IXGRP: number; + export var S_IRWXO: number; + export var S_IROTH: number; + export var S_IWOTH: number; + export var S_IXOTH: number; + export var S_IFLNK: number; + export var O_CREAT: number; + export var O_EXCL: number; + export var O_NOCTTY: number; + export var O_DIRECTORY: number; + export var O_NOATIME: number; + export var O_NOFOLLOW: number; + export var O_SYNC: number; + export var O_SYMLINK: number; + export var O_DIRECT: number; + export var O_NONBLOCK: number; + export var O_TRUNC: number; + export var O_APPEND: number; + export var F_OK: number; + export var R_OK: number; + export var W_OK: number; + export var X_OK: number; + export var UV_UDP_REUSEADDR: number; +} + +declare module "module" { + export = NodeModule; } declare module "process" { - export = process; -} - -declare module "v8" { - interface HeapSpaceInfo { - space_name: string; - space_size: number; - space_used_size: number; - space_available_size: number; - physical_space_size: number; - } - - const enum DoesZapCodeSpaceFlag { - Disabled = 0, - Enabled = 1 - } - - interface HeapInfo { - total_heap_size: number; - total_heap_size_executable: number; - total_physical_size: number; - total_available_size: number; - used_heap_size: number; - heap_size_limit: number; - malloced_memory: number; - peak_malloced_memory: number; - does_zap_garbage: DoesZapCodeSpaceFlag; - } - - export function getHeapStatistics(): HeapInfo; - export function getHeapSpaceStatistics(): HeapSpaceInfo[]; - export function setFlagsFromString(flags: string): void; + export = process; } declare module "timers" { - export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearTimeout(timeoutId: NodeJS.Timer): void; - export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function clearInterval(intervalId: NodeJS.Timer): void; - export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; - export function clearImmediate(immediateId: any): void; -} - -declare module "console" { - export = console; -} - -/** - * _debugger module is not documented. - * Source code is at https://github.com/nodejs/node/blob/master/lib/_debugger.js - */ -declare module "_debugger" { - export interface Packet { - raw: string; - headers: string[]; - body: Message; - } - - export interface Message { - seq: number; - type: string; - } - - export interface RequestInfo { - command: string; - arguments: any; - } - - export interface Request extends Message, RequestInfo { - } - - export interface Event extends Message { - event: string; - body?: any; - } - - export interface Response extends Message { - request_seq: number; - success: boolean; - /** Contains error message if success === false. */ - message?: string; - /** Contains message body if success === true. */ - body?: any; - } - - export interface BreakpointMessageBody { - type: string; - target: number; - line: number; - } - - export class Protocol { - res: Packet; - state: string; - execute(data: string): void; - serialize(rq: Request): string; - onResponse: (pkt: Packet) => void; - } - - export var NO_FRAME: number; - export var port: number; - - export interface ScriptDesc { - name: string; - id: number; - isNative?: boolean; - handle?: number; - type: string; - lineOffset?: number; - columnOffset?: number; - lineCount?: number; - } - - export interface Breakpoint { - id: number; - scriptId: number; - script: ScriptDesc; - line: number; - condition?: string; - scriptReq?: string; - } - - export interface RequestHandler { - (err: boolean, body: Message, res: Packet): void; - request_seq?: number; - } - - export interface ResponseBodyHandler { - (err: boolean, body?: any): void; - request_seq?: number; - } - - export interface ExceptionInfo { - text: string; - } - - export interface BreakResponse { - script?: ScriptDesc; - exception?: ExceptionInfo; - sourceLine: number; - sourceLineText: string; - sourceColumn: number; - } - - export function SourceInfo(body: BreakResponse): string; - - export interface ClientInstance extends NodeJS.EventEmitter { - protocol: Protocol; - scripts: ScriptDesc[]; - handles: ScriptDesc[]; - breakpoints: Breakpoint[]; - currentSourceLine: number; - currentSourceColumn: number; - currentSourceLineText: string; - currentFrame: number; - currentScript: string; - - connect(port: number, host: string): void; - req(req: any, cb: RequestHandler): void; - reqFrameEval(code: string, frame: number, cb: RequestHandler): void; - mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void; - setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void; - clearBreakpoint(rq: Request, cb: RequestHandler): void; - listbreakpoints(cb: RequestHandler): void; - reqSource(from: number, to: number, cb: RequestHandler): void; - reqScripts(cb: any): void; - reqContinue(cb: RequestHandler): void; - } - - export var Client : { - new (): ClientInstance - } + export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate; + export function clearTimeout(timeoutId: NodeJS.Timer): void; + export function clearInterval(intervalId: NodeJS.Timer): void; + export function clearImmediate(immediateId: NodeJS.Immediate): void; } From 41da5eb070a6578eb8cbef441d8bc474908d91e7 Mon Sep 17 00:00:00 2001 From: Hinell Date: Sun, 8 Jan 2017 01:30:51 +0300 Subject: [PATCH 004/248] Fixed @node/node interface according to official API. Resolving #13782 Changed api: stream.Readable, Renamed: NodeJS.Console to NodeJS.ConsoleConstructor Reconciled all consequent interfaces, like writeStream etc. --- node/index.d.ts | 7241 +++++++++++++++++++++++++---------------------- 1 file changed, 3797 insertions(+), 3444 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index e6333dd7d1..0620b9df9a 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -8,162 +8,37 @@ * Node.js v6.x API * * * ************************************************/ -interface NodeError { - /** - * Returns a string describing the point in the code at which the Error was instantiated. - * - * For example: - * - * ``` - * Error: Things keep happening! - * at /home/gbusey/file.js:525:2 - * at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21) - * at Actor. (/home/gbusey/actors.js:400:8) - * at increaseSynergy (/home/gbusey/actors.js:701:6) - * ``` - * - * The first line is formatted as : , and is followed by a series of stack frames (each line beginning with "at "). Each frame describes a call site within the code that lead to the error being generated. V8 attempts to display a name for each function (by variable name, function name, or object method name), but occasionally it will not be able to find a suitable name. If V8 cannot determine a name for the function, only location information will be displayed for that frame. Otherwise, the determined function name will be displayed with location information appended in parentheses. - */ - stack?: string; - /** - * Returns the string description of error as set by calling new Error(message). The message passed to the constructor will also appear in the first line of the stack trace of the Error, however changing this property after the Error object is created may not change the first line of the stack trace. - * - * ``` - * const err = new Error('The message'); - * console.log(err.message); - * // Prints: The message - * ``` - */ - message: string; +// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build +interface Console { + Console: NodeJS.ConsoleConstructor; + assert(value: any, message?: string, ...optionalParams: any[]): void; + dir(obj: any, options?: {showHidden?: boolean, depth?: number, colors?: boolean}): void; + error(message?: any, ...optionalParams: any[]): void; + info(message?: any, ...optionalParams: any[]): void; + log(message?: any, ...optionalParams: any[]): void; + time(label: string): void; + timeEnd(label: string): void; + trace(message?: any, ...optionalParams: any[]): void; + warn(message?: any, ...optionalParams: any[]): void; } -interface Error extends NodeError { } +interface Error { + stack?: string; +} interface ErrorConstructor { - /** - * Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()`` was called. - * - * ```js - * const myObject = {}; - * Error.captureStackTrace(myObject); - * myObject.stack // similar to `new Error().stack` - * ``` - * - * The first line of the trace, instead of being prefixed with `ErrorType : message`, will be the result of calling `targetObject.toString()``. - * - * The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. - * - * The constructorOpt argument is useful for hiding implementation details of error generation from an end user. For instance: - * - * ```js - * function MyError() { - * Error.captureStackTrace(this, MyError); - * } - * - * // Without passing MyError to captureStackTrace, the MyError - * // frame would should up in the .stack property. by passing - * // the constructor, we omit that frame and all frames above it. - * new MyError().stack - * ``` - */ - captureStackTrace(targetObject: T, constructorOpt?: new () => T): void; - - /** - * The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj))``. - * - * The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. - * - * If set to a non-number value, or set to a negative number, stack traces will not capture any frames. - */ - stackTraceLimit: number; + captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + stackTraceLimit: number; } -// ES2015 collection types -interface NodeCollection { - size: number; -} - -interface NodeWeakCollection {} - -interface IterableIterator {} - -interface NodeCollectionConstructor { - prototype: T; -} - -interface Map extends NodeCollection { - clear(): void; - delete(key: K): boolean; - entries(): Array<[K, V]>; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - keys(): Array; - set(key: K, value?: V): Map; - values(): Array; - // [Symbol.iterator]():Array<[K,V]>; - // [Symbol.toStringTag]: "Map"; -} - -interface MapConstructor extends NodeCollectionConstructor> { - new (): Map; - new (): Map; -} - -declare var Map: MapConstructor; - -interface WeakMap extends NodeWeakCollection { - clear(): void; - delete(key: K): boolean; - get(key: K): V | void; - has(key: K): boolean; - set(key: K, value?: V): WeakMap; -} - -interface WeakMapConstructor extends NodeCollectionConstructor> { - new (): WeakMap; - new (): WeakMap; -} - -declare var WeakMap: WeakMapConstructor; - -interface Set extends NodeCollection { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - entries(): Array<[T, T]>; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - keys(): Array; - values(): Array; - // [Symbol.iterator]():Array; - // [Symbol.toStringTag]: "Set"; -} - -interface SetConstructor extends NodeCollectionConstructor> { - new (): Set; - new (): Set; - new (iterable: Array): Set; -} - -declare var Set: SetConstructor; - -interface WeakSet extends NodeWeakCollection { - add(value: T): WeakSet; - clear(): void; - delete(value: T): boolean; - has(value: T): boolean; - // [Symbol.toStringTag]: "WeakSet"; -} - -interface WeakSetConstructor extends NodeCollectionConstructor> { - new (): WeakSet; - new (): WeakSet; - new (iterable: Array): WeakSet; -} - -declare var WeakSet: WeakSetConstructor; +// compat for TypeScript 1.8 +// if you use with --target es3 or --target es5 and use below definitions, +// use the lib.es6.d.ts that is bundled with TypeScript 1.8. +interface MapConstructor { } +interface WeakMapConstructor { } +interface SetConstructor { } +interface WeakSetConstructor { } /************************************************ * * @@ -172,6 +47,7 @@ declare var WeakSet: WeakSetConstructor; ************************************************/ declare var process: NodeJS.Process; declare var global: NodeJS.Global; +declare var console: Console; declare var __filename: string; declare var __dirname: string; @@ -184,44 +60,26 @@ declare function setImmediate(callback: (...args: any[]) => void, ...args: any[] declare function clearImmediate(immediateId: any): void; interface NodeRequireFunction { - (id: string): any; + (id: string): any; } interface NodeRequire extends NodeRequireFunction { - resolve(id: string): string; - cache: { [filename: string]: NodeModule }; - extensions: NodeExtensions; - main: any; -} - -interface NodeExtensions { - '.js': (m: NodeModule, filename: string) => any; - '.json': (m: NodeModule, filename: string) => any; - '.node': (m: NodeModule, filename: string) => any; - [ext: string]: (m: NodeModule, filename: string) => any; + resolve(id: string): string; + cache: any; + extensions: any; + main: NodeModule | undefined; } declare var require: NodeRequire; -declare class NodeModule { - static runMain(): void; - static wrap(code: string): string; - static _nodeModulePaths(path: string): string[]; - static _load(request: string, parent?: NodeModule, isMain?: boolean): any; - static _resolveFilename(request: string, parent?: NodeModule, isMain?: boolean): string; - static _extensions: NodeExtensions; - - constructor(filename: string); - _compile(code: string, filename: string): string; - - id: string; - parent: NodeModule; - filename: string; - paths: string[]; - children: NodeModule[]; - exports: any; - loaded: boolean; - require: NodeRequireFunction; +interface NodeModule { + exports: any; + require: NodeRequireFunction; + id: string; + filename: string; + loaded: boolean; + parent: NodeModule | null; + children: NodeModule[]; } declare var module: NodeModule; @@ -229,209 +87,159 @@ declare var module: NodeModule; // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (size: Uint8Array): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; }; -// Console class (compatible with TypeScript `lib.d.ts`). -declare interface Console { - log(msg: any, ...params: any[]): void; - info(msg: any, ...params: any[]): void; - warn(msg: any, ...params: any[]): void; - error(msg: any, ...params: any[]): void; - dir(value: any, ...params: any[]): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(msg: any, ...params: any[]): void; - assert(test?: boolean, msg?: string, ...params: any[]): void; - Console: new (stdout: NodeJS.WritableStream) => Console; -} +// Buffer class +type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex"; +interface Buffer extends NodeBuffer { } -declare var console: Console; - -declare class Buffer extends Uint8Array { - [index: number]: number; - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - constructor(str: string, encoding?: string); - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - constructor(size: number); - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - constructor(array: Uint8Array); - /** - * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. - * - * - * @param arrayBuffer The ArrayBuffer with which to share memory. - */ - constructor(arrayBuffer: ArrayBuffer); - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - constructor(array: any[]); - /** - * Copies the passed {buffer} data onto a new {Buffer} instance. - * - * @param buffer The buffer to copy. - */ - constructor(buffer: Buffer); - /** - * Allocates a new Buffer using an {array} of octets. - * - * @param array - */ - static from(array: any[]): Buffer; - /** - * When passed a reference to the .buffer property of a TypedArray instance, - * the newly created Buffer will share the same allocated memory as the TypedArray. - * The optional {byteOffset} and {length} arguments specify a memory range - * within the {arrayBuffer} that will be shared by the Buffer. - * - * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() - * @param byteOffset - * @param length - */ - static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - /** - * Copies the passed {buffer} data onto a new Buffer instance. - * - * @param buffer - */ - static from(buffer: Buffer): Buffer; - /** - * Creates a new Buffer containing the given JavaScript string {str}. - * If provided, the {encoding} parameter identifies the character encoding. - * If not provided, {encoding} defaults to 'utf8'. - * - * @param str - */ - static from(str: string, encoding?: string): Buffer; - /** - * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be _zero-filled_. - * - * @param size The desired length of the new `Buffer` - * @param fill A value to pre-fill the new `Buffer` with. Default: `0` - * @param encoding If `fill` is a string, this is its encoding. Default: `'utf8'` - */ - static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; - /** - * Allocates a new _non-zero-filled_ `Buffer` of `size` bytes. The `size` must be less than or equal to the value of `buffer.kMaxLength`. Otherwise, a `RangeError` is thrown. A zero-length `Buffer` will be created if `size <= 0`. - * - * The underlying memory for `Buffer` instances created in this way is not initialized. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize such `Buffer` instances to zeroes. - * - * @param size The desired length of the new `Buffer` - */ - static allocUnsafe(size: number): Buffer; - /** - * Returns `true` if `obj` is a Buffer, `false` otherwise. - */ - static isBuffer(obj: any): obj is Buffer; - /** - * Returns `true` if `encoding` contains a supported character encoding, or `false` otherwise. - * - * @param encoding A character encoding name to check. - */ - static isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - static byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - static concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): any; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAssert?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): this; - indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; - swap16(): this; - swap32(): this; - swap64(): this; - includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; - entries(): IterableIterator<[number, number]>; - keys(): IterableIterator; - values(): IterableIterator; -} +/** + * Raw data is stored in instances of the Buffer class. + * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. + * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + */ +declare var Buffer: { + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + new (str: string, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + new (size: number): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: Uint8Array): Buffer; + /** + * Produces a Buffer backed by the same allocated memory as + * the given {ArrayBuffer}. + * + * + * @param arrayBuffer The ArrayBuffer with which to share memory. + */ + new (arrayBuffer: ArrayBuffer): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: any[]): Buffer; + /** + * Copies the passed {buffer} data onto a new {Buffer} instance. + * + * @param buffer The buffer to copy. + */ + new (buffer: Buffer): Buffer; + prototype: Buffer; + /** + * Allocates a new Buffer using an {array} of octets. + * + * @param array + */ + from(array: any[]): Buffer; + /** + * When passed a reference to the .buffer property of a TypedArray instance, + * the newly created Buffer will share the same allocated memory as the TypedArray. + * The optional {byteOffset} and {length} arguments specify a memory range + * within the {arrayBuffer} that will be shared by the Buffer. + * + * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer() + * @param byteOffset + * @param length + */ + from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; + /** + * Copies the passed {buffer} data onto a new Buffer instance. + * + * @param buffer + */ + from(buffer: Buffer): Buffer; + /** + * Creates a new Buffer containing the given JavaScript string {str}. + * If provided, the {encoding} parameter identifies the character encoding. + * If not provided, {encoding} defaults to 'utf8'. + * + * @param str + */ + from(str: string, encoding?: string): Buffer; + /** + * Returns true if {obj} is a Buffer + * + * @param obj object to test. + */ + isBuffer(obj: any): obj is Buffer; + /** + * Returns true if {encoding} is a valid encoding argument. + * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + * + * @param encoding string to test. + */ + isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + compare(buf1: Buffer, buf2: Buffer): number; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + * @param fill if specified, buffer will be initialized by calling buf.fill(fill). + * If parameter is omitted, buffer will be filled with zeros. + * @param encoding encoding used for call to buf.fill while initalizing + */ + alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + allocUnsafe(size: number): Buffer; + /** + * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents + * of the newly created Buffer are unknown and may contain sensitive data. + * + * @param size count of octets to allocate + */ + allocUnsafeSlow(size: number): Buffer; +}; /************************************************ * * @@ -439,244 +247,301 @@ declare class Buffer extends Uint8Array { * * ************************************************/ declare namespace NodeJS { - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } + export interface ConsoleConstructor { + prototype: Console; + new(stdout: WritableStream, stderr?: WritableStream): Console; + } - export interface EventEmitter { - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - prependListener(event: string, listener: Function): this; - prependOnceListener(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - eventNames(): string[]; - listenerCount(type: string): number; - } + export interface ErrnoException extends Error { + errno?: number; + code?: string; + path?: string; + syscall?: string; + stack?: string; + } - export interface ReadableStream extends EventEmitter { - readable: boolean; - read(size?: number): string | Buffer; - setEncoding(encoding: string): this; - isPaused(): boolean; - pause(): this; - resume(): this; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } + export class EventEmitter { + addListener(event: string | symbol, listener: Function): this; + on(event: string | symbol, listener: Function): this; + once(event: string | symbol, listener: Function): this; + removeListener(event: string | symbol, listener: Function): this; + removeAllListeners(event?: string | symbol): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string | symbol): Function[]; + emit(event: string | symbol, ...args: any[]): boolean; + listenerCount(type: string | symbol): number; + // Added in Node 6... + prependListener(event: string | symbol, listener: Function): this; + prependOnceListener(event: string | symbol, listener: Function): this; + eventNames(): (string | symbol)[]; + } - export interface WritableStream extends EventEmitter { - writable: boolean; - setDefaultEncoding(encoding: string): this; - write(buffer: Buffer | string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } + export interface ReadableStream extends EventEmitter { + readable: boolean; + isTTY?: boolean; + read(size?: number): string | Buffer; + setEncoding(encoding: string | null): this; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): this; + unpipe(destination?: T): this; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } - export interface ReadWriteStream extends ReadableStream, WritableStream { } + export interface WritableStream extends EventEmitter { + writable: boolean; + isTTY?: boolean; + write(buffer: Buffer | string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } - export interface Events extends EventEmitter { } + export interface ReadWriteStream extends ReadableStream, WritableStream { } - export interface Domain extends Events { - run(fn: Function): void; - add(emitter: Events): void; - remove(emitter: Events): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; + export interface Events extends EventEmitter { } - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - } + export interface Domain extends Events { + run(fn: Function): void; + add(emitter: Events): void; + remove(emitter: Events): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; - export interface MemoryUsage { - rss: number; - heapTotal: number; - heapUsed: number; - } + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + } - export interface Env { - PATH: string; - [key: string]: string; - } + export interface MemoryUsage { + rss: number; + heapTotal: number; + heapUsed: number; + } - export interface Versions { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - modules: string; - openssl: string; - } + export interface CpuUsage { + user: number; + system: number; + } - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - argv0: string; - /** - * The process.execArgv property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the process.argv property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent. - */ - execArgv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: Env; - exit(code?: number): void; - exitCode?: number; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: Versions; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string | number): void; - pid: number; - title: string; - arch: string; - platform: string; - memoryUsage(): MemoryUsage; - nextTick(callback: Function): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?: [number, number]): [number, number]; - domain: Domain; + export interface ProcessVersions { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + modules: string; + openssl: string; + } - // Worker - send?(message: any, sendHandle?: any): void; - disconnect(): void; - connected: boolean; - } + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + argv0: string; + execArgv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + exitCode: number; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: ProcessVersions; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string | number): void; + pid: number; + title: string; + arch: string; + platform: string; + mainModule?: NodeModule; + memoryUsage(): MemoryUsage; + cpuUsage(previousValue?: CpuUsage): CpuUsage; + nextTick(callback: Function, ...args: any[]): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?: [number, number]): [number, number]; + domain: Domain; - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } + // Worker + send?(message: any, sendHandle?: any): void; + disconnect(): void; + connected: boolean; + } - export interface Timer { - ref(): void; - unref(): void; - _called: boolean; - _onTimeout: Function; - _timerArgs?: any[]; - } + export interface Global { + Array: typeof Array; + ArrayBuffer: typeof ArrayBuffer; + Boolean: typeof Boolean; + Buffer: typeof Buffer; + DataView: typeof DataView; + Date: typeof Date; + Error: typeof Error; + EvalError: typeof EvalError; + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Function: typeof Function; + GLOBAL: Global; + Infinity: typeof Infinity; + Int16Array: typeof Int16Array; + Int32Array: typeof Int32Array; + Int8Array: typeof Int8Array; + Intl: typeof Intl; + JSON: typeof JSON; + Map: MapConstructor; + Math: typeof Math; + NaN: typeof NaN; + Number: typeof Number; + Object: typeof Object; + Promise: Function; + RangeError: typeof RangeError; + ReferenceError: typeof ReferenceError; + RegExp: typeof RegExp; + Set: SetConstructor; + String: typeof String; + Symbol: Function; + SyntaxError: typeof SyntaxError; + TypeError: typeof TypeError; + URIError: typeof URIError; + Uint16Array: typeof Uint16Array; + Uint32Array: typeof Uint32Array; + Uint8Array: typeof Uint8Array; + Uint8ClampedArray: Function; + WeakMap: WeakMapConstructor; + WeakSet: WeakSetConstructor; + clearImmediate: (immediateId: any) => void; + clearInterval: (intervalId: NodeJS.Timer) => void; + clearTimeout: (timeoutId: NodeJS.Timer) => void; + console: typeof console; + decodeURI: typeof decodeURI; + decodeURIComponent: typeof decodeURIComponent; + encodeURI: typeof encodeURI; + encodeURIComponent: typeof encodeURIComponent; + escape: (str: string) => string; + eval: typeof eval; + global: Global; + isFinite: typeof isFinite; + isNaN: typeof isNaN; + parseFloat: typeof parseFloat; + parseInt: typeof parseInt; + process: Process; + root: Global; + setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; + setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + undefined: typeof undefined; + unescape: (str: string) => string; + gc: () => void; + v8debug?: any; + } - export interface Immediate { - _argv?: any[]; - _callback: Function; - _onImmediate: Function; - } + export interface Timer { + ref(): void; + unref(): void; + } +} + +interface IterableIterator { } + +/** + * @deprecated + */ +interface NodeBuffer extends Uint8Array { + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): { type: 'Buffer', data: any[] }; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAssert?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + swap16(): Buffer; + swap32(): Buffer; + swap64(): Buffer; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): this; + indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number; + entries(): IterableIterator<[number, number]>; + includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean; + keys(): IterableIterator; + values(): IterableIterator; } /************************************************ @@ -685,3078 +550,3566 @@ declare namespace NodeJS { * * ************************************************/ declare module "buffer" { - export var INSPECT_MAX_BYTES: number; - export var kMaxLength: number; - - export type Encoding = "ascii" | "latin1" | "binary" | "utf8" | "utf-8" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "hex" | "base64"; - - var BuffType: typeof Buffer; - var SlowBuffType: typeof SlowBuffer; - - export { BuffType as Buffer, SlowBuffType as SlowBuffer }; + export var INSPECT_MAX_BYTES: number; + var BuffType: typeof Buffer; + var SlowBuffType: typeof SlowBuffer; + export { BuffType as Buffer, SlowBuffType as SlowBuffer }; } declare module "querystring" { - export interface StringifyOptions { - encodeURIComponent?: Function; - } + export interface StringifyOptions { + encodeURIComponent?: Function; + } - export interface ParseOptions { - maxKeys?: number; - decodeURIComponent?: Function; - } + export interface ParseOptions { + maxKeys?: number; + decodeURIComponent?: Function; + } - export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; - export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; - export function escape(str: string): string; - export function unescape(str: string): string; + export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any; + export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T; + export function escape(str: string): string; + export function unescape(str: string): string; } declare module "events" { - export class EventEmitter implements NodeJS.EventEmitter { - static EventEmitter: EventEmitter; - static listenerCount(emitter: EventEmitter, event: string): number; // deprecated - static defaultMaxListeners: number; + class internal extends NodeJS.EventEmitter { } - addListener(event: string, listener: (...args: any[]) => void): this; - on(event: string, listener: (...args: any[]) => void): this; - once(event: string, listener: (...args: any[]) => void): this; - prependListener(event: string, listener: (...args: any[]) => void): this; - prependOnceListener(event: string, listener: (...args: any[]) => void): this; - removeListener(event: string, listener: (...args: any[]) => void): this; - removeAllListeners(event?: string): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string): Array<(...args: any[]) => void>; - listenerCount(event: string): number; - emit(event: string, ...args: any[]): boolean; - eventNames(): string[]; - } + namespace internal { + export class EventEmitter extends internal { + static listenerCount(emitter: EventEmitter, event: string | symbol): number; // deprecated + static defaultMaxListeners: number; - export interface Listener { - on(event: E, listener: L): this; - once(event: E, listener: L): this; - addListener(event: E, listener: L): this; - removeListener(event: E, listener: L): this; - listeners(event: E): L[]; - } + addListener(event: string | symbol, listener: Function): this; + on(event: string | symbol, listener: Function): this; + once(event: string | symbol, listener: Function): this; + prependListener(event: string | symbol, listener: Function): this; + prependOnceListener(event: string | symbol, listener: Function): this; + removeListener(event: string | symbol, listener: Function): this; + removeAllListeners(event?: string | symbol): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string | symbol): Function[]; + emit(event: string | symbol, ...args: any[]): boolean; + eventNames(): (string | symbol)[]; + listenerCount(type: string | symbol): number; + } + } + + export = internal; } declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; + import * as events from "events"; + import * as net from "net"; + import * as stream from "stream"; - export interface OutgoingHeaders { - [header: string]: number | string | string[]; - } + export interface RequestOptions { + protocol?: string; + host?: string; + hostname?: string; + family?: number; + port?: number; + localAddress?: string; + socketPath?: string; + method?: string; + path?: string; + headers?: { [key: string]: any }; + auth?: string; + agent?: Agent | boolean; + } - export interface IncomingHeaders { - [header: string]: string | string[]; - } - - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number | string; - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: OutgoingHeaders; - auth?: string; - agent?: Agent | boolean; - } - - export class Server extends net.Server { - setTimeout(msecs: number, callback: Function): void; - maxHeadersCount: number; - timeout: number; - listening: boolean; - } - - export class ServerResponse extends stream.Writable { - finished: boolean; - headersSent: boolean; - statusCode: number; - statusMessage: string; - sendDate: boolean; - - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, statusText?: string, headers?: OutgoingHeaders): void; - writeHead(statusCode: number, headers?: OutgoingHeaders): void; - setHeader(name: string, value: string | string[]): void; - setTimeout(msecs: number, callback: () => void): this; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: OutgoingHeaders): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } - - export class ClientRequest extends stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - setHeader(name: string, value: string | string[]): void; - getHeader(name: string): string; - removeHeader(name: string): void; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - - export class IncomingMessage extends stream.Readable { - httpVersion: string; - headers: IncomingHeaders; - rawHeaders: string[]; - trailers: IncomingHeaders; - rawTrailers: string[]; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - destroy(error?: Error): void; + export interface Server extends net.Server { + setTimeout(msecs: number, callback: Function): void; + maxHeadersCount: number; + timeout: number; + listening: boolean; + } /** - * Only valid for request obtained from http.Server. + * @deprecated Use IncomingMessage */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - } + export interface ServerRequest extends IncomingMessage { + connection: net.Socket; + } + export interface ServerResponse extends stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; - export interface AgentOptions { + writeContinue(): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; + writeHead(statusCode: number, headers?: any): void; + statusCode: number; + statusMessage: string; + headersSent: boolean; + setHeader(name: string, value: string | string[]): void; + setTimeout(msecs: number, callback: Function): ServerResponse; + sendDate: boolean; + getHeader(name: string): string; + removeHeader(name: string): void; + write(chunk: any, encoding?: string): any; + addTrailers(headers: any): void; + finished: boolean; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface ClientRequest extends stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + write(chunk: any, encoding?: string): void; + abort(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + setHeader(name: string, value: string | string[]): void; + getHeader(name: string): string; + removeHeader(name: string): void; + addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface IncomingMessage extends stream.Readable { + httpVersion: string; + httpVersionMajor: number; + httpVersionMinor: number; + connection: net.Socket; + headers: any; + rawHeaders: string[]; + trailers: any; + rawTrailers: any; + setTimeout(msecs: number, callback: Function): NodeJS.Timer; + /** + * Only valid for request obtained from http.Server. + */ + method?: string; + /** + * Only valid for request obtained from http.Server. + */ + url?: string; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusCode?: number; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusMessage?: string; + socket: net.Socket; + destroy(error?: Error): void; + } /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false + * @deprecated Use IncomingMessage */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } + export interface ClientResponse extends IncomingMessage { } - export class Agent { - maxSockets: number; - sockets: any; - requests: any; + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } - constructor(opts?: AgentOptions); + export class Agent { + maxSockets: number; + sockets: any; + requests: any; - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } + constructor(opts?: AgentOptions); - export var METHODS: string[]; + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; + export var METHODS: string[]; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: string | RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; + export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) => void): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; + export var globalAgent: Agent; } declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; + import * as child from "child_process"; + import * as events from "events"; + import * as net from "net"; - export interface ClusterSettings { - exec?: string; - args?: string[]; - silent?: boolean; - } + // interfaces + export interface ClusterSettings { + execArgv?: string[]; // default: process.execArgv + exec?: string; + args?: string[]; + silent?: boolean; + stdio?: any[]; + uid?: number; + gid?: number; + } - export interface Address { - address: string; - port: number; - addressType: string; - } + export interface ClusterSetupMasterSettings { + exec?: string; // default: process.argv[1] + args?: string[]; // default: process.argv.slice(2) + silent?: boolean; // default: false + stdio?: any[]; + } - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): boolean; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - isConnected(): boolean; - isDead(): boolean; - } + export interface Address { + address: string; + port: number; + addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6" + } - export var settings: ClusterSettings; - export var isMaster: boolean; - export var isWorker: boolean; - export function setupMaster(settings?: ClusterSettings): void; - export function fork(env?: any): Worker; - export function disconnect(callback?: Function): void; - export var worker: Worker; - export var workers: { - [index: string]: Worker - }; + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): boolean; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + isConnected(): boolean; + isDead(): boolean; + exitedAfterDisconnect: boolean; - // Event emitter - export function addListener(event: string, listener: Function): void; - export function on(event: "disconnect", listener: (worker: Worker) => void): void; - export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void; - export function on(event: "fork", listener: (worker: Worker) => void): void; - export function on(event: "listening", listener: (worker: Worker, address: any) => void): void; - export function on(event: "message", listener: (worker: Worker, message: any) => void): void; - export function on(event: "online", listener: (worker: Worker) => void): void; - export function on(event: "setup", listener: (settings: any) => void): void; - export function on(event: string, listener: Function): any; - export function once(event: string, listener: Function): void; - export function removeListener(event: string, listener: Function): void; - export function removeAllListeners(event?: string): void; - export function setMaxListeners(n: number): void; - export function listeners(event: string): Function[]; - export function emit(event: string, ...args: any[]): boolean; + /** + * events.EventEmitter + * 1. disconnect + * 2. error + * 3. exit + * 4. listening + * 5. message + * 6. online + */ + addListener(event: string, listener: Function): this; + addListener(event: "disconnect", listener: () => void): this; + addListener(event: "error", listener: (code: number, signal: string) => void): this; + addListener(event: "exit", listener: (code: number, signal: string) => void): this; + addListener(event: "listening", listener: (address: Address) => void): this; + addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: () => void): this; + + emit(event: string, listener: Function): boolean + emit(event: "disconnect", listener: () => void): boolean + emit(event: "error", listener: (code: number, signal: string) => void): boolean + emit(event: "exit", listener: (code: number, signal: string) => void): boolean + emit(event: "listening", listener: (address: Address) => void): boolean + emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean + emit(event: "online", listener: () => void): boolean + + on(event: string, listener: Function): this; + on(event: "disconnect", listener: () => void): this; + on(event: "error", listener: (code: number, signal: string) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "listening", listener: (address: Address) => void): this; + on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: () => void): this; + + once(event: string, listener: Function): this; + once(event: "disconnect", listener: () => void): this; + once(event: "error", listener: (code: number, signal: string) => void): this; + once(event: "exit", listener: (code: number, signal: string) => void): this; + once(event: "listening", listener: (address: Address) => void): this; + once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "disconnect", listener: () => void): this; + prependListener(event: "error", listener: (code: number, signal: string) => void): this; + prependListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependListener(event: "listening", listener: (address: Address) => void): this; + prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependListener(event: "online", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "disconnect", listener: () => void): this; + prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "listening", listener: (address: Address) => void): this; + prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener(event: "online", listener: () => void): this; + } + + export interface Cluster extends events.EventEmitter { + Worker: Worker; + disconnect(callback?: Function): void; + fork(env?: any): Worker; + isMaster: boolean; + isWorker: boolean; + // TODO: cluster.schedulingPolicy + settings: ClusterSettings; + setupMaster(settings?: ClusterSetupMasterSettings): void; + worker: Worker; + workers: { + [index: string]: Worker + }; + + /** + * events.EventEmitter + * 1. disconnect + * 2. exit + * 3. fork + * 4. listening + * 5. message + * 6. online + * 7. setup + */ + addListener(event: string, listener: Function): this; + addListener(event: "disconnect", listener: (worker: Worker) => void): this; + addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + addListener(event: "fork", listener: (worker: Worker) => void): this; + addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + addListener(event: "online", listener: (worker: Worker) => void): this; + addListener(event: "setup", listener: (settings: any) => void): this; + + emit(event: string, listener: Function): boolean; + emit(event: "disconnect", listener: (worker: Worker) => void): boolean; + emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; + emit(event: "fork", listener: (worker: Worker) => void): boolean; + emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; + emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; + emit(event: "online", listener: (worker: Worker) => void): boolean; + emit(event: "setup", listener: (settings: any) => void): boolean; + + on(event: string, listener: Function): this; + on(event: "disconnect", listener: (worker: Worker) => void): this; + on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + on(event: "fork", listener: (worker: Worker) => void): this; + on(event: "listening", listener: (worker: Worker, address: Address) => void): this; + on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + on(event: "online", listener: (worker: Worker) => void): this; + on(event: "setup", listener: (settings: any) => void): this; + + once(event: string, listener: Function): this; + once(event: "disconnect", listener: (worker: Worker) => void): this; + once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + once(event: "fork", listener: (worker: Worker) => void): this; + once(event: "listening", listener: (worker: Worker, address: Address) => void): this; + once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + once(event: "online", listener: (worker: Worker) => void): this; + once(event: "setup", listener: (settings: any) => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependListener(event: "fork", listener: (worker: Worker) => void): this; + prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependListener(event: "online", listener: (worker: Worker) => void): this; + prependListener(event: "setup", listener: (settings: any) => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this; + prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this; + prependOnceListener(event: "fork", listener: (worker: Worker) => void): this; + prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this; + prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined. + prependOnceListener(event: "online", listener: (worker: Worker) => void): this; + prependOnceListener(event: "setup", listener: (settings: any) => void): this; + + } + + export function disconnect(callback?: Function): void; + export function fork(env?: any): Worker; + export var isMaster: boolean; + export var isWorker: boolean; + // TODO: cluster.schedulingPolicy + export var settings: ClusterSettings; + export function setupMaster(settings?: ClusterSetupMasterSettings): void; + export var worker: Worker; + export var workers: { + [index: string]: Worker + }; + + /** + * events.EventEmitter + * 1. disconnect + * 2. exit + * 3. fork + * 4. listening + * 5. message + * 6. online + * 7. setup + */ + export function addListener(event: string, listener: Function): Cluster; + export function addListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; + export function addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; + export function addListener(event: "fork", listener: (worker: Worker) => void): Cluster; + export function addListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; + export function addListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. + export function addListener(event: "online", listener: (worker: Worker) => void): Cluster; + export function addListener(event: "setup", listener: (settings: any) => void): Cluster; + + export function emit(event: string, listener: Function): boolean; + export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean; + export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean; + export function emit(event: "fork", listener: (worker: Worker) => void): boolean; + export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean; + export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean; + export function emit(event: "online", listener: (worker: Worker) => void): boolean; + export function emit(event: "setup", listener: (settings: any) => void): boolean; + + export function on(event: string, listener: Function): Cluster; + export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster; + export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; + export function on(event: "fork", listener: (worker: Worker) => void): Cluster; + export function on(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; + export function on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. + export function on(event: "online", listener: (worker: Worker) => void): Cluster; + export function on(event: "setup", listener: (settings: any) => void): Cluster; + + export function once(event: string, listener: Function): Cluster; + export function once(event: "disconnect", listener: (worker: Worker) => void): Cluster; + export function once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; + export function once(event: "fork", listener: (worker: Worker) => void): Cluster; + export function once(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; + export function once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. + export function once(event: "online", listener: (worker: Worker) => void): Cluster; + export function once(event: "setup", listener: (settings: any) => void): Cluster; + + export function removeListener(event: string, listener: Function): Cluster; + export function removeAllListeners(event?: string): Cluster; + export function setMaxListeners(n: number): Cluster; + export function getMaxListeners(): number; + export function listeners(event: string): Function[]; + export function listenerCount(type: string): number; + + export function prependListener(event: string, listener: Function): Cluster; + export function prependListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; + export function prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; + export function prependListener(event: "fork", listener: (worker: Worker) => void): Cluster; + export function prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; + export function prependListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. + export function prependListener(event: "online", listener: (worker: Worker) => void): Cluster; + export function prependListener(event: "setup", listener: (settings: any) => void): Cluster; + + export function prependOnceListener(event: string, listener: Function): Cluster; + export function prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): Cluster; + export function prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster; + export function prependOnceListener(event: "fork", listener: (worker: Worker) => void): Cluster; + export function prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): Cluster; + export function prependOnceListener(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): Cluster; // the handle is a net.Socket or net.Server object, or undefined. + export function prependOnceListener(event: "online", listener: (worker: Worker) => void): Cluster; + export function prependOnceListener(event: "setup", listener: (settings: any) => void): Cluster; + + export function eventNames(): string[]; } declare module "zlib" { - import * as stream from "stream"; + import * as stream from "stream"; + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; finishFlush?: number } - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - export interface ZlibCallback { (error: Error, result: any): void } + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; + export function deflate(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; + export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer; + export function deflateRaw(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; + export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer; + export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function gzipSync(buf: Buffer, options?: ZlibOptions): Buffer; + export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer; + export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function inflateSync(buf: Buffer, options?: ZlibOptions): Buffer; + export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function inflateRawSync(buf: Buffer, options?: ZlibOptions): Buffer; + export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; - export function deflate(buf: Buffer | string, callback?: ZlibCallback): void; - export function deflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function deflateSync(buf: Buffer | string, options?: ZlibOptions): any; - export function deflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; - export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; - export function gzip(buf: Buffer | string, callback?: ZlibCallback): void; - export function gzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function gzipSync(buf: Buffer | string, options?: ZlibOptions): any; - export function gunzip(buf: Buffer | string, callback?: ZlibCallback): void; - export function gunzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function gunzipSync(buf: Buffer | string, options?: ZlibOptions): any; - export function inflate(buf: Buffer | string, callback?: ZlibCallback): void; - export function inflate(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function inflateSync(buf: Buffer | string, options?: ZlibOptions): any; - export function inflateRaw(buf: Buffer | string, callback?: ZlibCallback): void; - export function inflateRaw(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function inflateRawSync(buf: Buffer | string, options?: ZlibOptions): any; - export function unzip(buf: Buffer | string, callback?: ZlibCallback): void; - export function unzip(buf: Buffer | string, options: ZlibOptions, callback?: ZlibCallback): void; - export function unzipSync(buf: Buffer | string, options?: ZlibOptions): any; - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; - export var Z_NULL: number; + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; } declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; + export interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + }; + } + + export interface NetworkInterfaceInfo { + address: string; + netmask: string; + family: string; + mac: string; + internal: boolean; + } + + export function hostname(): string; + export function loadavg(): number[]; + export function uptime(): number; + export function freemem(): number; + export function totalmem(): number; + export function cpus(): CpuInfo[]; + export function type(): string; + export function release(): string; + export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; + export function homedir(): string; + export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: any, homedir: string } + export var constants: { + UV_UDP_REUSEADDR: number, + errno: { + SIGHUP: number; + SIGINT: number; + SIGQUIT: number; + SIGILL: number; + SIGTRAP: number; + SIGABRT: number; + SIGIOT: number; + SIGBUS: number; + SIGFPE: number; + SIGKILL: number; + SIGUSR1: number; + SIGSEGV: number; + SIGUSR2: number; + SIGPIPE: number; + SIGALRM: number; + SIGTERM: number; + SIGCHLD: number; + SIGSTKFLT: number; + SIGCONT: number; + SIGSTOP: number; + SIGTSTP: number; + SIGTTIN: number; + SIGTTOU: number; + SIGURG: number; + SIGXCPU: number; + SIGXFSZ: number; + SIGVTALRM: number; + SIGPROF: number; + SIGWINCH: number; + SIGIO: number; + SIGPOLL: number; + SIGPWR: number; + SIGSYS: number; + SIGUNUSED: number; + }, + signals: { + E2BIG: number; + EACCES: number; + EADDRINUSE: number; + EADDRNOTAVAIL: number; + EAFNOSUPPORT: number; + EAGAIN: number; + EALREADY: number; + EBADF: number; + EBADMSG: number; + EBUSY: number; + ECANCELED: number; + ECHILD: number; + ECONNABORTED: number; + ECONNREFUSED: number; + ECONNRESET: number; + EDEADLK: number; + EDESTADDRREQ: number; + EDOM: number; + EDQUOT: number; + EEXIST: number; + EFAULT: number; + EFBIG: number; + EHOSTUNREACH: number; + EIDRM: number; + EILSEQ: number; + EINPROGRESS: number; + EINTR: number; + EINVAL: number; + EIO: number; + EISCONN: number; + EISDIR: number; + ELOOP: number; + EMFILE: number; + EMLINK: number; + EMSGSIZE: number; + EMULTIHOP: number; + ENAMETOOLONG: number; + ENETDOWN: number; + ENETRESET: number; + ENETUNREACH: number; + ENFILE: number; + ENOBUFS: number; + ENODATA: number; + ENODEV: number; + ENOENT: number; + ENOEXEC: number; + ENOLCK: number; + ENOLINK: number; + ENOMEM: number; + ENOMSG: number; + ENOPROTOOPT: number; + ENOSPC: number; + ENOSR: number; + ENOSTR: number; + ENOSYS: number; + ENOTCONN: number; + ENOTDIR: number; + ENOTEMPTY: number; + ENOTSOCK: number; + ENOTSUP: number; + ENOTTY: number; + ENXIO: number; + EOPNOTSUPP: number; + EOVERFLOW: number; + EPERM: number; + EPIPE: number; + EPROTO: number; + EPROTONOSUPPORT: number; + EPROTOTYPE: number; + ERANGE: number; + EROFS: number; + ESPIPE: number; + ESRCH: number; + ESTALE: number; + ETIME: number; + ETIMEDOUT: number; + ETXTBSY: number; + EWOULDBLOCK: number; + EXDEV: number; + }, }; - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function tmpdir(): string; - export function homedir(): string; - export function endianness(): "BE" | "LE"; - export function hostname(): string; - export function type(): string; - export function platform(): string; - export function arch(): string; - export function release(): string; - export function uptime(): number; - export function loadavg(): number[]; - export function totalmem(): number; - export function freemem(): number; - export function cpus(): CpuInfo[]; - export function networkInterfaces(): { [index: string]: NetworkInterfaceInfo[] }; - export function userInfo(options?: { encoding: 'buffer' }): { username: Buffer, uid: number, gid: number, shell: Buffer | null, homedir: Buffer } - export function userInfo(options?: { encoding: string }): { username: string, uid: number, gid: number, shell: string | null, homedir: string } - export var EOL: string; + export function arch(): string; + export function platform(): string; + export function tmpdir(): string; + export var EOL: string; + export function endianness(): "BE" | "LE"; } declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; + import * as tls from "tls"; + import * as events from "events"; + import * as http from "http"; - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string) => any; - } + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any; + } - export interface RequestOptions extends http.RequestOptions { - pfx?: string | Buffer; - key?: string | Buffer; - passphrase?: string; - cert?: string | Buffer; - ca?: string | Buffer | string[] | Buffer[]; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } + export interface RequestOptions extends http.RequestOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + } - export interface AgentOptions extends http.AgentOptions { - /** - * Certificate, Private key and CA certificates to use for SSL. Default `null`. - */ - pfx?: string | Buffer; - /** - * Private key to use for SSL. Default `null`. - */ - key?: string | Buffer | string[] | Buffer[]; - /** - * A string of passphrase for the private key or pfx. Default `null`. - */ - passphrase?: string; - /** - * Public x509 certificate to use. Default `null`. - */ - cert?: string | Buffer | string[] | Buffer[]; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. - */ - ca?: string | Buffer | string[] | Buffer[]; - /** - * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. - */ - ciphers?: string; - /** - * If `true`, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Default `true`. - */ - rejectUnauthorized?: boolean; - /** - * Servername for SNI (Server Name Indication) TLS extension. - */ - servername?: string; - /** - * The SSL method to use, e.g. `SSLv3_method` to force SSL version 3. The possible values depend on your installation of OpenSSL and are defined in the constant SSL_METHODS. - */ - secureProtocol?: string; - maxCachedSessions?: number; - } + export interface Agent extends http.Agent { } - export class Agent extends http.Agent { - constructor(options?: AgentOptions); - } + export interface AgentOptions extends http.AgentOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + maxCachedSessions?: number; + } - export class Server extends tls.Server { } - - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export function get(options: string | RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; - export var globalAgent: Agent; + export var Agent: { + new (options?: AgentOptions): Agent; + }; + export interface Server extends tls.Server { } + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest; + export var globalAgent: Agent; } declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): number[]; + encode(codePoints: number[]): string; + } + export var version: any; } declare module "repl" { - import { EventEmitter } from "events"; - import { Interface } from "readline"; + import * as stream from "stream"; + import * as readline from "readline"; - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - completer?: Function; - replMode?: symbol; - breakEvalOnSigint?: boolean; - } + export interface ReplOptions { + prompt?: string; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + completer?: Function; + replMode?: any; + breakEvalOnSigint?: any; + } - export function start(options: ReplOptions): REPLServer; + export interface REPLServer extends readline.ReadLine { + defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; + displayPrompt(preserveCursor?: boolean): void; - export type REPLCommand = (this: REPLServer, rest: string) => void; + /** + * events.EventEmitter + * 1. exit + * 2. reset + **/ - export class REPLServer extends Interface { - inputStream: NodeJS.ReadableStream; - outputStream: NodeJS.WritableStream; - useColors: boolean; - commands: { - [command: string]: REPLCommand; - }; - defineCommand(keyword: string, cmd: REPLCommand | { help: string, action: REPLCommand }): void; - displayPrompt(preserveCursor?: boolean): void; - setPrompt(prompt: string): void; - turnOffEditorMode(): void; - } + addListener(event: string, listener: Function): this; + addListener(event: "exit", listener: () => void): this; + addListener(event: "reset", listener: Function): this; - export class Recoverable extends SyntaxError { - err: Error; - constructor(err: Error); - } + emit(event: string, ...args: any[]): boolean; + emit(event: "exit"): boolean; + emit(event: "reset", context: any): boolean; + + on(event: string, listener: Function): this; + on(event: "exit", listener: () => void): this; + on(event: "reset", listener: Function): this; + + once(event: string, listener: Function): this; + once(event: "exit", listener: () => void): this; + once(event: "reset", listener: Function): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "exit", listener: () => void): this; + prependListener(event: "reset", listener: Function): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "exit", listener: () => void): this; + prependOnceListener(event: "reset", listener: Function): this; + } + + export function start(options: ReplOptions): REPLServer; } declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; + import * as events from "events"; + import * as stream from "stream"; - export interface Key { - sequence?: string; - name?: string; - ctrl?: boolean; - meta?: boolean; - shift?: boolean; - } + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } - export class Interface extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: (answer: string) => void): void; - pause(): this; - resume(): this; - close(): void; - write(data: string | Buffer, key?: Key): void; - } + export interface ReadLine extends events.EventEmitter { + setPrompt(prompt: string): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: (answer: string) => void): void; + pause(): ReadLine; + resume(): ReadLine; + close(): void; + write(data: string | Buffer, key?: Key): void; - export interface Completer { - (line: string): CompleterResult; - (line: string, callback: (err: any, result: CompleterResult) => void): any; - } + /** + * events.EventEmitter + * 1. close + * 2. line + * 3. pause + * 4. resume + * 5. SIGCONT + * 6. SIGINT + * 7. SIGTSTP + **/ - export interface CompleterResult { - completions: string[]; - line: string; - } + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "line", listener: (input: any) => void): this; + addListener(event: "pause", listener: () => void): this; + addListener(event: "resume", listener: () => void): this; + addListener(event: "SIGCONT", listener: () => void): this; + addListener(event: "SIGINT", listener: () => void): this; + addListener(event: "SIGTSTP", listener: () => void): this; - export interface InterfaceOptions { - input: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - completer?: Completer; - terminal?: boolean; - historySize?: number; - } + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "line", input: any): boolean; + emit(event: "pause"): boolean; + emit(event: "resume"): boolean; + emit(event: "SIGCONT"): boolean; + emit(event: "SIGINT"): boolean; + emit(event: "SIGTSTP"): boolean; - export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): Interface; - export function createInterface(options: InterfaceOptions): Interface; + on(event: string, listener: Function): this; + on(event: "close", listener: () => void): this; + on(event: "line", listener: (input: any) => void): this; + on(event: "pause", listener: () => void): this; + on(event: "resume", listener: () => void): this; + on(event: "SIGCONT", listener: () => void): this; + on(event: "SIGINT", listener: () => void): this; + on(event: "SIGTSTP", listener: () => void): this; - export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; - export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; - export function clearLine(stream: NodeJS.WritableStream, dir: number): void; - export function clearScreenDown(stream: NodeJS.WritableStream): void; + once(event: string, listener: Function): this; + once(event: "close", listener: () => void): this; + once(event: "line", listener: (input: any) => void): this; + once(event: "pause", listener: () => void): this; + once(event: "resume", listener: () => void): this; + once(event: "SIGCONT", listener: () => void): this; + once(event: "SIGINT", listener: () => void): this; + once(event: "SIGTSTP", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "line", listener: (input: any) => void): this; + prependListener(event: "pause", listener: () => void): this; + prependListener(event: "resume", listener: () => void): this; + prependListener(event: "SIGCONT", listener: () => void): this; + prependListener(event: "SIGINT", listener: () => void): this; + prependListener(event: "SIGTSTP", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "line", listener: (input: any) => void): this; + prependOnceListener(event: "pause", listener: () => void): this; + prependOnceListener(event: "resume", listener: () => void): this; + prependOnceListener(event: "SIGCONT", listener: () => void): this; + prependOnceListener(event: "SIGINT", listener: () => void): this; + prependOnceListener(event: "SIGTSTP", listener: () => void): this; + } + + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } + + export type CompleterResult = [string[], string]; + + export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + completer?: Completer; + terminal?: boolean; + historySize?: number; + } + + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; + export function createInterface(options: ReadLineOptions): ReadLine; + + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; } declare module "vm" { - export interface Context { } - - export interface ScriptOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - cachedData?: Buffer; - produceCachedData?: boolean; - } - - export interface RunInNewContextOptions { - filename?: string; - lineOffset?: number; - columnOffset?: number; - displayErrors?: boolean; - timeout?: number; - } - - export interface RunInContextOptions extends RunInNewContextOptions { - breakOnSigint?: boolean; - } - - export class Script { - constructor(code: string, options?: string | ScriptOptions); - runInContext(contextifiedSandbox: Context, options?: RunInContextOptions): any; - runInNewContext(sandbox?: Context, options?: RunInNewContextOptions): any; - runInThisContext(options?: RunInNewContextOptions): any; - } - - export function createContext(sandbox?: Context): Context; - export function isContext(sandbox: Context): boolean; - export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunInNewContextOptions): any; - export function runInDebugContext(code: string): any; - export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInNewContextOptions): any; - export function runInThisContext(code: string, options?: string | RunInNewContextOptions): any; - /** - * @deprecated - */ - export function createScript(code: string, options?: string | ScriptOptions): Script; + export interface Context { } + export interface ScriptOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + cachedData?: Buffer; + produceCachedData?: boolean; + } + export interface RunningScriptOptions { + filename?: string; + lineOffset?: number; + columnOffset?: number; + displayErrors?: boolean; + timeout?: number; + } + export class Script { + constructor(code: string, options?: ScriptOptions); + runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any; + runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any; + runInThisContext(options?: RunningScriptOptions): any; + } + export function createContext(sandbox?: Context): Context; + export function isContext(sandbox: Context): boolean; + export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any; + export function runInDebugContext(code: string): any; + export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any; + export function runInThisContext(code: string, options?: RunningScriptOptions): any; } declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - import * as buffer from "buffer"; - import * as net from "net"; + import * as events from "events"; + import * as stream from "stream"; + import * as net from "net"; - export class ChildProcess extends events.EventEmitter implements - events.Listener<'close', (code: number, signal: string) => void>, - events.Listener<'error', (error: Error) => void>, - events.Listener<'exit', ((code: number, signal: string | null) => void) | ((code: number | null, signal: string) => void)>, - events.Listener<'message', (message: any, sendHandle?: net.Socket | net.Server) => void>, - events.Listener<'disconnect', () => void> { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - stdio: [stream.Writable, stream.Readable, stream.Readable]; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): boolean; - connected: boolean; - disconnect(): void; - unref(): void; - } + export interface ChildProcess extends events.EventEmitter { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + stdio: [stream.Writable, stream.Readable, stream.Readable]; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle?: any): boolean; + connected: boolean; + disconnect(): void; + unref(): void; + ref(): void; - export interface SpawnOptions { - cwd?: string; - env?: any; - stdio?: any; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - } + /** + * events.EventEmitter + * 1. close + * 2. disconnet + * 3. error + * 4. exit + * 5. message + **/ - export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: (code: number, signal: string) => void): this; + addListener(event: "disconnet", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "exit", listener: (code: number, signal: string) => void): this; + addListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - export interface ExecOptions { - cwd?: string; - env?: any; - shell?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - encoding?: buffer.Encoding | 'buffer'; - } + emit(event: string, ...args: any[]): boolean; + emit(event: "close", code: number, signal: string): boolean; + emit(event: "disconnet"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "exit", code: number, signal: string): boolean; + emit(event: "message", message: any, sendHandle: net.Socket | net.Server): boolean; - export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function exec(command: string, options: ExecOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + on(event: string, listener: Function): this; + on(event: "close", listener: (code: number, signal: string) => void): this; + on(event: "disconnet", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "exit", listener: (code: number, signal: string) => void): this; + on(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - export interface ExecFileOptions { - cwd?: string; - env?: any; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - uid?: number; - gid?: number; - encoding?: buffer.Encoding | 'buffer'; - } + once(event: string, listener: Function): this; + once(event: "close", listener: (code: number, signal: string) => void): this; + once(event: "disconnet", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "exit", listener: (code: number, signal: string) => void): this; + once(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions & { encoding: 'buffer' }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; - export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: (code: number, signal: string) => void): this; + prependListener(event: "disconnet", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; - export interface ForkOptions { - cwd?: string; - env?: any; - execPath?: string; - execArgv?: string[]; - silent?: boolean; - uid?: number; - gid?: number; - } + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "disconnet", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this; + prependOnceListener(event: "message", listener: (message: any, sendHandle: net.Socket | net.Server) => void): this; + } - export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; + export interface SpawnOptions { + cwd?: string; + env?: any; + stdio?: any; + detached?: boolean; + uid?: number; + gid?: number; + shell?: boolean | string; + } + export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess; - export interface SpawnSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - shell?: boolean | string; - encoding?: buffer.Encoding | 'buffer'; - } + export interface ExecOptions { + cwd?: string; + env?: any; + shell?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + } + export interface ExecOptionsWithStringEncoding extends ExecOptions { + encoding: BufferEncoding; + } + export interface ExecOptionsWithBufferEncoding extends ExecOptions { + encoding: string; // specify `null`. + } + export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {}); + export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export interface SpawnSyncReturns { - pid: number; - output: string[]; - stdout: T; - stderr: T; - status: number; - signal: string; - error: Error; - } - export function spawnSync(command: string): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; - export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions & { encoding: 'buffer' }): SpawnSyncReturns; - export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; + export interface ExecFileOptions { + cwd?: string; + env?: any; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + uid?: number; + gid?: number; + } + export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions { + encoding: BufferEncoding; + } + export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions { + encoding: string; // specify `null`. + } + export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {}); + export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; + // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {}); + export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) => void): ChildProcess; + export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) => void): ChildProcess; - export interface ExecSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - shell?: string; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: buffer.Encoding | 'buffer'; - } + export interface ForkOptions { + cwd?: string; + env?: any; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; + } + export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess; - export function execSync(command: string): Buffer; - export function execSync(command: string, options?: ExecSyncOptions & { encoding: 'buffer' }): Buffer; - export function execSync(command: string, options?: ExecSyncOptions): Buffer; + export interface SpawnSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: string; + shell?: boolean | string; + } + export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions { + encoding: BufferEncoding; + } + export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions { + encoding: string; // specify `null`. + } + export interface SpawnSyncReturns { + pid: number; + output: string[]; + stdout: T; + stderr: T; + status: number; + signal: string; + error: Error; + } + export function spawnSync(command: string): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; + export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns; + export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns; - export interface ExecFileSyncOptions { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - killSignal?: string; - maxBuffer?: number; - encoding?: buffer.Encoding | 'buffer'; - } + export interface ExecSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + shell?: string; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: string; + } + export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions { + encoding: BufferEncoding; + } + export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions { + encoding: string; // specify `null`. + } + export function execSync(command: string): Buffer; + export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string; + export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer; + export function execSync(command: string, options?: ExecSyncOptions): Buffer; - export function execFileSync(command: string): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; - export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions & { encoding: 'buffer' }): Buffer; - export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; + export interface ExecFileSyncOptions { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + killSignal?: string; + maxBuffer?: number; + encoding?: string; + } + export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions { + encoding: BufferEncoding; + } + export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions { + encoding: string; // specify `null`. + } + export function execFileSync(command: string): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string; + export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; + export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer; + export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer; } declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: string | any; - slashes?: boolean; - hash?: string; - path?: string; - } + export interface Url { + href?: string; + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: string | any; + slashes?: boolean; + hash?: string; + path?: string; + } - export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; - export function format(url: Url | string): string; - export function resolve(from: string, to: string): string; + export function parse(urlStr: string, parseQueryString?: boolean, slashesDenoteHost?: boolean): Url; + export function format(url: Url): string; + export function resolve(from: string, to: string): string; } declare module "dns" { - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + export interface MxRecord { + exchange: string, + priority: number + } - export const NODATA: 'ENODATA'; - export const FORMERR: 'EFORMERR'; - export const SERVFAIL: 'ESERVFAIL'; - export const NOTFOUND: 'ENOTFOUND'; - export const NOTIMP: 'ENOTIMP'; - export const REFUSED: 'EREFUSED'; - export const BADQUERY: 'EBADQUERY'; - export const BADNAME: 'EBADNAME'; - export const BADFAMILY: 'EBADFAMILY'; - export const BADRESP: 'EBADRESP'; - export const CONNREFUSED: 'ECONNREFUSED'; - export const TIMEOUT: 'ETIMEOUT'; - export const EOF: 'EOF'; - export const FILE: 'EFILE'; - export const NOMEM: 'ENOMEM'; - export const DESTRUCTION: 'EDESTRUCTION'; - export const BADSTR: 'EBADSTR'; - export const BADFLAGS: 'EBADFLAGS'; - export const NONAME: 'ENONAME'; - export const BADHINTS: 'EBADHINTS'; - export const NOTINITIALIZED: 'ENOTINITIALIZED'; - export const LOADIPHLPAPI: 'ELOADIPHLPAPI'; - export const ADDRGETNETWORKPARAMS: 'EADDRGETNETWORKPARAMS'; - export const CANCELLED: 'ECANCELLED'; + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) => void): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) => void): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + export function setServers(servers: string[]): void; + + //Error codes + export var NODATA: string; + export var FORMERR: string; + export var SERVFAIL: string; + export var NOTFOUND: string; + export var NOTIMP: string; + export var REFUSED: string; + export var BADQUERY: string; + export var BADNAME: string; + export var BADFAMILY: string; + export var BADRESP: string; + export var CONNREFUSED: string; + export var TIMEOUT: string; + export var EOF: string; + export var FILE: string; + export var NOMEM: string; + export var DESTRUCTION: string; + export var BADSTR: string; + export var BADFLAGS: string; + export var NONAME: string; + export var BADHINTS: string; + export var NOTINITIALIZED: string; + export var LOADIPHLPAPI: string; + export var ADDRGETNETWORKPARAMS: string; + export var CANCELLED: string; } declare module "net" { - import * as stream from "stream"; + import * as stream from "stream"; + import * as events from "events"; - export class Socket extends stream.Duplex { - constructor(options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }); + export interface Socket extends stream.Duplex { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; + connect(port: number, host?: string, connectionListener?: Function): void; + connect(path: string, connectionListener?: Function): void; + bufferSize: number; + setEncoding(encoding?: string): this; + write(data: any, encoding?: string, callback?: Function): void; + destroy(): void; + pause(): this; + resume(): this; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + unref(): void; + ref(): void; - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - write(data: any, encoding?: string, callback?: Function): void; - destroy(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; + remoteAddress: string; + remoteFamily: string; + remotePort: number; + localAddress: string; + localPort: number; + bytesRead: number; + bytesWritten: number; + destroyed: boolean; - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } + /** + * events.EventEmitter + * 1. close + * 2. connect + * 3. data + * 4. drain + * 5. end + * 6. error + * 7. lookup + * 8. timeout + */ + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: (had_error: boolean) => void): this; + addListener(event: "connect", listener: () => void): this; + addListener(event: "data", listener: (data: Buffer) => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + addListener(event: "timeout", listener: () => void): this; - export interface ListenOptions { - port?: number; - host?: string; - backlog?: number; - path?: string; - exclusive?: boolean; - } + emit(event: string, ...args: any[]): boolean; + emit(event: "close", had_error: boolean): boolean; + emit(event: "connect"): boolean; + emit(event: "data", data: Buffer): boolean; + emit(event: "drain"): boolean; + emit(event: "end"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean; + emit(event: "timeout"): boolean; - export class Server extends Socket { - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): this; - listen(port: number, hostname?: string, listeningListener?: Function): this; - listen(port: number, backlog?: number, listeningListener?: Function): this; - listen(port: number, listeningListener?: Function): this; - listen(path: string, backlog?: number, listeningListener?: Function): this; - listen(path: string, listeningListener?: Function): this; - listen(handle: any, backlog?: number, listeningListener?: Function): this; - listen(handle: any, listeningListener?: Function): this; - listen(options: ListenOptions, listeningListener?: Function): this; - close(callback?: () => void): this; - address(): { port: number; family: string; address: string; }; - getConnections(cb: (error: Error, count: number) => void): void; - ref(): this; - unref(): this; - maxConnections: number; - connections: number; - } + on(event: string, listener: Function): this; + on(event: "close", listener: (had_error: boolean) => void): this; + on(event: "connect", listener: () => void): this; + on(event: "data", listener: (data: Buffer) => void): this; + on(event: "drain", listener: () => void): this; + on(event: "end", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + on(event: "timeout", listener: () => void): this; - export function createServer(connectionListener?: (socket: Socket) => void): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; - export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; + once(event: string, listener: Function): this; + once(event: "close", listener: (had_error: boolean) => void): this; + once(event: "connect", listener: () => void): this; + once(event: "data", listener: (data: Buffer) => void): this; + once(event: "drain", listener: () => void): this; + once(event: "end", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + once(event: "timeout", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: (had_error: boolean) => void): this; + prependListener(event: "connect", listener: () => void): this; + prependListener(event: "data", listener: (data: Buffer) => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + prependListener(event: "timeout", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: (had_error: boolean) => void): this; + prependOnceListener(event: "connect", listener: () => void): this; + prependOnceListener(event: "data", listener: (data: Buffer) => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this; + prependOnceListener(event: "timeout", listener: () => void): this; + } + + export var Socket: { + new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; + }; + + export interface ListenOptions { + port?: number; + host?: string; + backlog?: number; + path?: string; + exclusive?: boolean; + } + + export interface Server extends events.EventEmitter { + listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server; + listen(port: number, hostname?: string, listeningListener?: Function): Server; + listen(port: number, backlog?: number, listeningListener?: Function): Server; + listen(port: number, listeningListener?: Function): Server; + listen(path: string, backlog?: number, listeningListener?: Function): Server; + listen(path: string, listeningListener?: Function): Server; + listen(options: ListenOptions, listeningListener?: Function): Server; + listen(handle: any, backlog?: number, listeningListener?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + close(callback?: Function): Server; + address(): { port: number; family: string; address: string; }; + getConnections(cb: (error: Error, count: number) => void): void; + ref(): Server; + unref(): Server; + maxConnections: number; + connections: number; + + /** + * events.EventEmitter + * 1. close + * 2. connection + * 3. error + * 4. listening + */ + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "connection", listener: (socket: Socket) => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "connection", socket: Socket): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + + on(event: string, listener: Function): this; + on(event: "close", listener: () => void): this; + on(event: "connection", listener: (socket: Socket) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + + once(event: string, listener: Function): this; + once(event: "close", listener: () => void): this; + once(event: "connection", listener: (socket: Socket) => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "connection", listener: (socket: Socket) => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "connection", listener: (socket: Socket) => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + } + export function createServer(connectionListener?: (socket: Socket) => void): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) => void): Server; + export function connect(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(port: number, host?: string, connectionListener?: Function): Socket; + export function connect(path: string, connectionListener?: Function): Socket; + export function createConnection(options: { port: number, host?: string, localAddress?: string, localPort?: string, family?: number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; + export function createConnection(path: string, connectionListener?: Function): Socket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; } declare module "dgram" { - import * as events from "events"; + import * as events from "events"; - export interface RemoteInfo { - address: string; - port: number; - size: number; - } + interface RemoteInfo { + address: string; + family: string; + port: number; + } - export interface AddressInfo { - address: string; - family: string; - port: number; - } + interface AddressInfo { + address: string; + family: string; + port: number; + } - export interface BindOptions { - port: number; - address?: string; - exclusive?: boolean; - } + interface BindOptions { + port: number; + address?: string; + exclusive?: boolean; + } - export interface SocketOptions { - type: string; - reuseAddr?: boolean; - } + interface SocketOptions { + type: "udp4" | "udp6"; + reuseAddr?: boolean; + } - export function createSocket(type: string | SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + export function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - export class Socket extends events.EventEmitter { - send(msg: Buffer | string | Array, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - send(msg: Buffer | string | Array, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port: number, address?: string, callback?: () => void): void; - bind(options: BindOptions, callback?: () => void): void; - close(callback?: () => void): void; - setTTL(ttl: number): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - ref(): void; - unref(): void; - } + export interface Socket extends events.EventEmitter { + send(msg: Buffer | String | any[], port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + bind(port?: number, address?: string, callback?: () => void): void; + bind(options: BindOptions, callback?: Function): void; + close(callback?: any): void; + address(): AddressInfo; + setBroadcast(flag: boolean): void; + setTTL(ttl: number): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + ref(): this; + unref(): this; + + /** + * events.EventEmitter + * 1. close + * 2. error + * 3. listening + * 4. message + **/ + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "listening", listener: () => void): this; + addListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; + + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "listening"): boolean; + emit(event: "message", msg: Buffer, rinfo: AddressInfo): boolean; + + on(event: string, listener: Function): this; + on(event: "close", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "listening", listener: () => void): this; + on(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; + + once(event: string, listener: Function): this; + once(event: "close", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "listening", listener: () => void): this; + once(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "listening", listener: () => void): this; + prependListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "listening", listener: () => void): this; + prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: AddressInfo) => void): this; + } } declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - import * as buffer from "buffer"; + import * as stream from "stream"; + import * as events from "events"; + + interface Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; + birthtime: Date; + } + + interface FSWatcher extends events.EventEmitter { + close(): void; + + /** + * events.EventEmitter + * 1. change + * 2. error + */ + addListener(event: string, listener: Function): this; + addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + addListener(event: "error", listener: (code: number, signal: string) => void): this; + + on(event: string, listener: Function): this; + on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + on(event: "error", listener: (code: number, signal: string) => void): this; + + once(event: string, listener: Function): this; + once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + once(event: "error", listener: (code: number, signal: string) => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependListener(event: "error", listener: (code: number, signal: string) => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this; + prependOnceListener(event: "error", listener: (code: number, signal: string) => void): this; + } + + export interface ReadStream extends stream.Readable { + close(): void; + destroy(): void; + bytesRead: number; + path: string | Buffer; + + /** + * events.EventEmitter + * 1. open + * 2. close + */ + addListener(event: string, listener: Function): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "close", listener: () => void): this; + + on(event: string, listener: Function): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "close", listener: () => void): this; + + once(event: string, listener: Function): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "close", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "close", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + } + + export interface WriteStream extends stream.Writable { + close(): void; + bytesWritten: number; + path: string | Buffer; + + /** + * events.EventEmitter + * 1. open + * 2. close + */ + addListener(event: string, listener: Function): this; + addListener(event: "open", listener: (fd: number) => void): this; + addListener(event: "close", listener: () => void): this; + + on(event: string, listener: Function): this; + on(event: "open", listener: (fd: number) => void): this; + on(event: "close", listener: () => void): this; + + once(event: string, listener: Function): this; + once(event: "open", listener: (fd: number) => void): this; + once(event: "close", listener: () => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "open", listener: (fd: number) => void): this; + prependListener(event: "close", listener: () => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "open", listener: (fd: number) => void): this; + prependOnceListener(event: "close", listener: () => void): this; + } - /** - * Objects returned from `fs.stat()`, `fs.lstat()` and `fs.fstat()` and their synchronous counterparts are of this type. - */ - export class Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; /** - * "Access Time" - Time when file data last accessed. Changed by the `mknod(2)`, `utimes(2)`, and `read(2)` system calls. + * Asynchronous rename. + * @param oldPath + * @param newPath + * @param callback No arguments other than a possible exception are given to the completion callback. */ - atime: Date; + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** - * "Modified Time" - Time when file data last modified. Changed by the `mknod(2)`, `utimes(2)`, and `write(2)` system calls. + * Synchronous rename + * @param oldPath + * @param newPath */ - mtime: Date; - /** - * "Change Time" - Time when file status was last changed (inode data modification). Changed by the `chmod(2)`, `chown(2)`, `link(2)`, `mknod(2)`, `rename(2)`, `unlink(2)`,` utimes(2)`, `read(2)`, and `write(2)` system calls. + export function renameSync(oldPath: string, newPath: string): void; + export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncate(path: string | Buffer, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncateSync(path: string | Buffer, len?: number): void; + export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncateSync(fd: number, len?: number): void; + export function chown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chownSync(path: string | Buffer, uid: number, gid: number): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchownSync(fd: number, uid: number, gid: number): void; + export function lchown(path: string | Buffer, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchownSync(path: string | Buffer, uid: number, gid: number): void; + export function chmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmodSync(path: string | Buffer, mode: number): void; + export function chmodSync(path: string | Buffer, mode: string): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmodSync(fd: number, mode: number): void; + export function fchmodSync(fd: number, mode: string): void; + export function lchmod(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmod(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmodSync(path: string | Buffer, mode: number): void; + export function lchmodSync(path: string | Buffer, mode: string): void; + export function stat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function lstat(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function statSync(path: string | Buffer): Stats; + export function lstatSync(path: string | Buffer): Stats; + export function fstatSync(fd: number): Stats; + export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function linkSync(srcpath: string | Buffer, dstpath: string | Buffer): void; + export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function symlinkSync(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): void; + export function readlink(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; + export function readlinkSync(path: string | Buffer): string; + export function realpath(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpathSync(path: string | Buffer, cache?: { [path: string]: string }): string; + /* + * Asynchronous unlink - deletes the file specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. */ - ctime: Date; - /** - * "Birth Time" - Time of file creation. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the `ctime` or `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). Note that this value may be greater than `atime` or `mtime` in this case. On Darwin and other FreeBSD variants, also set if the `atime` is explicitly set to an earlier value than the current `birthtime` using the `utimes(2)` system call. + export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous unlink - deletes the file specified in {path} + * + * @param path */ - birthtime: Date; - } - - export type WatchListener = (eventType: string, filename?: string | Buffer) => void; - - /** - * Objects returned from fs.watch() are of this type. - */ - export class FSWatcher extends events.EventEmitter implements - events.Listener<'change', WatchListener> { - close(): void; - } - - export class ReadStream extends stream.Readable implements - events.Listener<'open', (fd: number) => void>, - events.Listener<'close', () => void> { - bytesRead: number; - path: string | Buffer; - close(): void; - destroy(): void; - } - - export class WriteStream extends stream.Writable implements - events.Listener<'open', (fd: number) => void>, - events.Listener<'close', () => void> { - close(): void; - bytesWritten: number; - path: string | Buffer; - } - - export const F_OK: number; - export const R_OK: number; - export const W_OK: number; - export const X_OK: number; - - export const constants: { - O_RDONLY: number; - O_WRONLY: number; - O_RDWR: number; - S_IFMT: number; - S_IFREG: number; - S_IFDIR: number; - S_IFCHR: number; - S_IFBLK: number; - S_IFIFO: number; - S_IFLNK: number; - S_IFSOCK: number; - O_CREAT: number; - O_EXCL: number; - O_NOCTTY: number; - O_TRUNC: number; - O_APPEND: number; - O_DIRECTORY: number; - O_NOFOLLOW: number; - O_SYNC: number; - O_SYMLINK: number; - O_NONBLOCK: number; - S_IRWXU: number; - S_IRUSR: number; - S_IWUSR: number; - S_IXUSR: number; - S_IRWXG: number; - S_IRGRP: number; - S_IWGRP: number; - S_IXGRP: number; - S_IRWXO: number; - S_IROTH: number; - S_IWOTH: number; - S_IXOTH: number; - F_OK: number; - R_OK: number; - W_OK: number; - X_OK: number; - [key: string]: number; - } - - /** - * Tests a user's permissions for the file or directory specified by `path`. The `mode` argument is an optional integer that specifies the accessibility checks to be performed. The following constants define the possible values of `mode`. It is possible to create a mask consisting of the bitwise OR of two or more values. - */ - export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous version of `fs.access()`. This throws if any accessibility checks fail, and does nothing otherwise. - */ - export function accessSync(path: string | Buffer, mode?: number): void; - - export interface AppendFileOptions { - encoding?: buffer.Encoding; - mode?: number; - flag?: string; - } - - /** - * Asynchronously append data to a file, creating the file if it does not yet exist. `data` can be a string or a buffer. - */ - export function appendFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - export function appendFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | AppendFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * The synchronous version of `fs.appendFile()`. - */ - export function appendFileSync(file: string | Buffer | number, data: string | Buffer, options?: AppendFileOptions | null): void; - - /** - * Asynchronous chmod(2). - */ - export function chmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous chmod(2). - */ - export function chmodSync(path: string | Buffer, mode: number): void; - - /** - * Asynchronous chown(2). - */ - export function chown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous chown(2). - */ - export function chownSync(path: string | Buffer, uid: number, gid: number): void; - - /** - * Asynchronous close(2). - */ - export function close(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous close(2). - */ - export function closeSync(fd: number): void; - - export interface ReadStreamOptions { - flags?: string; - encoding?: buffer.Encoding; - fd?: number; - mode?: number; - autoClose?: boolean; - start?: number; - end?: number; - } - - /** - * Returns a new ReadStream object. - * - * Be aware that, unlike the default value set for `highWaterMark` on a readable stream (16 kb), the stream returned by this method has a default value of 64 kb for the same parameter. - */ - export function createReadStream(path: string | Buffer, options?: ReadStreamOptions | null): ReadStream; - - export interface WriteStreamOptions { - flags?: string; - defaultEncoding?: buffer.Encoding; - fd?: number; - mode?: number; - autoClose?: boolean; - start: number; - end: number; - } - - /** - * Returns a new WriteStream object. - */ - export function createWriteStream(path: string | Buffer, options?: WriteStreamOptions | null): WriteStream; - - /** - * Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false. - * - * @deprecated - */ - export function exists(path: string | Buffer, callback: (exists: boolean) => void): void; - - /** - * Synchronous version of `fs.exists()`. Returns true if the file exists, false otherwise. - */ - export function existsSync(path: string | Buffer): boolean; - - /** - * Asynchronous fchmod(2). - */ - export function fchmod(fd: number, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous fchmod(2). - */ - export function fchmodSync(fd: number, mode: number): void; - - /** - * Asynchronous fchown(2). - */ - export function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous fchown(2). - */ - export function fchownSync(fd: number, uid: number, gid: number): void; - - /** - * Asynchronous fdatasync(2). - */ - export function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous fdatasync(2). - */ - export function fdatasyncSync(fd: number): void; - - /** - * Asynchronous fstat(2). - */ - export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; - - /** - * Synchronous fstat(2). - */ - export function fstatSync(fd: number): Stats; - - /** - * Asynchronous fsync(2). - */ - export function fsync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous fsync(2). - */ - export function fsyncSync(fd: number): void; - - /** - * Asynchronous ftruncate(2). - * - * If the file referred to by the file descriptor was larger than `len` bytes, only the first `len` bytes will be retained in the file. - * - * If the file previously was shorter than `len` bytes, it is extended, and the extended part is filled with null bytes ('\0'). - */ - export function ftruncate(fd: number, len: number | null | undefined, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous ftruncate(2). - */ - export function ftruncateSync(fd: number, len?: number | null): void; - - /** - * Change the file timestamps of a file referenced by the supplied file descriptor. - */ - export function futimes(fd: number, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous version of `fs.futimes()`. - */ - export function futimesSync(fd: number, atime: number, mtime: number): void; - - /** - * Asynchronous lchmod(2). - * - * Only available on Mac OS X. - * - * @deprecated - */ - export function lchmod(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous lchmod(2). - * - * @deprecated - */ - export function lchmodSync(path: string | Buffer, mode: number): void; - - /** - * Asynchronous lchown(2). - * - * @deprecated - */ - export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous lchown(2). - * - * @deprecated - */ - export function lchownSync(path: string | Buffer, uid: number, gid: number): void; - - /** - * Asynchronous link(2). - */ - export function link(existingPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous link(2). - */ - export function linkSync(existingPath: string | Buffer, newPath: string | Buffer): void; - - /** - * Asynchronous lstat(2). `lstat()` is identical to `stat()`, except that if `path` is a symbolic link, then the link itself is stat-ed, not the file that it refers to. - */ - export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; - - /** - * Synchronous lstat(2). - */ - export function lstatSync(path: string | Buffer): Stats; - - /** - * Asynchronous mkdir(2). `mode` defaults to `0o777`. - */ - export function mkdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - export function mkdir(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous mkdir(2). - */ - export function mkdirSync(path: string | Buffer, mode?: number): void; - - export interface MkdtempOptions { - encoding: buffer.Encoding; - } - - /** - * Creates a unique temporary directory. - * - * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * - * The created folder path is passed as a string to the callback's second parameter. - */ - export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; - export function mkdtemp(prefix: string, options: buffer.Encoding | MkdtempOptions | null, callback: (err: NodeJS.ErrnoException | null, dir: string) => void): void; - - /** - * The synchronous version of fs.mkdtemp(). Returns the created folder path. - */ - export function mkdtempSync(prefix: string, options?: buffer.Encoding | MkdtempOptions | null): string; - - /** - * Asynchronous file open. See open(2). `flags` can be: - * - * 'r' - Open file for reading. An exception occurs if the file does not exist. - * - * 'r+' - Open file for reading and writing. An exception occurs if the file does not exist. - * - * 'rs+' - Open file for reading and writing in synchronous mode. Instructs the operating system to bypass the local file system cache. - * - * This is primarily useful for opening files on NFS mounts as it allows you to skip the potentially stale local cache. It has a very real impact on I/O performance so don't use this flag unless you need it. - * - * Note that this doesn't turn `fs.open()` into a synchronous blocking call. If that's what you want then you should be using `fs.openSync()` - * - * 'w' - Open file for writing. The file is created (if it does not exist) or truncated (if it exists). - * - * 'wx' - Like `'w'` but fails if `path` exists. - * - * 'w+' - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). - * - * 'wx+' - Like `'w+'` but fails if `path` exists. - * - * 'a' - Open file for appending. The file is created if it does not exist. - * - * 'ax' - Like 'a' but fails if `path` exists. - * - * 'a+' - Open file for reading and appending. The file is created if it does not exist. - * - * 'ax+' - Like 'a+' but fails if `path` exists. - * - * `mode` sets the file mode (permission and sticky bits), but only if the file was created. It defaults to `0666`, readable and writable. - */ - export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; - export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; - - /** - * Synchronous version of `fs.open()`. - */ - export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; - - /** - * Read data from the file specified by fd. - * - * @param buffer is the buffer that the data will be written to. - * @param offset is the offset in the buffer to start writing at. - * @param length is an integer specifying the number of bytes to read. - * @param position is an integer specifying where to begin reading from in the file. If position is null, data will be read from the current file position. - */ - export function read(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Buffer) => void): void; - - export interface ReaddirOptions { - encoding?: buffer.Encoding | 'buffer'; - } - - /** - * Asynchronous readdir(3). Reads the contents of a directory. - * - * @param files is an array of the names of the files in the directory excluding '.' and '..'. - */ - export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; - export function readdir(path: string | Buffer, options: 'buffer' | (ReadFileOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void): void; - export function readdir(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; - - /** - * Synchronous readdir(3). Returns an array of filenames excluding '.' and '..'. - */ - export function readdirSync(path: string | Buffer): string[]; - export function readdirSync(path: string | Buffer, options: 'buffer' | (ReaddirOptions & { encoding: 'buffer' })): Buffer[]; - export function readdirSync(path: string | Buffer, options: buffer.Encoding | ReaddirOptions | null): string[]; - - export interface ReadFileOptions { - encoding?: buffer.Encoding | 'buffer'; - flag?: string; - } - - /** - * Asynchronously reads the entire contents of a file. - */ - export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; - export function readFile(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding }), callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; - export function readFile(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; - - /** - * Synchronous version of `fs.readFile`. - */ - export function readFileSync(file: string | Buffer | number): Buffer; - export function readFileSync(file: string | Buffer | number, options: buffer.Encoding | (ReadFileOptions & { encoding: buffer.Encoding })): string; - export function readFileSync(file: string | Buffer | number, options: 'buffer' | ReadFileOptions | null): Buffer; - - export interface ReadlinkOptions { - encoding?: buffer.Encoding | 'buffer'; - } - - /** - * Asynchronous readlink(2). - */ - export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void; - export function readlink(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; - export function readlink(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null, callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void): void; - - /** - * Synchronous readlink(2). - */ - export function readlinkSync(path: string | Buffer): string; - export function readlinkSync(path: string | Buffer, options: 'buffer' | (ReadlinkOptions & { encoding: 'buffer' })): Buffer; - export function readlinkSync(path: string | Buffer, options: buffer.Encoding | ReadlinkOptions | null): string; - - /** - * Synchronous version of `fs.read()`. - */ - export function readSync(fd: number, buffer: string | Buffer, offset: number, length: number, position: number): number; - - export interface RealpathOptions { - encoding?: buffer.Encoding | 'buffer'; - } - - /** - * Asynchronous realpath(3). May use `process.cwd` to resolve relative paths. - * - * Only paths that can be converted to UTF8 strings are supported. - */ - export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => void): void; - export function realpath(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' }), callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; - export function realpath(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null, callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void): void; - - /** - * Synchronous realpath(3). Returns the resolved path. - * - * Only paths that can be converted to UTF8 strings are supported. - */ - export function realpathSync(path: string | Buffer): string; - export function realpathSync(path: string | Buffer, options: 'buffer' | (RealpathOptions & { encoding: 'buffer' })): Buffer; - export function realpathSync(path: string | Buffer, options: buffer.Encoding | RealpathOptions | null): string; - - /** - * Asynchronous rename(2). - */ - export function rename(oldPath: string | Buffer, newPath: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous rename(2). - */ - export function renameSync(oldPath: string | Buffer, newPath: string | Buffer): void; - - /** - * Asynchronous rmdir(2). - */ - export function rmdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous rmdir(2). - */ - export function rmdirSync(path: string | Buffer): void; - - /** - * Asynchronous stat(2). - * - * In case of an error, the `err.code` will be one of Common System Errors. - * - * Using `fs.stat()` to check for the existence of a file before calling `fs.open()`, `fs.readFile()` or `fs.writeFile()` is not recommended. Instead, user code should open/read/write the file directly and handle the error raised if the file is not available. - * - * To check if a file exists without manipulating it afterwards, `fs.access()` is recommended. - */ - export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void; - - /** - * Synchronous stat(2). - */ - export function statSync(path: string | Buffer): Stats; - - /** - * Asynchronous symlink(2). The type argument is only available on Windows (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. When using `'junction'`, the target argument will automatically be normalized to absolute path. - */ - export function symlink(target: string | Buffer, path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - export function symlink(target: string | Buffer, path: string | Buffer, type: 'dir' | 'file' | 'junction', callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous symlink(2). - */ - export function symlinkSync(target: string | Buffer, path: string | Buffer, type?: 'dir' | 'file' | 'junction'): void; - - /** - * Asynchronous truncate(2). - */ - export function truncate(path: string | Buffer, len: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous truncate(2). - */ - export function truncateSync(path: string | Buffer, len?: number): void; - - /** - * Asynchronous unlink(2). - */ - export function unlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous unlink(2). - */ - export function unlinkSync(path: string | Buffer): void; - - /** - * Stop watching for changes on `filename`. If `listener` is specified, only that particular listener is removed. Otherwise, _all_ listeners are removed and you have effectively stopped watching `filename`. - * - * Calling `fs.unwatchFile()` with a filename that is not being watched is a no-op, not an error. - * - * Note: `fs.watch()` is more efficient than `fs.watchFile()` and `fs.unwatchFile()`. `fs.watch()` should be used instead of `fs.watchFile()` and `fs.unwatchFile()` when possible. - */ - export function unwatchFile(filename: string | Buffer, listener?: WatchListener): void; - - /** - * Change file timestamps of the file referenced by the supplied path. - * - * Note: the arguments `atime` and `mtime` of the following related functions follow these rules: - * - * - The value should be a Unix timestamp in seconds. For example, `Date.now()` returns milliseconds, so it should be divided by 1000 before passing it in. - * If the value is a numeric string like `'123456789'`, the value will get converted to the corresponding number. - * If the value is `NaN` or `Infinity`, the value will get converted to `Date.now() / 1000`. - */ - export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err: NodeJS.ErrnoException | null) => void): void; - - /** - * Synchronous version of `fs.utimes()`. - */ - export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; - - export interface WatchOptions { - /** - * Indicates whether the process should continue to run as long as files are being watched. default = `true`. + export function unlinkSync(path: string | Buffer): void; + /* + * Asynchronous rmdir - removes the directory specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. */ - persistent?: boolean; - /** - * Indicates whether all subdirectories should be watched, or only the current directory. The applies when a directory is specified, and only on supported platforms (See Caveats). default = `false`. + export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous rmdir - removes the directory specified in {path} + * + * @param path */ - recursive?: boolean; - /** - * Specifies the character encoding to be used for the filename passed to the listener. default = `'utf8'`. + export function rmdirSync(path: string | Buffer): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. */ - encoding?: buffer.Encoding; - } - - /** - * Watch for changes on `filename`, where `filename` is either a file or a directory. The returned object is a `fs.FSWatcher`. - * - * Please note the listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but they are not the same thing. - */ - export function watch(filename: string | Buffer): FSWatcher; - export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null): FSWatcher; - export function watch(filename: string | Buffer, listener: WatchListener): FSWatcher; - export function watch(filename: string | Buffer, options: buffer.Encoding | WatchOptions | null, listener: WatchListener): FSWatcher; - - export interface WatchFileOptions { - /** - * Indicates whether the process should continue to run as long as files are being watched + export function mkdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. */ - persistent: boolean; - /** - * Indicates how often the target should be polled in milliseconds. The default is `5007`. + export function mkdir(path: string | Buffer, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. */ - interval: number; - } + export function mkdir(path: string | Buffer, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string | Buffer, mode?: number): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string | Buffer, mode?: string): void; + /* + * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * + * @param prefix + * @param callback The created folder path is passed as a string to the callback's second parameter. + */ + export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void; + /* + * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. + * + * @param prefix + * @returns Returns the created folder path. + */ + export function mkdtempSync(prefix: string): string; + export function readdir(path: string | Buffer, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; + export function readdirSync(path: string | Buffer): string[]; + export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function closeSync(fd: number): void; + export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; + export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; + export function openSync(path: string | Buffer, flags: string | number, mode?: number): number; + export function utimes(path: string | Buffer, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimesSync(path: string | Buffer, atime: number, mtime: number): void; + export function utimesSync(path: string | Buffer, atime: Date, mtime: Date): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimesSync(fd: number, atime: number, mtime: number): void; + export function futimesSync(fd: number, atime: Date, mtime: Date): void; + export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fsyncSync(fd: number): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number; + export function writeSync(fd: number, data: any, position?: number, enconding?: string): number; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + */ + export function readFileSync(filename: string, encoding: string): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; + export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; + export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; + export function watch(filename: string, encoding: string, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; + export function watch(filename: string, options: { persistent?: boolean; recursive?: boolean; encoding?: string }, listener?: (event: string, filename: string | Buffer) => any): FSWatcher; + export function exists(path: string | Buffer, callback?: (exists: boolean) => void): void; + export function existsSync(path: string | Buffer): boolean; - /** - * Watch for changes on filename. The callback listener will be called each time the file is accessed. - * - * Note: when an `fs.watchFile` operation results in an `ENOENT` error, it will invoke the listener once, with all the fields zeroed (or, for dates, the Unix Epoch). In Windows, `blksize` and `blocks` fields will be `undefined`, instead of zero. If the file is created later on, the listener will be called again, with the latest stat objects. - * - * Note: `fs.watch()` is more efficient than `fs.watchFile` and `fs.unwatchFile`. `fs.watch` should be used instead of `fs.watchFile` and `fs.unwatchFile` when possible. - */ - export function watchFile(filename: string | Buffer, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string | Buffer, options: WatchFileOptions | null, listener: (curr: Stats, prev: Stats) => void): void; + export namespace constants { + // File Access Constants - /** - * Write `buffer` to the file specified by `fd`. - * - * `offset` and `length` determine the part of the buffer to be written. - * - * `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'number'`, the data will be written at the current position. See pwrite(2). - * - * Note that it is unsafe to use `fs.write` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. - * - * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file. - */ - export function write(fd: number, buffer: string | Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: string | Buffer, offset: number, length: number, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; - export function write(fd: number, data: string | Buffer, position: number, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; - export function write(fd: number, data: string | Buffer, position: number, encoding: buffer.Encoding, callback: (err: NodeJS.ErrnoException | null, written: number, string: string) => void): void; + /** Constant for fs.access(). File is visible to the calling process. */ + export const F_OK: number; - export interface WriteFileOptions { - encoding?: buffer.Encoding; - mode?: number; - flag?: string; - } + /** Constant for fs.access(). File can be read by the calling process. */ + export const R_OK: number; - /** - * Asynchronously writes data to a file, replacing the file if it already exists. - * - * Note that it is unsafe to use `fs.writeFile` multiple times on the same file without waiting for the callback. For this scenario, `fs.createWriteStream` is strongly recommended. - * - * Note: If a file descriptor is specified as the `file`, it will not be closed automatically. - */ - export function writeFile(file: string | Buffer | number, data: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; - export function writeFile(file: string | Buffer | number, data: string | Buffer, options: buffer.Encoding | WriteFileOptions | null, callback: (err: NodeJS.ErrnoException | null) => void): void; + /** Constant for fs.access(). File can be written by the calling process. */ + export const W_OK: number; - /** - * The synchronous version of `fs.writeFile()`. - */ - export function writeFileSync(file: string | Buffer | number, data: string | Buffer, options?: buffer.Encoding | WriteFileOptions | null): void; + /** Constant for fs.access(). File can be executed by the calling process. */ + export const X_OK: number; - /** - * Synchronous `fs.write`. - */ - export function writeSync(fd: number, buffer: string | Buffer, offset: number, length: number, position?: number): void; - export function writeSync(fd: number, data: string | Buffer, position?: number, encoding?: buffer.Encoding): void; + // File Open Constants + + /** Constant for fs.open(). Flag indicating to open a file for read-only access. */ + export const O_RDONLY: number; + + /** Constant for fs.open(). Flag indicating to open a file for write-only access. */ + export const O_WRONLY: number; + + /** Constant for fs.open(). Flag indicating to open a file for read-write access. */ + export const O_RDWR: number; + + /** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */ + export const O_CREAT: number; + + /** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */ + export const O_EXCL: number; + + /** Constant for fs.open(). Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one). */ + export const O_NOCTTY: number; + + /** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */ + export const O_TRUNC: number; + + /** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */ + export const O_APPEND: number; + + /** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */ + export const O_DIRECTORY: number; + + /** Constant for fs.open(). Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only. */ + export const O_NOATIME: number; + + /** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */ + export const O_NOFOLLOW: number; + + /** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */ + export const O_SYNC: number; + + /** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */ + export const O_SYMLINK: number; + + /** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */ + export const O_DIRECT: number; + + /** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */ + export const O_NONBLOCK: number; + + // File Type Constants + + /** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */ + export const S_IFMT: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */ + export const S_IFREG: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */ + export const S_IFDIR: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */ + export const S_IFCHR: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */ + export const S_IFBLK: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */ + export const S_IFIFO: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */ + export const S_IFLNK: number; + + /** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */ + export const S_IFSOCK: number; + + // File Mode Constants + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */ + export const S_IRWXU: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */ + export const S_IRUSR: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */ + export const S_IWUSR: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */ + export const S_IXUSR: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */ + export const S_IRWXG: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */ + export const S_IRGRP: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */ + export const S_IWGRP: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */ + export const S_IXGRP: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */ + export const S_IRWXO: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */ + export const S_IROTH: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */ + export const S_IWOTH: number; + + /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */ + export const S_IXOTH: number; + } + + /** Tests a user's permissions for the file specified by path. */ + export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; + export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; + /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ + export function accessSync(path: string | Buffer, mode?: number): void; + export function createReadStream(path: string | Buffer, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + end?: number; + }): ReadStream; + export function createWriteStream(path: string | Buffer, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + }): WriteStream; + export function fdatasync(fd: number, callback: Function): void; + export function fdatasyncSync(fd: number): void; } declare module "path" { - /** - * A parsed path object generated by path.parse() or consumed by path.format(). - */ - export interface ParsedPath { /** - * The root of the path such as '/' or 'c:\' + * A parsed path object generated by path.parse() or consumed by path.format(). */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } + export interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ - export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. - */ - export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: string[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ - export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ - export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ - export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ - export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ - export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ - export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; - - export module posix { + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths paths to join. + */ export function join(...paths: string[]): string; - export function resolve(...pathSegments: string[]): string; - export function isAbsolute(p: string): boolean; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: any[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; - export module win32 { - export function normalize(p: string): string; - export function join(...paths: string[]): string; - export function resolve(...pathSegments: string[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } + export module posix { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } + + export module win32 { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } } declare module "string_decoder" { - import * as buffer from "buffer"; - - export class StringDecoder { - /** - * @param encoding The character encoding the `StringDecoder` will use. Defaults to `'utf8'`. - */ - constructor(encoding?: buffer.Encoding); - /** - * Returns a decoded string, ensuring that any incomplete multibyte characters at the end of the `Buffer` are omitted from the returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`. - * - * @param buffer A `Buffer` containing the bytes to decode. - */ - write(buffer: Buffer): string; - /** - * Returns any remaining input stored in the internal buffer as a string. Bytes representing incomplete UTF-8 and UTF-16 characters will be replaced with substitution characters appropriate for the character encoding. - * - * If the `buffer` argument is provided, one final call to `stringDecoder.write()` is performed before returning the remaining input. - * - * @param buffer A `Buffer` containing the bytes to decode. - */ - end(buffer?: Buffer): string; - } + export interface NodeStringDecoder { + write(buffer: Buffer): string; + end(buffer?: Buffer): string; + } + export var StringDecoder: { + new (encoding?: string): NodeStringDecoder; + }; } declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; + import * as crypto from "crypto"; + import * as net from "net"; + import * as stream from "stream"; - export var CLIENT_RENEG_LIMIT: number; - export var CLIENT_RENEG_WINDOW: number; - export var SLAB_BUFFER_SIZE: number; - export var DEFAULT_CIPHERS: string; - export var DEFAULT_ECDH_CURVE: string; + var CLIENT_RENEG_LIMIT: number; + var CLIENT_RENEG_WINDOW: number; - export class Server extends net.Server { - /** - * The `server.addContext()` method adds a secure context that will be used if the client request's SNS hostname matches the supplied `hostname` (or wildcard). - * - * @param hostname A SNI hostname or wildcard (e.g. `'*'`) - * @param options An object containing any of the possible properties from the `tls.createSecureContext()` options arguments - */ - addContext(hostName: string, options: SecureContextOptions): void; - /** - * Returns a `Buffer` instance holding the keys currently used for encryption/decryption of the TLS Session Tickets. - */ - getTicketKeys(): Buffer; - /** - * Updates the keys for encryption/decryption of the TLS Session Tickets. - * - * Note: The key's Buffer should be 48 bytes long. See ticketKeys option in tls.createServer for more information on how it is used. - * - * Note: Changes to the ticket keys are effective only for future server connections. Existing or currently pending server connections will use the previous keys. - */ - setTicketKeys(keys: Buffer): void; - /** - * Returns the current number of concurrent connections on the server. - */ - connections: number; - } + export interface Certificate { + /** + * Country code. + */ + C: string; + /** + * Street. + */ + ST: string; + /** + * Locality. + */ + L: string; + /** + * Organization. + */ + O: string; + /** + * Organizational unit. + */ + OU: string; + /** + * Common name. + */ + CN: string; + } - export interface Certificate { - /** - * Country code. - */ - C: string; - /** - * Street. - */ - ST: string; - /** - * Locality. - */ - L: string; - /** - * Organization. - */ - O: string; - /** - * Organizational unit. - */ - OU: string; - /** - * Common name. - */ - CN: string; - } + export interface CipherNameAndProtocol { + /** + * The cipher name. + */ + name: string; + /** + * SSL/TLS protocol version. + */ + version: string; + } - export interface Cipher { - /** - * The cipher name. - */ - name: string; - /** - * SSL/TLS protocol version. - */ - version: string; - } + export class TLSSocket extends stream.Duplex { + /** + * Construct a new tls.TLSSocket object from an existing TCP socket. + */ + constructor(socket:net.Socket, options?: { + /** + * An optional TLS context object from tls.createSecureContext() + */ + secureContext?: SecureContext, + /** + * If true the TLS socket will be instantiated in server-mode. + * Defaults to false. + */ + isServer?: boolean, + /** + * An optional net.Server instance. + */ + server?: net.Server, + /** + * If true the server will request a certificate from clients that + * connect and attempt to verify that certificate. Defaults to + * false. + */ + requestCert?: boolean, + /** + * If true the server will reject any connection which is not + * authorized with the list of supplied CAs. This option only has an + * effect if requestCert is true. Defaults to false. + */ + rejectUnauthorized?: boolean, + /** + * An array of strings or a Buffer naming possible NPN protocols. + * (Protocols should be ordered by their priority.) + */ + NPNProtocols?: string[] | Buffer, + /** + * An array of strings or a Buffer naming possible ALPN protocols. + * (Protocols should be ordered by their priority.) When the server + * receives both NPN and ALPN extensions from the client, ALPN takes + * precedence over NPN and the server does not send an NPN extension + * to the client. + */ + ALPNProtocols?: string[] | Buffer, + /** + * SNICallback(servername, cb) A function that will be + * called if the client supports SNI TLS extension. Two arguments + * will be passed when called: servername and cb. SNICallback should + * invoke cb(null, ctx), where ctx is a SecureContext instance. + * (tls.createSecureContext(...) can be used to get a proper + * SecureContext.) If SNICallback wasn't provided the default callback + * with high-level API will be used (see below). + */ + SNICallback?: Function, + /** + * An optional Buffer instance containing a TLS session. + */ + session?: Buffer, + /** + * If true, specifies that the OCSP status request extension will be + * added to the client hello and an 'OCSPResponse' event will be + * emitted on the socket before establishing a secure communication + */ + requestOCSP?: boolean + }); + /** + * Returns the bound address, the address family name and port of the underlying socket as reported by + * the operating system. + * @returns {any} - An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. + */ + address(): { port: number; family: string; address: string }; + /** + * A boolean that is true if the peer certificate was signed by one of the specified CAs, otherwise false. + */ + authorized: boolean; + /** + * The reason why the peer's certificate has not been verified. + * This property becomes available only when tlsSocket.authorized === false. + */ + authorizationError: Error; + /** + * Static boolean value, always true. + * May be used to distinguish TLS sockets from regular ones. + */ + encrypted: boolean; + /** + * Returns an object representing the cipher name and the SSL/TLS protocol version of the current connection. + * @returns {CipherNameAndProtocol} - Returns an object representing the cipher name + * and the SSL/TLS protocol version of the current connection. + */ + getCipher(): CipherNameAndProtocol; + /** + * Returns an object representing the peer's certificate. + * The returned object has some properties corresponding to the field of the certificate. + * If detailed argument is true the full chain with issuer property will be returned, + * if false only the top certificate without issuer property. + * If the peer does not provide a certificate, it returns null or an empty object. + * @param {boolean} detailed - If true; the full chain with issuer property will be returned. + * @returns {any} - An object representing the peer's certificate. + */ + getPeerCertificate(detailed?: boolean): { + subject: Certificate; + issuerInfo: Certificate; + issuer: Certificate; + raw: any; + valid_from: string; + valid_to: string; + fingerprint: string; + serialNumber: string; + }; + /** + * Could be used to speed up handshake establishment when reconnecting to the server. + * @returns {any} - ASN.1 encoded TLS session or undefined if none was negotiated. + */ + getSession(): any; + /** + * NOTE: Works only with client TLS sockets. + * Useful only for debugging, for session reuse provide session option to tls.connect(). + * @returns {any} - TLS session ticket or undefined if none was negotiated. + */ + getTLSTicket(): any; + /** + * The string representation of the local IP address. + */ + localAddress: string; + /** + * The numeric representation of the local port. + */ + localPort: string; + /** + * The string representation of the remote IP address. + * For example, '74.125.127.100' or '2001:4860:a005::68'. + */ + remoteAddress: string; + /** + * The string representation of the remote IP family. 'IPv4' or 'IPv6'. + */ + remoteFamily: string; + /** + * The numeric representation of the remote port. For example, 443. + */ + remotePort: number; + /** + * Initiate TLS renegotiation process. + * + * NOTE: Can be used to request peer's certificate after the secure connection has been established. + * ANOTHER NOTE: When running as the server, socket will be destroyed with an error after handshakeTimeout timeout. + * @param {TlsOptions} options - The options may contain the following fields: rejectUnauthorized, + * requestCert (See tls.createServer() for details). + * @param {Function} callback - callback(err) will be executed with null as err, once the renegotiation + * is successfully completed. + */ + renegotiate(options: TlsOptions, callback: (err: Error) => any): any; + /** + * Set maximum TLS fragment size (default and maximum value is: 16384, minimum is: 512). + * Smaller fragment size decreases buffering latency on the client: large fragments are buffered by + * the TLS layer until the entire fragment is received and its integrity is verified; + * large fragments can span multiple roundtrips, and their processing can be delayed due to packet + * loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, + * which may decrease overall server throughput. + * @param {number} size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). + * @returns {boolean} - Returns true on success, false otherwise. + */ + setMaxSendFragment(size: number): boolean; - export interface EphemeralKeyInfo { - type: 'DH' | 'ECDH'; - name?: string; - size: number; - } + /** + * events.EventEmitter + * 1. OCSPResponse + * 2. secureConnect + **/ + addListener(event: string, listener: Function): this; + addListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + addListener(event: "secureConnect", listener: () => void): this; - export interface PeerCertificate { - subject: Certificate; - issuerInfo: Certificate; - issuer: Certificate; - raw: Buffer; - valid_from: string; - valid_to: string; - fingerprint: string; - serialNumber: string; - } + emit(event: string, ...args: any[]): boolean; + emit(event: "OCSPResponse", response: Buffer): boolean; + emit(event: "secureConnect"): boolean; - export interface TLSSocketOptions { - /** - * An optional TLS context object from `tls.createSecureContext()`. - */ - secureContext?: SecureContext; - /** - * If true the TLS socket will be instantiated in server-mode. Defaults to `false`. - */ - isServer?: boolean; - /** - * An optional net.Server instance. - */ - server?: net.Server; - /** - * Optional, see `tls.createServer()`. - */ - requestCert?: boolean; - /** - * Optional, see `tls.createServer()`. - */ - rejectUnauthorized?: boolean; - /** - * Optional, see `tls.createServer()`. - */ - NPNProtocols?: string[] | Buffer; - /** - * Optional, see `tls.createServer()`. - */ - ALPNProtocols?: string[] | Buffer; - /** - * Optional, see `tls.createServer()`. - */ - SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; - /** - * An optional Buffer instance containing a TLS session. - */ - session?: Buffer; - /** - * If `true`, specifies that the OCSP status request extension will be added to the client hello and an 'OCSPResponse' event will be emitted on the socket before establishing a secure communication - */ - requestOCSP?: boolean; - } + on(event: string, listener: Function): this; + on(event: "OCSPResponse", listener: (response: Buffer) => void): this; + on(event: "secureConnect", listener: () => void): this; - export interface RenegotiateOptions { - rejectUnauthorized?: boolean; - requestCert?: boolean; - } + once(event: string, listener: Function): this; + once(event: "OCSPResponse", listener: (response: Buffer) => void): this; + once(event: "secureConnect", listener: () => void): this; - export class TLSSocket extends net.Socket { - /** - * Construct a new `tls.TLSSocket` object from an existing TCP socket. - */ - constructor(socket: net.Socket, options?: TLSSocketOptions); - /** - * Returns `true` if the peer certificate was signed by one of the CAs specified when creating the `tls.TLSSocket` instance, otherwise `false`. - */ - authorized: boolean; - /** - * Returns the reason why the peer's certificate was not been verified. This property is set only when `tlsSocket.authorized === false`. - */ - authorizationError?: Error; - /** - * Always returns `true`. This may be used to distinguish TLS sockets from regular `net.Socket` instances. - */ - encrypted: true; - /** - * Returns an object representing the cipher name and the SSL/TLS protocol version that first defined the cipher. - */ - getCipher(): Cipher; - /** - * Returns an object representing the type, name, and size of parameter of an ephemeral key exchange in Perfect Forward Secrecy on a client connection. It returns an empty object when the key exchange is not ephemeral. As this is only supported on a client socket; `null` is returned if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The `name` property is available only when type is `'ECDH'`. - */ - getEphemeralKeyInfo(): EphemeralKeyInfo; - /** - * Returns an object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. - * - * @param detailed Specify `true` to request that the full certificate chain with the `issuer` property be returned; false to return only the top certificate without the `issuer` property. - */ - getPeerCertificate(detailed?: boolean): PeerCertificate; - /** - * Returns a string containing the negotiated SSL/TLS protocol version of the current connection. The value `'unknown'` will be returned for connected sockets that have not completed the handshaking process. The value `null` will be returned for server sockets or disconnected client sockets. - */ - getProtocol(): string | null; - /** - * Returns the ASN.1 encoded TLS session or `undefined` if no session was negotiated. Can be used to speed up handshake establishment when reconnecting to the server. - */ - getSession(): Buffer | undefined; - /** - * Returns the TLS session ticket or `undefined` if no session was negotiated. - * - * Note: This only works with client TLS sockets. Useful only for debugging, for session reuse `provide` session option to `tls.connect()`. - */ - getTLSTicket(): Buffer | undefined; - /** - * Returns the string representation of the local IP address. - */ - localAddress: string; - /** - * Returns the numeric representation of the local port. - */ - localPort: number; - /** - * Returns the string representation of the remote IP address. For example, `'74.125.127.100'` or `'2001:4860:a005::68'`. - */ - remoteAddress: string; - /** - * Returns the string representation of the remote IP family. `'IPv4'` or `'IPv6'`. - */ - remoteFamily: string; - /** - * The numeric representation of the remote port. For example, 443. - */ - remotePort: number; - /** - * The `tlsSocket.renegotiate()` method initiates a TLS renegotiation process. - * - * Note: This method can be used to request a peer's certificate after the secure connection has been established. - * - * Note: When running as the server, the socket will be destroyed with an error after `handshakeTimeout` timeout. - */ - renegotiate(options: RenegotiateOptions, callback: (err: Error | null) => any): any; - /** - * The `tlsSocket.setMaxSendFragment()` method sets the maximum TLS fragment size. Returns `true` if setting the limit succeeded; false otherwise. - * - * Smaller fragment sizes decrease the buffering latency on the client: larger fragments are buffered by the TLS layer until the entire fragment is received and its integrity is verified; large fragments can span multiple roundtrips and their processing can be delayed due to packet loss or reordering. However, smaller fragments add extra TLS framing bytes and CPU overhead, which may decrease overall server throughput. - * - * @param size The maximum TLS fragment size. Defaults to `16384`. The maximum value is `16384`. - */ - setMaxSendFragment(size: number): boolean; - } + prependListener(event: string, listener: Function): this; + prependListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependListener(event: "secureConnect", listener: () => void): this; - export interface ConnectOptions { - /** - * Host the client should connect to. - */ - host?: string; - /** - * Port the client should connect to. - */ - port?: number | string; - /** - * Establish secure connection on a given socket rather than creating a new socket. If this option is specified, `host` and `port` are ignored. - */ - socket?: net.Socket; - /** - * Creates unix socket connection to path. If this option is specified, `host` and `port` are ignored. - */ - path?: string; - /** - * A `string` or `Buffer` containing the private key, certificate, and CA certs of the client in PFX or PKCS12 format. - */ - pfx?: string | Buffer; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s containing the private key of the client in PEM format. - */ - key?: string | Buffer | string[] | Buffer[]; - /** - * A string containing the passphrase for the private key or pfx. - */ - passphrase?: string; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s containing the certificate key of the client in PEM format. - */ - cert?: string | Buffer | string[] | Buffer[]; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If this is omitted several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. - */ - ca?: string | Buffer | string[] | Buffer[]; - /** - * A string describing the ciphers to use or exclude, separated by `:`. Uses the same default cipher suite as `tls.createServer()`. - */ - ciphers?: string; - /** - * If true, the server certificate is verified against the list of supplied CAs. An `'error'` event is emitted if verification fails; `err.code` contains the OpenSSL error code. Defaults to `true`. - */ - rejectUnauthorized?: boolean; - /** - * An array of strings or `Buffer`s containing supported NPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler, e.g. `['hello', 'world']`. - */ - NPNProtocols?: string[] | Buffer[]; - /** - * An array of strings or `Buffer`s containing the supported ALPN protocols. `Buffer`s should have the format `[len][name][len][name]...` e.g. `0x05hello0x05world`, where the first byte is the length of the next protocol name. Passing an array is usually much simpler: `['hello', 'world']`.) - */ - ALPNProtocols?: string[] | Buffer[]; - /** - * Server name for the SNI (Server Name Indication) TLS extension. - */ - servername?: string; - /** - * A callback function to be used when checking the server's hostname against the certificate. This should throw an error if verification fails. The method should return `undefined` if the `servername` and `cert` are verified. - */ - checkServerIdentity?: (servername: string, cert: Buffer) => void; - /** - * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. - */ - secureProtocol?: string; - /** - * An optional TLS context object as returned by from `tls.createSecureContext( ... )`. It can be used for caching client certificates, keys, and CA certificates. - */ - secureContext?: SecureContext; - /** - * A `Buffer` instance, containing TLS session. - */ - session?: Buffer; - /** - * Minimum size of the DH parameter in bits to accept a TLS connection. When a server offers a DH parameter with a size less than `minDHSize`, the TLS connection is destroyed and an error is thrown. Defaults to `1024`. - */ - minDHSize?: number; - } + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "OCSPResponse", listener: (response: Buffer) => void): this; + prependOnceListener(event: "secureConnect", listener: () => void): this; + } - export interface SecureContextOptions { - /** - * A string or `Buffer` holding the PFX or PKCS12 encoded private key, certificate, and CA certificates. - */ - pfx?: string | Buffer; - /** - * The private key of the server in PEM format. To support multiple keys using different algorithms, an array can be provided either as an array of key strings or as an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. - */ - key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; - /** - * A string containing the passphrase for the private key or pfx. - */ - passphrase?: string; - /** - * A string containing the PEM encoded certificate. - */ - cert?: string | Buffer | string[] | Buffer[]; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. - */ - ca?: string | Buffer | string[] | Buffer[]; - /** - * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). - */ - crl?: string | string[]; - /** - * A string describing the ciphers to use or exclude. Consult https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT for details on the format. - */ - ciphers?: string; - /** - * If `true`, when a cipher is being selected, the server's preferences will be used instead of the client preferences. - */ - honorCipherOrder?: boolean; - } + export interface TlsOptions { + host?: string; + port?: number; + pfx?: string | Buffer[]; + key?: string | string[] | Buffer | any[]; + passphrase?: string; + cert?: string | string[] | Buffer | Buffer[]; + ca?: string | string[] | Buffer | Buffer[]; + crl?: string | string[]; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: string[] | Buffer; + SNICallback?: (servername: string, cb: (err: Error, ctx: SecureContext) => any) => any; + ecdhCurve?: string; + dhparam?: string | Buffer; + handshakeTimeout?: number; + ALPNProtocols?: string[] | Buffer; + sessionTimeout?: number; + ticketKeys?: any; + sessionIdContext?: string; + secureProtocol?: string; + } - export interface CreateServerOptions { - /** - * A `string` or `Buffer` containing the private key, certificate and CA certs of the server in PFX or PKCS12 format. (Mutually exclusive with the `key`, `cert`, and `ca` options.) - */ - pfx?: string | Buffer; - /** - * The private key of the server in PEM format. To support multiple keys using different algorithms an array can be provided either as a plain array of key strings or an array of objects in the format `{pem: key, passphrase: passphrase}`. This option is required for ciphers that make use of private keys. - */ - key?: string | string[] | Buffer | Array<{ pem: string | string[] | Buffer, passphrase: string }>; - /** - * A string containing the passphrase for the private key or pfx. - */ - passphrase?: string; - /** - * A string containing the PEM encoded certificate. - */ - cert?: string | Buffer | string[] | Buffer[]; - /** - * A string, `Buffer`, array of strings, or array of `Buffer`s of trusted certificates in PEM format. If omitted, several well known "root" CAs (like VeriSign) will be used. These are used to authorize connections. - */ - ca?: string | Buffer | string[] | Buffer[]; - /** - * Either a string or array of strings of PEM encoded CRLs (Certificate Revocation List). - */ - crl?: string | string[]; - /** - * A string describing the ciphers to use or exclude, separated by `:`. - */ - ciphers?: string; - /** - * A string describing a named curve to use for ECDH key agreement or false to disable ECDH. Defaults to `prime256v1` (NIST P-256). Use crypto.getCurves() to obtain a list of available curve names. On recent releases, `openssl ecparam -list_curves` will also display the name and description of each available elliptic curve. - */ - ecdhCurve?: string; - /** - * A string or `Buffer` containing Diffie Hellman parameters, required for Perfect Forward Secrecy. Use `openssl dhparam` to create the parameters. The key length must be greater than or equal to 1024 bits, otherwise an error will be thrown. It is strongly recommended to use 2048 bits or larger for stronger security. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available. - */ - dhparam?: string | Buffer; - /** - * Abort the connection if the SSL/TLS handshake does not finish in the specified number of milliseconds. Defaults to `120` seconds. A `'clientError'` is emitted on the `tls.Server` object whenever a handshake times out. - */ - handshakeTimeout?: number; - /** - * When choosing a cipher, use the server's preferences instead of the client preferences. Defaults to `true`. - */ - honorCipherOrder?: boolean; - /** - * If `true` the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to `false`. - */ - requestCert?: boolean; - /** - * If `true` the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if `requestCert` is `true`. Defaults to `false`. - */ - rejectUnauthorized?: boolean; - /** - * An array of strings or a `Buffer` naming possible NPN protocols. (Protocols should be ordered by their priority.) - */ - NPNProtocols?: string[] | Buffer; - /** - * An array of strings or a `Buffer` naming possible ALPN protocols. (Protocols should be ordered by their priority.) When the server receives both NPN and ALPN extensions from the client, ALPN takes precedence over NPN and the server does not send an NPN extension to the client. - */ - ALPNProtocols?: string[] | Buffer; - /** - * A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: `servername` and `cb`. `SNICallback` should invoke `cb(null, ctx)`, where `ctx` is a SecureContext instance. (`tls.createSecureContext(...)` can be used to get a proper SecureContext.) If `SNICallback` wasn't provided the default callback with high-level API will be used (see below). - */ - SNICallback?: (servername: string, cb: (err: Error | null, ctx: SecureContext) => void) => void; - /** - * An integer specifying the number of seconds after which the TLS session identifiers and TLS session tickets created by the server will time out. See SSL_CTX_set_timeout for more details. - */ - sessionTimeout?: number; - /** - * A 48-byte `Buffer` instance consisting of a 16-byte prefix, a 16-byte HMAC key, and a 16-byte AES key. This can be used to accept TLS session tickets on multiple instances of the TLS server. Note that this is automatically shared between `cluster` module workers. - */ - ticketKeys?: Buffer; - /** - * A string containing an opaque identifier for session resumption. If `requestCert` is true, the default is a 128 bit truncated SHA1 hash value generated from the command-line. Otherwise, a default is not provided. - */ - sessionIdContext?: string; - /** - * The SSL method to use, e.g., `SSLv3_method` to force SSL version 3. The possible values depend on the version of OpenSSL installed in the environment and are defined in the constant SSL_METHODS. - */ - secureProtocol?: string; - } + export interface ConnectionOptions { + host?: string; + port?: number; + socket?: net.Socket; + pfx?: string | Buffer + key?: string | string[] | Buffer | Buffer[]; + passphrase?: string; + cert?: string | string[] | Buffer | Buffer[]; + ca?: string | Buffer | (string | Buffer)[]; + rejectUnauthorized?: boolean; + NPNProtocols?: (string | Buffer)[]; + servername?: string; + path?: string; + ALPNProtocols?: (string | Buffer)[]; + checkServerIdentity?: (servername: string, cert: string | Buffer | (string | Buffer)[]) => any; + secureProtocol?: string; + secureContext?: Object; + session?: Buffer; + minDHSize?: number; + } - export interface SecureContext { - context: any; - } + export interface Server extends net.Server { + close(callback?: Function): Server; + address(): { port: number; family: string; address: string; }; + addContext(hostName: string, credentials: { + key: string; + cert: string; + ca: string; + }): void; + maxConnections: number; + connections: number; - /** - * Creates a new tls.Server. The secureConnectionListener, if provided, is automatically set as a listener for the `'secureConnection'` event. - */ - export function createServer(options: CreateServerOptions, secureConnectionListener?: (socket: TLSSocket) => void): Server; + /** + * events.EventEmitter + * 1. tlsClientError + * 2. newSession + * 3. OCSPRequest + * 4. resumeSession + * 5. secureConnection + **/ + addListener(event: string, listener: Function): this; + addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; + addListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; + addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; + addListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - /** - * Creates a new client connection to the given `port` and `host` or `options.port` and `options.host`. (If `host` is omitted, it defaults to `localhost`.) - */ - export function connect(options: ConnectOptions, callback?: () => void): TLSSocket; - export function connect(port: number, options?: ConnectOptions, callback?: () => void): TLSSocket; - export function connect(port: number, host?: string, options?: ConnectOptions, callback?: () => void): TLSSocket; + emit(event: string, ...args: any[]): boolean; + emit(event: "tlsClientError", err: Error, tlsSocket: TLSSocket): boolean; + emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void): boolean; + emit(event: "OCSPRequest", certificate: Buffer, issuer: Buffer, callback: Function): boolean; + emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean; + emit(event: "secureConnection", tlsSocket: TLSSocket): boolean; - /** - * The `tls.createSecureContext()` method creates a credentials object. - * - * If the `'ca'` option is not given, then Node.js will use the default publicly trusted list of CAs as given in http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt. - */ - export function createSecureContext(options: SecureContextOptions): SecureContext; + on(event: string, listener: Function): this; + on(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; + on(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; + on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; + on(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; - /** - * Returns an array with the names of the supported SSL ciphers. - */ - export function getCiphers(): string[]; + once(event: string, listener: Function): this; + once(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; + once(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; + once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; + once(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; + prependListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; + prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; + prependListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: TLSSocket) => void): this; + prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: Buffer) => void) => void): this; + prependOnceListener(event: "OCSPRequest", listener: (certificate: Buffer, issuer: Buffer, callback: Function) => void): this; + prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this; + prependOnceListener(event: "secureConnection", listener: (tlsSocket: TLSSocket) => void): this; + } + + export interface ClearTextStream extends stream.Duplex { + authorized: boolean; + authorizationError: Error; + getPeerCertificate(): any; + getCipher: { + name: string; + version: string; + }; + address: { + port: number; + family: string; + address: string; + }; + remoteAddress: string; + remotePort: number; + } + + export interface SecurePair { + encrypted: any; + cleartext: any; + } + + export interface SecureContextOptions { + pfx?: string | Buffer; + key?: string | Buffer; + passphrase?: string; + cert?: string | Buffer; + ca?: string | Buffer; + crl?: string | string[] + ciphers?: string; + honorCipherOrder?: boolean; + } + + export interface SecureContext { + context: any; + } + + export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) => void): Server; + export function connect(options: ConnectionOptions, secureConnectionListener?: () => void): ClearTextStream; + export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream; + export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): ClearTextStream; + export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; + export function createSecureContext(details: SecureContextOptions): SecureContext; } declare module "crypto" { - import * as stream from "stream"; + export interface Certificate { + exportChallenge(spkac: string | Buffer): Buffer; + exportPublicKey(spkac: string | Buffer): Buffer; + verifySpkac(spkac: Buffer): boolean; + } + export var Certificate: { + new (): Certificate; + (): Certificate; + } - export var constants: { - defaultCipherList: string; - defaultCoreCipherList: string; - [key: string]: string | number; - } + export var fips: boolean; - export function getCiphers(): string[]; - export function getCurves(): string[]; - export function getHashes(): string[]; + export interface CredentialDetails { + pfx: string; + key: string; + passphrase: string; + cert: string; + ca: string | string[]; + crl: string | string[]; + ciphers: string; + } + export interface Credentials { context?: any; } + export function createCredentials(details: CredentialDetails): Credentials; + export function createHash(algorithm: string): Hash; + export function createHmac(algorithm: string, key: string | Buffer): Hmac; - export class Certificate { - constructor(); - exportChallenge(spkac: string | Buffer, encoding?: string): string; - exportPublicKey(spkac: string | Buffer, encoding?: string): Buffer; - verifySpkac(spkac: Buffer): boolean; - } + type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1"; + type HexBase64Latin1Encoding = "latin1" | "hex" | "base64"; + type Utf8AsciiBinaryEncoding = "utf8" | "ascii" | "binary"; + type HexBase64BinaryEncoding = "binary" | "base64" | "hex"; + type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; - export function createHash(algorithm: string): Hash; - - export class Hash extends stream.Transform { - update(data: string | Buffer, input_encoding?: string): Hash; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): string; - digest(): Buffer; - } - - export function createHmac(algorithm: string, key: string | Buffer): Hmac; - - export class Hmac extends stream.Transform { - update(data: string | Buffer, input_encoding?: string): Hmac; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): string; - digest(): Buffer; - } - - export function createCipher(algorithm: string, password: string | Buffer): Cipher; - export function createCipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Cipher; - - export class Cipher extends stream.Transform { - update(data: Buffer): Buffer; - update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1"): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: "binary" | "latin1" | "base64" | "hex"): string; - update(data: string, input_encoding: "utf8" | "ascii" | "binary" | "latin1", output_encoding: "binary" | "latin1" | "base64" | "hex"): string; - final(): Buffer; - final(output_encoding: string): string; - setAAD(buffer: Buffer): void; - setAutoPadding(auto_padding: boolean): void; - getAuthTag(): Buffer; - } - - export function createDecipher(algorithm: string, password: string | Buffer): Decipher; - export function createDecipheriv(algorithm: string, key: string | Buffer, iv: string | Buffer): Decipher; - - export class Decipher extends stream.Transform { - update(data: Buffer): Buffer; - update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex"): Buffer; - update(data: Buffer, input_encoding: any, output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; - update(data: string, input_encoding: "binary" | "latin1" | "base64" | "hex", output_encoding: "utf8" | "ascii" | "binary" | "latin1"): string; - final(): Buffer; - final(output_encoding: string): string; - setAAD(buffer: Buffer): void; - setAutoPadding(auto_padding: boolean): void; - setAuthTag(tag: Buffer): void; - } - - export function createSign(algorithm: string): Signer; - - export class Signer extends stream.Writable { - update(data: string | Buffer): void; - sign(private_key: string): Buffer; - sign(private_key: string, output_format: string): string; - } - - export function createVerify(algorith: string): Verify; - - export class Verify extends stream.Writable { - update(data: string | Buffer): void; - verify(object: string, signature: string, signature_format?: string): boolean; - } - - export function createDiffieHellman(prime: number, prime_encoding?: string, generator?: number | string | Buffer, generator_encoding?: string): DiffieHellman; - export function createDiffieHellman(prime_length: number, generator?: number | string | Buffer): DiffieHellman; - export function getDiffieHellman(group_name: string): DiffieHellman; - - export class DiffieHellman { - verifyError: number; - computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; - generateKeys(encoding?: string): string; - getPrime(encoding?: string): string; - getGenerator(encoding?: string): string; - getPublicKey(encoding?: string): string; - getPrivateKey(encoding?: string): string; - setPublicKey(public_key: string, encoding?: string): void; - setPrivateKey(public_key: string, encoding?: string): void; - } - - export function createECDH(curve_name: string): ECDH; - - export class ECDH { - computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; - generateKeys(encoding?: string, format?: string): string; - getPrivateKey(encoding?: string): string; - getPublicKey(encoding?: string, format?: string): string; - setPrivateKey(private_key: string, encoding?: string): void; - } - - export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => void): void; - export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => void): void; - - export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number): Buffer; - export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; - - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; - - export interface RsaKey { - key: string; - passphrase?: string, - padding?: number; - } - - export function timingSafeEqual(a: Buffer, b: Buffer): boolean; - export function publicEncrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; - export function privateEncrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; - export function publicDecrypt(public_key: string | RsaKey, buffer: Buffer): Buffer; - export function privateDecrypt(private_key: string | RsaKey, buffer: Buffer): Buffer; - - export function setEngine(engine: string, flags?: number): void; + export interface Hash extends NodeJS.ReadWriteStream { + update(data: string | Buffer): Hash; + update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hash; + digest(): Buffer; + digest(encoding: HexBase64Latin1Encoding): string; + } + export interface Hmac extends NodeJS.ReadWriteStream { + update(data: string | Buffer): Hmac; + update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Hmac; + digest(): Buffer; + digest(encoding: HexBase64Latin1Encoding): string; + } + export function createCipher(algorithm: string, password: any): Cipher; + export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; + export interface Cipher extends NodeJS.ReadWriteStream { + update(data: Buffer): Buffer; + update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: HexBase64BinaryEncoding): string; + update(data: string, input_encoding: Utf8AsciiBinaryEncoding, output_encoding: HexBase64BinaryEncoding): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding?: boolean): void; + getAuthTag(): Buffer; + setAAD(buffer: Buffer): void; + } + export function createDecipher(algorithm: string, password: any): Decipher; + export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; + export interface Decipher extends NodeJS.ReadWriteStream { + update(data: Buffer): Buffer; + update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer; + update(data: Buffer, input_encoding: any, output_encoding: Utf8AsciiBinaryEncoding): string; + update(data: string, input_encoding: HexBase64BinaryEncoding, output_encoding: Utf8AsciiBinaryEncoding): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding?: boolean): void; + setAuthTag(tag: Buffer): void; + setAAD(buffer: Buffer): void; + } + export function createSign(algorithm: string): Signer; + export interface Signer extends NodeJS.WritableStream { + update(data: string | Buffer): Signer; + update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Signer; + sign(private_key: string | { key: string; passphrase: string }): Buffer; + sign(private_key: string | { key: string; passphrase: string }, output_format: HexBase64Latin1Encoding): string; + } + export function createVerify(algorith: string): Verify; + export interface Verify extends NodeJS.WritableStream { + update(data: string | Buffer): Verify; + update(data: string | Buffer, input_encoding: Utf8AsciiLatin1Encoding): Verify; + verify(object: string, signature: Buffer): boolean; + verify(object: string, signature: string, signature_format: HexBase64Latin1Encoding): boolean; + } + export function createDiffieHellman(prime_length: number, generator?: number): DiffieHellman; + export function createDiffieHellman(prime: Buffer): DiffieHellman; + export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman; + export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Buffer): DiffieHellman; + export function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman; + export interface DiffieHellman { + generateKeys(): Buffer; + generateKeys(encoding: HexBase64Latin1Encoding): string; + computeSecret(other_public_key: Buffer): Buffer; + computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; + computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; + getPrime(): Buffer; + getPrime(encoding: HexBase64Latin1Encoding): string; + getGenerator(): Buffer; + getGenerator(encoding: HexBase64Latin1Encoding): string; + getPublicKey(): Buffer; + getPublicKey(encoding: HexBase64Latin1Encoding): string; + getPrivateKey(): Buffer; + getPrivateKey(encoding: HexBase64Latin1Encoding): string; + setPublicKey(public_key: Buffer): void; + setPublicKey(public_key: string, encoding: string): void; + setPrivateKey(private_key: Buffer): void; + setPrivateKey(private_key: string, encoding: string): void; + verifyError: number; + } + export function getDiffieHellman(group_name: string): DiffieHellman; + export function pbkdf2(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string | Buffer, salt: string | Buffer, iterations: number, keylen: number, digest: string): Buffer; + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) => void): void; + export interface RsaPublicKey { + key: string; + padding?: number; + } + export interface RsaPrivateKey { + key: string; + passphrase?: string, + padding?: number; + } + export function publicEncrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer + export function privateDecrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer + export function privateEncrypt(private_key: string | RsaPrivateKey, buffer: Buffer): Buffer + export function publicDecrypt(public_key: string | RsaPublicKey, buffer: Buffer): Buffer + export function getCiphers(): string[]; + export function getCurves(): string[]; + export function getHashes(): string[]; + export interface ECDH { + generateKeys(): Buffer; + generateKeys(encoding: HexBase64Latin1Encoding): string; + generateKeys(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; + computeSecret(other_public_key: Buffer): Buffer; + computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer; + computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string; + getPrivateKey(): Buffer; + getPrivateKey(encoding: HexBase64Latin1Encoding): string; + getPublicKey(): Buffer; + getPublicKey(encoding: HexBase64Latin1Encoding): string; + getPublicKey(encoding: HexBase64Latin1Encoding, format: ECDHKeyFormat): string; + setPrivateKey(private_key: Buffer): void; + setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void; + } + export function createECDH(curve_name: string): ECDH; + export function timingSafeEqual(a: Buffer, b: Buffer): boolean; + export var DEFAULT_ENCODING: string; } declare module "stream" { - import * as events from "events"; + import * as events from "events"; - export class Stream extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } + class internal extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } + namespace internal { - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - read?: (this: Readable, size?: number) => any; - } + export class Stream extends internal { } - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - _read(size: number): void; - read(size?: number): any; - isPaused(): boolean; - setEncoding(encoding: string): this; - pause(): this; - resume(): this; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - } + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + read?: (size?: number) => any; + } - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + protected _read(size: number): void; + read(size?: number): any; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): this; + unpipe(destination?: T): this; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - setDefaultEncoding(encoding: string): this; - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. data + * 3. end + * 4. readable + * 5. error + **/ + addListener(event: string, listener: Function): this; + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "data", listener: (chunk: Buffer | string) => void): this; + addListener(event: "end", listener: () => void): this; + addListener(event: "readable", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - readableObjectMode?: boolean; - writableObjectMode?: boolean; - } + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "data", chunk: Buffer | string): boolean; + emit(event: "end"): boolean; + emit(event: "readable"): boolean; + emit(event: "error", err: Error): boolean; - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements Writable { - writable: boolean; - constructor(opts?: DuplexOptions); - setDefaultEncoding(encoding: string): this; - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } + on(event: string, listener: Function): this; + on(event: "close", listener: () => void): this; + on(event: "data", listener: (chunk: Buffer | string) => void): this; + on(event: "end", listener: () => void): this; + on(event: "readable", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; - export interface TransformOptions extends ReadableOptions, WritableOptions { - write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; - writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; - } + once(event: string, listener: Function): this; + once(event: "close", listener: () => void): this; + once(event: "data", listener: (chunk: Buffer | string) => void): this; + once(event: "end", listener: () => void): this; + once(event: "readable", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; - export class Transform extends Duplex { - constructor(opts?: TransformOptions); - _transform(chunk: any, encoding: string, callback: Function): void; - } + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependListener(event: "end", listener: () => void): this; + prependListener(event: "readable", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; - export class PassThrough extends Transform { } + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this; + prependOnceListener(event: "end", listener: () => void): this; + prependOnceListener(event: "readable", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + + removeListener(event: string, listener: Function): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "data", listener: (chunk: Buffer | string) => void): this; + removeListener(event: "end", listener: () => void): this; + removeListener(event: "readable", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + } + + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + objectMode?: boolean; + write?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + writev?: (chunks: { chunk: string | Buffer, encoding: string }[], callback: Function) => any; + } + + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + protected _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + + /** + * Event emitter + * The defined events on documents including: + * 1. close + * 2. drain + * 3. error + * 4. finish + * 5. pipe + * 6. unpipe + **/ + addListener(event: string, listener: Function): this; + addListener(event: "close", listener: () => void): this; + addListener(event: "drain", listener: () => void): this; + addListener(event: "error", listener: (err: Error) => void): this; + addListener(event: "finish", listener: () => void): this; + addListener(event: "pipe", listener: (src: Readable) => void): this; + addListener(event: "unpipe", listener: (src: Readable) => void): this; + + emit(event: string, ...args: any[]): boolean; + emit(event: "close"): boolean; + emit(event: "drain", chunk: Buffer | string): boolean; + emit(event: "error", err: Error): boolean; + emit(event: "finish"): boolean; + emit(event: "pipe", src: Readable): boolean; + emit(event: "unpipe", src: Readable): boolean; + + on(event: string, listener: Function): this; + on(event: "close", listener: () => void): this; + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "finish", listener: () => void): this; + on(event: "pipe", listener: (src: Readable) => void): this; + on(event: "unpipe", listener: (src: Readable) => void): this; + + once(event: string, listener: Function): this; + once(event: "close", listener: () => void): this; + once(event: "drain", listener: () => void): this; + once(event: "error", listener: (err: Error) => void): this; + once(event: "finish", listener: () => void): this; + once(event: "pipe", listener: (src: Readable) => void): this; + once(event: "unpipe", listener: (src: Readable) => void): this; + + prependListener(event: string, listener: Function): this; + prependListener(event: "close", listener: () => void): this; + prependListener(event: "drain", listener: () => void): this; + prependListener(event: "error", listener: (err: Error) => void): this; + prependListener(event: "finish", listener: () => void): this; + prependListener(event: "pipe", listener: (src: Readable) => void): this; + prependListener(event: "unpipe", listener: (src: Readable) => void): this; + + prependOnceListener(event: string, listener: Function): this; + prependOnceListener(event: "close", listener: () => void): this; + prependOnceListener(event: "drain", listener: () => void): this; + prependOnceListener(event: "error", listener: (err: Error) => void): this; + prependOnceListener(event: "finish", listener: () => void): this; + prependOnceListener(event: "pipe", listener: (src: Readable) => void): this; + prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this; + + removeListener(event: string, listener: Function): this; + removeListener(event: "close", listener: () => void): this; + removeListener(event: "drain", listener: () => void): this; + removeListener(event: "error", listener: (err: Error) => void): this; + removeListener(event: "finish", listener: () => void): this; + removeListener(event: "pipe", listener: (src: Readable) => void): this; + removeListener(event: "unpipe", listener: (src: Readable) => void): this; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + readableObjectMode?: boolean; + writableObjectMode?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements NodeJS.ReadWriteStream { + // Readable + pause(): this; + resume(): this; + // Writeable + writable: boolean; + constructor(opts?: DuplexOptions); + protected _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends DuplexOptions { + transform?: (chunk: string | Buffer, encoding: string, callback: Function) => any; + flush?: (callback: Function) => any; + } + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + protected _transform(chunk: any, encoding: string, callback: Function): void; + protected _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): this; + pause(): this; + resume(): this; + pipe(destination: T, options?: { end?: boolean; }): this; + unpipe(destination?: T): this; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform { } + } + + export = internal; } declare module "util" { - /** - * The `util.debuglog()` method is used to create a function that conditionally writes debug messages to `stderr` based on the existence of the `NODE_DEBUG` environment variable. If the `section` name appears within the value of that environment variable, then the returned function operates similar to console.error(). If not, then the returned function is a no-op. - */ - export function debuglog(section: string): (msg: any, ...args: any[]) => void; - - export interface InspectOptions { - /** - * If `true`, the `object`'s non-enumerable symbols and properties will be included in the formatted result. Defaults to `false`. - */ - showHidden?: boolean; - /** - * Specifies the number of times to recurse while formatting the `object`. This is useful for inspecting large complicated objects. Defaults to `2`. To make it recurse indefinitely pass `null`. - */ - depth?: number | null; - /** - * If `true`, the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see "Customizing util.inspect colors". - */ - colors?: boolean; - /** - * If `false`, then custom `inspect(depth, opts)` functions exported on the object being inspected will not be called. Defaults to `true`. - */ - customInspect?: boolean; - /** - * If `true`, then objects and functions that are `Proxy` objects will be introspected to show their `target` and `handler` objects. Defaults to `false`. - */ - showProxy?: boolean; - /** - * Specifies the maximum number of array and `TypedArray` elements to include when formatting. Defaults to `100`. Set to `null` to show all array elements. Set to `0` or negative to show no array elements. - */ - maxArrayLength?: number | null; - /** - * The length at which an object's keys are split across multiple lines. Set to `Infinity` to format an object as a single line. Defaults to `60` for legacy compatibility. - */ - breakLength?: number; - } - - /** - * The `util.inspect()` method returns a string representation of object that is primarily useful for debugging. - */ - export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - - export namespace inspect { - export var colors: { - bold: [number, number]; - italic: [number, number]; - underline: [number, number]; - inverse: [number, number]; - white: [number, number]; - grey: [number, number]; - black: [number, number]; - blue: [number, number]; - cyan: [number, number]; - green: [number, number]; - magenta: [number, number]; - red: [number, number]; - yellow: [number, number]; + export interface InspectOptions { + showHidden?: boolean; + depth?: number; + colors?: boolean; + customInspect?: boolean; } - export var styles: { - special: string; - number: string; - boolean: string; - undefined: string; - null: string; - string: string; - symbol: string; - date: string; - regexp: string; - }; - - export var custom: symbol; - } - - /** - * The `util.deprecate()` method wraps the given function or class in such a way that it is marked as deprecated. - */ - export function deprecate(fn: T, string: string): T; - - /** - * The `util.format()` method returns a formatted string using the first argument as a printf-like format. - */ - export function format(format: any, ...param: any[]): string; - - /** - * Inherit the prototype methods from one constructor into another. The prototype of constructor will be set to a new object created from superConstructor. - */ - export function inherits(constructor: any, superConstructor: any): void; - - /** - * Deprecated predecessor of `console.error`. - * - * @deprecated - */ - export function debug(string: string): void; - - /** - * Deprecated predecessor of `console.error`. - * - * @deprecated - */ - export function error(...strings: string[]): void; - - /** - * Internal alias for `Array.isArray`. - * - * @deprecated - */ - export function isArray(object: any): object is any[]; - - /** - * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isBoolean(object: any): object is boolean; - - /** - * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isBuffer(object: any): object is Buffer; - - /** - * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isDate(object: any): object is Date; - - /** - * Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isError(object: any): object is Error; - - /** - * Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isFunction(object: any): object is Function; - - /** - * Returns `true` if the given `object` is strictly `null`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isNull(object: any): object is null; - - /** - * Returns `true` if the given `object` is `null` or `undefined`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isNullOrUndefined(object: any): object is null | undefined; - - /** - * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isNumber(object: any): object is number; - - /** - * Returns true if the given `object` is strictly an `Object` and not a `Function`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isObject(object: any): object is Object; - - /** - * Returns true if the given `object` is a primitive type. Otherwise, returns `false`. - * - * @deprecated - */ - export function isPrimitive(object: any): object is string | number | boolean | null | undefined; - - /** - * Returns true if the given `object` is a `RegExp`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isRegExp(object: any): object is RegExp; - - /** - * Returns true if the given `object` is a `String`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isString(object: any): object is string; - - /** - * Returns true if the given `object` is a `Symbol`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isSymbol(object: any): object is symbol; - - /** - * Returns true if the given `object` is `undefined`. Otherwise, returns `false`. - * - * @deprecated - */ - export function isUndefined(object: any): object is symbol; - - /** - * The `util.log()` method prints the given `string` to `stdout` with an included timestamp. - * - * @deprecated - */ - export function log(string: string): void; - - /** - * Deprecated predecessor of `console.log`. - * - * @deprecated - */ - export function print(strings: string[]): void; - - /** - * Deprecated predecessor of `console.log`. - * - * @deprecated - */ - export function puts(strings: string[]): void; - - /** - * The `util._extend()` method was never intended to be used outside of internal Node.js modules. The community found and used it anyway. - * - * It is deprecated and should not be used in new code. JavaScript comes with very similar built-in functionality through `Object.assign()`. - * - * @deprecated - */ - export function _extend(target: T, source: U): T & U; + export function format(format: any, ...param: any[]): string; + export function debug(string: string): void; + export function error(...param: any[]): void; + export function puts(...param: any[]): void; + export function print(...param: any[]): void; + export function log(string: string): void; + export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + export function isArray(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isDate(object: any): boolean; + export function isError(object: any): boolean; + export function inherits(constructor: any, superConstructor: any): void; + export function debuglog(key: string): (msg: string, ...param: any[]) => void; + export function isBoolean(object: any): boolean; + export function isBuffer(object: any): boolean; + export function isFunction(object: any): boolean; + export function isNull(object: any): boolean; + export function isNullOrUndefined(object: any): boolean; + export function isNumber(object: any): boolean; + export function isObject(object: any): boolean; + export function isPrimitive(object: any): boolean; + export function isString(object: any): boolean; + export function isSymbol(object: any): boolean; + export function isUndefined(object: any): boolean; + export function deprecate(fn: Function, message: string): Function; } declare module "assert" { - function internal(value: any, message?: string): void; - namespace internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; + function internal(value: any, message?: string): void; + namespace internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; - constructor(options?: { - message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function - }); + constructor(options?: { + message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function + }); + } + + export function fail(actual: any, expected: any, message: string, operator: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export function deepStrictEqual(actual: any, expected: any, message?: string): void; + export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export function ifError(value: any): void; } - export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; - } - - export = internal; + export = internal; } declare module "tty" { - import * as net from "net"; + import * as net from "net"; - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - isTTY: boolean; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - isTTY: boolean; - } + export function isatty(fd: number): boolean; + export interface ReadStream extends net.Socket { + isRaw: boolean; + setRawMode(mode: boolean): void; + isTTY: boolean; + } + export interface WriteStream extends net.Socket { + columns: number; + rows: number; + isTTY: boolean; + } } declare module "domain" { - import * as events from "events"; + import * as events from "events"; - export class Domain extends events.EventEmitter implements NodeJS.Domain { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - members: any[]; - enter(): void; - exit(): void; - } + export class Domain extends events.EventEmitter implements NodeJS.Domain { + run(fn: Function): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + members: any[]; + enter(): void; + exit(): void; + } - export function create(): Domain; + export function create(): Domain; } declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFBLK: number; - export var S_IFIFO: number; - export var S_IFSOCK: number; - export var S_IRWXU: number; - export var S_IRUSR: number; - export var S_IWUSR: number; - export var S_IXUSR: number; - export var S_IRWXG: number; - export var S_IRGRP: number; - export var S_IWGRP: number; - export var S_IXGRP: number; - export var S_IRWXO: number; - export var S_IROTH: number; - export var S_IWOTH: number; - export var S_IXOTH: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_NOCTTY: number; - export var O_DIRECTORY: number; - export var O_NOATIME: number; - export var O_NOFOLLOW: number; - export var O_SYNC: number; - export var O_SYMLINK: number; - export var O_DIRECT: number; - export var O_NONBLOCK: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; -} - -declare module "module" { - export = NodeModule; + export var E2BIG: number; + export var EACCES: number; + export var EADDRINUSE: number; + export var EADDRNOTAVAIL: number; + export var EAFNOSUPPORT: number; + export var EAGAIN: number; + export var EALREADY: number; + export var EBADF: number; + export var EBADMSG: number; + export var EBUSY: number; + export var ECANCELED: number; + export var ECHILD: number; + export var ECONNABORTED: number; + export var ECONNREFUSED: number; + export var ECONNRESET: number; + export var EDEADLK: number; + export var EDESTADDRREQ: number; + export var EDOM: number; + export var EEXIST: number; + export var EFAULT: number; + export var EFBIG: number; + export var EHOSTUNREACH: number; + export var EIDRM: number; + export var EILSEQ: number; + export var EINPROGRESS: number; + export var EINTR: number; + export var EINVAL: number; + export var EIO: number; + export var EISCONN: number; + export var EISDIR: number; + export var ELOOP: number; + export var EMFILE: number; + export var EMLINK: number; + export var EMSGSIZE: number; + export var ENAMETOOLONG: number; + export var ENETDOWN: number; + export var ENETRESET: number; + export var ENETUNREACH: number; + export var ENFILE: number; + export var ENOBUFS: number; + export var ENODATA: number; + export var ENODEV: number; + export var ENOENT: number; + export var ENOEXEC: number; + export var ENOLCK: number; + export var ENOLINK: number; + export var ENOMEM: number; + export var ENOMSG: number; + export var ENOPROTOOPT: number; + export var ENOSPC: number; + export var ENOSR: number; + export var ENOSTR: number; + export var ENOSYS: number; + export var ENOTCONN: number; + export var ENOTDIR: number; + export var ENOTEMPTY: number; + export var ENOTSOCK: number; + export var ENOTSUP: number; + export var ENOTTY: number; + export var ENXIO: number; + export var EOPNOTSUPP: number; + export var EOVERFLOW: number; + export var EPERM: number; + export var EPIPE: number; + export var EPROTO: number; + export var EPROTONOSUPPORT: number; + export var EPROTOTYPE: number; + export var ERANGE: number; + export var EROFS: number; + export var ESPIPE: number; + export var ESRCH: number; + export var ETIME: number; + export var ETIMEDOUT: number; + export var ETXTBSY: number; + export var EWOULDBLOCK: number; + export var EXDEV: number; + export var WSAEINTR: number; + export var WSAEBADF: number; + export var WSAEACCES: number; + export var WSAEFAULT: number; + export var WSAEINVAL: number; + export var WSAEMFILE: number; + export var WSAEWOULDBLOCK: number; + export var WSAEINPROGRESS: number; + export var WSAEALREADY: number; + export var WSAENOTSOCK: number; + export var WSAEDESTADDRREQ: number; + export var WSAEMSGSIZE: number; + export var WSAEPROTOTYPE: number; + export var WSAENOPROTOOPT: number; + export var WSAEPROTONOSUPPORT: number; + export var WSAESOCKTNOSUPPORT: number; + export var WSAEOPNOTSUPP: number; + export var WSAEPFNOSUPPORT: number; + export var WSAEAFNOSUPPORT: number; + export var WSAEADDRINUSE: number; + export var WSAEADDRNOTAVAIL: number; + export var WSAENETDOWN: number; + export var WSAENETUNREACH: number; + export var WSAENETRESET: number; + export var WSAECONNABORTED: number; + export var WSAECONNRESET: number; + export var WSAENOBUFS: number; + export var WSAEISCONN: number; + export var WSAENOTCONN: number; + export var WSAESHUTDOWN: number; + export var WSAETOOMANYREFS: number; + export var WSAETIMEDOUT: number; + export var WSAECONNREFUSED: number; + export var WSAELOOP: number; + export var WSAENAMETOOLONG: number; + export var WSAEHOSTDOWN: number; + export var WSAEHOSTUNREACH: number; + export var WSAENOTEMPTY: number; + export var WSAEPROCLIM: number; + export var WSAEUSERS: number; + export var WSAEDQUOT: number; + export var WSAESTALE: number; + export var WSAEREMOTE: number; + export var WSASYSNOTREADY: number; + export var WSAVERNOTSUPPORTED: number; + export var WSANOTINITIALISED: number; + export var WSAEDISCON: number; + export var WSAENOMORE: number; + export var WSAECANCELLED: number; + export var WSAEINVALIDPROCTABLE: number; + export var WSAEINVALIDPROVIDER: number; + export var WSAEPROVIDERFAILEDINIT: number; + export var WSASYSCALLFAILURE: number; + export var WSASERVICE_NOT_FOUND: number; + export var WSATYPE_NOT_FOUND: number; + export var WSA_E_NO_MORE: number; + export var WSA_E_CANCELLED: number; + export var WSAEREFUSED: number; + export var SIGHUP: number; + export var SIGINT: number; + export var SIGILL: number; + export var SIGABRT: number; + export var SIGFPE: number; + export var SIGKILL: number; + export var SIGSEGV: number; + export var SIGTERM: number; + export var SIGBREAK: number; + export var SIGWINCH: number; + export var SSL_OP_ALL: number; + export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; + export var SSL_OP_CISCO_ANYCONNECT: number; + export var SSL_OP_COOKIE_EXCHANGE: number; + export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + export var SSL_OP_EPHEMERAL_RSA: number; + export var SSL_OP_LEGACY_SERVER_CONNECT: number; + export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; + export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; + export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; + export var SSL_OP_NETSCAPE_CA_DN_BUG: number; + export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; + export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NO_COMPRESSION: number; + export var SSL_OP_NO_QUERY_MTU: number; + export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + export var SSL_OP_NO_SSLv2: number; + export var SSL_OP_NO_SSLv3: number; + export var SSL_OP_NO_TICKET: number; + export var SSL_OP_NO_TLSv1: number; + export var SSL_OP_NO_TLSv1_1: number; + export var SSL_OP_NO_TLSv1_2: number; + export var SSL_OP_PKCS1_CHECK_1: number; + export var SSL_OP_PKCS1_CHECK_2: number; + export var SSL_OP_SINGLE_DH_USE: number; + export var SSL_OP_SINGLE_ECDH_USE: number; + export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; + export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; + export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; + export var SSL_OP_TLS_D5_BUG: number; + export var SSL_OP_TLS_ROLLBACK_BUG: number; + export var ENGINE_METHOD_DSA: number; + export var ENGINE_METHOD_DH: number; + export var ENGINE_METHOD_RAND: number; + export var ENGINE_METHOD_ECDH: number; + export var ENGINE_METHOD_ECDSA: number; + export var ENGINE_METHOD_CIPHERS: number; + export var ENGINE_METHOD_DIGESTS: number; + export var ENGINE_METHOD_STORE: number; + export var ENGINE_METHOD_PKEY_METHS: number; + export var ENGINE_METHOD_PKEY_ASN1_METHS: number; + export var ENGINE_METHOD_ALL: number; + export var ENGINE_METHOD_NONE: number; + export var DH_CHECK_P_NOT_SAFE_PRIME: number; + export var DH_CHECK_P_NOT_PRIME: number; + export var DH_UNABLE_TO_CHECK_GENERATOR: number; + export var DH_NOT_SUITABLE_GENERATOR: number; + export var NPN_ENABLED: number; + export var RSA_PKCS1_PADDING: number; + export var RSA_SSLV23_PADDING: number; + export var RSA_NO_PADDING: number; + export var RSA_PKCS1_OAEP_PADDING: number; + export var RSA_X931_PADDING: number; + export var RSA_PKCS1_PSS_PADDING: number; + export var POINT_CONVERSION_COMPRESSED: number; + export var POINT_CONVERSION_UNCOMPRESSED: number; + export var POINT_CONVERSION_HYBRID: number; + export var O_RDONLY: number; + export var O_WRONLY: number; + export var O_RDWR: number; + export var S_IFMT: number; + export var S_IFREG: number; + export var S_IFDIR: number; + export var S_IFCHR: number; + export var S_IFBLK: number; + export var S_IFIFO: number; + export var S_IFSOCK: number; + export var S_IRWXU: number; + export var S_IRUSR: number; + export var S_IWUSR: number; + export var S_IXUSR: number; + export var S_IRWXG: number; + export var S_IRGRP: number; + export var S_IWGRP: number; + export var S_IXGRP: number; + export var S_IRWXO: number; + export var S_IROTH: number; + export var S_IWOTH: number; + export var S_IXOTH: number; + export var S_IFLNK: number; + export var O_CREAT: number; + export var O_EXCL: number; + export var O_NOCTTY: number; + export var O_DIRECTORY: number; + export var O_NOATIME: number; + export var O_NOFOLLOW: number; + export var O_SYNC: number; + export var O_SYMLINK: number; + export var O_DIRECT: number; + export var O_NONBLOCK: number; + export var O_TRUNC: number; + export var O_APPEND: number; + export var F_OK: number; + export var R_OK: number; + export var W_OK: number; + export var X_OK: number; + export var UV_UDP_REUSEADDR: number; + export var SIGQUIT: number; + export var SIGTRAP: number; + export var SIGIOT: number; + export var SIGBUS: number; + export var SIGUSR1: number; + export var SIGUSR2: number; + export var SIGPIPE: number; + export var SIGALRM: number; + export var SIGCHLD: number; + export var SIGSTKFLT: number; + export var SIGCONT: number; + export var SIGSTOP: number; + export var SIGTSTP: number; + export var SIGTTIN: number; + export var SIGTTOU: number; + export var SIGURG: number; + export var SIGXCPU: number; + export var SIGXFSZ: number; + export var SIGVTALRM: number; + export var SIGPROF: number; + export var SIGIO: number; + export var SIGPOLL: number; + export var SIGPWR: number; + export var SIGSYS: number; + export var SIGUNUSED: number; + export var defaultCoreCipherList: string; + export var defaultCipherList: string; + export var ENGINE_METHOD_RSA: number; + export var ALPN_ENABLED: number; } declare module "process" { - export = process; + export = process; +} + +declare module "v8" { + interface HeapSpaceInfo { + space_name: string; + space_size: number; + space_used_size: number; + space_available_size: number; + physical_space_size: number; + } + + const enum DoesZapCodeSpaceFlag { + Disabled = 0, + Enabled = 1 + } + + interface HeapInfo { + total_heap_size: number; + total_heap_size_executable: number; + total_physical_size: number; + total_available_size: number; + used_heap_size: number; + heap_size_limit: number; + malloced_memory: number; + peak_malloced_memory: number; + does_zap_garbage: DoesZapCodeSpaceFlag; + } + + export function getHeapStatistics(): HeapInfo; + export function getHeapSpaceStatistics(): HeapSpaceInfo[]; + export function setFlagsFromString(flags: string): void; } declare module "timers" { - export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; - export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate; - export function clearTimeout(timeoutId: NodeJS.Timer): void; - export function clearInterval(intervalId: NodeJS.Timer): void; - export function clearImmediate(immediateId: NodeJS.Immediate): void; + export function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function clearTimeout(timeoutId: NodeJS.Timer): void; + export function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; + export function clearInterval(intervalId: NodeJS.Timer): void; + export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; + export function clearImmediate(immediateId: any): void; +} + +declare module "console" { + export = console; +} + +/** + * _debugger module is not documented. + * Source code is at https://github.com/nodejs/node/blob/master/lib/_debugger.js + */ +declare module "_debugger" { + export interface Packet { + raw: string; + headers: string[]; + body: Message; + } + + export interface Message { + seq: number; + type: string; + } + + export interface RequestInfo { + command: string; + arguments: any; + } + + export interface Request extends Message, RequestInfo { + } + + export interface Event extends Message { + event: string; + body?: any; + } + + export interface Response extends Message { + request_seq: number; + success: boolean; + /** Contains error message if success === false. */ + message?: string; + /** Contains message body if success === true. */ + body?: any; + } + + export interface BreakpointMessageBody { + type: string; + target: number; + line: number; + } + + export class Protocol { + res: Packet; + state: string; + execute(data: string): void; + serialize(rq: Request): string; + onResponse: (pkt: Packet) => void; + } + + export var NO_FRAME: number; + export var port: number; + + export interface ScriptDesc { + name: string; + id: number; + isNative?: boolean; + handle?: number; + type: string; + lineOffset?: number; + columnOffset?: number; + lineCount?: number; + } + + export interface Breakpoint { + id: number; + scriptId: number; + script: ScriptDesc; + line: number; + condition?: string; + scriptReq?: string; + } + + export interface RequestHandler { + (err: boolean, body: Message, res: Packet): void; + request_seq?: number; + } + + export interface ResponseBodyHandler { + (err: boolean, body?: any): void; + request_seq?: number; + } + + export interface ExceptionInfo { + text: string; + } + + export interface BreakResponse { + script?: ScriptDesc; + exception?: ExceptionInfo; + sourceLine: number; + sourceLineText: string; + sourceColumn: number; + } + + export function SourceInfo(body: BreakResponse): string; + + export interface ClientInstance extends NodeJS.EventEmitter { + protocol: Protocol; + scripts: ScriptDesc[]; + handles: ScriptDesc[]; + breakpoints: Breakpoint[]; + currentSourceLine: number; + currentSourceColumn: number; + currentSourceLineText: string; + currentFrame: number; + currentScript: string; + + connect(port: number, host: string): void; + req(req: any, cb: RequestHandler): void; + reqFrameEval(code: string, frame: number, cb: RequestHandler): void; + mirrorObject(obj: any, depth: number, cb: ResponseBodyHandler): void; + setBreakpoint(rq: BreakpointMessageBody, cb: RequestHandler): void; + clearBreakpoint(rq: Request, cb: RequestHandler): void; + listbreakpoints(cb: RequestHandler): void; + reqSource(from: number, to: number, cb: RequestHandler): void; + reqScripts(cb: any): void; + reqContinue(cb: RequestHandler): void; + } + + export var Client : { + new (): ClientInstance + } } From 03e2e599c5c0781b383744d9b954f4a6b226ec35 Mon Sep 17 00:00:00 2001 From: Hinell Date: Sun, 8 Jan 2017 02:00:20 +0300 Subject: [PATCH 005/248] node/node-test.ts Console testing update, mongodb reconciliation with node api --- mongodb/index.d.ts | 12 ++++++------ node/node-tests.ts | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mongodb/index.d.ts b/mongodb/index.d.ts index 26d1656baf..f96c699a6f 100644 --- a/mongodb/index.d.ts +++ b/mongodb/index.d.ts @@ -1173,7 +1173,7 @@ export interface Cursor extends Readable { next(): Promise; next(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#pipe - pipe(destination: Writable, options?: Object): void; + pipe(destination: Writable, options?: Object): this; //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 @@ -1202,7 +1202,7 @@ export interface Cursor extends Readable { toArray(): Promise; toArray(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unpipe - unpipe(destination?: Writable): void; + unpipe(destination?: Writable): this; //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift unshift(stream: Buffer | string): void; } @@ -1261,7 +1261,7 @@ export interface AggregationCursor extends Readable { // 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#pipe - pipe(destination: Writable, options?: Object): void; + pipe(destination: Writable, options?: Object): this; //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 @@ -1280,7 +1280,7 @@ export interface AggregationCursor extends Readable { toArray(): Promise; toArray(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#unpipe - unpipe(destination?: Writable): void; + unpipe(destination?: Writable): this; //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 @@ -1306,7 +1306,7 @@ export interface CommandCursor extends Readable { next(): Promise; next(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#pipe - pipe(destination: Writable, options?: Object): void; + pipe(destination: Writable, options?: Object): this; //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 @@ -1319,7 +1319,7 @@ export interface CommandCursor extends Readable { toArray(): Promise; toArray(callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unpipe - unpipe(destination?: Writable): void; + unpipe(destination?: Writable): this; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift unshift(stream: Buffer | string): void; } diff --git a/node/node-tests.ts b/node/node-tests.ts index 706e8b37f6..e34a67a41e 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -1630,6 +1630,11 @@ namespace console_tests { var _c: Console = console; _c = c; } + { + var writeStream = fs.createWriteStream('./index.d.ts'); + var consoleInstance = new console.Console(writeStream) + + } } /////////////////////////////////////////////////// From 1e18f44d5c2f6d46c8ae5b9b6461d49fbdb254e9 Mon Sep 17 00:00:00 2001 From: Hinell Date: Sun, 8 Jan 2017 03:09:50 +0300 Subject: [PATCH 006/248] mongodb/ methods duplication removal --- mongodb/index.d.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/mongodb/index.d.ts b/mongodb/index.d.ts index f96c699a6f..58b3d7aa0c 100644 --- a/mongodb/index.d.ts +++ b/mongodb/index.d.ts @@ -1172,8 +1172,6 @@ export interface Cursor extends Readable { // 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#pipe - pipe(destination: Writable, options?: Object): this; //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 @@ -1184,8 +1182,6 @@ export interface Cursor extends Readable { 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#setEncoding - setEncoding(encoding: string): this; // 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 @@ -1201,8 +1197,6 @@ export interface Cursor extends Readable { // 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#unpipe - unpipe(destination?: Writable): this; //http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html#unshift unshift(stream: Buffer | string): void; } @@ -1260,8 +1254,6 @@ export interface AggregationCursor extends Readable { 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#pipe - pipe(destination: Writable, options?: Object): this; //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 @@ -1271,16 +1263,12 @@ export interface AggregationCursor extends Readable { //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 - setEncoding(encoding: string): this; - // http://mongodb.github.io/node-mongodb-native/2.1/api/AggregationCursor.html#skip 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#unpipe - unpipe(destination?: Writable): this; //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 @@ -1305,21 +1293,15 @@ export interface CommandCursor extends Readable { // 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#pipe - pipe(destination: Writable, options?: Object): this; //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#setEncoding - setEncoding(encoding: string): this; // 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#unpipe - unpipe(destination?: Writable): this; //http://mongodb.github.io/node-mongodb-native/2.1/api/CommandCursor.html#unshift unshift(stream: Buffer | string): void; } From b4fc6f27dc2bcf91c31d536539fe4f48becd18d1 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 05:24:31 +0100 Subject: [PATCH 007/248] Jest update --- jest/index.d.ts | 68 +++++++++++++++++++++++++++++++++++---- jest/jest-tests.ts | 79 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 140 insertions(+), 7 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index fda6c66404..6e3d5381a8 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Jest 16.0.0 +// Type definitions for Jest 18.0.0 // Project: http://facebook.github.io/jest/ -// Definitions by: Asana , Ivo Stratev , jwbay +// Definitions by: Asana , Ivo Stratev , jwbay , Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare var beforeAll: jest.Lifecycle; declare var beforeEach: jest.Lifecycle; @@ -16,7 +17,7 @@ declare var xit: jest.It; declare var test: jest.It; declare var xtest: jest.It; -declare function expect(actual: any): jest.Matchers; +declare const expect: jest.Expect; interface NodeRequire { /** Returns the actual module instead of a mock, bypassing all checks on whether the module should receive a mock implementation or not. */ @@ -31,8 +32,10 @@ declare namespace jest { function autoMockOff(): typeof jest; /** Enables automatic mocking in the module loader. */ function autoMockOn(): typeof jest; - /** Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function. */ + /** @deprecated */ function clearAllMocks(): typeof jest; + /** Clears the mock.calls and mock.instances properties of all mocks. Equivalent to calling .mockClear() on every mocked function. */ + function resetAllMocks(): typeof jest; /** Removes any pending timers from the timer system. If any timers have been scheduled, they will be cleared and will never have the opportunity to execute in the future. */ function clearAllTimers(): typeof jest; /** Indicates that the module system should never return a mocked version of the specified module, including all of the specificied module's dependencies. */ @@ -111,6 +114,41 @@ declare namespace jest { skip: Describe; } + interface MatcherUtils { + readonly isNot: boolean; + utils: { + readonly EXPECTED_COLOR: string; + readonly RECEIVED_COLOR: string; + ensureActualIsNumber(actual: any, matcherName?: string): void; + ensureExpectedIsNumber(actual: any, matcherName?: string): void; + ensureNoExpected(actual: any, matcherName?: string): void; + ensureNumbers(actual: any, expected: any, matcherName?: string): void; + /** get the type of a value with handling the edge cases like `typeof []` and `typeof null` */ + getType(value: any): string; + matcherHint(matcherName: string, received?: string, expected?: string, options?: { secondArgument?: string, isDirectExpectCall?: boolean }): string; + pluralize(word: string, count: number): string; + printExpected(value: any): string; + printReceived(value: any): string; + printWithType(name: string, received: any, print: (value: any) => string): string; + stringify(object: {}, maxDepth?: number): string; + } + } + + interface ExpectExtendMap { + [key: string]: (this: MatcherUtils, received: any, actual: any) => { message: () => string, pass: boolean }; + } + + interface Expect { + (actual: any): Matchers; + anything(): void; + any(cs: any): void; + arrayContaining(arr: any[]): void; + assertions(num: number): void; + extend(obj: ExpectExtendMap): void; + objectContaining(obj: {}): void; + stringMatching(str: string | RegExp): void; + } + interface Matchers { not: Matchers; lastCalledWith(...args: any[]): void; @@ -135,9 +173,11 @@ declare namespace jest { toHaveBeenCalledTimes(expected: number): boolean; toHaveBeenCalledWith(...params: any[]): boolean; toHaveBeenLastCalledWith(...params: any[]): boolean; + toHaveLength(expected: number): void; + toHaveProperty(propertyPath: string, value?: any): void; toMatch(expected: string | RegExp): void; toMatchObject(expected: {}): void; - toMatchSnapshot(): void; + toMatchSnapshot(snapshotName?: string): void; toThrow(): void; toThrowError(error?: string | Constructable | RegExp): void; toThrowErrorMatchingSnapshot(): void; @@ -147,9 +187,25 @@ declare namespace jest { new (...args: any[]): any } - interface Mock extends Function { + interface Mock extends Function, MockInstance { new (): T; (...args: any[]): any; + } + + /** + * Wrap module with mock definitions + * @example + * jest.mock("../api"); + * import { Api } from "../api"; + * + * const myApi: jest.Mocked = new Api() as any; + * myApi.myApiMethod.mockImplementation(() => "test"); + */ + type Mocked = T & { + [P in keyof T]: T[P] & MockInstance; + } & MockInstance; + + interface MockInstance { mock: MockContext; mockClear(): void; mockImplementation(fn: Function): Mock; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index 913a671fa1..e1f8fb120f 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -171,6 +171,60 @@ describe('toThrow API', function () { }); }); +describe('Assymetric matchers', function () { + it('works', function () { + expect({ + timestamp: 1480807810388, + text: 'Some text content, but we care only about *this part*' + }).toEqual({ + timestamp: expect.any(Number), + text: expect.stringMatching('*this part*') + }); + + const callback = jest.fn(); + expect(callback).toEqual(expect.any(Function)); + callback(5, "test"); + expect(callback).toBeCalledWith(expect.any(Number), expect.any(String)) + const obj = { + items: [1] + }; + expect(obj).toEqual(expect.objectContaining({ + items: expect.arrayContaining([ + expect.any(Number) + ]) + })); + + expect.assertions(4); + }); +}); + +describe('Extending extend', function () { + it('works', function () { + expect.extend({ + toBeNumber(received: any, actual: any) { + const pass = received === actual; + const message = + () => `expected ${received} ${pass ? 'not ' : ''} to be ${actual}`; + return { message, pass }; + }, + toBeTest(received: any, actual: any) { + this.utils.ensureNoExpected(received); + this.utils.ensureActualIsNumber(received); + this.utils.ensureExpectedIsNumber(actual); + this.utils.ensureNumbers(received, actual); + + return { + message: () => ` + ${this.utils.getType(received).toLowerCase()} \n\n + ${this.utils.matcherHint(".not.toBe")} ${this.utils.printExpected(actual)} ${this.utils.printReceived(received)}\n\n + `, + pass: true + }; + } + }); + }); +}); + describe('missing tests', function () { it('creates closures', function () { class Closure { @@ -208,7 +262,7 @@ describe('missing tests', function () { expect(getFruits()).toContain('Orange'); mock.mockReturnValueOnce(['Apple', 'Plum']); expect(mock()).not.toContain('Orange'); - const myBeverage: any = {delicious: true, sour: false}; + const myBeverage: any = {delicious: true, sour: false}; expect(myBeverage).toContainEqual({delicious: true, sour: false}); mock.mockReturnValue([]); //Deprecated: Use jest.fn(() => value) instead. mock.mockClear(); @@ -248,6 +302,10 @@ describe('toMatchSnapshot', function () { it('compares snapshots', function () { expect({ type: 'a', props: { href: 'https://www.facebook.com/' }, children: [ 'Facebook' ] }).toMatchSnapshot(); }); + + it('can give name to snapshot', function () { + expect({ type: 'a', props: { href: 'https://www.facebook.com/' }, children: [ 'Facebook' ] }).toMatchSnapshot('given name'); + }); }); describe('toThrowErrorMatchingSnapshot', function () { @@ -367,3 +425,22 @@ describe('strictNullChecks', function () { done(); }) }); + +interface TestApi { + testProp: boolean; + testMethod(a: number): void; +} + +describe("Mocked type", function () { + it("Works", function () { + const mock: jest.Mocked = jest.fn(() => ({ + testProp: true, + testMethod1: jest.fn(), + testMethod2: jest.fn() + })) as any; + mock.testProp; + mock.testMethod.mockImplementation(() => "test"); + mock.testMethod(5); + mock.mockClear(); + }); +}); From f2581e2b98d07073207ab3e5685dc44c5435ca32 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 06:59:08 +0100 Subject: [PATCH 008/248] Added one more example for jest.Mocked --- jest/index.d.ts | 5 +++++ jest/jest-tests.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/jest/index.d.ts b/jest/index.d.ts index 6e3d5381a8..2f246f2bfe 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -200,6 +200,11 @@ declare namespace jest { * * const myApi: jest.Mocked = new Api() as any; * myApi.myApiMethod.mockImplementation(() => "test"); + * + * jest.mock("./func"); + * const myFuncMock: jest.Mocked = require("./func"); + * myFuncMock.mockImplementation(() => 5); + * myFuncMock(); */ type Mocked = T & { [P in keyof T]: T[P] & MockInstance; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index e1f8fb120f..f2866d1689 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -431,6 +431,8 @@ interface TestApi { testMethod(a: number): void; } +declare function mockedFunc(a: number): string; + describe("Mocked type", function () { it("Works", function () { const mock: jest.Mocked = jest.fn(() => ({ @@ -442,5 +444,9 @@ describe("Mocked type", function () { mock.testMethod.mockImplementation(() => "test"); mock.testMethod(5); mock.mockClear(); + + const funcMock: jest.Mocked = require("./mockedFunc"); + funcMock.mockImplementation(() => "test"); + funcMock(5).toUpperCase(); }); }); From a0a9fe2efe4aa8a9c6ad765d6ccc471341964332 Mon Sep 17 00:00:00 2001 From: Rafael Salguero Iturrios Date: Sun, 8 Jan 2017 23:08:31 -0700 Subject: [PATCH 009/248] Update index.d.ts --- rx-lite/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rx-lite/index.d.ts b/rx-lite/index.d.ts index fb5056c478..7e085031aa 100644 --- a/rx-lite/index.d.ts +++ b/rx-lite/index.d.ts @@ -232,7 +232,7 @@ declare namespace Rx { withLatestFrom(souces: (Observable | IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; concat(...sources: (Observable | IPromise)[]): Observable; concat(sources: (Observable | IPromise)[]): Observable; - concatAll(): Observable; + concatAll(): T; concatObservable(): Observable; // alias for concatAll concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat From 3e757ce66287de54c45ecb30945c869ce7ad9809 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Mon, 9 Jan 2017 20:26:28 +0100 Subject: [PATCH 010/248] Infer type for jest.fn() for subtypes of object --- jest/index.d.ts | 1 + jest/jest-tests.ts | 43 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index 2f246f2bfe..e81a08c1ca 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -49,6 +49,7 @@ declare namespace jest { /** Enables automatic mocking in the module loader. */ function enableAutomock(): typeof jest; /** Creates a mock function. Optionally takes a mock implementation. */ + function fn(implementation: (...args: any[]) => T): Mock; function fn(implementation?: Function): Mock; /** Use the automatic mocking system to generate a mocked version of the given module. */ function genMockFromModule(moduleName: string): T; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index f2866d1689..c42df8fef4 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -433,20 +433,53 @@ interface TestApi { declare function mockedFunc(a: number): string; -describe("Mocked type", function () { - it("Works", function () { +describe('Mocked type', function () { + it('Works', function () { const mock: jest.Mocked = jest.fn(() => ({ testProp: true, testMethod1: jest.fn(), testMethod2: jest.fn() })) as any; mock.testProp; - mock.testMethod.mockImplementation(() => "test"); + mock.testMethod.mockImplementation(() => 'test'); mock.testMethod(5); mock.mockClear(); - const funcMock: jest.Mocked = require("./mockedFunc"); - funcMock.mockImplementation(() => "test"); + const funcMock: jest.Mocked = require('./mockedFunc'); + funcMock.mockImplementation(() => 'test'); funcMock(5).toUpperCase(); }); }); + +describe('Mocks', function () { + it('jest.fn() without args is a function type', function () { + const test = jest.fn(); + test(); + new test(); + test.mock.instances[0]; + test.mockImplementation(() => { }); + }); + + it('jest.fn() with returned object infers type', function () { + const testMock = jest.fn(() => ({ a: 5, test: jest.fn() })); + + testMock(5, 5, 'a'); + testMock.mockImplementation(() => { }); + testMock.caller; + + const ins = new testMock(); + ins.a; + ins.test(); + ins.test.mockImplementation(() => 5); + ins.test.mock.calls; + + const anotherMock = jest.fn(() => { + const api: Partial = { + testMethod: jest.fn() + }; + return api; + }); + const anotherIns: jest.Mocked = new anotherMock() as any; + anotherIns.testMethod.mockImplementation(() => 1); + }); +}); From 654c2b4e117145df33183ebb67a9f9938e2937e6 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 11 Jan 2017 06:36:08 +0100 Subject: [PATCH 011/248] Fix Mocked type --- jest/index.d.ts | 7 +------ jest/jest-tests.ts | 18 +++++------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index e81a08c1ca..020376004b 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -201,15 +201,10 @@ declare namespace jest { * * const myApi: jest.Mocked = new Api() as any; * myApi.myApiMethod.mockImplementation(() => "test"); - * - * jest.mock("./func"); - * const myFuncMock: jest.Mocked = require("./func"); - * myFuncMock.mockImplementation(() => 5); - * myFuncMock(); */ type Mocked = T & { [P in keyof T]: T[P] & MockInstance; - } & MockInstance; + }; interface MockInstance { mock: MockContext; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index c42df8fef4..d2fcd6d007 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -426,28 +426,20 @@ describe('strictNullChecks', function () { }) }); -interface TestApi { +class TestApi { + constructor() { }; testProp: boolean; - testMethod(a: number): void; + testMethod(a: number): string { return ""; } } declare function mockedFunc(a: number): string; describe('Mocked type', function () { it('Works', function () { - const mock: jest.Mocked = jest.fn(() => ({ - testProp: true, - testMethod1: jest.fn(), - testMethod2: jest.fn() - })) as any; + const mock: jest.Mocked = new TestApi() as any; mock.testProp; mock.testMethod.mockImplementation(() => 'test'); - mock.testMethod(5); - mock.mockClear(); - - const funcMock: jest.Mocked = require('./mockedFunc'); - funcMock.mockImplementation(() => 'test'); - funcMock(5).toUpperCase(); + mock.testMethod(5).toUpperCase(); }); }); From 1c1fc8eea20aafce4605999732c282380d8cc1d9 Mon Sep 17 00:00:00 2001 From: Hinell Date: Thu, 12 Jan 2017 02:00:56 +0300 Subject: [PATCH 012/248] [Archiver] reconciliation with [node] --- archiver/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/archiver/index.d.ts b/archiver/index.d.ts index ea117239ac..665624143e 100644 --- a/archiver/index.d.ts +++ b/archiver/index.d.ts @@ -31,7 +31,6 @@ declare namespace archiver { } export interface Archiver extends STREAM.Transform { - pipe(writeStream: FS.WriteStream): void; append(source: STREAM.Readable | Buffer | string, name: nameInterface): void; directory(dirpath: string, destpath: nameInterface | string): void; From b29bba797511449ee8f6bbd8fac2cdda56d0caef Mon Sep 17 00:00:00 2001 From: Hinell Date: Thu, 12 Jan 2017 02:44:29 +0300 Subject: [PATCH 013/248] [node] Rolled back node stream.readable.pipe() method according to official API Read here: https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L612 --- node/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index ea1c42aad9..606276e9a6 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -285,7 +285,7 @@ declare namespace NodeJS { pause(): this; resume(): this; isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): this; + pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): this; unshift(chunk: string): void; unshift(chunk: Buffer): void; @@ -3341,7 +3341,7 @@ declare module "stream" { pause(): this; resume(): this; isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): this; + pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): this; unshift(chunk: any): void; wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; @@ -3531,7 +3531,7 @@ declare module "stream" { pause(): this; resume(): this; isPaused(): boolean; - pipe(destination: T, options?: { end?: boolean; }): this; + pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): this; unshift(chunk: any): void; wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; From 99a7b5915bc1dad725ef9759a68ba05b7633e798 Mon Sep 17 00:00:00 2001 From: Hinell Date: Thu, 12 Jan 2017 02:55:06 +0300 Subject: [PATCH 014/248] [bufferstream] reconciliation with [node] --- bufferstream/index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bufferstream/index.d.ts b/bufferstream/index.d.ts index 69a16d98e0..9b2b15d525 100644 --- a/bufferstream/index.d.ts +++ b/bufferstream/index.d.ts @@ -109,10 +109,6 @@ declare module 'bufferstream/postbuffer' { set a callback to get all post data from a http server request */ onEnd(callback: (data: any) => void): void; - /* - pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe - */ - pipe(stream: NodeJS.WritableStream, options?: BufferStream.Opts): NodeJS.ReadableStream; } export = PostBuffer; From 6de3e0630cd2bf63fd4b01b4d5d97931c3715ebf Mon Sep 17 00:00:00 2001 From: Luca Vazzano Date: Fri, 13 Jan 2017 00:23:25 +0100 Subject: [PATCH 015/248] updated Definitions for Raven-JS --- raven-js/index.d.ts | 393 +++++++++++++++++++++++++++++--------------- 1 file changed, 256 insertions(+), 137 deletions(-) diff --git a/raven-js/index.d.ts b/raven-js/index.d.ts index 6ecb6a0cdd..fda465c30d 100644 --- a/raven-js/index.d.ts +++ b/raven-js/index.d.ts @@ -1,209 +1,302 @@ // Type definitions for Raven.js // Project: https://github.com/getsentry/raven-js -// Definitions by: Santi Albo , Benjamin Pannell , Gary Blackwood , Rich Rout -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Original Definitions by: Santi Albo , Benjamin Pannell +// ; DefinitelyTyped +// Updated by: Ben Vinegar , Ilya Pirogov +// , Eli White , David Cramer +// , Connor Peet , comaz +// , Luca Vazzano + declare var Raven: RavenStatic; - -declare module 'raven-js' { - export default Raven; -} - -interface RavenOptions { - /** The name of the logger used by Sentry. Default: javascript */ - logger?: string; - - /** The release version of the application you are monitoring with Sentry */ - release?: string; - - /** The environment in which the application is running. */ - environment?: string; - - /** The name of the server or device that the client is running on */ - serverName?: string; - - /** List of messages to be fitlered out before being sent to Sentry. */ - ignoreErrors?: string[]; - - /** Similar to ignoreErrors, but will ignore errors from whole urls patching a regex pattern. */ - ignoreUrls?: RegExp[]; - - /** The inverse of ignoreUrls. Only report errors from whole urls matching a regex pattern. */ - whitelistUrls?: RegExp[]; - - /** An array of regex patterns to indicate which urls are a part of your app. */ - includePaths?: RegExp[]; - - /** Additional data to be tagged onto the error. */ - tags?: { - [id: string]: string; - }; - - /** A function which allows mutation of the data payload right before being sent to Sentry */ - dataCallback?: (data: any) => any; - - /** A callback function that allows you to apply your own filters to determine if the message should be sent to Sentry. */ - shouldSendCallback?: (data: any) => boolean; - - /** By default, Raven does not truncate messages. If you need to truncate characters for whatever reason, you may set this to limit the length. */ - maxMessageLength?: number; - - /** Enables/disables automatic collection of breadcrumbs. Default: true. */ - autoBreadcrumbs?: any; - - /** The max number of breadcrumb captures. Default: 100. */ - maxBreadcrumbs?: number; - - /** Override the default HTTP data transport handler. */ - transport?: (options: RavenTransportOptions) => void; - - /** Allow the use of a Sentry DSN with a private key. Default: false. */ - allowSecretKey?: boolean; -} - -interface RavenAdditionalData { - /** The name of the logger used by Sentry. Default: javascript */ - logger?: string; - - /** The log level associated with this event. Default: error */ - level?: string; - - /** Additional data to be tagged onto the error. */ - tags?: { - [id: string]: string; - }; - - extra?: any; -} +export = Raven; interface RavenStatic { - /** Raven.js version. */ VERSION: string; + /** A list of currently active plugins. */ Plugins: { [id: string]: RavenPlugin }; - /* - * Allow Raven to be configured as soon as it is loaded + /** + * Allow Raven to be configured as soon as it is loaded. * It uses a global RavenConfig = {dsn: '...', config: {}} - * - * @return undefined */ afterLoad(): void; - /* + /** * Allow multiple versions of Raven to be installed. * Strip Raven from the global context and returns the instance. - * - * @return {Raven} */ noConflict(): RavenStatic; - /* + /** * Configure Raven with a DSN and extra options * - * @param {string} dsn The public Sentry DSN - * @param {object} options Optional set of of global options [optional] - * @return {Raven} + * @param dsn The public Sentry DSN + * @param options Optional set of of global options */ - config(dsn: string, options?: RavenOptions): RavenStatic; + config(dsn: string, options?: RavenGlobalOptions): RavenStatic; - /* - * Installs a global window.onerror error handler - * to capture and report uncaught exceptions. - * At this point, install() is required to be called due - * to the way TraceKit is set up. + /** + * Set the DSN (can be called multiple times, unlike config) * - * @return {Raven} + * @param dsn The public Sentry DSN + */ + setDSN(dsn: string); + + /** + * Installs a global window.onerror error handler to capture and report uncaught exceptions. + * At this point, install() is required to be called due to the way TraceKit is set up. */ install(): RavenStatic; - /* + /** * Adds a plugin to Raven - * - * @return {Raven} */ addPlugin(plugin: RavenPlugin, ...pluginArgs: any[]): RavenStatic; - /* - * Wrap code within a context so Raven can capture errors - * reliably across domains that is executed immediately. + /** + * Wrap code within a context so Raven can capture errors reliably across domains that is + * executed immediately. * - * @param {object} options A specific set of options for this context [optional] - * @param {function} func The callback to be immediately executed within the context - * @param {array} args An array of arguments to be called with the callback [optional] + * @param options A specific set of options for this context + * @param func The callback to be immediately executed within the context + * @param args An array of arguments to be called with the callback */ context(func: Function, ...args: any[]): void; - context(options: RavenAdditionalData, func: Function, ...args: any[]): void; + context(options: RavenWrapOptions, func: Function, ...args: any[]): void; - /* + /** * Wrap code within a context and returns back a new function to be executed * - * @param {object} options A specific set of options for this context [optional] - * @param {function} func The function to be wrapped in a new context - * @return {function} The newly wrapped functions with a context + * @param options A specific set of options for this context + * @param func The function to be wrapped in a new context + * @return The newly wrapped functions with a context */ wrap(func: Function): Function; - wrap(options: RavenAdditionalData, func: Function): Function; + wrap(options: RavenWrapOptions, func: Function): Function; wrap(func: T): T; - wrap(options: RavenAdditionalData, func: T): T; + wrap(options: RavenWrapOptions, func: T): T; - /* + /** * Uninstalls the global error handler. - * - * @return {Raven} */ uninstall(): RavenStatic; - /* + /** * Manually capture an exception and send it over to Sentry * - * @param {error} ex An exception to be logged - * @param {object} options A specific set of options for this error [optional] - * @return {Raven} + * @param ex An exception to be logged + * @param options A specific set of options for this error */ - captureException(ex: Error, options?: RavenAdditionalData): RavenStatic; + captureException(ex: Error, options?: RavenOptions): RavenStatic; /* * Manually send a message to Sentry * - * @param {string} msg A plain message to be captured in Sentry - * @param {object} options A specific set of options for this message [optional] - * @return {Raven} + * @param msg A plain message to be captured in Sentry + * @param options A specific set of options for this message */ - captureMessage(msg: string, options?: RavenAdditionalData): RavenStatic; + captureMessage(msg: string, options?: RavenOptions): RavenStatic; + + /** + * Add a breadcrumb + * @param crumb The trail which should be added to the trail + */ + captureBreadcrumb(crumb: RavenBreadcrumb): RavenStatic; + + /** + * Set a user to be sent along with payloads. + * + * @param user The definition of the currently active user's unique identity + */ + setUserContext(user: RavenUserContext): RavenStatic; /** * Clear the user context, removing the user data that would be sent to Sentry. */ setUserContext(): RavenStatic; - /* - * Set a user to be sent along with the payload. - * - * @param {object} user An object representing user data [optional] - * @return {Raven} + /** + * Add arbitrary data to be sent along with the payload. + * @param extra data of an arbitrary, nested type which will be added */ - setUserContext(user: { - id?: string; - username?: string; - email?: string; - }): RavenStatic; + setExtraContext(extra: { [prop: string]: any }): RavenStatic; - /** Override the default HTTP data transport handler. */ - setTransport(transportFunction: (options: RavenTransportOptions) => void): RavenStatic; + /** + * Add additional tags to be sent along with payloads. + * @param tags A key/value-pair which will be added + */ + setTagsContext(tags: { [id: string]: string }): RavenStatic; - /** An event id is a globally unique id for the event that was just sent. This event id can be used to find the exact event from within Sentry. */ + /** + * Clear the whole currently set context. + */ + clearContext(): RavenStatic; + + /** + * Get a copy of the current context. + */ + getContext(): Object; + + /** + * Set environment of application + * @param environment Typically something like 'production' + */ + setEnvironment(environment: string): RavenStatic; + + /** + * Set release version of application + * @param release Typically something like a git SHA to identify the current version + */ + setRelease(release: string): RavenStatic; + + /** + * Specify a function that can mutate the payload right before it is being sent to Sentry. + * @param callback The function which can mutate the data + */ + setDataCallback(callback: (data: any, orig?: string) => any): RavenStatic; + + /** + * Specify a callback function that can mutate or filter breadcrumbs when they are captured. + * @param callback The function which applies the filter + */ + setBreadcrumbCallback(callback :(data: any, orig?: string) => any): RavenStatic; + + /** + * Specify a callback function that determines if the given message should be sent to Sentry. + * @param callback The function which determines if the given blob should be sent + */ + setShouldSendCallback(callback: (data: any, orig?: string) => boolean): RavenStatic; + + /** + * Override the default HTTP data transport handler. + * @param transport The function which will be invoked to handle the data transmission + */ + setTransport(transport: (options: RavenTransportOptions) => void): RavenStatic; + + /** + * Get the latest raw exception that was captured by Raven. + */ + lastException(): Error; + + /** + * Get the ID of the last Event captured by Raven. + */ lastEventId(): string; - /** If you need to conditionally check if raven needs to be initialized or not, you can use the isSetup function. It will return true if Raven is already initialized. */ + /** + * Determine if Raven is setup and ready to go. + */ isSetup(): boolean; - showReportDialog(options: RavenOptions): void; + /** + * Show the User Feedback Dialog of Sentry + * @param RavenReportDialogOptions Optional Options to set for the User Feedback + */ + showReportDialog(options?: RavenReportDialogOptions): void; +} - setTagsContext(tags: { [id: string]: string; }): void; - setExtraContext(context: any): void; +// --- Helper Interfaces for Options -------------- +interface RavenBreadcrumOptions { + /** Whether to collect XHR calls, defaults to true */ + xhr?: boolean; + + /** Whether to collect console logs, defaults to true */ + console?: boolean; + + /** Whether to collect dom events, defaults to true */ + dom?: boolean; + + /** Whether to record window location and navigation, defaults to true */ + location?: boolean; +} + +interface CommonRavenOptions { + /** The environment of the application you are monitoring with Sentry */ + environment?: string; + + /** The release version of the application you are monitoring with Sentry */ + release?: string; + + /** Additional key/value-data to be tagged onto the error. */ + tags?: { [id: string]: string }; + + /** Additional, arbitrary metadata to collect */ + extra?: { [prop: string]: any }; + + /** The name of the logger used by Sentry. Default: javascript */ + logger?: string; + + /** set to true to get the strack trace of your message */ + stacktrace?: boolean; +} + +interface RavenOptions extends CommonRavenOptions { + /** The name of the server or device that the client is running on */ + server_name?: string; + + /** The log level associated with this event. Default: error */ + level?: string; + + /** In some cases you may see issues where Sentry groups multiple events together when they + * should be separate entities. In other cases, Sentry simply doesn’t group events together + * because they’re so sporadic that they never look the same. */ + fingerprint?: string[]; + + /** Number of frames to trim off the stacktrace. Default: 1 */ + trimHeadFrames?: number; + + /** The name of the device platform. Default: "javascript" */ + platform?: string; +} + +interface RavenGlobalOptions extends CommonRavenOptions { + /** The name of the server or device that the client is running on */ + serverName?: string; + + /** Configures which breadcrumbs are collected automatically */ + autoBreadcrumbs?: boolean | RavenBreadcrumOptions; + + /** Whether to collect errors on the window via TraceKit.collectWindowErrors. Default: true. */ + collectWindowErrors?: boolean; + + /** Max number of breadcrumbs to collect. Default: 100 */ + maxBreadcrumbs?: number; + + /** Exclude messages which match one of the given RegEx-Patterns from being sent to Sentry. */ + ignoreErrors?: (RegExp | string)[]; + + /** Exclude messages which come from whole urls matching one of the given RegEx patterns. */ + ignoreUrls?: (RegExp | string)[]; + + /** Only report messages which come from whole urls matching one of the given RegEx patterns. */ + whitelistUrls?: (RegExp | string)[]; + + /** An array of RegEx patterns to indicate which urls are a part of your app. */ + includePaths?: (RegExp | string)[]; + + /** Maximum amount of stack frames to collect. Default: Infinity */ + stackTraceLimit?: number; + + /** Override the default HTTP data transport handler. */ + transport?: (options: RavenTransportOptions) => void; + + /** Limit the maxium length of a message to this number of characters. Default: Infinity */ + maxMessageLength?: number; + + /** Allows you to apply your own filters to determine if the message should be sent to Sentry. */ + shouldSendCallback?: (data: any) => boolean; + + /** A function which allows mutation of the data payload right before being sent to Sentry */ + dataCallback?: (data: any) => any; +} + +interface RavenWrapOptions extends RavenOptions { + /** Whether to run the wrap recursively. Default: false. */ + deep?: boolean; } interface RavenTransportOptions { @@ -218,6 +311,32 @@ interface RavenTransportOptions { onFailure: () => void; } +interface RavenReportDialogOptions { + eventId?: number, + dsn?: string, + user?: { + name?: string, + email?: string + } +} + + +// --- Helper Interfaces for complex Data Structures -------------- interface RavenPlugin { (raven: RavenStatic, ...args: any[]): RavenStatic; } + +interface RavenUserContext { + id?: string; + username?: string; + email?: string; + ip_address?: string; + extra?: { [prop: string]: any }; +} + +interface RavenBreadcrumb { + message: string; + data: { [id: string]: string }; + category: string; + level: string; +} From 861c2abc61efdc93cebc5387233e226dead003e3 Mon Sep 17 00:00:00 2001 From: Luca Vazzano Date: Fri, 13 Jan 2017 00:46:01 +0100 Subject: [PATCH 016/248] fixed tests --- raven-js/index.d.ts | 28 ++++++++-------- raven-js/raven-js-tests.ts | 67 +++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/raven-js/index.d.ts b/raven-js/index.d.ts index fda465c30d..ddb5e8503d 100644 --- a/raven-js/index.d.ts +++ b/raven-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Raven.js +// Type definitions for Raven.js // Project: https://github.com/getsentry/raven-js // Original Definitions by: Santi Albo , Benjamin Pannell // ; DefinitelyTyped @@ -8,8 +8,8 @@ // , Luca Vazzano -declare var Raven: RavenStatic; -export = Raven; +declare let Raven: RavenStatic; +export default Raven; interface RavenStatic { /** Raven.js version. */ @@ -43,7 +43,7 @@ interface RavenStatic { * * @param dsn The public Sentry DSN */ - setDSN(dsn: string); + setDSN(dsn: string): RavenStatic; /** * Installs a global window.onerror error handler to capture and report uncaught exceptions. @@ -200,7 +200,7 @@ interface RavenStatic { // --- Helper Interfaces for Options -------------- -interface RavenBreadcrumOptions { +export interface RavenBreadcrumOptions { /** Whether to collect XHR calls, defaults to true */ xhr?: boolean; @@ -214,7 +214,7 @@ interface RavenBreadcrumOptions { location?: boolean; } -interface CommonRavenOptions { +export interface CommonRavenOptions { /** The environment of the application you are monitoring with Sentry */ environment?: string; @@ -234,7 +234,7 @@ interface CommonRavenOptions { stacktrace?: boolean; } -interface RavenOptions extends CommonRavenOptions { +export interface RavenOptions extends CommonRavenOptions { /** The name of the server or device that the client is running on */ server_name?: string; @@ -253,7 +253,7 @@ interface RavenOptions extends CommonRavenOptions { platform?: string; } -interface RavenGlobalOptions extends CommonRavenOptions { +export interface RavenGlobalOptions extends CommonRavenOptions { /** The name of the server or device that the client is running on */ serverName?: string; @@ -294,12 +294,12 @@ interface RavenGlobalOptions extends CommonRavenOptions { dataCallback?: (data: any) => any; } -interface RavenWrapOptions extends RavenOptions { +export interface RavenWrapOptions extends RavenOptions { /** Whether to run the wrap recursively. Default: false. */ deep?: boolean; } -interface RavenTransportOptions { +export interface RavenTransportOptions { url: string; data: any; auth: { @@ -311,7 +311,7 @@ interface RavenTransportOptions { onFailure: () => void; } -interface RavenReportDialogOptions { +export interface RavenReportDialogOptions { eventId?: number, dsn?: string, user?: { @@ -322,11 +322,11 @@ interface RavenReportDialogOptions { // --- Helper Interfaces for complex Data Structures -------------- -interface RavenPlugin { +export interface RavenPlugin { (raven: RavenStatic, ...args: any[]): RavenStatic; } -interface RavenUserContext { +export interface RavenUserContext { id?: string; username?: string; email?: string; @@ -334,7 +334,7 @@ interface RavenUserContext { extra?: { [prop: string]: any }; } -interface RavenBreadcrumb { +export interface RavenBreadcrumb { message: string; data: { [id: string]: string }; category: string; diff --git a/raven-js/raven-js-tests.ts b/raven-js/raven-js-tests.ts index 9608e41322..bbd3285e1e 100644 --- a/raven-js/raven-js-tests.ts +++ b/raven-js/raven-js-tests.ts @@ -1,24 +1,24 @@ - - import RavenJS from 'raven-js'; RavenJS.config('https://public@getsentry.com/1').install(); -var options: RavenOptions = { - logger: 'my-logger', - ignoreUrls: [ - /graph\.facebook\.com/i - ], - ignoreErrors: [ - 'fb_xd_fragment' - ], - includePaths: [ - /https?:\/\/(www\.)?getsentry\.com/, - /https?:\/\/d3nslu0hdya83q\.cloudfront\.net/ - ] -}; -Raven.config('https://public@getsentry.com/1', options).install(); +RavenJS.config( + 'https://public@getsentry.com/1', + { + logger: 'my-logger', + ignoreUrls: [ + /graph\.facebook\.com/i + ], + ignoreErrors: [ + 'fb_xd_fragment' + ], + includePaths: [ + /https?:\/\/(www\.)?getsentry\.com/, + /https?:\/\/d3nslu0hdya83q\.cloudfront\.net/ + ] + } +).install(); var throwsError = () => { throw new Error('broken'); @@ -27,28 +27,35 @@ var throwsError = () => { try { throwsError(); } catch(e) { - Raven.captureException(e); - Raven.captureException(e, {tags: { key: "value" }}); + RavenJS.captureException(e); + RavenJS.captureException(e, {tags: { key: "value" }}); } -Raven.context(throwsError); -Raven.context({tags: { key: "value" }}, throwsError); -Raven.context({extra: {planet: {name: 'Earth'}}}, throwsError); +RavenJS.context(throwsError); +RavenJS.context({tags: { key: "value" }}, throwsError); +RavenJS.context({extra: {planet: {name: 'Earth'}}}, throwsError); -setTimeout(Raven.wrap(throwsError), 1000); -Raven.wrap({logger: "my.module"}, throwsError)(); -Raven.wrap({tags: {git_commit: 'c0deb10c4'}}, throwsError)(); +setTimeout(RavenJS.wrap(throwsError), 1000); +RavenJS.wrap({logger: "my.module"}, throwsError)(); +RavenJS.wrap({tags: {git_commit: 'c0deb10c4'}}, throwsError)(); -Raven.setUserContext({ +RavenJS.setUserContext({ email: 'matt@example.com', id: '123' }); -Raven.captureMessage('Broken!'); -Raven.captureMessage('Broken!', {tags: { key: "value" }}); +RavenJS.captureMessage('Broken!'); +RavenJS.captureMessage('Broken!', {tags: { key: "value" }}); -Raven.showReportDialog(options); +RavenJS.showReportDialog({ + eventId: 0815, + dsn:'1337asdf', + user: { + name: 'DefenitelyTyped', + email: 'df@ts.ms' + } +}); -Raven.setTagsContext({ key: "value" }); +RavenJS.setTagsContext({ key: "value" }); -Raven.setExtraContext({ foo: "bar" }); +RavenJS.setExtraContext({ foo: "bar" }); From 9ef1ed01256fc403e35fb4cb756310d3df2e658c Mon Sep 17 00:00:00 2001 From: Luca Vazzano Date: Fri, 13 Jan 2017 00:54:16 +0100 Subject: [PATCH 017/248] fixed BOM --- raven-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raven-js/index.d.ts b/raven-js/index.d.ts index ddb5e8503d..b264b9d786 100644 --- a/raven-js/index.d.ts +++ b/raven-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Raven.js +// Type definitions for Raven.js // Project: https://github.com/getsentry/raven-js // Original Definitions by: Santi Albo , Benjamin Pannell // ; DefinitelyTyped From e1bd300cd1d205dbcf4709c0f3d25d2413123cd6 Mon Sep 17 00:00:00 2001 From: Luca Vazzano Date: Fri, 13 Jan 2017 01:20:04 +0100 Subject: [PATCH 018/248] fixed 'Definitions:'/'Definitions by:' comment at the top of raven-js/index.d.ts --- raven-js/index.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/raven-js/index.d.ts b/raven-js/index.d.ts index b264b9d786..7b54ec7372 100644 --- a/raven-js/index.d.ts +++ b/raven-js/index.d.ts @@ -1,11 +1,7 @@ // Type definitions for Raven.js // Project: https://github.com/getsentry/raven-js -// Original Definitions by: Santi Albo , Benjamin Pannell -// ; DefinitelyTyped -// Updated by: Ben Vinegar , Ilya Pirogov -// , Eli White , David Cramer -// , Connor Peet , comaz -// , Luca Vazzano +// Definitions by: Santi Albo , Benjamin Pannell , Gary Blackwood , Rich Rout , Ben Vinegar , Ilya Pirogov , Eli White , David Cramer , Connor Peet , comaz , Luca Vazzano +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare let Raven: RavenStatic; From 004db1e2c6dd5795264b2e98e67f0a579f44d42d Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Fri, 13 Jan 2017 05:09:16 +0100 Subject: [PATCH 019/248] Added mockReset() --- jest/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jest/index.d.ts b/jest/index.d.ts index 020376004b..acfe70a0f6 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -209,6 +209,7 @@ declare namespace jest { interface MockInstance { mock: MockContext; mockClear(): void; + mockReset(): void; mockImplementation(fn: Function): Mock; mockImplementationOnce(fn: Function): Mock; mockReturnThis(): Mock; From 771ef63514fb41176875407fb93a540c162e9e33 Mon Sep 17 00:00:00 2001 From: scippio Date: Sat, 14 Jan 2017 00:31:01 +0100 Subject: [PATCH 020/248] added new option parameter added new option parameter for new package version compatibility --- cron/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cron/index.d.ts b/cron/index.d.ts index e962a9eb27..79a5b96a01 100644 --- a/cron/index.d.ts +++ b/cron/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cron 1.0.9 +// Type definitions for cron 1.2.1 // Project: https://www.npmjs.com/package/cron // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,9 +6,9 @@ interface CronJobStatic { - new (cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any): CronJob; + new (cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean): CronJob; new (options: { - cronTime: string | Date; onTick: () => void; onComplete?: () => void; start?: boolean; timeZone?: string; context?: any + cronTime: string | Date; onTick: () => void; onComplete?: () => void; start?: boolean; timeZone?: string; context?: any; runOnInit?: boolean }): CronJob; } interface CronJob { From ee373b10745c1324ebc30d6c302ccc10cc6d6786 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:13:18 +0100 Subject: [PATCH 021/248] Add definitions for shipit, shipit-utils and express-rate-limit. --- .../express-rate-limit-tests.ts | 25 ++++++++ express-rate-limit/index.d.ts | 37 +++++++++++ express-rate-limit/tsconfig.json | 20 ++++++ shipit-utils/index.d.ts | 22 +++++++ shipit-utils/shipit-utils-tests.ts | 11 ++++ shipit-utils/tsconfig.json | 20 ++++++ shipit/index.d.ts | 61 +++++++++++++++++++ shipit/shipit-cli-tests.ts | 50 +++++++++++++++ shipit/tsconfig.json | 20 ++++++ 9 files changed, 266 insertions(+) create mode 100644 express-rate-limit/express-rate-limit-tests.ts create mode 100644 express-rate-limit/index.d.ts create mode 100644 express-rate-limit/tsconfig.json create mode 100644 shipit-utils/index.d.ts create mode 100644 shipit-utils/shipit-utils-tests.ts create mode 100644 shipit-utils/tsconfig.json create mode 100644 shipit/index.d.ts create mode 100644 shipit/shipit-cli-tests.ts create mode 100644 shipit/tsconfig.json diff --git a/express-rate-limit/express-rate-limit-tests.ts b/express-rate-limit/express-rate-limit-tests.ts new file mode 100644 index 0000000000..761a6d23f8 --- /dev/null +++ b/express-rate-limit/express-rate-limit-tests.ts @@ -0,0 +1,25 @@ +import RateLimit = require("express-rate-limit"); + +var apiLimiter = new RateLimit({ + windowMs: 15 * 60 * 1000, // 15 minutes + max: 100, + delayMs: 0 // disabled +}); + +var createAccountLimiter = new RateLimit({ + windowMs: 60 * 60 * 1000, // 1 hour window + delayAfter: 1, // begin slowing down responses after the first request + delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request + max: 5, // start blocking after 5 requests + message: "Too many accounts created from this IP, please try again after an hour" +}); + +class SomeStore implements RateLimit.Store { + incr(key: string, cb: RateLimit.StoreIncrementCallback) { } + resetAll() { } + resetKey(key: string) { }; +}; + +var limiterWithStore = new RateLimit({ + store: new SomeStore() +}); diff --git a/express-rate-limit/index.d.ts b/express-rate-limit/index.d.ts new file mode 100644 index 0000000000..57eb003694 --- /dev/null +++ b/express-rate-limit/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for express-rate-limit 2.6.0 +// Project: https://github.com/nfriedly/express-rate-limit +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import express = require("express"); + +declare namespace RateLimit { + type StoreIncrementCallback = (err?: {}, hits?: number) => void; + + export interface Store { + incr: (key: string, cb: StoreIncrementCallback) => void; + resetAll: () => void; + resetKey: (key: string) => void; + } + + export interface Options { + delayAfter?: number; + delayMs?: number; + headers?: boolean; + keyGenerator?: Function; + max?: number; + message?: string; + statusCode?: number; + store?: Store; + windowMs?: number; + } +} + +interface RateLimitStatic { + new(options: RateLimit.Options): express.RequestHandler; +} + +declare var RateLimit: RateLimitStatic; +export = RateLimit; diff --git a/express-rate-limit/tsconfig.json b/express-rate-limit/tsconfig.json new file mode 100644 index 0000000000..560edfef9d --- /dev/null +++ b/express-rate-limit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-rate-limit-tests.ts" + ] +} diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts new file mode 100644 index 0000000000..a66b681c37 --- /dev/null +++ b/shipit-utils/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for shipit-utils 1.4.0 +// Project: https://github.com/shipitjs/shipit-utils +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "shipit-utils" { + import shipit = require("shipit-cli"); + + type GruntOrShipit = typeof shipit | {}; + + export function equalValues(value: any[]): void; + + export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; + export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit; + + export function registerTask(gruntOrShipit: GruntOrShipit, name: string, task: Function): typeof shipit; + export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependencies: string[]): typeof shipit; + + export function runTask(gruntOrShipit: {}): void; +} diff --git a/shipit-utils/shipit-utils-tests.ts b/shipit-utils/shipit-utils-tests.ts new file mode 100644 index 0000000000..15f0d5547b --- /dev/null +++ b/shipit-utils/shipit-utils-tests.ts @@ -0,0 +1,11 @@ +import shipit = require("shipit-cli"); +import utils = require("shipit-utils"); + +var originalShipit = utils.getShipit(shipit); + +var task = () => { + return shipit.local("sleep 10s"); +}; + +utils.registerTask(originalShipit, "myTask", task); +utils.registerTask(originalShipit, "myTask", ["some", "other", "tasks"]); diff --git a/shipit-utils/tsconfig.json b/shipit-utils/tsconfig.json new file mode 100644 index 0000000000..fa4b1ce3b6 --- /dev/null +++ b/shipit-utils/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-utils-tests.ts" + ] +} diff --git a/shipit/index.d.ts b/shipit/index.d.ts new file mode 100644 index 0000000000..e0a528a2f2 --- /dev/null +++ b/shipit/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for shipit 1.5.1 +// Project: https://github.com/shipitjs/shipit +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "shipit-cli" { + import shipit = require("shipit-cli"); + + import * as fs from "fs"; + import * as child_process from "child_process"; + + type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike; + type TaskExecution = (name: string, depsOrFn: string[] | Function, fn: Function) => any; + + export interface Options { + environment: string; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + export interface ShipitLocal { + child: child_process.ChildProcess; + stderr: fs.WriteStream; + stdout: fs.WriteStream; + } + + export interface Tasks { + [name: string]: Task; + } + + export interface Task { + blocking: boolean; + dep: string[]; + fn: Function; + name: string; + } + + export function blTask(name: string, depsOrFn: string[] | Function, fn?: Function): any; + export function emit(name: string): any; + export function initConfig(config: {}): typeof shipit; + export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function log(log: any): void; + export function log(...log: any[]): void; + export function on(name: string, callback: Function): any; + export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike; + export function start(tasks: string): typeof shipit; + export function start(tasks: string[]): typeof shipit; + export function start(...tasks: string[]): typeof shipit; + export function task(name: string, depsOrFn: string[] | Function, fn?: Function): typeof shipit; + + export var config: {}; + export var domain: any; + export var doneCallback: any; + export var environment: string; + export var seq: any[]; + export var tasks: Tasks; + export var isRunning: boolean; +} diff --git a/shipit/shipit-cli-tests.ts b/shipit/shipit-cli-tests.ts new file mode 100644 index 0000000000..50dff54978 --- /dev/null +++ b/shipit/shipit-cli-tests.ts @@ -0,0 +1,50 @@ +import shipit = require("shipit-cli"); + +shipit.initConfig({ + default: { + workspace: "/tmp/github-monitor", + deployTo: "/tmp/deploy_to", + repositoryUrl: "https://github.com/user/repo.git", + ignores: [".git", "node_modules"], + rsync: ["--del"], + keepReleases: 2, + key: "/path/to/key", + shallowClone: true + }, + staging: { + servers: "user@myserver.com" + } +}); + +shipit.task("build", () => { + shipit.emit("built"); +}); + +shipit.on("built", () => { + shipit.start("start-server"); +}); + +shipit.task("pwd", () => { + return shipit.remote("pwd"); +}); + +shipit.blTask("pwd", () => { + return shipit.remote("pwd"); +}); + +shipit.start("task"); +shipit.start("task1", "task2"); +shipit.start(["task1", "task2"]); + +shipit.local("ls -lah", {cwd: "/tmp/deploy/workspace"}).then((res: any) => { + console.log(res.stdout); + console.log(res.stderr); +}); + +shipit.remote("ls -lah").then((res: any) => { + console.log(res[0].stdout); + console.log(res[0].stderr); +}); + +shipit.remoteCopy("/tmp/workspace", "/opt/web/myapp").then(() => {}); +shipit.log("hello %s", "world"); diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json new file mode 100644 index 0000000000..da7bec35d8 --- /dev/null +++ b/shipit/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-cli-tests.ts" + ] +} From d4044f0ce56b80c6ed0403ff17305678a85423b2 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:18:20 +0100 Subject: [PATCH 022/248] Fix definition header for shipit-cli. --- shipit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shipit/index.d.ts b/shipit/index.d.ts index e0a528a2f2..ab44d7abd8 100644 --- a/shipit/index.d.ts +++ b/shipit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit 1.5.1 +// Type definitions for shipit-cli 1.5.1 // Project: https://github.com/shipitjs/shipit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 6c7cd1ed7b83005c26891581f6cffb54eafa63d7 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Sat, 14 Jan 2017 21:19:11 +0100 Subject: [PATCH 023/248] Rename "shipit-cli-tests" to "shipit-tests". --- shipit/{shipit-cli-tests.ts => shipit-tests.ts} | 0 shipit/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename shipit/{shipit-cli-tests.ts => shipit-tests.ts} (100%) diff --git a/shipit/shipit-cli-tests.ts b/shipit/shipit-tests.ts similarity index 100% rename from shipit/shipit-cli-tests.ts rename to shipit/shipit-tests.ts diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json index da7bec35d8..254ac2d9a5 100644 --- a/shipit/tsconfig.json +++ b/shipit/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "shipit-cli-tests.ts" + "shipit-tests.ts" ] } From 040c1365bc12314f7ce49799cd2cdcb8e6c295f5 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Tue, 17 Jan 2017 12:32:34 +0900 Subject: [PATCH 024/248] Update react-router-redux to user history 4.5.x --- react-router-redux/index.d.ts | 111 ++++++++---------- .../react-router-redux-tests.ts | 20 +++- react-router-redux/tsconfig.json | 17 ++- react-router-redux/tslint.json | 1 + 4 files changed, 76 insertions(+), 73 deletions(-) create mode 100644 react-router-redux/tslint.json diff --git a/react-router-redux/index.d.ts b/react-router-redux/index.d.ts index 16438f9452..a6d3bd8c00 100644 --- a/react-router-redux/index.d.ts +++ b/react-router-redux/index.d.ts @@ -1,65 +1,58 @@ -// Type definitions for react-router-redux v4.0.0 +// Type definitions for react-router-redux 4.0 // Project: https://github.com/rackt/react-router-redux -// Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg +// Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import { Action, Middleware, Store } from "redux"; +import { History, Location, LocationDescriptor } from "history"; -import * as Redux from "redux"; -import * as History from "history"; +export const CALL_HISTORY_METHOD: string; +export const LOCATION_CHANGE: string; -export = ReactRouterRedux; - -declare namespace ReactRouterRedux { - import R = Redux; - - const CALL_HISTORY_METHOD: string; - const LOCATION_CHANGE: string; - - const push: PushAction; - const replace: ReplaceAction; - const go: GoAction; - const goBack: GoForwardAction; - const goForward: GoBackAction; - const routerActions: RouteActions; - - type LocationDescriptor = History.LocationDescriptor; - type PushAction = (nextLocation: LocationDescriptor) => RouterAction; - type ReplaceAction = (nextLocation: LocationDescriptor) => RouterAction; - type GoAction = (n: number) => RouterAction; - type GoForwardAction = () => RouterAction; - type GoBackAction = () => RouterAction; - - type RouterAction = { - type: string - payload?: LocationDescriptor - } - - interface RouteActions { - push: PushAction; - replace: ReplaceAction; - go: GoAction; - goForward: GoForwardAction; - goBack: GoBackAction; - } - interface ReactRouterReduxHistory extends History.History { - unsubscribe(): void; - } - - interface DefaultSelectLocationState extends Function { - (state: any): any; - } - - interface SyncHistoryWithStoreOptions { - selectLocationState?: DefaultSelectLocationState; - adjustUrlOnReplay?: boolean; - } - - interface RouterState { - locationBeforeTransitions: History.Location - } - - function routerReducer(state?: RouterState, action?: R.Action): RouterState; - function syncHistoryWithStore(history: History.History, store: R.Store, options?: SyncHistoryWithStoreOptions): ReactRouterReduxHistory; - function routerMiddleware(history: History.History): R.Middleware; +export interface LocationActionPayload { + method: string; + args?: any[]; } + +export interface RouterAction extends Action { + payload?: LocationActionPayload; +} + +type LocationAction = (nextLocation: LocationDescriptor) => RouterAction; +type GoAction = (n: number) => RouterAction; +type NavigateAction = () => RouterAction; + +export const push: LocationAction; +export const replace: LocationAction; +export const go: GoAction; +export const goBack: NavigateAction; +export const goForward: NavigateAction; + +interface RouteActions { + push: typeof push; + replace: typeof replace; + go: typeof go; + goForward: typeof goForward; + goBack: typeof goBack; +} + +export const routerActions: RouteActions; + +export interface RouterState { + locationBeforeTransitions: Location +} + +export type DefaultSelectLocationState = (state: any) => RouterState + +export interface SyncHistoryWithStoreOptions { + selectLocationState?: DefaultSelectLocationState; + adjustUrlOnReplay?: boolean; +} + +export interface HistoryUnsubscribe { + unsubscribe(): void; +} + +export function routerReducer(state?: RouterState, action?: Action): RouterState; +export function syncHistoryWithStore(history: History, store: Store, options?: SyncHistoryWithStoreOptions): History & HistoryUnsubscribe; +export function routerMiddleware(history: History): Middleware; diff --git a/react-router-redux/react-router-redux-tests.ts b/react-router-redux/react-router-redux-tests.ts index 1d73706c4e..87b99b2a69 100644 --- a/react-router-redux/react-router-redux-tests.ts +++ b/react-router-redux/react-router-redux-tests.ts @@ -1,9 +1,16 @@ -/// -/// - import { createStore, combineReducers, applyMiddleware } from 'redux'; import { browserHistory } from 'react-router'; -import { syncHistoryWithStore, routerReducer, routerMiddleware, push, replace, go, goForward, goBack } from 'react-router-redux'; +import { + syncHistoryWithStore, + routerReducer, + routerMiddleware, + push, + replace, + go, + goForward, + goBack, + routerActions +} from 'react-router-redux'; const reducer = combineReducers({ routing: routerReducer }); @@ -25,3 +32,8 @@ store.dispatch(replace('/foo')); store.dispatch(go(1)); store.dispatch(goForward()); store.dispatch(goBack()); +store.dispatch(routerActions.push('/foo')); +store.dispatch(routerActions.replace('/foo')); +store.dispatch(routerActions.go(1)); +store.dispatch(routerActions.goForward()); +store.dispatch(routerActions.goBack()); diff --git a/react-router-redux/tsconfig.json b/react-router-redux/tsconfig.json index b2efdcc111..64b2c38849 100644 --- a/react-router-redux/tsconfig.json +++ b/react-router-redux/tsconfig.json @@ -1,23 +1,20 @@ { - "files": [ - "index.d.ts", - "react-router-redux-tests.ts" - ], "compilerOptions": { "module": "commonjs", "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", - "paths": { - "history": ["history/v2"] - }, "typeRoots": [ - "../" + "../" ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - } + }, + "files": [ + "index.d.ts", + "react-router-redux-tests.ts" + ] } diff --git a/react-router-redux/tslint.json b/react-router-redux/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-router-redux/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 69a9f6d6718fba210ab007541572ff8459c6d1ce Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Tue, 17 Jan 2017 18:29:47 +0900 Subject: [PATCH 025/248] Update react-router definitions to 3.0.x --- react-router/index.d.ts | 137 +++++------ react-router/lib/IndexLink.d.ts | 16 +- react-router/lib/IndexRedirect.d.ts | 25 +-- react-router/lib/IndexRoute.d.ts | 44 ++-- react-router/lib/Link.d.ts | 22 +- react-router/lib/PatternUtils.d.ts | 4 +- react-router/lib/PropTypes.d.ts | 35 +-- react-router/lib/Redirect.d.ts | 27 +-- react-router/lib/Route.d.ts | 50 +++-- react-router/lib/RouteUtils.d.ts | 9 +- react-router/lib/Router.d.ts | 212 +++++++++--------- react-router/lib/RouterContext.d.ts | 27 +-- react-router/lib/applyRouterMiddleware.d.ts | 12 +- react-router/lib/browserHistory.d.ts | 4 +- react-router/lib/createMemoryHistory.d.ts | 6 +- react-router/lib/hashHistory.d.ts | 4 +- react-router/lib/match.d.ts | 25 +-- react-router/lib/useRouterHistory.d.ts | 8 +- react-router/lib/withRouter.d.ts | 11 +- react-router/react-router-tests.tsx | 33 ++- react-router/tsconfig.json | 3 - react-router/v2/index.d.ts | 91 ++++++++ react-router/v2/lib/IndexLink.d.ts | 5 + react-router/v2/lib/IndexRedirect.d.ts | 17 ++ react-router/v2/lib/IndexRoute.d.ts | 20 ++ react-router/{ => v2}/lib/Lifecycle.d.ts | 0 react-router/v2/lib/Link.d.ts | 19 ++ react-router/v2/lib/PatternUtils.d.ts | 1 + react-router/v2/lib/PropTypes.d.ts | 19 ++ react-router/v2/lib/Redirect.d.ts | 19 ++ react-router/v2/lib/Route.d.ts | 25 +++ react-router/{ => v2}/lib/RouteContext.d.ts | 0 react-router/v2/lib/RouteUtils.d.ts | 8 + react-router/v2/lib/Router.d.ts | 116 ++++++++++ react-router/v2/lib/RouterContext.d.ts | 25 +++ .../v2/lib/applyRouterMiddleware.d.ts | 9 + react-router/v2/lib/browserHistory.d.ts | 3 + react-router/v2/lib/createMemoryHistory.d.ts | 3 + react-router/v2/lib/hashHistory.d.ts | 3 + react-router/v2/lib/match.d.ts | 17 ++ react-router/{ => v2}/lib/routerHistory.d.ts | 0 react-router/v2/lib/useRouterHistory.d.ts | 7 + react-router/{ => v2}/lib/useRoutes.d.ts | 0 react-router/v2/lib/withRouter.d.ts | 4 + 44 files changed, 749 insertions(+), 376 deletions(-) create mode 100644 react-router/v2/index.d.ts create mode 100644 react-router/v2/lib/IndexLink.d.ts create mode 100644 react-router/v2/lib/IndexRedirect.d.ts create mode 100644 react-router/v2/lib/IndexRoute.d.ts rename react-router/{ => v2}/lib/Lifecycle.d.ts (100%) create mode 100644 react-router/v2/lib/Link.d.ts create mode 100644 react-router/v2/lib/PatternUtils.d.ts create mode 100644 react-router/v2/lib/PropTypes.d.ts create mode 100644 react-router/v2/lib/Redirect.d.ts create mode 100644 react-router/v2/lib/Route.d.ts rename react-router/{ => v2}/lib/RouteContext.d.ts (100%) create mode 100644 react-router/v2/lib/RouteUtils.d.ts create mode 100644 react-router/v2/lib/Router.d.ts create mode 100644 react-router/v2/lib/RouterContext.d.ts create mode 100644 react-router/v2/lib/applyRouterMiddleware.d.ts create mode 100644 react-router/v2/lib/browserHistory.d.ts create mode 100644 react-router/v2/lib/createMemoryHistory.d.ts create mode 100644 react-router/v2/lib/hashHistory.d.ts create mode 100644 react-router/v2/lib/match.d.ts rename react-router/{ => v2}/lib/routerHistory.d.ts (100%) create mode 100644 react-router/v2/lib/useRouterHistory.d.ts rename react-router/{ => v2}/lib/useRoutes.d.ts (100%) create mode 100644 react-router/v2/lib/withRouter.d.ts diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 59f33e1960..8398838aef 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,91 +1,56 @@ -// Type definitions for react-router v2.0.0 +// Type definitions for react-router 3.0 // Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov +// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - -export as namespace ReactRouter; - -import * as React from 'react'; - -export const routerShape: React.Requireable - -export const locationShape: React.Requireable - -import Router from "./lib/Router"; -import Link from "./lib/Link"; -import IndexLink from "./lib/IndexLink"; -import IndexRedirect from "./lib/IndexRedirect"; -import IndexRoute from "./lib/IndexRoute"; -import Redirect from "./lib/Redirect"; -import Route from "./lib/Route"; -import * as History from "./lib/routerHistory"; -import Lifecycle from "./lib/Lifecycle"; -import RouteContext from "./lib/RouteContext"; -import browserHistory from "./lib/browserHistory"; -import hashHistory from "./lib/hashHistory"; -import useRoutes from "./lib/useRoutes"; -import { createRoutes } from "./lib/RouteUtils"; -import { formatPattern } from "./lib/PatternUtils"; -import RouterContext from "./lib/RouterContext"; -import PropTypes from "./lib/PropTypes"; -import match from "./lib/match"; -import useRouterHistory from "./lib/useRouterHistory"; -import createMemoryHistory from "./lib/createMemoryHistory"; -import withRouter from "./lib/withRouter"; -import applyRouterMiddleware from "./lib/applyRouterMiddleware"; - -// PlainRoute is defined in the API documented at: -// https://github.com/rackt/react-router/blob/master/docs/API.md -// but not included in any of the .../lib modules above. -export type PlainRoute = Router.PlainRoute; - -// The following definitions are also very useful to export -// because by using these types lots of potential type errors -// can be exposed: -export type EnterHook = Router.EnterHook; -export type LeaveHook = Router.LeaveHook; -export type ParseQueryString = Router.ParseQueryString; -export type LocationDescriptor = Router.LocationDescriptor; -export type RedirectFunction = Router.RedirectFunction; -export type RouteComponent = Router.RouteComponent; -export type RouteComponentProps = Router.RouteComponentProps; -export type RouteConfig = Router.RouteConfig; -export type RouteHook = Router.RouteHook; -export type StringifyQuery = Router.StringifyQuery; -export type RouterListener = Router.RouterListener; -export type RouterState = Router.RouterState; -export type InjectedRouter = Router.InjectedRouter; - -export type HistoryBase = History.HistoryBase; -export type RouterOnContext = Router.RouterOnContext; -export type RouteProps = Route.RouteProps; -export type LinkProps = Link.LinkProps; - export { - Router, - Link, - IndexLink, - IndexRedirect, - IndexRoute, - Redirect, - Route, - History, - browserHistory, - hashHistory, - Lifecycle, - RouteContext, - useRoutes, - createRoutes, - formatPattern, - RouterContext, - PropTypes, - match, - useRouterHistory, - createMemoryHistory, - withRouter, - applyRouterMiddleware -}; + Basename, + ChangeHook, + EnterHook, + InjectedRouter, + LeaveHook, + Location, + LocationDescriptor, + ParseQueryString, + RouteComponent, + RouteComponents, + RouteComponentProps, + RouteConfig, + RoutePattern, + RouterProps, + RouterState, + StringifyQuery, + Query +} from "react-router/lib/Router"; +export { LinkProps } from "react-router/lib/Link"; +export { IndexLinkProps } from "react-router/lib/IndexLink"; +export { RouteProps, PlainRoute } from "react-router/lib/Route"; +export { IndexRouteProps } from "react-router/lib/IndexRoute"; +export { RedirectProps } from "react-router/lib/Redirect"; +export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; -export default Router; +/* components */ +export { default as Router } from "react-router/lib/Router"; +export { default as Link } from "react-router/lib/Link"; +export { default as IndexLink } from "react-router/lib/IndexLink"; +export { default as withRouter } from "react-router/lib/withRouter"; + +/* components (configuration) */ +export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; +export { default as IndexRoute } from "react-router/lib/IndexRoute"; +export { default as Redirect } from "react-router/lib/Redirect"; +export { default as Route } from "react-router/lib/Route"; + +/* utils */ +export { createRoutes } from "react-router/lib/RouteUtils"; +export { default as RouterContext } from "react-router/lib/RouterContext"; +export { routerShape, locationShape } from "react-router/lib/PropTypes"; +export { default as match } from "react-router/lib/match"; +export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; +export { formatPattern } from "react-router/lib/PatternUtils"; +export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; + +/* histories */ +export { default as browserHistory } from "react-router/lib/browserHistory"; +export { default as hashHistory } from "react-router/lib/hashHistory"; +export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; diff --git a/react-router/lib/IndexLink.d.ts b/react-router/lib/IndexLink.d.ts index 56ecf82c1d..0c62010262 100644 --- a/react-router/lib/IndexLink.d.ts +++ b/react-router/lib/IndexLink.d.ts @@ -1,5 +1,15 @@ -import Link from './Link'; +import { ComponentClass, CSSProperties, HTMLProps } from "react"; +import { Location, LocationDescriptor } from "react-router/lib/Router"; + +type ToLocationFunction = (location: Location) => LocationDescriptor; + +export interface IndexLinkProps extends HTMLProps { + to: LocationDescriptor | ToLocationFunction; + activeClassName?: string; + activeStyle?: CSSProperties; +} + +type IndexLink = ComponentClass; +declare const IndexLink: IndexLink; -declare const IndexLink: Link; export default IndexLink; - diff --git a/react-router/lib/IndexRedirect.d.ts b/react-router/lib/IndexRedirect.d.ts index 41dab299c8..3b8187d09b 100644 --- a/react-router/lib/IndexRedirect.d.ts +++ b/react-router/lib/IndexRedirect.d.ts @@ -1,17 +1,12 @@ -import Router from './Router'; -import * as React from 'react'; -import * as H from 'history'; +import { ComponentClass, ClassAttributes } from "react"; +import { RoutePattern, Query } from "react-router"; -declare const self: self.IndexRedirect; -type self = self.IndexRedirect; -export default self; - -declare namespace self { - interface IndexRedirectProps extends React.Props { - to: Router.RoutePattern; - query?: H.Query; - state?: H.LocationState; - } - interface IndexRedirectElement extends React.ReactElement { } - interface IndexRedirect extends React.ComponentClass { } +export interface IndexRedirectProps extends ClassAttributes { + to: RoutePattern; + query?: Query; } + +type IndexRedirect = ComponentClass; +declare const IndexRedirect: IndexRedirect; + +export default IndexRedirect; diff --git a/react-router/lib/IndexRoute.d.ts b/react-router/lib/IndexRoute.d.ts index b11b16d0e2..b0574df26a 100644 --- a/react-router/lib/IndexRoute.d.ts +++ b/react-router/lib/IndexRoute.d.ts @@ -1,20 +1,28 @@ -import * as React from 'react'; -import Router from './Router'; -import * as H from 'history'; +import { ComponentClass, ClassAttributes } from "react"; +import { LocationState } from "history"; +import { + EnterHook, + ChangeHook, + LeaveHook, + RouteComponent, + RouteComponents, + RouterState +} from "react-router"; -declare const self: self.IndexRoute; -type self = self.IndexRoute; -export default self; +type ComponentCallback = (err: any, component: RouteComponent) => void; +type ComponentsCallback = (err: any, components: RouteComponents) => void; -declare namespace self { - interface IndexRouteProps extends React.Props { - component?: Router.RouteComponent; - components?: Router.RouteComponents; - getComponent?: (location: H.Location, cb: (error: any, component?: Router.RouteComponent) => void) => void; - getComponents?: (location: H.Location, cb: (error: any, components?: Router.RouteComponents) => void) => void; - onEnter?: Router.EnterHook; - onLeave?: Router.LeaveHook; - } - interface IndexRoute extends React.ComponentClass { } - interface IndexRouteElement extends React.ReactElement { } -} \ No newline at end of file +export interface IndexRouteProps { + component?: RouteComponent; + components?: RouteComponents; + getComponent?(nextState: RouterState, callback: ComponentCallback): void; + getComponents?(nextState: RouterState, callback: ComponentsCallback): void; + onEnter?: EnterHook; + onChange?: ChangeHook; + onLeave?: LeaveHook; +} + +type IndexRoute = ComponentClass; +declare const IndexRoute: IndexRoute; + +export default IndexRoute; diff --git a/react-router/lib/Link.d.ts b/react-router/lib/Link.d.ts index d90578b9f9..eca6e66abd 100644 --- a/react-router/lib/Link.d.ts +++ b/react-router/lib/Link.d.ts @@ -1,19 +1,11 @@ -import * as React from 'react'; -import Router from './Router'; +import { ComponentClass, CSSProperties, HTMLProps } from "react"; +import { IndexLinkProps } from "react-router/lib/IndexLink"; +export interface LinkProps extends IndexLinkProps { + onlyActiveOnIndex?: boolean; +} + +type Link = ComponentClass; declare const Link: Link; -type Link = Link.Link; export default Link; - -declare namespace Link { - interface LinkProps extends React.HTMLAttributes { - activeStyle?: React.CSSProperties; - activeClassName?: string; - onlyActiveOnIndex?: boolean; - to: Router.RoutePattern | Router.LocationDescriptor | ((...args: any[]) => Router.LocationDescriptor); - } - - interface Link extends React.ComponentClass {} - interface LinkElement extends React.ReactElement {} -} diff --git a/react-router/lib/PatternUtils.d.ts b/react-router/lib/PatternUtils.d.ts index 50e90f6e49..2c32b2a286 100644 --- a/react-router/lib/PatternUtils.d.ts +++ b/react-router/lib/PatternUtils.d.ts @@ -1 +1,3 @@ -export function formatPattern(pattern: string, params: {}): string; +import { RoutePattern } from "react-router"; + +export function formatPattern(pattern: RoutePattern, params: any): string; diff --git a/react-router/lib/PropTypes.d.ts b/react-router/lib/PropTypes.d.ts index bbd6431070..c9140777cb 100644 --- a/react-router/lib/PropTypes.d.ts +++ b/react-router/lib/PropTypes.d.ts @@ -1,19 +1,22 @@ -import * as React from 'react'; +import { Requireable, Validator } from "react"; -export function falsy(props: any, propName: string, componentName: string): Error; -export const history: React.Requireable; -export const location: React.Requireable; -export const component: React.Requireable; -export const components: React.Requireable; -export const route: React.Requireable; -export const routes: React.Requireable; +export interface RouterShape extends Validator { + push: Requireable; + replace: Requireable; + go: Requireable; + goBack: Requireable; + goForward: Requireable; + setRouteLeaveHook: Requireable; + isActive: Requireable; +} -export default { - falsy, - history, - location, - component, - components, - route -}; +export interface LocationShape extends Validator { + pathname: Requireable; + search: Requireable; + state: any; + action: Requireable; + key: any; +} +export const routerShape: RouterShape; +export const locationShape: LocationShape; diff --git a/react-router/lib/Redirect.d.ts b/react-router/lib/Redirect.d.ts index e09b576d53..bb8254b4f5 100644 --- a/react-router/lib/Redirect.d.ts +++ b/react-router/lib/Redirect.d.ts @@ -1,19 +1,12 @@ -import * as React from 'react'; -import Router from './Router'; -import * as H from 'history'; +import { ComponentClass, ClassAttributes } from "react"; +import { RoutePattern, Query } from "react-router"; +import { IndexRedirectProps } from "react-router/lib/IndexRedirect"; -declare const self: self.Redirect; -type self = typeof self; -export default self; - -declare namespace self { - interface RedirectProps extends React.Props { - path?: Router.RoutePattern; - from?: Router.RoutePattern; // alias for path - to: Router.RoutePattern; - query?: H.Query; - state?: H.LocationState; - } - interface Redirect extends React.ComponentClass { } - interface RedirectElement extends React.ReactElement { } +export interface RedirectProps extends IndexRedirectProps { + from: RoutePattern; } + +type Redirect = ComponentClass; +declare const Redirect: Redirect; + +export default Redirect; diff --git a/react-router/lib/Route.d.ts b/react-router/lib/Route.d.ts index 2f5425b55a..15aafebc75 100644 --- a/react-router/lib/Route.d.ts +++ b/react-router/lib/Route.d.ts @@ -1,25 +1,31 @@ -import * as React from 'react'; -import Router from './Router'; -import { Location } from 'history'; +import { ComponentClass, ClassAttributes } from "react"; +import { LocationState } from "history"; +import { + EnterHook, + ChangeHook, + LeaveHook, + RouteComponent, + RouteComponents, + RoutePattern, + RouterState +} from "react-router"; +import { IndexRouteProps } from "react-router/lib/IndexRoute"; -declare const self: self.Route; -type self = self.Route; -export default self; +export interface RouteProps extends IndexRouteProps { + path?: RoutePattern; +} -declare namespace self { +type Route = ComponentClass; +declare const Route: Route; - interface RouteProps extends React.Props { - path?: Router.RoutePattern; - component?: Router.RouteComponent; - components?: Router.RouteComponents; - getComponent?: (nextState: Router.RouterState, cb: (error: any, component?: Router.RouteComponent) => void) => void - getComponents?: (nextState: Router.RouterState, cb: (error: any, components?: Router.RouteComponents) => void) => void - onEnter?: Router.EnterHook; - onLeave?: Router.LeaveHook; - onChange?: Router.ChangeHook; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: Router.RouteConfig) => void) => void; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: Router.RouteConfig) => void) => void; - } - interface Route extends React.ComponentClass {} - interface RouteElement extends React.ReactElement {} -} \ No newline at end of file +export default Route; + +type RouteCallback = (err: any, route: PlainRoute) => void; +type RoutesCallback = (err: any, routesArray: PlainRoute[]) => void; + +export interface PlainRoute extends RouteProps { + childRoutes?: PlainRoute[]; + getChildRoutes?(partialNextState: LocationState, callback: RoutesCallback): void; + indexRoute?: PlainRoute; + getIndexRoute?(partialNextState: LocationState, callback: RouteCallback): void; +} diff --git a/react-router/lib/RouteUtils.d.ts b/react-router/lib/RouteUtils.d.ts index 7065056ff5..6304f5d7bf 100644 --- a/react-router/lib/RouteUtils.d.ts +++ b/react-router/lib/RouteUtils.d.ts @@ -1,8 +1,3 @@ -import * as React from 'react'; -import Router from './Router'; +import { RouteConfig, PlainRoute } from "react-router"; -type E = React.ReactElement; -export function isReactChildren(object: E | E[]): boolean; -export function createRouteFromReactElement(element: E): Router.PlainRoute; -export function createRoutesFromReactChildren(children: E | E[], parentRoute: Router.PlainRoute): Router.PlainRoute[]; -export function createRoutes(routes: Router.RouteConfig): Router.PlainRoute[]; +export function createRoutes(routes: RouteConfig): PlainRoute[]; diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index a9c5417f47..160694953f 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -1,116 +1,106 @@ -import * as React from 'react'; -import RouterContext from './RouterContext'; +import { Component, ComponentClass, ClassAttributes, ReactNode, StatelessComponent } from "react"; import { - QueryString, Query, - Location, LocationDescriptor, LocationState as HLocationState, - History, Href, - Pathname, Path } from 'history'; + Hash, + History, + Href, + LocationKey, + LocationState, + Path, + Pathname, + Search +} from "history"; +import { PlainRoute } from "react-router"; +export type Basename = string; +export type Query = any; +export type Action = "PUSH" | "REPLACE" | "POP"; +export interface Params { + [key: string]: string; +} +export type RoutePattern = string; +export type RouteComponent = ComponentClass | StatelessComponent; +export interface RouteComponents { + [name: string]: RouteComponent; +} +export type RouteConfig = ReactNode | PlainRoute | PlainRoute[]; + +export type ParseQueryString = (queryString: Search) => Query; +export type StringifyQuery = (queryObject: Query) => Search; + +type AnyFunction = (...args: any[]) => any; + +export type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; +export type LeaveHook = (prevState: RouterState) => any; +export type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; +export type RouteHook = (nextLocation?: Location) => any; + +export interface Location { + patname: Pathname; + search: Search; + query: Query; + state: LocationState; + action: Action; + key: LocationKey; +} + +export interface LocationDescriptorObject { + pathname?: Pathname; + query?: Query; + hash?: Hash; + state?: LocationState; +} + +export type LocationDescriptor = Path | LocationDescriptorObject; + +export interface RedirectFunction { + (location: LocationDescriptor): void; + (state: LocationState, pathname: Pathname | Path, query?: Query): void; +} + +export interface RouterState { + location: Location; + routes: PlainRoute[]; + params: Params; + components: RouteComponent[]; +} + +type LocationFunction = (location: LocationDescriptor) => void; +type GoFunction = (n: number) => void; +type NavigateFunction = () => void; +type ActiveFunction = (location: LocationDescriptor, indexOnly?: boolean) => boolean; +type LeaveHookFunction = (route: any, callback: RouteHook) => void; +type CreatePartFunction = (path: Path, query?: any) => Part; + +export interface InjectedRouter { + push: LocationFunction; + replace: LocationFunction; + go: GoFunction; + goBack: NavigateFunction; + goForward: NavigateFunction; + setRouteLeaveHook: LeaveHookFunction; + createPath: CreatePartFunction; + createHref: CreatePartFunction; + isActive: ActiveFunction; +} + +export interface RouteComponentProps { + location?: Location; + params?: P & R; + route?: PlainRoute; + router?: InjectedRouter; + routeParams?: R; +} + +export interface RouterProps extends ClassAttributes { + routes?: RouteConfig; + history?: History; + createElement?(component: RouteComponent, props: any): any; + onError?(error: any): any; + onUpdate?(): any; + render?(props: any): ReactNode; +} + +type Router = ComponentClass; declare const Router: Router; -interface Router extends React.ComponentClass { } export default Router; - -// types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md - -declare namespace Router { - type RouteConfig = React.ReactNode | PlainRoute | PlainRoute[]; - type RoutePattern = string; - type RouteComponents = { [key: string]: RouteComponent }; - - type ParseQueryString = (queryString: QueryString) => Query; - type StringifyQuery = (queryObject: Query) => QueryString; - - type Component = React.ReactType; - type RouteComponent = Component; - - type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void; - type LeaveHook = () => void; - type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void; - type RouteHook = (nextLocation?: Location) => any; - - type Params = { [param: string]: string }; - - type RouterListener = (error: Error, nextState: RouterState) => void; - - type LocationDescriptor = { - pathname?: Pathname - query?: Query - hash?: Href - state?: HLocationState - } - - interface RedirectFunction { - (location: LocationDescriptor): void; - /** - * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated - */ - (state: HLocationState, pathname: Pathname | Path, query?: Query): void; - } - - interface RouterState { - location: Location; - routes: PlainRoute[]; - params: Params; - components: RouteComponent[]; - } - - interface RouterProps extends React.Props { - history?: History; - routes?: RouteConfig; // alias for children - createElement?: (component: RouteComponent, props: Object) => any; - onError?: (error: any) => any; - onUpdate?: () => any; - parseQueryString?: ParseQueryString; - stringifyQuery?: StringifyQuery; - basename?: string; - render?: (renderProps: React.Props<{}>) => RouterContext; - } - - interface PlainRoute { - path?: RoutePattern; - component?: RouteComponent; - components?: RouteComponents; - getComponent?: (location: Location, cb: (error: any, component?: RouteComponent) => void) => void; - getComponents?: (location: Location, cb: (error: any, components?: RouteComponents) => void) => void; - onEnter?: EnterHook; - onLeave?: LeaveHook; - indexRoute?: PlainRoute; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: RouteConfig) => void) => void; - childRoutes?: PlainRoute[]; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: RouteConfig) => void) => void; - } - - interface RouteComponentProps { - history?: History; - location?: Location; - params?: P; - route?: PlainRoute; - routeParams?: R; - routes?: PlainRoute[]; - children?: React.ReactElement; - } - - interface RouterOnContext extends History { - setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void; - isActive(pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean): boolean; - } - - // Wrap a component using withRouter(Component) to provide a router object - // to the Component's props, allowing the Component to programmatically call - // push and other functions. - // - // https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md - - interface InjectedRouter { - push: (pathOrLoc: Path | LocationDescriptor) => void - replace: (pathOrLoc: Path | LocationDescriptor) => void - go: (n: number) => void - goBack: () => void - goForward: () => void - setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void - createPath(path: History.Path, query?: History.Query): History.Path - createHref(path: History.Path, query?: History.Query): History.Href - isActive: (pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean) => boolean - } -} diff --git a/react-router/lib/RouterContext.d.ts b/react-router/lib/RouterContext.d.ts index b6eab5831c..b04e6e01ae 100644 --- a/react-router/lib/RouterContext.d.ts +++ b/react-router/lib/RouterContext.d.ts @@ -1,25 +1,6 @@ -import * as React from 'react'; -import * as H from 'history'; -import Router from './Router'; +import { ComponentClass } from "react"; -declare const self: self.RouterContext; -type self = self.RouterContext; -export default self; +type RouterContext = ComponentClass; +declare const RouterContext: RouterContext; -declare namespace self { - interface RouterContextProps extends React.Props { - history?: H.History; - router: Router; - createElement: (component: Router.RouteComponent, props: Object) => any; - location: H.Location; - routes: Router.RouteConfig; - params: Router.Params; - components?: Router.RouteComponent[]; - } - interface RouterContext extends React.ComponentClass {} - interface RouterContextElement extends React.ReactElement { - history?: H.History; - location: H.Location; - router?: Router; - } -} \ No newline at end of file +export default RouterContext; diff --git a/react-router/lib/applyRouterMiddleware.d.ts b/react-router/lib/applyRouterMiddleware.d.ts index ed87d815db..e4d023a792 100644 --- a/react-router/lib/applyRouterMiddleware.d.ts +++ b/react-router/lib/applyRouterMiddleware.d.ts @@ -1,9 +1,9 @@ -import * as React from 'react'; -import Router from './Router'; -import RouterContext from './RouterContext'; +import { RouteComponent } from "react-router"; +import RouterContext from "react-router/lib/RouterContext"; export interface Middleware { - renderRouterContext?: (previous: RouterContext, props: React.Props<{}>) => RouterContext; - renderRouteComponent?: (previous: Router.RouteComponent, props: React.Props<{}>) => Router.RouteComponent; + renderRouterContext?: (previous: RouterContext, props: any) => RouterContext; + renderRouteComponent?: (previous: RouteComponent, props: any) => RouteComponent; } -export default function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: React.Props<{}>) => RouterContext; + +export default function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: any) => RouterContext; diff --git a/react-router/lib/browserHistory.d.ts b/react-router/lib/browserHistory.d.ts index aabbdc23f9..8f45db6412 100644 --- a/react-router/lib/browserHistory.d.ts +++ b/react-router/lib/browserHistory.d.ts @@ -1,3 +1,5 @@ -import { History } from './routerHistory'; +import { History } from "history"; + declare const browserHistory: History; + export default browserHistory; diff --git a/react-router/lib/createMemoryHistory.d.ts b/react-router/lib/createMemoryHistory.d.ts index 5df481bfa1..bb2fed561b 100644 --- a/react-router/lib/createMemoryHistory.d.ts +++ b/react-router/lib/createMemoryHistory.d.ts @@ -1,3 +1,5 @@ -import * as H from 'history'; +import { History, CreateHistory } from "history"; -export default function createMemoryHistory(options?: H.HistoryOptions): H.History; \ No newline at end of file +declare const createMemoryHistory: CreateHistory; + +export default createMemoryHistory; diff --git a/react-router/lib/hashHistory.d.ts b/react-router/lib/hashHistory.d.ts index 79f89c2f1a..6a17e65af9 100644 --- a/react-router/lib/hashHistory.d.ts +++ b/react-router/lib/hashHistory.d.ts @@ -1,3 +1,5 @@ -import { History } from './routerHistory'; +import { History } from "history"; + declare const hashHistory: History; + export default hashHistory; diff --git a/react-router/lib/match.d.ts b/react-router/lib/match.d.ts index e311ea69df..bc5af4fda8 100644 --- a/react-router/lib/match.d.ts +++ b/react-router/lib/match.d.ts @@ -1,17 +1,16 @@ -import * as H from 'history'; -import Router from './Router'; +import { History } from "history"; +import { Basename, LocationDescriptor, ParseQueryString, RouteConfig, StringifyQuery } from "react-router"; interface MatchArgs { - routes?: Router.RouteConfig; - history?: H.History; - location?: H.Location | string; - parseQueryString?: Router.ParseQueryString; - stringifyQuery?: Router.StringifyQuery; + routes: RouteConfig; + location: LocationDescriptor; + history?: History; + basename?: Basename; + parseQueryString?: ParseQueryString; + stringifyQuery?: StringifyQuery; } -interface MatchState extends Router.RouterState { - history: H.History; - router: Router; - createElement: (component: Router.RouteComponent, props: Object) => any; -} -export default function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void; + +export type MatchCallback = (error: any, redirectLocation: Location, renderProps: any) => void; + +export default function match(args: MatchArgs, cb: MatchCallback): void; diff --git a/react-router/lib/useRouterHistory.d.ts b/react-router/lib/useRouterHistory.d.ts index d3e043b609..1371baa07b 100644 --- a/react-router/lib/useRouterHistory.d.ts +++ b/react-router/lib/useRouterHistory.d.ts @@ -1,7 +1,5 @@ -import { History, HistoryOptions, HistoryQueries, CreateHistory } from 'history'; +import { History, CreateHistoryEnhancer } from "history"; -interface CreateRouterHistory { - (options?: HistoryOptions): History & HistoryQueries; -} +declare const useRouterHistory: CreateHistoryEnhancer; -export default function useRouterHistory(createHistory: CreateHistory): CreateRouterHistory; +export default useRouterHistory; diff --git a/react-router/lib/withRouter.d.ts b/react-router/lib/withRouter.d.ts index f698d94fd0..25f9d357c7 100644 --- a/react-router/lib/withRouter.d.ts +++ b/react-router/lib/withRouter.d.ts @@ -1,4 +1,9 @@ -import * as React from 'react'; +import { ComponentClass, StatelessComponent } from "react"; -declare function withRouter | React.StatelessComponent | React.PureComponent>(component: C): C -export default withRouter; +interface Options { + withRef?: boolean; +} + +type ComponentConstructor

= ComponentClass

| StatelessComponent

; + +export default function withRouter

(component: ComponentConstructor

, options?: Options): ComponentClass

; diff --git a/react-router/react-router-tests.tsx b/react-router/react-router-tests.tsx index 6c83ca180a..dda05ef9d8 100644 --- a/react-router/react-router-tests.tsx +++ b/react-router/react-router-tests.tsx @@ -1,22 +1,39 @@ -import * as React from "react" -import * as ReactDOM from "react-dom" -import {renderToString} from "react-dom/server"; +import * as React from "react"; +import { Component, ValidationMap } from "react"; +import * as ReactDOM from "react-dom"; +import { renderToString } from "react-dom/server"; -import { applyRouterMiddleware, browserHistory, hashHistory, match, createMemoryHistory, withRouter, routerShape, Router, Route, IndexRoute, InjectedRouter, Link, RouterOnContext, RouterContext, LinkProps} from "react-router"; +import { + applyRouterMiddleware, + browserHistory, + hashHistory, + match, + createMemoryHistory, + withRouter, + routerShape, + Router, + Route, + IndexRoute, + InjectedRouter, + Link, + RouterContext, + LinkProps +} from "react-router"; const NavLink = (props: LinkProps) => ( ) interface MasterContext { - router: RouterOnContext; + router: InjectedRouter; } -class Master extends React.Component, {}> { +class Master extends Component { - static contextTypes: React.ValidationMap = { - router: routerShape + static contextTypes: ValidationMap = { + "router": routerShape }; + context: MasterContext; navigate() { diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index d887e5e5ec..47b5b439bf 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -11,9 +11,6 @@ "strictNullChecks": false, "jsx": "react", "baseUrl": "../", - "paths": { - "history": ["history/v2"] - }, "typeRoots": [ "../" ], diff --git a/react-router/v2/index.d.ts b/react-router/v2/index.d.ts new file mode 100644 index 0000000000..59f33e1960 --- /dev/null +++ b/react-router/v2/index.d.ts @@ -0,0 +1,91 @@ +// Type definitions for react-router v2.0.0 +// Project: https://github.com/rackt/react-router +// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export as namespace ReactRouter; + +import * as React from 'react'; + +export const routerShape: React.Requireable + +export const locationShape: React.Requireable + +import Router from "./lib/Router"; +import Link from "./lib/Link"; +import IndexLink from "./lib/IndexLink"; +import IndexRedirect from "./lib/IndexRedirect"; +import IndexRoute from "./lib/IndexRoute"; +import Redirect from "./lib/Redirect"; +import Route from "./lib/Route"; +import * as History from "./lib/routerHistory"; +import Lifecycle from "./lib/Lifecycle"; +import RouteContext from "./lib/RouteContext"; +import browserHistory from "./lib/browserHistory"; +import hashHistory from "./lib/hashHistory"; +import useRoutes from "./lib/useRoutes"; +import { createRoutes } from "./lib/RouteUtils"; +import { formatPattern } from "./lib/PatternUtils"; +import RouterContext from "./lib/RouterContext"; +import PropTypes from "./lib/PropTypes"; +import match from "./lib/match"; +import useRouterHistory from "./lib/useRouterHistory"; +import createMemoryHistory from "./lib/createMemoryHistory"; +import withRouter from "./lib/withRouter"; +import applyRouterMiddleware from "./lib/applyRouterMiddleware"; + +// PlainRoute is defined in the API documented at: +// https://github.com/rackt/react-router/blob/master/docs/API.md +// but not included in any of the .../lib modules above. +export type PlainRoute = Router.PlainRoute; + +// The following definitions are also very useful to export +// because by using these types lots of potential type errors +// can be exposed: +export type EnterHook = Router.EnterHook; +export type LeaveHook = Router.LeaveHook; +export type ParseQueryString = Router.ParseQueryString; +export type LocationDescriptor = Router.LocationDescriptor; +export type RedirectFunction = Router.RedirectFunction; +export type RouteComponent = Router.RouteComponent; +export type RouteComponentProps = Router.RouteComponentProps; +export type RouteConfig = Router.RouteConfig; +export type RouteHook = Router.RouteHook; +export type StringifyQuery = Router.StringifyQuery; +export type RouterListener = Router.RouterListener; +export type RouterState = Router.RouterState; +export type InjectedRouter = Router.InjectedRouter; + +export type HistoryBase = History.HistoryBase; +export type RouterOnContext = Router.RouterOnContext; +export type RouteProps = Route.RouteProps; +export type LinkProps = Link.LinkProps; + +export { + Router, + Link, + IndexLink, + IndexRedirect, + IndexRoute, + Redirect, + Route, + History, + browserHistory, + hashHistory, + Lifecycle, + RouteContext, + useRoutes, + createRoutes, + formatPattern, + RouterContext, + PropTypes, + match, + useRouterHistory, + createMemoryHistory, + withRouter, + applyRouterMiddleware +}; + +export default Router; diff --git a/react-router/v2/lib/IndexLink.d.ts b/react-router/v2/lib/IndexLink.d.ts new file mode 100644 index 0000000000..56ecf82c1d --- /dev/null +++ b/react-router/v2/lib/IndexLink.d.ts @@ -0,0 +1,5 @@ +import Link from './Link'; + +declare const IndexLink: Link; +export default IndexLink; + diff --git a/react-router/v2/lib/IndexRedirect.d.ts b/react-router/v2/lib/IndexRedirect.d.ts new file mode 100644 index 0000000000..41dab299c8 --- /dev/null +++ b/react-router/v2/lib/IndexRedirect.d.ts @@ -0,0 +1,17 @@ +import Router from './Router'; +import * as React from 'react'; +import * as H from 'history'; + +declare const self: self.IndexRedirect; +type self = self.IndexRedirect; +export default self; + +declare namespace self { + interface IndexRedirectProps extends React.Props { + to: Router.RoutePattern; + query?: H.Query; + state?: H.LocationState; + } + interface IndexRedirectElement extends React.ReactElement { } + interface IndexRedirect extends React.ComponentClass { } +} diff --git a/react-router/v2/lib/IndexRoute.d.ts b/react-router/v2/lib/IndexRoute.d.ts new file mode 100644 index 0000000000..b11b16d0e2 --- /dev/null +++ b/react-router/v2/lib/IndexRoute.d.ts @@ -0,0 +1,20 @@ +import * as React from 'react'; +import Router from './Router'; +import * as H from 'history'; + +declare const self: self.IndexRoute; +type self = self.IndexRoute; +export default self; + +declare namespace self { + interface IndexRouteProps extends React.Props { + component?: Router.RouteComponent; + components?: Router.RouteComponents; + getComponent?: (location: H.Location, cb: (error: any, component?: Router.RouteComponent) => void) => void; + getComponents?: (location: H.Location, cb: (error: any, components?: Router.RouteComponents) => void) => void; + onEnter?: Router.EnterHook; + onLeave?: Router.LeaveHook; + } + interface IndexRoute extends React.ComponentClass { } + interface IndexRouteElement extends React.ReactElement { } +} \ No newline at end of file diff --git a/react-router/lib/Lifecycle.d.ts b/react-router/v2/lib/Lifecycle.d.ts similarity index 100% rename from react-router/lib/Lifecycle.d.ts rename to react-router/v2/lib/Lifecycle.d.ts diff --git a/react-router/v2/lib/Link.d.ts b/react-router/v2/lib/Link.d.ts new file mode 100644 index 0000000000..d90578b9f9 --- /dev/null +++ b/react-router/v2/lib/Link.d.ts @@ -0,0 +1,19 @@ +import * as React from 'react'; +import Router from './Router'; + +declare const Link: Link; +type Link = Link.Link; + +export default Link; + +declare namespace Link { + interface LinkProps extends React.HTMLAttributes { + activeStyle?: React.CSSProperties; + activeClassName?: string; + onlyActiveOnIndex?: boolean; + to: Router.RoutePattern | Router.LocationDescriptor | ((...args: any[]) => Router.LocationDescriptor); + } + + interface Link extends React.ComponentClass {} + interface LinkElement extends React.ReactElement {} +} diff --git a/react-router/v2/lib/PatternUtils.d.ts b/react-router/v2/lib/PatternUtils.d.ts new file mode 100644 index 0000000000..50e90f6e49 --- /dev/null +++ b/react-router/v2/lib/PatternUtils.d.ts @@ -0,0 +1 @@ +export function formatPattern(pattern: string, params: {}): string; diff --git a/react-router/v2/lib/PropTypes.d.ts b/react-router/v2/lib/PropTypes.d.ts new file mode 100644 index 0000000000..bbd6431070 --- /dev/null +++ b/react-router/v2/lib/PropTypes.d.ts @@ -0,0 +1,19 @@ +import * as React from 'react'; + +export function falsy(props: any, propName: string, componentName: string): Error; +export const history: React.Requireable; +export const location: React.Requireable; +export const component: React.Requireable; +export const components: React.Requireable; +export const route: React.Requireable; +export const routes: React.Requireable; + +export default { + falsy, + history, + location, + component, + components, + route +}; + diff --git a/react-router/v2/lib/Redirect.d.ts b/react-router/v2/lib/Redirect.d.ts new file mode 100644 index 0000000000..e09b576d53 --- /dev/null +++ b/react-router/v2/lib/Redirect.d.ts @@ -0,0 +1,19 @@ +import * as React from 'react'; +import Router from './Router'; +import * as H from 'history'; + +declare const self: self.Redirect; +type self = typeof self; +export default self; + +declare namespace self { + interface RedirectProps extends React.Props { + path?: Router.RoutePattern; + from?: Router.RoutePattern; // alias for path + to: Router.RoutePattern; + query?: H.Query; + state?: H.LocationState; + } + interface Redirect extends React.ComponentClass { } + interface RedirectElement extends React.ReactElement { } +} diff --git a/react-router/v2/lib/Route.d.ts b/react-router/v2/lib/Route.d.ts new file mode 100644 index 0000000000..2f5425b55a --- /dev/null +++ b/react-router/v2/lib/Route.d.ts @@ -0,0 +1,25 @@ +import * as React from 'react'; +import Router from './Router'; +import { Location } from 'history'; + +declare const self: self.Route; +type self = self.Route; +export default self; + +declare namespace self { + + interface RouteProps extends React.Props { + path?: Router.RoutePattern; + component?: Router.RouteComponent; + components?: Router.RouteComponents; + getComponent?: (nextState: Router.RouterState, cb: (error: any, component?: Router.RouteComponent) => void) => void + getComponents?: (nextState: Router.RouterState, cb: (error: any, components?: Router.RouteComponents) => void) => void + onEnter?: Router.EnterHook; + onLeave?: Router.LeaveHook; + onChange?: Router.ChangeHook; + getIndexRoute?: (location: Location, cb: (error: any, indexRoute: Router.RouteConfig) => void) => void; + getChildRoutes?: (location: Location, cb: (error: any, childRoutes: Router.RouteConfig) => void) => void; + } + interface Route extends React.ComponentClass {} + interface RouteElement extends React.ReactElement {} +} \ No newline at end of file diff --git a/react-router/lib/RouteContext.d.ts b/react-router/v2/lib/RouteContext.d.ts similarity index 100% rename from react-router/lib/RouteContext.d.ts rename to react-router/v2/lib/RouteContext.d.ts diff --git a/react-router/v2/lib/RouteUtils.d.ts b/react-router/v2/lib/RouteUtils.d.ts new file mode 100644 index 0000000000..7065056ff5 --- /dev/null +++ b/react-router/v2/lib/RouteUtils.d.ts @@ -0,0 +1,8 @@ +import * as React from 'react'; +import Router from './Router'; + +type E = React.ReactElement; +export function isReactChildren(object: E | E[]): boolean; +export function createRouteFromReactElement(element: E): Router.PlainRoute; +export function createRoutesFromReactChildren(children: E | E[], parentRoute: Router.PlainRoute): Router.PlainRoute[]; +export function createRoutes(routes: Router.RouteConfig): Router.PlainRoute[]; diff --git a/react-router/v2/lib/Router.d.ts b/react-router/v2/lib/Router.d.ts new file mode 100644 index 0000000000..a9c5417f47 --- /dev/null +++ b/react-router/v2/lib/Router.d.ts @@ -0,0 +1,116 @@ +import * as React from 'react'; +import RouterContext from './RouterContext'; +import { + QueryString, Query, + Location, LocationDescriptor, LocationState as HLocationState, + History, Href, + Pathname, Path } from 'history'; + +declare const Router: Router; +interface Router extends React.ComponentClass { } + +export default Router; + +// types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md + +declare namespace Router { + type RouteConfig = React.ReactNode | PlainRoute | PlainRoute[]; + type RoutePattern = string; + type RouteComponents = { [key: string]: RouteComponent }; + + type ParseQueryString = (queryString: QueryString) => Query; + type StringifyQuery = (queryObject: Query) => QueryString; + + type Component = React.ReactType; + type RouteComponent = Component; + + type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void; + type LeaveHook = () => void; + type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void; + type RouteHook = (nextLocation?: Location) => any; + + type Params = { [param: string]: string }; + + type RouterListener = (error: Error, nextState: RouterState) => void; + + type LocationDescriptor = { + pathname?: Pathname + query?: Query + hash?: Href + state?: HLocationState + } + + interface RedirectFunction { + (location: LocationDescriptor): void; + /** + * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated + */ + (state: HLocationState, pathname: Pathname | Path, query?: Query): void; + } + + interface RouterState { + location: Location; + routes: PlainRoute[]; + params: Params; + components: RouteComponent[]; + } + + interface RouterProps extends React.Props { + history?: History; + routes?: RouteConfig; // alias for children + createElement?: (component: RouteComponent, props: Object) => any; + onError?: (error: any) => any; + onUpdate?: () => any; + parseQueryString?: ParseQueryString; + stringifyQuery?: StringifyQuery; + basename?: string; + render?: (renderProps: React.Props<{}>) => RouterContext; + } + + interface PlainRoute { + path?: RoutePattern; + component?: RouteComponent; + components?: RouteComponents; + getComponent?: (location: Location, cb: (error: any, component?: RouteComponent) => void) => void; + getComponents?: (location: Location, cb: (error: any, components?: RouteComponents) => void) => void; + onEnter?: EnterHook; + onLeave?: LeaveHook; + indexRoute?: PlainRoute; + getIndexRoute?: (location: Location, cb: (error: any, indexRoute: RouteConfig) => void) => void; + childRoutes?: PlainRoute[]; + getChildRoutes?: (location: Location, cb: (error: any, childRoutes: RouteConfig) => void) => void; + } + + interface RouteComponentProps { + history?: History; + location?: Location; + params?: P; + route?: PlainRoute; + routeParams?: R; + routes?: PlainRoute[]; + children?: React.ReactElement; + } + + interface RouterOnContext extends History { + setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void; + isActive(pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean): boolean; + } + + // Wrap a component using withRouter(Component) to provide a router object + // to the Component's props, allowing the Component to programmatically call + // push and other functions. + // + // https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md + + interface InjectedRouter { + push: (pathOrLoc: Path | LocationDescriptor) => void + replace: (pathOrLoc: Path | LocationDescriptor) => void + go: (n: number) => void + goBack: () => void + goForward: () => void + setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void + createPath(path: History.Path, query?: History.Query): History.Path + createHref(path: History.Path, query?: History.Query): History.Href + isActive: (pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean) => boolean + } +} diff --git a/react-router/v2/lib/RouterContext.d.ts b/react-router/v2/lib/RouterContext.d.ts new file mode 100644 index 0000000000..b6eab5831c --- /dev/null +++ b/react-router/v2/lib/RouterContext.d.ts @@ -0,0 +1,25 @@ +import * as React from 'react'; +import * as H from 'history'; +import Router from './Router'; + +declare const self: self.RouterContext; +type self = self.RouterContext; +export default self; + +declare namespace self { + interface RouterContextProps extends React.Props { + history?: H.History; + router: Router; + createElement: (component: Router.RouteComponent, props: Object) => any; + location: H.Location; + routes: Router.RouteConfig; + params: Router.Params; + components?: Router.RouteComponent[]; + } + interface RouterContext extends React.ComponentClass {} + interface RouterContextElement extends React.ReactElement { + history?: H.History; + location: H.Location; + router?: Router; + } +} \ No newline at end of file diff --git a/react-router/v2/lib/applyRouterMiddleware.d.ts b/react-router/v2/lib/applyRouterMiddleware.d.ts new file mode 100644 index 0000000000..ed87d815db --- /dev/null +++ b/react-router/v2/lib/applyRouterMiddleware.d.ts @@ -0,0 +1,9 @@ +import * as React from 'react'; +import Router from './Router'; +import RouterContext from './RouterContext'; + +export interface Middleware { + renderRouterContext?: (previous: RouterContext, props: React.Props<{}>) => RouterContext; + renderRouteComponent?: (previous: Router.RouteComponent, props: React.Props<{}>) => Router.RouteComponent; +} +export default function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: React.Props<{}>) => RouterContext; diff --git a/react-router/v2/lib/browserHistory.d.ts b/react-router/v2/lib/browserHistory.d.ts new file mode 100644 index 0000000000..aabbdc23f9 --- /dev/null +++ b/react-router/v2/lib/browserHistory.d.ts @@ -0,0 +1,3 @@ +import { History } from './routerHistory'; +declare const browserHistory: History; +export default browserHistory; diff --git a/react-router/v2/lib/createMemoryHistory.d.ts b/react-router/v2/lib/createMemoryHistory.d.ts new file mode 100644 index 0000000000..5df481bfa1 --- /dev/null +++ b/react-router/v2/lib/createMemoryHistory.d.ts @@ -0,0 +1,3 @@ +import * as H from 'history'; + +export default function createMemoryHistory(options?: H.HistoryOptions): H.History; \ No newline at end of file diff --git a/react-router/v2/lib/hashHistory.d.ts b/react-router/v2/lib/hashHistory.d.ts new file mode 100644 index 0000000000..79f89c2f1a --- /dev/null +++ b/react-router/v2/lib/hashHistory.d.ts @@ -0,0 +1,3 @@ +import { History } from './routerHistory'; +declare const hashHistory: History; +export default hashHistory; diff --git a/react-router/v2/lib/match.d.ts b/react-router/v2/lib/match.d.ts new file mode 100644 index 0000000000..e311ea69df --- /dev/null +++ b/react-router/v2/lib/match.d.ts @@ -0,0 +1,17 @@ +import * as H from 'history'; +import Router from './Router'; + +interface MatchArgs { + routes?: Router.RouteConfig; + history?: H.History; + location?: H.Location | string; + parseQueryString?: Router.ParseQueryString; + stringifyQuery?: Router.StringifyQuery; +} +interface MatchState extends Router.RouterState { + history: H.History; + router: Router; + createElement: (component: Router.RouteComponent, props: Object) => any; +} +export default function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void; + diff --git a/react-router/lib/routerHistory.d.ts b/react-router/v2/lib/routerHistory.d.ts similarity index 100% rename from react-router/lib/routerHistory.d.ts rename to react-router/v2/lib/routerHistory.d.ts diff --git a/react-router/v2/lib/useRouterHistory.d.ts b/react-router/v2/lib/useRouterHistory.d.ts new file mode 100644 index 0000000000..d3e043b609 --- /dev/null +++ b/react-router/v2/lib/useRouterHistory.d.ts @@ -0,0 +1,7 @@ +import { History, HistoryOptions, HistoryQueries, CreateHistory } from 'history'; + +interface CreateRouterHistory { + (options?: HistoryOptions): History & HistoryQueries; +} + +export default function useRouterHistory(createHistory: CreateHistory): CreateRouterHistory; diff --git a/react-router/lib/useRoutes.d.ts b/react-router/v2/lib/useRoutes.d.ts similarity index 100% rename from react-router/lib/useRoutes.d.ts rename to react-router/v2/lib/useRoutes.d.ts diff --git a/react-router/v2/lib/withRouter.d.ts b/react-router/v2/lib/withRouter.d.ts new file mode 100644 index 0000000000..f698d94fd0 --- /dev/null +++ b/react-router/v2/lib/withRouter.d.ts @@ -0,0 +1,4 @@ +import * as React from 'react'; + +declare function withRouter | React.StatelessComponent | React.PureComponent>(component: C): C +export default withRouter; From 61af45367251ddb146a5c483f4cb2e6e88883868 Mon Sep 17 00:00:00 2001 From: Hutson Betts Date: Tue, 17 Jan 2017 14:03:06 -0600 Subject: [PATCH 026/248] fix(mocha): add index definition Add index definition to IHookCallbackContext to support Mocha's built-in context shared between setup, tear-down, and test cases. Context is Mocha's support for Shared Behaviors (https://github.com/mochajs/mocha/wiki/Shared-Behaviours) --- mocha/index.d.ts | 2 ++ mocha/mocha-tests.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/mocha/index.d.ts b/mocha/index.d.ts index 9ac84fa097..ec6fc5e142 100644 --- a/mocha/index.d.ts +++ b/mocha/index.d.ts @@ -118,6 +118,7 @@ declare namespace Mocha { interface IHookCallbackContext { skip(): void; timeout(ms: number): void; + [index: string]: any; } @@ -126,6 +127,7 @@ declare namespace Mocha { timeout(ms: number): void; retries(n: number): void; slow(ms: number): void; + [index: string]: any; } /** Partial interface for Mocha's `Runnable` class. */ diff --git a/mocha/mocha-tests.ts b/mocha/mocha-tests.ts index fc17a18221..8e8dc0d938 100644 --- a/mocha/mocha-tests.ts +++ b/mocha/mocha-tests.ts @@ -47,6 +47,8 @@ function test_it() { it('does something', () => { }); + it('does something', function () { this['sharedState'] = true; }); + it('does something', (done) => { done(); }); it.only('does something', () => { }); @@ -64,6 +66,8 @@ function test_test() { test('does something', () => { }); + test('does something', function () { this['sharedState'] = true; }); + test('does something', (done) => { done(); }); test.only('does something', () => { }); @@ -81,6 +85,8 @@ function test_specify() { specify('does something', () => { }); + specify('does something', function () { this['sharedState'] = true; }); + specify('does something', (done) => { done(); }); specify.only('does something', () => { }); @@ -97,6 +103,8 @@ function test_specify() { function test_before() { before(() => { }); + before(function () { this['sharedState'] = true; }); + before((done) => { done(); }); before("my description", () => { }); @@ -120,6 +128,17 @@ function test_setup() { string = this.currentTest.state; }); + setup(function() { + this['sharedState'] = true; + boolean = this.currentTest.async; + boolean = this.currentTest.pending; + boolean = this.currentTest.sync; + boolean = this.currentTest.timedOut; + string = this.currentTest.title; + string = this.currentTest.fullTitle(); + string = this.currentTest.state; + }); + setup(function (done) { done(); boolean = this.currentTest.async; @@ -135,6 +154,8 @@ function test_setup() { function test_after() { after(() => { }); + after(function () { this['sharedState'] = true; }); + after((done) => { done(); }); after("my description", () => { }); @@ -153,6 +174,17 @@ function test_teardown() { string = this.currentTest.state; }); + teardown(function() { + this['sharedState'] = true; + boolean = this.currentTest.async; + boolean = this.currentTest.pending; + boolean = this.currentTest.sync; + boolean = this.currentTest.timedOut; + string = this.currentTest.title; + string = this.currentTest.fullTitle(); + string = this.currentTest.state; + }); + teardown(function(done) { done(); boolean = this.currentTest.async; @@ -176,6 +208,17 @@ function test_beforeEach() { string = this.currentTest.state; }); + beforeEach(function () { + this['sharedState'] = true; + boolean = this.currentTest.async; + boolean = this.currentTest.pending; + boolean = this.currentTest.sync; + boolean = this.currentTest.timedOut; + string = this.currentTest.title; + string = this.currentTest.fullTitle(); + string = this.currentTest.state; + }); + beforeEach(function (done) { done(); boolean = this.currentTest.async; @@ -212,6 +255,8 @@ function test_beforeEach() { function test_suiteSetup() { suiteSetup(() => { }); + suiteSetup(function () { this['sharedState'] = true; }); + suiteSetup((done) => { done(); }); } @@ -226,6 +271,17 @@ function test_afterEach() { string = this.currentTest.state; }); + afterEach(function () { + this['sharedState'] = true; + boolean = this.currentTest.async; + boolean = this.currentTest.pending; + boolean = this.currentTest.sync; + boolean = this.currentTest.timedOut; + string = this.currentTest.title; + string = this.currentTest.fullTitle(); + string = this.currentTest.state; + }); + afterEach(function (done) { done(); boolean = this.currentTest.async; @@ -263,6 +319,8 @@ function test_afterEach() { function test_suiteTeardown() { suiteTeardown(() => { }); + suiteTeardown(function () { this['sharedState'] = true; }); + suiteTeardown((done) => { done(); }); } From 42e178120b56f2bd1ec20fb1075f9b709ca68f13 Mon Sep 17 00:00:00 2001 From: Marco Arruda Date: Tue, 17 Jan 2017 20:20:21 -0200 Subject: [PATCH 027/248] get actionlib servers --- roslib/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roslib/index.d.ts b/roslib/index.d.ts index fbb6deff6e..14fe2c1e3e 100644 --- a/roslib/index.d.ts +++ b/roslib/index.d.ts @@ -66,6 +66,16 @@ declare namespace ROSLIB { */ callOnConnection(message:any):void; + /** + * Retrieves list of actionlib servers in ROS as an array. + * + * @param callback function with params: + * * action_servers - Array of actionlib servers names + * @param failedCallback - the callback function when the ros call failed (optional). Params: + * * error - the error message reported by ROS + */ + getActionServers(callback:(action_servers:string[]) => void, failedCallback?:(error:any)=>void):void; + /** * Retrieves list of topics in ROS as an array. * From 9f396a35febe9d229c876d8cbeca26627594a604 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Wed, 18 Jan 2017 17:09:27 +0100 Subject: [PATCH 028/248] Add "tslint.json" file. Replace "major.minor.build" by "major.minor". --- express-rate-limit/index.d.ts | 2 +- express-rate-limit/tsconfig.json | 38 +++++++++++++++++--------------- express-rate-limit/tslint.json | 1 + shipit-utils/index.d.ts | 2 +- shipit-utils/tsconfig.json | 38 +++++++++++++++++--------------- shipit-utils/tslint.json | 1 + shipit/index.d.ts | 2 +- shipit/tsconfig.json | 38 +++++++++++++++++--------------- shipit/tslint.json | 1 + 9 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 express-rate-limit/tslint.json create mode 100644 shipit-utils/tslint.json create mode 100644 shipit/tslint.json diff --git a/express-rate-limit/index.d.ts b/express-rate-limit/index.d.ts index 57eb003694..07cb5853a5 100644 --- a/express-rate-limit/index.d.ts +++ b/express-rate-limit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for express-rate-limit 2.6.0 +// Type definitions for express-rate-limit 2.6 // Project: https://github.com/nfriedly/express-rate-limit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/express-rate-limit/tsconfig.json b/express-rate-limit/tsconfig.json index 560edfef9d..ca3c32c3bb 100644 --- a/express-rate-limit/tsconfig.json +++ b/express-rate-limit/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "express-rate-limit-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-rate-limit-tests.ts" + ] } diff --git a/express-rate-limit/tslint.json b/express-rate-limit/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/express-rate-limit/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/shipit-utils/index.d.ts b/shipit-utils/index.d.ts index a66b681c37..63df44974f 100644 --- a/shipit-utils/index.d.ts +++ b/shipit-utils/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit-utils 1.4.0 +// Type definitions for shipit-utils 1.4 // Project: https://github.com/shipitjs/shipit-utils // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/shipit-utils/tsconfig.json b/shipit-utils/tsconfig.json index fa4b1ce3b6..d2fdb45d17 100644 --- a/shipit-utils/tsconfig.json +++ b/shipit-utils/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "shipit-utils-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-utils-tests.ts" + ] } diff --git a/shipit-utils/tslint.json b/shipit-utils/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/shipit-utils/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/shipit/index.d.ts b/shipit/index.d.ts index ab44d7abd8..7b153ae197 100644 --- a/shipit/index.d.ts +++ b/shipit/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for shipit-cli 1.5.1 +// Type definitions for shipit-cli 1.5 // Project: https://github.com/shipitjs/shipit // Definitions by: Cyril Schumacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/shipit/tsconfig.json b/shipit/tsconfig.json index 254ac2d9a5..17049e7271 100644 --- a/shipit/tsconfig.json +++ b/shipit/tsconfig.json @@ -1,20 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "shipit-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shipit-tests.ts" + ] } diff --git a/shipit/tslint.json b/shipit/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/shipit/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 65701d7b2b3d60b309a7acd2fda6c10d2a77aec1 Mon Sep 17 00:00:00 2001 From: Pablo Moleri Date: Wed, 18 Jan 2017 14:03:23 -0300 Subject: [PATCH 029/248] Fix getLocation return type Also renamed GeoLocation type because it was being merged with Location type. --- webdriverio/index.d.ts | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index fbc6925fa9..f033ec2bfc 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -352,36 +352,37 @@ declare namespace WebdriverIO { ): Client

; getHTML

(includeSelectorTag: boolean): Client

; - getLocation(selector?: string): Size; - getLocation(selector: string, axis: string): number; - getLocation(axis: string): number; + getLocation(selector?: string): Location; + getLocation(selector: string, axis: Axis): number; + getLocation(axis: Axis): number; getLocation

(selector?: string): Client

; getLocation

( selector: string, - axis: string + axis: Axis ): Client

; - getLocation

(axis: string): Client

; + getLocation

(axis: Axis): Client

; - getLocationInView(selector: string): Size; - getLocationInView(selector: string): Size[]; - getLocationInView(): Size; - getLocationInView(): Size[]; + getLocationInView(selector: string): Location; + getLocationInView(selector: string): Location[]; + getLocationInView(): Location; + getLocationInView(): Location[]; getLocationInView( selector: string, - axis: string + axis: Axis ): number; getLocationInView( selector: string, - axis: string + axis: Axis ): number[]; - getLocationInView(axis: string): number; - getLocationInView(axis: string): number[]; + getLocationInView(axis: Axis): number; + getLocationInView(axis: Axis): number[]; getLocationInView

(selector?: string): Client

; getLocationInView

( selector: string, - axis: string + axis: Axis ): Client

; - getLocationInView

(axis: string): Client

; + getLocationInView

(axis: Axis): Client

; + getSource(): Client; getSource

(): Client

; @@ -428,7 +429,7 @@ declare namespace WebdriverIO { value: any; } - export interface Location { + export interface GeoLocation { latitude: number; longitude: number; altitude: number; @@ -983,6 +984,8 @@ declare namespace WebdriverIO { switchTab

(windowHandle?: string): Client

; } + export type Axis = "x" | "y"; + export interface Options { protocol: string; waitforTimeout: number; From b033ae77a87c91fb93f351a29088e3806aa55b12 Mon Sep 17 00:00:00 2001 From: Andrew Zheng Date: Wed, 18 Jan 2017 15:14:17 -0800 Subject: [PATCH 030/248] Add optional parameter to verifyNoOutstandingExpectation() --- angular-mocks/angular-mocks-tests.ts | 1 + angular-mocks/index.d.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/angular-mocks/angular-mocks-tests.ts b/angular-mocks/angular-mocks-tests.ts index 8ea42e4122..cabbf7c578 100644 --- a/angular-mocks/angular-mocks-tests.ts +++ b/angular-mocks/angular-mocks-tests.ts @@ -118,6 +118,7 @@ httpBackendService.flush(); httpBackendService.flush(1234); httpBackendService.resetExpectations(); httpBackendService.verifyNoOutstandingExpectation(); +httpBackendService.verifyNoOutstandingExpectation(false); httpBackendService.verifyNoOutstandingRequest(); requestHandler = httpBackendService.expect('GET', 'http://test.local'); diff --git a/angular-mocks/index.d.ts b/angular-mocks/index.d.ts index ddded4d0a8..767eb65f04 100644 --- a/angular-mocks/index.d.ts +++ b/angular-mocks/index.d.ts @@ -132,8 +132,9 @@ declare module 'angular' { /** * Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception. + * @param digest Do digest before checking expectation. Pass anything expect false to trigger digest. */ - verifyNoOutstandingExpectation(): void; + verifyNoOutstandingExpectation(digest?: boolean): void; /** * Verifies that there are no outstanding requests that need to be flushed. From d11a1c562bae120d910d3542552285e5a142fbb1 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 09:46:36 +0900 Subject: [PATCH 031/248] Update some definitions based on history v2 --- react-router/index.d.ts | 13 +++++++++++++ react-router/lib/Router.d.ts | 4 +++- react-router/lib/createMemoryHistory.d.ts | 3 ++- react-router/lib/useRouterHistory.d.ts | 5 +++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 8398838aef..2b10a4cbcb 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -3,6 +3,19 @@ // Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/* Replacement from old history definitions */ +export interface HistoryOptions { + getCurrentLocation?(): Location; + getUserConfirmation?(message: string, callback: (result: boolean) => void): void; + pushLocation?(nextLocation: Location): void; + replaceLocation?(nextLocation: Location): void; + go?(n: number): void; + keyLength?: number; +} + +export type CreateHistory = (options?: HistoryOptions) => T; +export type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory; + export { Basename, ChangeHook, diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index 160694953f..dbd2d43fff 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -1,5 +1,6 @@ import { Component, ComponentClass, ClassAttributes, ReactNode, StatelessComponent } from "react"; import { + Action, Hash, History, Href, @@ -11,12 +12,13 @@ import { } from "history"; import { PlainRoute } from "react-router"; +/* Replacement from old history definitions */ export type Basename = string; export type Query = any; -export type Action = "PUSH" | "REPLACE" | "POP"; export interface Params { [key: string]: string; } + export type RoutePattern = string; export type RouteComponent = ComponentClass | StatelessComponent; export interface RouteComponents { diff --git a/react-router/lib/createMemoryHistory.d.ts b/react-router/lib/createMemoryHistory.d.ts index bb2fed561b..038e707e6b 100644 --- a/react-router/lib/createMemoryHistory.d.ts +++ b/react-router/lib/createMemoryHistory.d.ts @@ -1,4 +1,5 @@ -import { History, CreateHistory } from "history"; +import { History } from "history"; +import { CreateHistory } from "react-router"; declare const createMemoryHistory: CreateHistory; diff --git a/react-router/lib/useRouterHistory.d.ts b/react-router/lib/useRouterHistory.d.ts index 1371baa07b..7dc2bdd3ab 100644 --- a/react-router/lib/useRouterHistory.d.ts +++ b/react-router/lib/useRouterHistory.d.ts @@ -1,5 +1,6 @@ -import { History, CreateHistoryEnhancer } from "history"; +import { History } from "history"; +import { CreateHistoryEnhancer } from "react-router"; -declare const useRouterHistory: CreateHistoryEnhancer; +declare const useRouterHistory: CreateHistoryEnhancer; export default useRouterHistory; From 5ce5e784689f0ddccc1e7cdba6df700f2f435cef Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 10:15:36 +0900 Subject: [PATCH 032/248] Remove unnecessary files, add tsconfig for old version --- react-router/index.d.ts.orig | 109 ---------- react-router/lib/Route.d.ts.orig | 49 ----- react-router/lib/Router.d.ts.orig | 213 -------------------- react-router/lib/useRouterHistory.d.ts.orig | 10 - react-router/lib/withRouter.d.ts.orig | 14 -- react-router/v2/tsconfig.json | 27 +++ 6 files changed, 27 insertions(+), 395 deletions(-) delete mode 100644 react-router/index.d.ts.orig delete mode 100644 react-router/lib/Route.d.ts.orig delete mode 100644 react-router/lib/Router.d.ts.orig delete mode 100644 react-router/lib/useRouterHistory.d.ts.orig delete mode 100644 react-router/lib/withRouter.d.ts.orig create mode 100644 react-router/v2/tsconfig.json diff --git a/react-router/index.d.ts.orig b/react-router/index.d.ts.orig deleted file mode 100644 index 52227f4d95..0000000000 --- a/react-router/index.d.ts.orig +++ /dev/null @@ -1,109 +0,0 @@ -<<<<<<< HEAD -// Type definitions for react-router 3.0 -======= -// Type definitions for react-router 2.0 ->>>>>>> upstream/master -// Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Karol Janyst -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/* Replacement from old history definitions */ -export interface HistoryOptions { - getCurrentLocation?(): Location; - getUserConfirmation?(message: string, callback: (result: boolean) => void): void; - pushLocation?(nextLocation: Location): void; - replaceLocation?(nextLocation: Location): void; - go?(n: number): void; - keyLength?: number; -} - -export type CreateHistory = (options?: HistoryOptions) => T; -export type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory; - -<<<<<<< HEAD -export { - Basename, - ChangeHook, - EnterHook, - InjectedRouter, - LeaveHook, - Location, - LocationDescriptor, - ParseQueryString, - RouteComponent, - RouteComponents, - RouteComponentProps, - RouteConfig, - RoutePattern, - RouterProps, - RouterState, - StringifyQuery, - Query -} from "react-router/lib/Router"; -export { LinkProps } from "react-router/lib/Link"; -export { IndexLinkProps } from "react-router/lib/IndexLink"; -export { RouteProps, PlainRoute } from "react-router/lib/Route"; -export { IndexRouteProps } from "react-router/lib/IndexRoute"; -export { RedirectProps } from "react-router/lib/Redirect"; -export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; -======= -import * as React from 'react'; - -export const routerShape: React.Requireable; - -export const locationShape: React.Requireable; - -import Router from "./lib/Router"; -import Link from "./lib/Link"; -import IndexLink from "./lib/IndexLink"; -import IndexRedirect from "./lib/IndexRedirect"; -import IndexRoute from "./lib/IndexRoute"; -import Redirect from "./lib/Redirect"; -import Route from "./lib/Route"; -import * as History from "./lib/routerHistory"; -import Lifecycle from "./lib/Lifecycle"; -import RouteContext from "./lib/RouteContext"; -import browserHistory from "./lib/browserHistory"; -import hashHistory from "./lib/hashHistory"; -import useRoutes from "./lib/useRoutes"; -import { createRoutes } from "./lib/RouteUtils"; -import { formatPattern } from "./lib/PatternUtils"; -import RouterContext from "./lib/RouterContext"; -import PropTypes from "./lib/PropTypes"; -import match from "./lib/match"; -import useRouterHistory from "./lib/useRouterHistory"; -import createMemoryHistory from "./lib/createMemoryHistory"; -import withRouter from "./lib/withRouter"; -import applyRouterMiddleware from "./lib/applyRouterMiddleware"; - -// PlainRoute is defined in the API documented at: -// https://github.com/rackt/react-router/blob/master/docs/API.md -// but not included in any of the .../lib modules above. -export type PlainRoute = Router.PlainRoute; ->>>>>>> upstream/master - -/* components */ -export { default as Router } from "react-router/lib/Router"; -export { default as Link } from "react-router/lib/Link"; -export { default as IndexLink } from "react-router/lib/IndexLink"; -export { default as withRouter } from "react-router/lib/withRouter"; - -/* components (configuration) */ -export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; -export { default as IndexRoute } from "react-router/lib/IndexRoute"; -export { default as Redirect } from "react-router/lib/Redirect"; -export { default as Route } from "react-router/lib/Route"; - -/* utils */ -export { createRoutes } from "react-router/lib/RouteUtils"; -export { default as RouterContext } from "react-router/lib/RouterContext"; -export { routerShape, locationShape } from "react-router/lib/PropTypes"; -export { default as match } from "react-router/lib/match"; -export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; -export { formatPattern } from "react-router/lib/PatternUtils"; -export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; - -/* histories */ -export { default as browserHistory } from "react-router/lib/browserHistory"; -export { default as hashHistory } from "react-router/lib/hashHistory"; -export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; diff --git a/react-router/lib/Route.d.ts.orig b/react-router/lib/Route.d.ts.orig deleted file mode 100644 index c8a211517c..0000000000 --- a/react-router/lib/Route.d.ts.orig +++ /dev/null @@ -1,49 +0,0 @@ -import { ComponentClass, ClassAttributes } from "react"; -import { LocationState } from "history"; -import { - EnterHook, - ChangeHook, - LeaveHook, - RouteComponent, - RouteComponents, - RoutePattern, - RouterState -} from "react-router"; -import { IndexRouteProps } from "react-router/lib/IndexRoute"; - -export interface RouteProps extends IndexRouteProps { - path?: RoutePattern; -} - -type Route = ComponentClass; -declare const Route: Route; - -<<<<<<< HEAD -export default Route; - -type RouteCallback = (err: any, route: PlainRoute) => void; -type RoutesCallback = (err: any, routesArray: PlainRoute[]) => void; - -export interface PlainRoute extends RouteProps { - childRoutes?: PlainRoute[]; - getChildRoutes?(partialNextState: LocationState, callback: RoutesCallback): void; - indexRoute?: PlainRoute; - getIndexRoute?(partialNextState: LocationState, callback: RouteCallback): void; -} -======= - interface RouteProps extends React.Props { - path?: Router.RoutePattern; - component?: Router.RouteComponent; - components?: Router.RouteComponents; - getComponent?: (nextState: Router.RouterState, cb: (error: any, component?: Router.RouteComponent) => void) => void; - getComponents?: (nextState: Router.RouterState, cb: (error: any, components?: Router.RouteComponents) => void) => void; - onEnter?: Router.EnterHook; - onLeave?: Router.LeaveHook; - onChange?: Router.ChangeHook; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: Router.RouteConfig) => void) => void; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: Router.RouteConfig) => void) => void; - } - interface Route extends React.ComponentClass {} - interface RouteElement extends React.ReactElement {} -} ->>>>>>> upstream/master diff --git a/react-router/lib/Router.d.ts.orig b/react-router/lib/Router.d.ts.orig deleted file mode 100644 index 8b77e41bdf..0000000000 --- a/react-router/lib/Router.d.ts.orig +++ /dev/null @@ -1,213 +0,0 @@ -import { Component, ComponentClass, ClassAttributes, ReactNode, StatelessComponent } from "react"; -import { - Action, - Hash, - History, - Href, - LocationKey, - LocationState, - Path, - Pathname, - Search -} from "history"; -import { PlainRoute } from "react-router"; - -/* Replacement from old history definitions */ -export type Basename = string; -export type Query = any; -export interface Params { - [key: string]: string; -} - -export type RoutePattern = string; -export type RouteComponent = ComponentClass | StatelessComponent; -export interface RouteComponents { - [name: string]: RouteComponent; -} -export type RouteConfig = ReactNode | PlainRoute | PlainRoute[]; - -export type ParseQueryString = (queryString: Search) => Query; -export type StringifyQuery = (queryObject: Query) => Search; - -type AnyFunction = (...args: any[]) => any; - -export type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; -export type LeaveHook = (prevState: RouterState) => any; -export type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback?: AnyFunction) => any; -export type RouteHook = (nextLocation?: Location) => any; - -<<<<<<< HEAD -export interface Location { - patname: Pathname; - search: Search; - query: Query; - state: LocationState; - action: Action; - key: LocationKey; -======= -// types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md - -declare namespace Router { - type RouteConfig = React.ReactNode | PlainRoute | PlainRoute[]; - type RoutePattern = string; - interface RouteComponents { [key: string]: RouteComponent; } - - type ParseQueryString = (queryString: QueryString) => Query; - type StringifyQuery = (queryObject: Query) => QueryString; - - type Component = React.ReactType; - type RouteComponent = Component; - - type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void; - type LeaveHook = () => void; - type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void; - type RouteHook = (nextLocation?: Location) => any; - - interface Params { [param: string]: string; } - - type RouterListener = (error: Error, nextState: RouterState) => void; - - interface LocationDescriptor { - pathname?: Pathname; - query?: Query; - hash?: Href; - state?: HLocationState; - } - - interface RedirectFunction { - (location: LocationDescriptor): void; - /** - * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated - */ - (state: HLocationState, pathname: Pathname | Path, query?: Query): void; - } - - interface RouterState { - location: Location; - routes: PlainRoute[]; - params: Params; - components: RouteComponent[]; - } - - interface RouterProps extends React.Props { - history?: History; - routes?: RouteConfig; // alias for children - createElement?: (component: RouteComponent, props: Object) => any; - onError?: (error: any) => any; - onUpdate?: () => any; - parseQueryString?: ParseQueryString; - stringifyQuery?: StringifyQuery; - basename?: string; - render?: (renderProps: React.Props<{}>) => RouterContext; - } - - interface PlainRoute { - path?: RoutePattern; - component?: RouteComponent; - components?: RouteComponents; - getComponent?: (location: Location, cb: (error: any, component?: RouteComponent) => void) => void; - getComponents?: (location: Location, cb: (error: any, components?: RouteComponents) => void) => void; - onEnter?: EnterHook; - onLeave?: LeaveHook; - indexRoute?: PlainRoute; - getIndexRoute?: (location: Location, cb: (error: any, indexRoute: RouteConfig) => void) => void; - childRoutes?: PlainRoute[]; - getChildRoutes?: (location: Location, cb: (error: any, childRoutes: RouteConfig) => void) => void; - } - - interface RouteComponentProps { - history?: History; - location?: Location; - params?: P; - route?: PlainRoute; - routeParams?: R; - routes?: PlainRoute[]; - children?: React.ReactElement; - } - - interface RouterOnContext extends History { - setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void; - isActive(pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean): boolean; - } - - // Wrap a component using withRouter(Component) to provide a router object - // to the Component's props, allowing the Component to programmatically call - // push and other functions. - // - // https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md - - interface InjectedRouter { - push: (pathOrLoc: Path | LocationDescriptor) => void; - replace: (pathOrLoc: Path | LocationDescriptor) => void; - go: (n: number) => void; - goBack: () => void; - goForward: () => void; - setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void; - createPath(path: History.Path, query?: History.Query): History.Path; - createHref(path: History.Path, query?: History.Query): History.Href; - isActive: (pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean) => boolean; - } ->>>>>>> upstream/master -} - -export interface LocationDescriptorObject { - pathname?: Pathname; - query?: Query; - hash?: Hash; - state?: LocationState; -} - -export type LocationDescriptor = Path | LocationDescriptorObject; - -export interface RedirectFunction { - (location: LocationDescriptor): void; - (state: LocationState, pathname: Pathname | Path, query?: Query): void; -} - -export interface RouterState { - location: Location; - routes: PlainRoute[]; - params: Params; - components: RouteComponent[]; -} - -type LocationFunction = (location: LocationDescriptor) => void; -type GoFunction = (n: number) => void; -type NavigateFunction = () => void; -type ActiveFunction = (location: LocationDescriptor, indexOnly?: boolean) => boolean; -type LeaveHookFunction = (route: any, callback: RouteHook) => void; -type CreatePartFunction = (path: Path, query?: any) => Part; - -export interface InjectedRouter { - push: LocationFunction; - replace: LocationFunction; - go: GoFunction; - goBack: NavigateFunction; - goForward: NavigateFunction; - setRouteLeaveHook: LeaveHookFunction; - createPath: CreatePartFunction; - createHref: CreatePartFunction; - isActive: ActiveFunction; -} - -export interface RouteComponentProps { - location?: Location; - params?: P & R; - route?: PlainRoute; - router?: InjectedRouter; - routeParams?: R; -} - -export interface RouterProps extends ClassAttributes { - routes?: RouteConfig; - history?: History; - createElement?(component: RouteComponent, props: any): any; - onError?(error: any): any; - onUpdate?(): any; - render?(props: any): ReactNode; -} - -type Router = ComponentClass; -declare const Router: Router; - -export default Router; diff --git a/react-router/lib/useRouterHistory.d.ts.orig b/react-router/lib/useRouterHistory.d.ts.orig deleted file mode 100644 index 01609c5a48..0000000000 --- a/react-router/lib/useRouterHistory.d.ts.orig +++ /dev/null @@ -1,10 +0,0 @@ -import { History } from "history"; -import { CreateHistoryEnhancer } from "react-router"; - -<<<<<<< HEAD -declare const useRouterHistory: CreateHistoryEnhancer; - -export default useRouterHistory; -======= -export default function useRouterHistory(createHistory: CreateHistory): (options?: HistoryOptions) => History & HistoryQueries; ->>>>>>> upstream/master diff --git a/react-router/lib/withRouter.d.ts.orig b/react-router/lib/withRouter.d.ts.orig deleted file mode 100644 index ab51b2111e..0000000000 --- a/react-router/lib/withRouter.d.ts.orig +++ /dev/null @@ -1,14 +0,0 @@ -import { ComponentClass, StatelessComponent } from "react"; - -<<<<<<< HEAD -interface Options { - withRef?: boolean; -} - -type ComponentConstructor

= ComponentClass

| StatelessComponent

; - -export default function withRouter

(component: ComponentConstructor

, options?: Options): ComponentClass

; -======= -declare function withRouter | React.StatelessComponent | React.PureComponent>(component: C): C; -export default withRouter; ->>>>>>> upstream/master diff --git a/react-router/v2/tsconfig.json b/react-router/v2/tsconfig.json new file mode 100644 index 0000000000..7cc347abc4 --- /dev/null +++ b/react-router/v2/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "history": ["history/v2"], + "react-router": ["react-router/v2"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-redux-tests.ts" + ] +} From f49ca4f7ab7ee036e3aa1deab3558758c70326f0 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 11:13:06 +0900 Subject: [PATCH 033/248] Update react-router-bootstrap definitions --- react-router-bootstrap/index.d.ts | 44 ++----------------- .../lib/IndexLinkContainer.d.ts | 7 +++ react-router-bootstrap/lib/LinkContainer.d.ts | 7 +++ react-router-bootstrap/tsconfig.json | 3 -- 4 files changed, 18 insertions(+), 43 deletions(-) create mode 100644 react-router-bootstrap/lib/IndexLinkContainer.d.ts create mode 100644 react-router-bootstrap/lib/LinkContainer.d.ts diff --git a/react-router-bootstrap/index.d.ts b/react-router-bootstrap/index.d.ts index b4b36006ec..c414d8f3b0 100644 --- a/react-router-bootstrap/index.d.ts +++ b/react-router-bootstrap/index.d.ts @@ -1,43 +1,7 @@ -// Type definitions for react-router-bootstrap +// Type definitions for react-router-bootstrap 0.23 // Project: https://github.com/react-bootstrap/react-router-bootstrap -// Definitions by: Vincent Lesierse +// Definitions by: Vincent Lesierse , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// - -declare namespace ReactRouterBootstrap { - interface LinkContainerProps extends ReactRouter.LinkProps { - disabled?: boolean - } - interface LinkContainer extends React.ComponentClass {} - interface LinkContainerElement extends React.ReactElement {} - const LinkContainer: LinkContainer - - const IndexLinkContainer: LinkContainer -} - -declare module "react-router-bootstrap/lib/LinkContainer" { - - export default ReactRouterBootstrap.LinkContainer - -} - -declare module "react-router-bootstrap/lib/IndexLinkContainer" { - - export default ReactRouterBootstrap.IndexLinkContainer - -} - -declare module "react-router-bootstrap" { - - import LinkContainer from "react-router-bootstrap/lib/LinkContainer" - - import IndexLinkContainer from "react-router-bootstrap/lib/IndexLinkContainer" - - export { - LinkContainer, - IndexLinkContainer - } - -} +export { default as LinkContainer } from "react-router-bootstrap/lib/LinkContainer" +export { default as IndexLinkContainer } from "react-router-bootstrap/lib/IndexLinkContainer" diff --git a/react-router-bootstrap/lib/IndexLinkContainer.d.ts b/react-router-bootstrap/lib/IndexLinkContainer.d.ts new file mode 100644 index 0000000000..045edc1fde --- /dev/null +++ b/react-router-bootstrap/lib/IndexLinkContainer.d.ts @@ -0,0 +1,7 @@ +import { ComponentClass } from "react"; +import { IndexLinkProps } from "react-router/lib/IndexLink"; + +type IndexLinkContainer = ComponentClass; +declare const IndexLinkContainer: IndexLinkContainer; + +export default IndexLinkContainer; diff --git a/react-router-bootstrap/lib/LinkContainer.d.ts b/react-router-bootstrap/lib/LinkContainer.d.ts new file mode 100644 index 0000000000..df5ac3cbdb --- /dev/null +++ b/react-router-bootstrap/lib/LinkContainer.d.ts @@ -0,0 +1,7 @@ +import { ComponentClass } from "react"; +import { LinkProps } from "react-router/lib/Link"; + +type LinkContainer = ComponentClass; +declare const LinkContainer: LinkContainer; + +export default LinkContainer; diff --git a/react-router-bootstrap/tsconfig.json b/react-router-bootstrap/tsconfig.json index 7e111b1004..ecee2cb765 100644 --- a/react-router-bootstrap/tsconfig.json +++ b/react-router-bootstrap/tsconfig.json @@ -10,9 +10,6 @@ "strictNullChecks": false, "jsx": "preserve", "baseUrl": "../", - "paths": { - "history": ["history/v2"] - }, "typeRoots": [ "../" ], From 4b89363df8ae1f1da5edba6f365c8c0a50d2d3f5 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 11:17:58 +0900 Subject: [PATCH 034/248] Fix tsconfig files --- react-router-bootstrap/tsconfig.json | 3 +++ react-router/tsconfig.json | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/react-router-bootstrap/tsconfig.json b/react-router-bootstrap/tsconfig.json index ecee2cb765..2fc57383ed 100644 --- a/react-router-bootstrap/tsconfig.json +++ b/react-router-bootstrap/tsconfig.json @@ -17,6 +17,9 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, + "include": [ + "lib/*.d.ts" + ], "files": [ "index.d.ts", "react-router-bootstrap-tests.tsx" diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index 8e5f5d47b6..e06f11b4a3 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -1,8 +1,4 @@ { - "files": [ - "index.d.ts", - "react-router-tests.tsx" - ], "compilerOptions": { "module": "commonjs", "lib": [ @@ -20,5 +16,12 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true - } + }, + "include": [ + "lib/*.d.ts" + ], + "files": [ + "index.d.ts", + "react-router-tests.tsx" + ], } From 2bef57bed0b9d40a708e845f52ca30cb2374b9c2 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 11:22:18 +0900 Subject: [PATCH 035/248] Fix react-router tsconfig --- react-router/tsconfig.json | 2 +- react-router/tslint.json | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index e06f11b4a3..d13560189e 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -23,5 +23,5 @@ "files": [ "index.d.ts", "react-router-tests.tsx" - ], + ] } diff --git a/react-router/tslint.json b/react-router/tslint.json index e050abdce9..f9e30021f4 100644 --- a/react-router/tslint.json +++ b/react-router/tslint.json @@ -1,7 +1,3 @@ { - "extends": "../tslint.json", - "rules": { - "forbidden-types": false, - "no-empty-interface": false - } -} \ No newline at end of file + "extends": "../tslint.json" +} From 3ce2018675b0606bd4149c59e602f64219f2535a Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 12:12:31 +0900 Subject: [PATCH 036/248] Change include to files in tsconfig --- react-router-bootstrap/tsconfig.json | 5 ++--- react-router/tsconfig.json | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/react-router-bootstrap/tsconfig.json b/react-router-bootstrap/tsconfig.json index 2fc57383ed..1760fc3f1a 100644 --- a/react-router-bootstrap/tsconfig.json +++ b/react-router-bootstrap/tsconfig.json @@ -17,11 +17,10 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "include": [ - "lib/*.d.ts" - ], "files": [ "index.d.ts", + "lib/IndexLinkContainer.d.ts", + "lib/LinkContainer.d.ts", "react-router-bootstrap-tests.tsx" ] } diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index d13560189e..c013e2c959 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -17,11 +17,26 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "include": [ - "lib/*.d.ts" - ], "files": [ "index.d.ts", + "lib/applyRouterMiddleware.d.ts", + "lib/browserHistory.d.ts", + "lib/createMemoryHistory.d.ts", + "lib/hashHistory.d.ts", + "lib/IndexLink.d.ts", + "lib/IndexRedirect.d.ts", + "lib/IndexRoute.d.ts", + "lib/Link.d.ts", + "lib/match.d.ts", + "lib/PatternUtils.d.ts", + "lib/PropTypes.d.ts", + "lib/Redirect.d.ts", + "lib/Route.d.ts", + "lib/Router.d.ts", + "lib/RouterContext.d.ts", + "lib/RouteUtils.d.ts", + "lib/useRouterHistory.d.ts", + "lib/withRouter.d.ts", "react-router-tests.tsx" ] } From ab95e31c3f86178515ec6450b50f5d80feaef881 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 19 Jan 2017 12:40:16 +0900 Subject: [PATCH 037/248] Remove test file from v2 tsconfig --- react-router/v2/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/react-router/v2/tsconfig.json b/react-router/v2/tsconfig.json index 7cc347abc4..c92402947c 100644 --- a/react-router/v2/tsconfig.json +++ b/react-router/v2/tsconfig.json @@ -21,7 +21,6 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "react-router-redux-tests.ts" + "index.d.ts" ] } From 2b5726e1b8f69514afd202e78c967e5cc6bac54a Mon Sep 17 00:00:00 2001 From: karak Date: Thu, 19 Jan 2017 15:19:50 +0900 Subject: [PATCH 038/248] [material-ui] Fixed muiThemeable on decorator usage #9843 --- material-ui/index.d.ts | 5 ++++- material-ui/material-ui-tests.tsx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/material-ui/index.d.ts b/material-ui/index.d.ts index 716505987d..f60bb7e7ae 100644 --- a/material-ui/index.d.ts +++ b/material-ui/index.d.ts @@ -452,7 +452,10 @@ declare namespace __MaterialUI { var lightBaseTheme: RawTheme; var darkBaseTheme: RawTheme; - export function muiThemeable, P, S>(): (component: TComponent) => TComponent; + export function muiThemeable(): < + TComponent extends React.ComponentClass

| React.StatelessComponent

, + P extends {muiTheme?: MuiTheme} + >(component: TComponent) => TComponent; interface MuiThemeProviderProps { muiTheme?: Styles.MuiTheme; diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index 04b8f0ec32..8dcc0fe07e 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -7,6 +7,7 @@ import * as React from 'react'; import {Component, PropTypes} from 'react'; import * as ReactDOM from 'react-dom'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; +import {muiThemeable} from 'material-ui/styles/muiThemeable'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme'; import {MuiTheme} from 'material-ui/styles'; @@ -321,6 +322,35 @@ class DeepDownTheTree extends React.Component<{} & {muiTheme: MuiTheme}, {}> { } +const MuiThemeableFunction = muiThemeable()((props: {label: string, muiTheme?: MuiTheme}) => { + return ( + + Applied the Theme to functional component: {props.label}. + + ); +}); + +@muiThemeable() +class MuiThemeableClass extends React.Component<{label: string} & {muiTheme?: MuiTheme}, {}> { + render() { + return ( + + Applied the Theme to class component decorated: {this.props.label}. + + ); + } +} + +const MuiThemeableContainer = (props: {}) => ( + +

+ + +
+ +); + + // "http://www.material-ui.com/#/customization/inline-styles" const InlineStylesCheckbox = () => ( Date: Thu, 19 Jan 2017 11:23:27 +0100 Subject: [PATCH 039/248] Add user object to Express.Request The JWT authentication middleware authenticates callers using a JWT. If the token is valid, req.user will be set with the JSON object decoded to be used by later middleware for authorization and access control. --- express-jwt/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/express-jwt/index.d.ts b/express-jwt/index.d.ts index e721094edc..edffeb9632 100644 --- a/express-jwt/index.d.ts +++ b/express-jwt/index.d.ts @@ -37,3 +37,10 @@ declare namespace jwt { unless?: typeof unless; } } +declare global { + namespace Express { + export interface Request { + user?: any + } + } +} From fac57d46263790b607f28881422aa9aac55d750c Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Thu, 19 Jan 2017 16:00:50 +0100 Subject: [PATCH 040/248] Fix a small issue withing the multer typing --- multer/index.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/multer/index.d.ts b/multer/index.d.ts index 2437f498db..1e388f7630 100644 --- a/multer/index.d.ts +++ b/multer/index.d.ts @@ -48,22 +48,22 @@ declare namespace multer { /** A function used to determine within which folder the uploaded files should be stored. Defaults to the system's default temporary directory. */ destination?: string | ((req: Express.Request, file: Express.Multer.File, callback: (error: Error, destination: string) => void) => void); /** A function used to determine what the file should be named inside the folder. Defaults to a random name with no file extension. */ - filename?: (req: Express.Request, file: Express.Multer.File, callback: (error: Error, filename: string) => void) => void; + filename?: (req: Express.Request, file: Express.Multer.File, callback: (error?: Error, filename?: string) => void) => void; } interface Instance { - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - single(): express.RequestHandler; - /** Accept a single file with the name fieldname. The single file will be stored in req.file. */ - single(fieldame: string): express.RequestHandler; - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - array(): express.RequestHandler; - /** Accept an array of files, all with the name fieldname. Optionally error out if more than maxCount files are uploaded. The array of files will be stored in req.files. */ - array(fieldame: string, maxCount?: number): express.RequestHandler; - /** Accept a mix of files, specified by fields. An object with arrays of files will be stored in req.files. */ - fields(fields: Field[]): express.RequestHandler; - /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ - any(): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + single(): express.RequestHandler; + /** Accept a single file with the name fieldname. The single file will be stored in req.file. */ + single(fieldame: string): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + array(): express.RequestHandler; + /** Accept an array of files, all with the name fieldname. Optionally error out if more than maxCount files are uploaded. The array of files will be stored in req.files. */ + array(fieldame: string, maxCount?: number): express.RequestHandler; + /** Accept a mix of files, specified by fields. An object with arrays of files will be stored in req.files. */ + fields(fields: Field[]): express.RequestHandler; + /** In case you need to handle a text-only multipart form, you can use any of the multer methods (.single(), .array(), fields()), req.body contains the text fields */ + any(): express.RequestHandler; } } From c779cebd7f18a885b1e956020d884438c1e5566e Mon Sep 17 00:00:00 2001 From: Jonathan Jayet Date: Thu, 19 Jan 2017 16:07:39 +0100 Subject: [PATCH 041/248] Better typing yet --- multer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multer/index.d.ts b/multer/index.d.ts index 1e388f7630..53fdcd7add 100644 --- a/multer/index.d.ts +++ b/multer/index.d.ts @@ -48,7 +48,7 @@ declare namespace multer { /** A function used to determine within which folder the uploaded files should be stored. Defaults to the system's default temporary directory. */ destination?: string | ((req: Express.Request, file: Express.Multer.File, callback: (error: Error, destination: string) => void) => void); /** A function used to determine what the file should be named inside the folder. Defaults to a random name with no file extension. */ - filename?: (req: Express.Request, file: Express.Multer.File, callback: (error?: Error, filename?: string) => void) => void; + filename?: (req: Express.Request, file: Express.Multer.File, callback: (error: Error | null, filename: string) => void) => void; } interface Instance { From e76c78bd71ea47bb417a853950844b9b320b86f9 Mon Sep 17 00:00:00 2001 From: Sergei Dorogin Date: Thu, 19 Jan 2017 21:26:35 +0300 Subject: [PATCH 042/248] jquery.fileupload added JQueryFileUploadXhr.headers field --- jquery.fileupload/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery.fileupload/index.d.ts b/jquery.fileupload/index.d.ts index 8eba9853b2..54ebb89c5c 100644 --- a/jquery.fileupload/index.d.ts +++ b/jquery.fileupload/index.d.ts @@ -284,6 +284,7 @@ interface JQueryFileUploadXhr { jqXHR: JQueryXHR; result: any; textStatus: string; + headers: {[key: string]: any}; } interface JQueryFileUploadFilesObject { From a4dec0334cc80b0f943f114770945bb154f9364d Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Fri, 20 Jan 2017 09:03:18 +0900 Subject: [PATCH 043/248] Fix react-breadcrumbs --- react-breadcrumbs/index.d.ts | 23 +++++++++-------------- react-breadcrumbs/tsconfig.json | 3 ++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/react-breadcrumbs/index.d.ts b/react-breadcrumbs/index.d.ts index 1d247f215d..67f1a89090 100644 --- a/react-breadcrumbs/index.d.ts +++ b/react-breadcrumbs/index.d.ts @@ -1,13 +1,17 @@ -// Type definitions for react-breadcrumbs 1.3.16 +// Type definitions for react-breadcrumbs 1.3 // Project: https://github.com/svenanders/react-breadcrumbs // Definitions by: Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// +import * as React from "react"; +import * as ReactRouter from "react-router"; -declare namespace ReactBreadcrumbs { - interface BreadcrumbsProps extends React.Props { +export = Breadcrumbs; +type Breadcrumbs = React.ComponentClass; +declare const Breadcrumbs: Breadcrumbs; + +declare namespace Breadcrumbs { + interface Props extends React.ClassAttributes { separator?: string | JSX.Element; displayMissing?: boolean; prettify?: boolean; @@ -26,13 +30,4 @@ declare namespace ReactBreadcrumbs { setDocumentTitle?: boolean; params?: any; // todo make it compatible with params of the ReactRouter.RouteComponentProps } - - interface Breadcrumbs extends React.ComponentClass {} - const Breadcrumbs: Breadcrumbs; -} - -declare module 'react-breadcrumbs' { - import Breadcrumbs = ReactBreadcrumbs.Breadcrumbs; - - export = Breadcrumbs; } diff --git a/react-breadcrumbs/tsconfig.json b/react-breadcrumbs/tsconfig.json index 0092616bce..d1a0ccc542 100644 --- a/react-breadcrumbs/tsconfig.json +++ b/react-breadcrumbs/tsconfig.json @@ -10,7 +10,8 @@ "strictNullChecks": false, "baseUrl": "../", "paths": { - "history": ["history/v2"] + "history": ["history/v2"], + "react-router": ["react-router/v2"] }, "typeRoots": [ "../" From 848999f5764d0a4af62ad49ee12ea6de80bcde51 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Fri, 20 Jan 2017 09:28:08 +0900 Subject: [PATCH 044/248] Add path mapping to react-i18next --- react-i18next/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/react-i18next/tsconfig.json b/react-i18next/tsconfig.json index bba519bbd3..5936e04b91 100644 --- a/react-i18next/tsconfig.json +++ b/react-i18next/tsconfig.json @@ -11,7 +11,8 @@ "baseUrl": "../", "paths": { "history": ["history/v2"], - "history/*": ["history/v2/*"] + "history/*": ["history/v2/*"], + "react-router": ["react-router/v2"], }, "typeRoots": [ "../" From 567657e3fab839bdeb535ea23c6593cbc8ce7588 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Thu, 19 Jan 2017 15:29:50 +0300 Subject: [PATCH 045/248] Added types for SIP.js --- SIP.js/SIP.js-tests.ts | 99 ++++++++++++ SIP.js/index.d.ts | 354 +++++++++++++++++++++++++++++++++++++++++ SIP.js/tsconfig.json | 23 +++ SIP.js/tslint.json | 1 + 4 files changed, 477 insertions(+) create mode 100644 SIP.js/SIP.js-tests.ts create mode 100644 SIP.js/index.d.ts create mode 100644 SIP.js/tsconfig.json create mode 100644 SIP.js/tslint.json diff --git a/SIP.js/SIP.js-tests.ts b/SIP.js/SIP.js-tests.ts new file mode 100644 index 0000000000..f688fe67ae --- /dev/null +++ b/SIP.js/SIP.js-tests.ts @@ -0,0 +1,99 @@ +import SIP = require("./index"); + +let ua: SIP.UA = new SIP.UA(); + +const mediaHandler = (session: SIP.Session, options: SIP.WebRTC.Options) => new SIP.WebRTC.MediaHandler(); +const logConnector = (level: string, category: string, label: string, content: string) => null; + +const uaWithConfig: SIP.UA = new SIP.UA({ + uri: "wss://uri", + wsServers: ["s1", "s2"], + allowLegacyNotifications: true, + authenticationFactory: mediaHandler, + authorizationUser: "user", + autostart: true, + connectionRecoveryMaxInterval: 1, + connectionRecoveryMinInterval: 1, + displayName: "name", + hackCleanJitsiSdpImageattr: true, + hackStripTcp: true, + hackIpInContact: true, + hackViaTcp: true, + hackWssInTransport: true, + iceCheckingTimeout: 1, + instanceId: "id", + log: { + builtinEnabled: true, + level: 1, + connector: logConnector + }, + mediaHandlerFactory: mediaHandler, + noAnswerTimeout: 1, + password: "", + register: true, + registerExpires: 1, + registrarServer: "sip:registrar.mydomain.com", + rel100: "", + replaces: "", + stunServers: ["", ""], + turnServers: [ + { + password: "", + username: "", + urls: ["", ""] + } + ], + usePreloadedRoute: true, + userAgentString: "", + wsServerMaxReconnection: 1, + wsServerReconnectionTimeout: 1 +}); + +ua.start(); +ua.stop(); + +ua.register(); +ua = ua.register({ extraHeaders: [""] }); + +ua.unregister() +ua.unregister({ extraHeaders: [""], all: true }); + +const isConnected: boolean = ua.isConnected(); +const isRegistered: boolean = ua.isRegistered(); + +const message: SIP.Message = ua.message("", "", { contentType: "" }); + +ua.subscribe("", "", { expires: 1, extraHeaders: [""]}); +const subscription: SIP.Subscription = ua.subscribe(new SIP.URI(), "", { expires: 1, extraHeaders: [""]}); + +let session = ua.invite("", new HTMLVideoElement()); + +const inviteOptions: SIP.InviteOptions = { + media: { + constraints: { audio: true, video: false }, + stream: new MediaStream(), + render: { remote: new Element(), local: new Element() }, + }, + anonymous: true, + rel100: "", + inviteWithoutSdp: true, + RTCConstraints: new RTCPeerConnection() +} + +session = ua.invite("", inviteOptions); + +ua.on('connected', (args: SIP.UA.EventArgs.ConnectedArgs) => {}); +ua.on('disconnected', () => {}); +ua.on('registered', () => {}); +ua.on('unregistered', (args: SIP.UA.EventArgs.UnregisteredArgs) => {}); +ua.on('registrationFailed', (args: SIP.UA.EventArgs.RegistrationFailedArgs) => {}); +ua.on('invite', (session: SIP.Session) => { + session.on('progress', (response) => { + }); + session.on('accepted', (response) => { + }); + session.on('rejected', (response) => { + }); + +}); +ua.on('message', (message: SIP.Message) => {}); diff --git a/SIP.js/index.d.ts b/SIP.js/index.d.ts new file mode 100644 index 0000000000..0eaabb9b48 --- /dev/null +++ b/SIP.js/index.d.ts @@ -0,0 +1,354 @@ +// Type definitions for SIP.js v0.7.6 +// Project: https://sipjs.com/ +// Definitions by: Kir Dergachev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = SIP; + +declare namespace SIP { + + class URI { + constructor( + scheme?: string, + user?: string, + host?: string, + port?: number, + parameters?: string[], + headers?: string[]); + + scheme?: string; + user?: string; + host?: string; + port?: number; + + setParam(key: string, value?: string): void; + getParam(key: string): string; + hasParam(key: string): string; + deleteParam(key: string): string; + clearParams(): void; + setHeader(name: string, value: string): void; + getHeader(name: string): string[]; + hasHeader(name: string): boolean; + deleteHeader(name: string): string[]; + clearHeaders(): void; + clone(): URI; + toString(): string; + + static parse(uri: string): URI; + } + + namespace UA.EventArgs { + interface ConnectedArgs { attempts: number } + interface UnregisteredArgs { response: string; cause: string; } + interface RegistrationFailedArgs extends UnregisteredArgs { } + } + + class UA { + constructor(configuration?: ConfigurationParameters); + start(): void; + stop(): void; + register(options?: ExtraHeadersOptions): UA; + unregister(options?: UnregisterOptions): void; + isRegistered(): boolean; + isConnected(): boolean; + message(target: string | URI, body: string, options?: MessageOptions): Message; + subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription; + invite(target: string | URI, options?: InviteOptions): Session; + invite(target: string | URI, element?: HTMLAudioElement | HTMLVideoElement): Session; + request(method: string, target: string | URI, options?: RequestOptions): ClientContext; + + on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; + on(name: 'disconnected' | 'registered', callback: () => void): void; + on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void; + on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void; + on(name: 'invite', callback: (session: Session) => void): void; + on(name: 'message', callback: (message: Message) => void): void; + } + + namespace UA.C { + class supported { + REQUIRED: string; + SUPPORTED: string; + UNSUPPORTED: string; + } + + class causes { + INVALID_TARGET: string; + CONNECTION_ERROR: string; + REQUEST_TIMEOUT: string; + SIP_FAILURE_CODE: string; + } + } + + class Session { + startTime?: Date; + endTime?: Date; + ua?: UA; + method?: string; + mediaHandler?: WebRTC.MediaHandler; + request?: IncomingRequest | OutgoingRequest; + localIdentity?: NameAddrHeader; + remoteIdentity?: NameAddrHeader; + data: ClientContext | ServerContext; + + dtmf(tone: string | number, options?: Session.DtmfOptions): Session; + terminate(options?: Session.CommonOptions): Session; + bye(options?: Session.CommonOptions): Session; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + refer(target: string | Session, options?: ExtraHeadersOptions): Session; + mute(options?: ExtraHeadersOptions): void; + unmute(options?: ExtraHeadersOptions): void; + cancel(options?: Session.CommonOptions): void; + progress(options?: Session.ProgressOptions): void; + accept(options?: Session.AcceptOptions): void; + reject(options?: Session.CommonOptions): void; + reply(options?: Session.CommonOptions): void; + followRefer(callback: Function): void; + + on(name: 'progress', callback: (response: IncomingResponse) => void): void; + on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; + on(name: 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'failed', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; + on(name: 'refer', callback: (request: IncomingRequest) => void): void; + on(name: 'cancel', callback: () => void): void; + on(name: 'replaced', callback: (newSession: Session) => void): void; + on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; + on(name: 'muted', callback: (data: Session.Muted) => void): void; + on(name: 'unmuted', callback: (data: Session.Muted) => void): void; + on(name: 'bye', callback: (request: IncomingRequest) => void): void; + } + + namespace Session { + interface DtmfOptions extends ExtraHeadersOptions { + duration?: number; + interToneGap?: number; + } + + interface CommonOptions extends ExtraHeadersOptions { + status_code?: number; + reason_phrase?: string; + body?: string; + } + + interface ProgressOptions extends ExtraHeadersOptions { + rel100?: boolean; + media?: MediaConstraints; + } + + interface AcceptOptions { + RTCConstraints?: RTCPeerConnection; + media?: MediaOptions; + } + + interface DTMF { + } + + interface Muted { + audio?: boolean; + video?: boolean + } + } + + interface RenderHint { + remote?: Element; + local?: Element + } + + interface MediaConstraints { + audio: boolean; + video: boolean; + } + + interface TurnServer { + urls?: string | string[]; + username?: string; + password?: string; + } + + namespace WebRTC { + + interface Options { + stunServers?: string | string[]; + turnServers?: TurnServer | TurnServer[]; + RTCConstraints?: RTCPeerConnection; + } + + type MediaHandlerFactory = (session: Session, options: Options) => MediaHandler; + + class MediaHandler { + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + render(renderHint: RenderHint): void; + + on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; + on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'userMediaFailed', callback: (error: string) => void): void; + on(name: 'iceGathering', callback: () => void): void; + on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; + on(name: 'iceGatheringComplete', callback: () => void): void; + on(name: 'iceConnection', callback: () => void): void; + on(name: 'iceConnectionChecking', callback: () => void): void; + on(name: 'iceConnectionConnected', callback: () => void): void; + on(name: 'iceConnectionCompleted', callback: () => void): void; + on(name: 'iceConnectionFailed', callback: () => void): void; + on(name: 'iceConnectionDisconnected', callback: () => void): void; + on(name: 'iceConnectionClosed', callback: () => void): void; + on(name: 'getDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; + on(name: 'dataChannel', callback: () => void): void; + on(name: 'addStream', callback: (stream: MediaStream) => void): void; + } + } + + /* Parameters */ + interface ConfigurationParameters { + uri?: string; + wsServers?: string | string[] | { ws_uri: string; weigth: number }[]; + allowLegacyNotifications?: boolean; + authenticationFactory?: WebRTC.MediaHandlerFactory; + authorizationUser?: string; + autostart?: boolean; + connectionRecoveryMaxInterval?: number; + connectionRecoveryMinInterval?: number; + displayName?: string; + hackCleanJitsiSdpImageattr?: boolean; + hackStripTcp?: boolean; + hackIpInContact?: boolean; + hackViaTcp?: boolean; + hackWssInTransport?: boolean; + iceCheckingTimeout?: number; + instanceId?: string; + log?: { + builtinEnabled?: boolean; + level?: number | string; + connector?: (level: string, category: string, label: string, content: string) => void; + }; + mediaHandlerFactory?: WebRTC.MediaHandlerFactory; + noAnswerTimeout?: number; + password?: string; + register?: boolean; + registerExpires?: number; + registrarServer?: string; + rel100?: string; + replaces?: string; + stunServers?: string | string[]; + traceSip?: boolean; + turnServers?: TurnServer | TurnServer[]; + usePreloadedRoute?: boolean; + userAgentString?: string; + wsServerMaxReconnection?: number; + wsServerReconnectionTimeout?: number; + } + + /* Options */ + interface ExtraHeadersOptions { + extraHeaders?: string[]; + } + + interface UnregisterOptions extends ExtraHeadersOptions { + all?: boolean; + } + + interface MessageOptions extends ExtraHeadersOptions { + contentType?: string; + } + + interface SubscribeOptions extends ExtraHeadersOptions { + expires?: number; + } + + interface MediaOptions { + constraints?: MediaConstraints; + stream?: MediaStream; + render?: RenderHint; + } + + interface InviteOptions extends ExtraHeadersOptions { + media?: MediaOptions; + anonymous?: boolean; + rel100?: string; + inviteWithoutSdp?: boolean; + RTCConstraints?: RTCPeerConnection; + } + + interface RequestOptions extends ExtraHeadersOptions { + body?: string; + } + + /* Contexts */ + interface Message extends ClientContext { + body: string; + } + + interface Subscription extends ClientContext { + id: string; + state: string; + event: string; + dialog: string; + timers: Object; + errorCodes: number[]; + subscribe(): Subscription; + unsubscribe(): void; + close(): void; + } + + /* Context */ + interface Context { + ua: UA; + method: string; + request: OutgoingRequest; + localIdentity: NameAddrHeader; + remoteIdentity: NameAddrHeader; + data: {}; + + on(name: 'progress', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'accepted', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'rejected', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'failed', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'notify', callback: (request: IncomingRequest) => void): void; + } + + interface ClientContext extends Context { + cancel(options?: { status_code?: number, reason_phrase?: string }): ClientContext; + } + + interface ServerContext extends Context { + progress(options?: Session.ProgressOptions): void; + accept(options?: Session.AcceptOptions): void; + reject(options?: Session.CommonOptions): void; + reply(options?: Session.CommonOptions): void; + } + + /* Request */ + interface Request extends Context { + } + + interface IncomingRequest extends Request { + } + + interface OutgoingRequest extends Request { + } + + interface IncomingResponse extends Request { + } + + interface IncomingMessage extends Request { + } + + /* Header */ + class NameAddrHeader { + constructor(uri: string | URI, displayName: string, parameters: { key: string, value: string }[]); + + uri: string | URI; + displayName: string; + + setParam(key: string, value?: string): void; + getParam(key: string): string; + deleteParam(key: string): string; + clearParams(): void; + + static parse(name_addr_header: string): NameAddrHeader; + } +} diff --git a/SIP.js/tsconfig.json b/SIP.js/tsconfig.json new file mode 100644 index 0000000000..93cce57ffb --- /dev/null +++ b/SIP.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": ["webrtc"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "SIP.js-tests.ts" + ] +} diff --git a/SIP.js/tslint.json b/SIP.js/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/SIP.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3de4a245bdc0dab48b91b51c3937391d04ef2902 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 12:14:28 +0300 Subject: [PATCH 046/248] Fixed package case --- {SIP.js => sip.js}/index.d.ts | 0 SIP.js/SIP.js-tests.ts => sip.js/sip.js-tests.ts | 0 {SIP.js => sip.js}/tsconfig.json | 2 +- {SIP.js => sip.js}/tslint.json | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {SIP.js => sip.js}/index.d.ts (100%) rename SIP.js/SIP.js-tests.ts => sip.js/sip.js-tests.ts (100%) rename {SIP.js => sip.js}/tsconfig.json (94%) rename {SIP.js => sip.js}/tslint.json (100%) diff --git a/SIP.js/index.d.ts b/sip.js/index.d.ts similarity index 100% rename from SIP.js/index.d.ts rename to sip.js/index.d.ts diff --git a/SIP.js/SIP.js-tests.ts b/sip.js/sip.js-tests.ts similarity index 100% rename from SIP.js/SIP.js-tests.ts rename to sip.js/sip.js-tests.ts diff --git a/SIP.js/tsconfig.json b/sip.js/tsconfig.json similarity index 94% rename from SIP.js/tsconfig.json rename to sip.js/tsconfig.json index 93cce57ffb..8c84c6273e 100644 --- a/SIP.js/tsconfig.json +++ b/sip.js/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "SIP.js-tests.ts" + "sip.js-tests.ts" ] } diff --git a/SIP.js/tslint.json b/sip.js/tslint.json similarity index 100% rename from SIP.js/tslint.json rename to sip.js/tslint.json From f0f803116b25f321fca2755a4e6c96129e6c4a7a Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 12:52:59 +0300 Subject: [PATCH 047/248] Move references from tsconfig --- sip.js/index.d.ts | 2 ++ sip.js/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 0eaabb9b48..3af04495c9 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + export = SIP; declare namespace SIP { diff --git a/sip.js/tsconfig.json b/sip.js/tsconfig.json index 8c84c6273e..b6532e5674 100644 --- a/sip.js/tsconfig.json +++ b/sip.js/tsconfig.json @@ -12,7 +12,7 @@ "typeRoots": [ "../" ], - "types": ["webrtc"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From cb6ec66ca995549337896b3e38dc79a097b50c08 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 13:22:30 +0300 Subject: [PATCH 048/248] Fix lint error --- sip.js/index.d.ts | 48 ++++++++++++++-------------------------------- sip.js/tslint.json | 7 ++++++- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 3af04495c9..8c7a297613 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -40,7 +40,7 @@ declare namespace SIP { } namespace UA.EventArgs { - interface ConnectedArgs { attempts: number } + interface ConnectedArgs { attempts: number; } interface UnregisteredArgs { response: string; cause: string; } interface RegistrationFailedArgs extends UnregisteredArgs { } } @@ -55,8 +55,7 @@ declare namespace SIP { isConnected(): boolean; message(target: string | URI, body: string, options?: MessageOptions): Message; subscribe(target: string | URI, event: string, options?: SubscribeOptions): Subscription; - invite(target: string | URI, options?: InviteOptions): Session; - invite(target: string | URI, element?: HTMLAudioElement | HTMLVideoElement): Session; + invite(target: string | URI, element?: InviteOptions | HTMLAudioElement | HTMLVideoElement): Session; request(method: string, target: string | URI, options?: RequestOptions): ClientContext; on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; @@ -110,16 +109,13 @@ declare namespace SIP { on(name: 'progress', callback: (response: IncomingResponse) => void): void; on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; - on(name: 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; - on(name: 'failed', callback: (response: IncomingResponse, cause: string) => void): void; + on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; - on(name: 'refer', callback: (request: IncomingRequest) => void): void; on(name: 'cancel', callback: () => void): void; on(name: 'replaced', callback: (newSession: Session) => void): void; on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; - on(name: 'muted', callback: (data: Session.Muted) => void): void; - on(name: 'unmuted', callback: (data: Session.Muted) => void): void; - on(name: 'bye', callback: (request: IncomingRequest) => void): void; + on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void; + on(name: 'refer' | 'bye', callback: (request: IncomingRequest) => void): void; } namespace Session { @@ -144,18 +140,17 @@ declare namespace SIP { media?: MediaOptions; } - interface DTMF { - } + interface DTMF extends Object {} interface Muted { audio?: boolean; - video?: boolean + video?: boolean; } } interface RenderHint { remote?: Element; - local?: Element + local?: Element; } interface MediaConstraints { @@ -185,29 +180,18 @@ declare namespace SIP { render(renderHint: RenderHint): void; on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; - on(name: 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'addStream' | 'userMedia', callback: (stream: MediaStream) => void): void; on(name: 'userMediaFailed', callback: (error: string) => void): void; - on(name: 'iceGathering', callback: () => void): void; on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; - on(name: 'iceGatheringComplete', callback: () => void): void; - on(name: 'iceConnection', callback: () => void): void; - on(name: 'iceConnectionChecking', callback: () => void): void; - on(name: 'iceConnectionConnected', callback: () => void): void; - on(name: 'iceConnectionCompleted', callback: () => void): void; - on(name: 'iceConnectionFailed', callback: () => void): void; - on(name: 'iceConnectionDisconnected', callback: () => void): void; - on(name: 'iceConnectionClosed', callback: () => void): void; - on(name: 'getDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; - on(name: 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; - on(name: 'dataChannel', callback: () => void): void; - on(name: 'addStream', callback: (stream: MediaStream) => void): void; + on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed', callback: () => void): void; + on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } } /* Parameters */ interface ConfigurationParameters { uri?: string; - wsServers?: string | string[] | { ws_uri: string; weigth: number }[]; + wsServers?: string | string[] | Array<{ ws_uri: string; weigth: number }>; allowLegacyNotifications?: boolean; authenticationFactory?: WebRTC.MediaHandlerFactory; authorizationUser?: string; @@ -304,11 +288,7 @@ declare namespace SIP { localIdentity: NameAddrHeader; remoteIdentity: NameAddrHeader; data: {}; - - on(name: 'progress', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'accepted', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'rejected', callback: (response: IncomingMessage, cause: string) => void): void; - on(name: 'failed', callback: (response: IncomingMessage, cause: string) => void): void; + on(name: 'progress' | 'accepted' | 'rejected' | 'failed', callback: (response: IncomingMessage, cause: string) => void): void; on(name: 'notify', callback: (request: IncomingRequest) => void): void; } @@ -341,7 +321,7 @@ declare namespace SIP { /* Header */ class NameAddrHeader { - constructor(uri: string | URI, displayName: string, parameters: { key: string, value: string }[]); + constructor(uri: string | URI, displayName: string, parameters: Array<{ key: string, value: string }>); uri: string | URI; displayName: string; diff --git a/sip.js/tslint.json b/sip.js/tslint.json index 377cc837d4..105f5736e6 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1 +1,6 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-empty-interface": false + } +} From 2cc1c6e25dc4fd757dc98503f985678ebf4a21ef Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 13:58:52 +0300 Subject: [PATCH 049/248] Fix type definition test errors --- sip.js/index.d.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 8c7a297613..a8d2b3c8db 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -1,13 +1,11 @@ -// Type definitions for SIP.js v0.7.6 +// Type definitions for SIP.js 0.7 // Project: https://sipjs.com/ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -export = SIP; - -declare namespace SIP { +export declare namespace SIP { class URI { constructor( @@ -105,7 +103,7 @@ declare namespace SIP { accept(options?: Session.AcceptOptions): void; reject(options?: Session.CommonOptions): void; reply(options?: Session.CommonOptions): void; - followRefer(callback: Function): void; + followRefer(callback: () => void): void; on(name: 'progress', callback: (response: IncomingResponse) => void): void; on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; @@ -273,7 +271,7 @@ declare namespace SIP { state: string; event: string; dialog: string; - timers: Object; + timers: {}; errorCodes: number[]; subscribe(): Subscription; unsubscribe(): void; From 1c753b2c69e2df6a45a06cdfa2568a30f7d655ba Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Fri, 20 Jan 2017 14:40:08 +0300 Subject: [PATCH 050/248] Fix tslint errors, configure rules --- sip.js/index.d.ts | 10 ++++++---- sip.js/tslint.json | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index a8d2b3c8db..942a0d22b3 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -1,11 +1,13 @@ -// Type definitions for SIP.js 0.7 -// Project: https://sipjs.com/ -// Definitions by: Kir Dergachev +// Type definitions for sip.js 0.7 +// Project: http://sipjs.com +// Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -export declare namespace SIP { +export = SIP; + +declare namespace SIP { class URI { constructor( diff --git a/sip.js/tslint.json b/sip.js/tslint.json index 105f5736e6..c78c443ad2 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1,6 +1,7 @@ { "extends": "../tslint.json", "rules": { - "no-empty-interface": false + "no-empty-interface": false, + "export-just-namespace": false } } From 6b1b8e745c79db044dc53eef44c6587113d03a60 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 20 Jan 2017 10:58:59 -0600 Subject: [PATCH 051/248] Fix props callbacks. Type dates as moment.Moment. --- react-datepicker/index.d.ts | 21 +++++++++++---------- react-datepicker/react-datepicker-tests.tsx | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/react-datepicker/index.d.ts b/react-datepicker/index.d.ts index aec8b61b72..109e47626c 100644 --- a/react-datepicker/index.d.ts +++ b/react-datepicker/index.d.ts @@ -3,9 +3,10 @@ // Definitions by: Rajab Shakirov , Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare module "react-datepicker" { + import * as React from "react"; + import * as moment from "moment"; + interface ReactDatePickerProps { autoComplete?: string; autoFocus?: boolean; @@ -14,7 +15,7 @@ declare module "react-datepicker" { dateFormat?: string; dateFormatCalendar?: string; disabled?: boolean; - endDate?: {}; + endDate?: moment.Moment; excludeDates?: any[]; filterDate?(): any; fixedHeight?: boolean; @@ -22,12 +23,12 @@ declare module "react-datepicker" { includeDates?: any[]; isClearable?: boolean; locale?: string; - maxDate?: {}; - minDate?: {}; + maxDate?: moment.Moment; + minDate?: moment.Moment; name?: string; - onBlur?(handler: (e: any) => void): any; - onChange(handler: (date?: any, e?: any) => void): any; - onFocus?(handler: (e: any) => void): any; + onBlur?(event: React.FocusEvent): void; + onChange(date: moment.Moment | null, event: React.SyntheticEvent | undefined): any; + onFocus?(event: React.FocusEvent): void; peekNextMonth?: boolean; placeholderText?: string; popoverAttachment?: string; @@ -37,13 +38,13 @@ declare module "react-datepicker" { renderCalendarTo?: any; required?: boolean; scrollableYearDropdown?: boolean; - selected?: {}; + selected?: moment.Moment | null; selectsEnd?: boolean; selectsStart?: boolean; showMonthDropdown?: boolean; showYearDropdown?: boolean; showWeekNumbers?: boolean; - startDate?: {}; + startDate?: moment.Moment; tabIndex?: number; tetherConstraints?: any[]; title?: string; diff --git a/react-datepicker/react-datepicker-tests.tsx b/react-datepicker/react-datepicker-tests.tsx index 53cd4723b5..df1b02dacf 100644 --- a/react-datepicker/react-datepicker-tests.tsx +++ b/react-datepicker/react-datepicker-tests.tsx @@ -2,8 +2,8 @@ import * as React from "react"; import * as moment from 'moment'; import * as DatePicker from 'react-datepicker'; -class ReactDatePicker extends React.Component<{}, {startDate:any,displayName:string}> { - constructor(props:any) { +class ReactDatePicker extends React.Component<{}, { startDate: moment.Moment; displayName:string; }> { + constructor(props: {}) { super(); this.state = { startDate: moment(), @@ -12,7 +12,7 @@ class ReactDatePicker extends React.Component<{}, {startDate:any,displayName:str this.handleChange = this.handleChange.bind(this); } - handleChange = function(date?:any) { + handleChange = function(date?: moment.Moment | null) { this.setState({ startDate: date }); From 0c26a340bb4b5f0c1f93ad66348cf72818d1302e Mon Sep 17 00:00:00 2001 From: John Date: Fri, 20 Jan 2017 11:05:05 -0600 Subject: [PATCH 052/248] Update version number --- react-datepicker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-datepicker/index.d.ts b/react-datepicker/index.d.ts index 109e47626c..3ba6f91386 100644 --- a/react-datepicker/index.d.ts +++ b/react-datepicker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-datepicker v0.28.1 +// Type definitions for react-datepicker v0.40.0 // Project: https://github.com/Hacker0x01/react-datepicker // Definitions by: Rajab Shakirov , Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 1e4d93b30843687a5e88ebb5b1574d0a94eb6d92 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 20 Jan 2017 17:50:22 -0500 Subject: [PATCH 053/248] fix seek(...) function so that it can return either a Howl object or a number --- howler/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/howler/index.d.ts b/howler/index.d.ts index 1b6604b1aa..df3f6a363b 100644 --- a/howler/index.d.ts +++ b/howler/index.d.ts @@ -66,7 +66,7 @@ interface Howl { rate(idOrSetRate: number): this | number; rate(rate: number, id: number): this; - seek(seek?: number, id?: number): this; + seek(seek?: number, id?: number): this | number; loop(loop?: boolean, id?: number): this; playing(id?: number): boolean; duration(id?: number): number; From 00aa560a49892cd736758f9a7a121097c95a84cd Mon Sep 17 00:00:00 2001 From: asankaf Date: Sat, 21 Jan 2017 12:58:53 +0530 Subject: [PATCH 054/248] Updates in the worksheet row type enum - Since couple of releases, worksheet row type enum values used for groupHeader and groupFooter were updated to group-header and group-footer. - New values are used in src\js\kendo.excel.js (lines 180 and 226) - v2017.1.118 --- kendo-ui/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kendo-ui/index.d.ts b/kendo-ui/index.d.ts index 5d6e4ec0a8..ecdbffae66 100644 --- a/kendo-ui/index.d.ts +++ b/kendo-ui/index.d.ts @@ -18307,7 +18307,7 @@ declare namespace kendo.ooxml { cells?: WorkbookSheetRowCell[]; index?: number; height?: number; - type?: "header" | "footer" | "groupHeader" | "groupFooter" | "data"; + type?: "header" | "footer" | "group-header" | "group-footer" | "data"; } interface WorkbookSheet { From 2f4008caa8b47224f6e0e40414807a141bd7a356 Mon Sep 17 00:00:00 2001 From: durad Date: Sat, 21 Jan 2017 12:59:37 -0800 Subject: [PATCH 055/248] Added definition for lorem-ipsum (#14161) * Implemented match, isMath and find * Added all functions * Made options optional. * Added tslint.json and fixed lint errors * Fixed definition for mapping function * Fixed issue with strict nulls * Added definition for lorem-ipsum --- lorem-ipsum/index.d.ts | 63 ++++++++++++++++++++++++++++++++ lorem-ipsum/lorem-ipsum-tests.ts | 14 +++++++ lorem-ipsum/tsconfig.json | 20 ++++++++++ lorem-ipsum/tslint.json | 1 + 4 files changed, 98 insertions(+) create mode 100644 lorem-ipsum/index.d.ts create mode 100644 lorem-ipsum/lorem-ipsum-tests.ts create mode 100644 lorem-ipsum/tsconfig.json create mode 100644 lorem-ipsum/tslint.json diff --git a/lorem-ipsum/index.d.ts b/lorem-ipsum/index.d.ts new file mode 100644 index 0000000000..825136f207 --- /dev/null +++ b/lorem-ipsum/index.d.ts @@ -0,0 +1,63 @@ +// Type definitions for lorem-ipsum 1.0 +// Project: https://github.com/knicklabs/node-lorem-ipsum +// Definitions by: Dusan Radovanovic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface LoremIpsumOptions { + /** + * Number of words, sentences, or paragraphs to generate. + */ + count?: number; + + /** + * Generate words, sentences, or paragraphs. + */ + units?: 'words' | 'sentences' | 'paragraphs'; + + /** + * Minimum words per sentence. + */ + sentenceLowerBound?: number; + + /** + * Maximum words per sentence. + */ + sentenceUpperBound?: number; + + /** + * Minimum sentences per paragraph. + */ + paragraphLowerBound?: number; + + /** + * Maximum sentences per paragraph. + */ + paragraphUpperBound?: number; + + /** + * Plain text or html. + */ + format?: 'plain' | 'html'; + + /** + * Custom word dictionary. + */ + words?: string[]; + + /** + * A PRNG function. Uses Math.random by default. + */ + random?: () => number; + + /** + * The character to insert between paragraphs. Defaults to default EOL. + */ + suffix?: string; +} + +/** + * Generate a passage of lorem ipsum text. + */ +declare function loremIpsum(options?: LoremIpsumOptions): string; + +export = loremIpsum; diff --git a/lorem-ipsum/lorem-ipsum-tests.ts b/lorem-ipsum/lorem-ipsum-tests.ts new file mode 100644 index 0000000000..dd5eb82ba6 --- /dev/null +++ b/lorem-ipsum/lorem-ipsum-tests.ts @@ -0,0 +1,14 @@ +import loremIpsum = require('lorem-ipsum'); + +let result: string; +result = loremIpsum(); +result = loremIpsum({}); +result = loremIpsum({ count: 20 }); +result = loremIpsum({ count: 20, units: 'words' }); +result = loremIpsum({ count: 3, units: 'paragraphs' }); +result = loremIpsum({ random: () => Math.random() * Math.random() }); +result = loremIpsum({ paragraphLowerBound: 3, paragraphUpperBound: 6, count: 3, units: 'paragraphs' }); +result = loremIpsum({ sentenceLowerBound: 10, sentenceUpperBound: 15, count: 5, units: 'sentences' }); +result = loremIpsum({ words: ['a', 'b', 'c'] }); +result = loremIpsum({ suffix: '-' }); +result = loremIpsum({ format: 'html' }); diff --git a/lorem-ipsum/tsconfig.json b/lorem-ipsum/tsconfig.json new file mode 100644 index 0000000000..7e756f052b --- /dev/null +++ b/lorem-ipsum/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lorem-ipsum-tests.ts" + ] +} diff --git a/lorem-ipsum/tslint.json b/lorem-ipsum/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/lorem-ipsum/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 4923ba548ae77ba4c5e18c17df40e6dda0c6e174 Mon Sep 17 00:00:00 2001 From: Rahul Ravikumar Date: Sat, 21 Jan 2017 13:08:53 -0800 Subject: [PATCH 056/248] Add definitions for opener (#14159) --- opener/index.d.ts | 14 ++++++++++++++ opener/opener-tests.ts | 11 +++++++++++ opener/tsconfig.json | 20 ++++++++++++++++++++ opener/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 opener/index.d.ts create mode 100644 opener/opener-tests.ts create mode 100644 opener/tsconfig.json create mode 100644 opener/tslint.json diff --git a/opener/index.d.ts b/opener/index.d.ts new file mode 100644 index 0000000000..b3e8c4ea73 --- /dev/null +++ b/opener/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for opener 1.4 +// Project: https://github.com/domenic/opener +// Definitions by: Rahul Ravikumar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { ChildProcess } from 'child_process'; + +type Callback = (error: Error, stdout: string, stderr: string) => void; +declare function opener( + args: string | string[], options?: {}, callback?: Callback): ChildProcess; + +export = opener; diff --git a/opener/opener-tests.ts b/opener/opener-tests.ts new file mode 100644 index 0000000000..477fe4b3f8 --- /dev/null +++ b/opener/opener-tests.ts @@ -0,0 +1,11 @@ +import opener = require('opener'); + +// all example code should compile + +opener('http://google.com'); +opener('./my-file.txt'); +opener('firefox'); +opener('npm run lint'); + +var editor = opener('documentation.odt'); +editor.unref(); diff --git a/opener/tsconfig.json b/opener/tsconfig.json new file mode 100644 index 0000000000..963f0f48b5 --- /dev/null +++ b/opener/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "opener-tests.ts" + ] +} diff --git a/opener/tslint.json b/opener/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/opener/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 5efea302f34c3a0a57daf2fc981b494e907ac2dd Mon Sep 17 00:00:00 2001 From: Vlad Rindevich Date: Sun, 22 Jan 2017 01:53:35 +0300 Subject: [PATCH 057/248] libpq: Fix wrong definitions (#14164) * fix(libpq): change returning type of `writable` method * fix(libpq): remove optionality for `prepare` method's arguments * fix(libpq): remove optionality for `sendPrepare` method's arguments --- libpq/index.d.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libpq/index.d.ts b/libpq/index.d.ts index df2135046a..1e9e38dd5c 100644 --- a/libpq/index.d.ts +++ b/libpq/index.d.ts @@ -307,11 +307,11 @@ declare class Libpq extends EventEmitter { * (sync) Sends a named statement to the server to be prepared for later execution. blocks * until a result from the prepare operation is received. * - * @param {string} [statementName=""] a required string of name of the statement to prepare. - * @param {string} [commandText=""] a required string of the query. - * @param {number} [nParams=0] a count of the number of parameters in the commandText. + * @param {string} statementName a required string of name of the statement to prepare. + * @param {string} commandText a required string of the query. + * @param {number} nParams a count of the number of parameters in the commandText. */ - prepare(statementName?: string, commandText?: string, nParams?: number): void; + prepare(statementName: string, commandText: string, nParams: number): void; /** * Retrieves detailed error information from the current result object. Very similar to @@ -363,12 +363,12 @@ declare class Libpq extends EventEmitter { /** * (async) Sends a request to the backend to prepare a named statement with the given name. * - * @param {string} [statementName=""] a required string of name of the statement to prepare. - * @param {string} [commandText=""] a required string of the query. - * @param {number} [nParams=0] a count of the number of parameters in the commandText. + * @param {string} statementName a required string of name of the statement to prepare. + * @param {string} commandText a required string of the query. + * @param {number} nParams a count of the number of parameters in the commandText. * @returns {boolean} true if the command was sent succesfully or false if it failed to send. */ - sendPrepare(statementName?: string, commandText?: string, nParams?: number): boolean; + sendPrepare(statementName: string, commandText: string, nParams: number): boolean; /** * (async) Sends a request to execute a previously prepared statement. @@ -421,8 +421,10 @@ declare class Libpq extends EventEmitter { * and PQflush for async writing. * * @param {Function} callback + * + * @returns {Libpq} */ - writable(callback: () => void): void; + writable(callback: () => void): this; } export = Libpq; From c71435a8cb52e11f1606dcaedff1c558eb74f917 Mon Sep 17 00:00:00 2001 From: Otoha Funabashi Date: Sun, 22 Jan 2017 07:53:57 +0900 Subject: [PATCH 058/248] shelljs: update exec for after v0.6.0 (#14143) * shelljs: update for after v0.6.0 exec.output was changed to exec.stdout, and missing exec.stderr. stderr: https://github.com/shelljs/shelljs/commit/74f1ff8748ab8261ad20062dfee40d39103e0a98 stdout: https://github.com/shelljs/shelljs/commit/8a7f7ceec4d3a77a9309d935755675ac368b1eda * shelljs: update testcode --- shelljs/index.d.ts | 7 ++++--- shelljs/shelljs-tests.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/shelljs/index.d.ts b/shelljs/index.d.ts index 26f92c379f..5e812947fd 100644 --- a/shelljs/index.d.ts +++ b/shelljs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ShellJS v0.3.0 +// Type definitions for ShellJS v0.6.0 // Project: http://shelljs.org // Definitions by: Niklas Mollenhauer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -463,7 +463,7 @@ export declare function exec(command: string, options: ExecOptions, callback: Ex export declare function exec(command: string, callback: ExecCallback): child.ChildProcess; export interface ExecCallback { - (code: number, output: string, error?: string): any; + (code: number, stdout: string, stderr: string): any; } export interface ExecOptions { @@ -473,7 +473,8 @@ export interface ExecOptions { export interface ExecOutputReturnValue { code: number; - output: string; + stdout: string; + stderr: string; } /** diff --git a/shelljs/shelljs-tests.ts b/shelljs/shelljs-tests.ts index 7934046d0a..a78b8e44e1 100644 --- a/shelljs/shelljs-tests.ts +++ b/shelljs/shelljs-tests.ts @@ -86,22 +86,22 @@ var testPath = shell.env["path"]; import child = require("child_process"); -var version = shell.exec("node --version").output; +var version = shell.exec("node --version").stdout; var version2 = shell.exec("node --version", { async: false }); -var output = version2.output; +var output = version2.stdout; var asyncVersion3 = shell.exec("node --version", { async: true }); var pid = asyncVersion3.pid; -shell.exec("node --version", { silent: true }, function (code, output) { - var version = output; +shell.exec("node --version", { silent: true }, function (code, stdout, stderr) { + var version = stdout; }); -shell.exec("node --version", { silent: true, async: true }, function (code, output) { - var version = output; +shell.exec("node --version", { silent: true, async: true }, function (code, stdout, stderr) { + var version = stdout; }); -shell.exec("node --version", function (code, output) { - var version = output; +shell.exec("node --version", function (code, stdout, stderr) { + var version = stdout; }); shell.exec("node --version", function (code: number) { var num: number = code; From 3357f1a6237e4995768df3456a479f6a63c913c7 Mon Sep 17 00:00:00 2001 From: Rafael Kr Date: Sat, 21 Jan 2017 23:55:02 +0100 Subject: [PATCH 059/248] [node] zlib: move constants into zlib.constants (#13945) * [node] zlib: move constants into zlib.constants * add flush property to ZlibOptions declare constants as namespace --- node/index.d.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++-- node/node-tests.ts | 4 ++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index 5fcd4eb5d5..1f32030db7 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -1043,7 +1043,17 @@ declare module "cluster" { declare module "zlib" { import * as stream from "stream"; - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; finishFlush?: number } + + export interface ZlibOptions { + flush?: number; // default: zlib.constants.Z_NO_FLUSH + finishFlush?: number; // default: zlib.constants.Z_FINISH + chunkSize?: number; // default: 16*1024 + windowBits?: number; + level?: number; // compression only + memLevel?: number; // compression only + strategy?: number; // compression only + dictionary?: any; // deflate/inflate only, empty dictionary by default + } export interface Gzip extends stream.Transform { } export interface Gunzip extends stream.Transform { } @@ -1076,6 +1086,45 @@ declare module "zlib" { export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; + export namespace constants { + // Allowed flush values. + + export const Z_NO_FLUSH: number; + export const Z_PARTIAL_FLUSH: number; + export const Z_SYNC_FLUSH: number; + export const Z_FULL_FLUSH: number; + export const Z_FINISH: number; + export const Z_BLOCK: number; + export const Z_TREES: number; + + // Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events. + + export const Z_OK: number; + export const Z_STREAM_END: number; + export const Z_NEED_DICT: number; + export const Z_ERRNO: number; + export const Z_STREAM_ERROR: number; + export const Z_DATA_ERROR: number; + export const Z_MEM_ERROR: number; + export const Z_BUF_ERROR: number; + export const Z_VERSION_ERROR: number; + + // Compression levels. + + export const Z_NO_COMPRESSION: number; + export const Z_BEST_SPEED: number; + export const Z_BEST_COMPRESSION: number; + export const Z_DEFAULT_COMPRESSION: number; + + // Compression strategy. + + export const Z_FILTERED: number; + export const Z_HUFFMAN_ONLY: number; + export const Z_RLE: number; + export const Z_FIXED: number; + export const Z_DEFAULT_STRATEGY: number; + } + // Constants export var Z_NO_FLUSH: number; export var Z_PARTIAL_FLUSH: number; @@ -1107,7 +1156,6 @@ declare module "zlib" { export var Z_ASCII: number; export var Z_UNKNOWN: number; export var Z_DEFLATED: number; - export var Z_NULL: number; } declare module "os" { diff --git a/node/node-tests.ts b/node/node-tests.ts index 1778c6e0aa..adcadb1a60 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -441,7 +441,7 @@ namespace util_tests { function stream_readable_pipe_test() { var rs = fs.createReadStream(Buffer.from('file.txt')); var r = fs.createReadStream('file.txt'); - var z = zlib.createGzip({ finishFlush: zlib.Z_FINISH }); + var z = zlib.createGzip({ finishFlush: zlib.constants.Z_FINISH }); var w = fs.createWriteStream('file.txt.gz'); assert(typeof r.bytesRead === 'number'); @@ -846,7 +846,7 @@ namespace http_tests { request.setNoDelay(true); request.abort(); } - + const options: http.RequestOptions = { timeout: 30000 }; From 756433aeb47ea33ec79bb634cef662be941178e8 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sun, 22 Jan 2017 00:58:37 +0200 Subject: [PATCH 060/248] Fix elastic.js typings. Adding module and namespace exports. (#14152) * Fix elastic.js typings namespace from 'elasticjs' to 'elastic.js'. This will allow using 'import' statement against elastic.js like so: import * as elasticjs from 'elastic.js'; This also makes using this typings to be TSlint "no-var-require" rule compliant. * Export elasticjs namespace. --- elastic.js/elastic.js-tests.ts | 2 ++ elastic.js/index.d.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/elastic.js/elastic.js-tests.ts b/elastic.js/elastic.js-tests.ts index 927cb73d91..e7bd65ea16 100644 --- a/elastic.js/elastic.js-tests.ts +++ b/elastic.js/elastic.js-tests.ts @@ -1,3 +1,5 @@ +import * as elasticjs from 'elastic.js'; + let body = new elasticjs.Request({}) .query(new elasticjs.MatchQuery('title_field', 'testQuery')) .facet(new elasticjs.TermsFacet('tags').field('tags')) diff --git a/elastic.js/index.d.ts b/elastic.js/index.d.ts index 99a45f58fa..adb0db6950 100644 --- a/elastic.js/index.d.ts +++ b/elastic.js/index.d.ts @@ -3,6 +3,10 @@ // Definitions by: Oleksii Trekhleb // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = elasticjs; + +export as namespace elasticjs; + declare module elasticjs { export interface Facet {} From cb95e528e74d728691e0a14482b5634685553893 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 19:49:48 -0500 Subject: [PATCH 061/248] Add ArrayBuffer parameter to js-md5 --- js-md5/index.d.ts | 4 ++++ js-md5/js-md5-tests.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 32ef8b30ff..d635a58a6c 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -9,24 +9,28 @@ interface JQuery { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } interface JQueryStatic { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } interface md5 { (value: string): string; (value: Array): string; (value: Uint8Array): string; + (value: ArrayBuffer): string; } interface String { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } declare module "js-md5" { diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index 984a919ec3..77b10c09ce 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -5,6 +5,7 @@ md5(''); md5('中文'); md5([]); md5(new Uint8Array([])); +md5(new ArrayBuffer(0)); $.md5('message'); $.md5('Message to hash'); @@ -12,9 +13,11 @@ $.md5(''); $.md5('中文'); $.md5([]); $.md5(new Uint8Array([])); +$.md5(new ArrayBuffer(0)); 'message'.md5('Message to hash'); 'message'.md5(''); 'message'.md5('中文'); 'message'.md5([]); -'message'.md5(new Uint8Array([])); \ No newline at end of file +'message'.md5(new Uint8Array([])); +'message'.md5(new ArrayBuffer(0)); \ No newline at end of file From bccb2cadc334c36fc262838879d51a9646de3627 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 19:54:19 -0500 Subject: [PATCH 062/248] Add ArrayBuffer parameter to js-md5 --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index d635a58a6c..7292463815 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for js-md5 v0.3.0 // Project: https://github.com/emn178/js-md5 -// Definitions by: Roland Greim +// Definitions by: Roland Greim , Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ /// From f96596fa4efa2156052e8a98f4da302d8918fcac Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 20:02:09 -0500 Subject: [PATCH 063/248] Increase version number in header --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 7292463815..db202ed628 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.3.0 +// Type definitions for js-md5 v0.3.1 // Project: https://github.com/emn178/js-md5 // Definitions by: Roland Greim , Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ From 50a4e099ba707bf937aa3bb361110a7deaf12d10 Mon Sep 17 00:00:00 2001 From: Jephir Date: Sat, 21 Jan 2017 21:09:51 -0500 Subject: [PATCH 064/248] Allow keySeperator, nsSeperator = false (2.1.0) https://github.com/i18next/i18next/blob/master/CHANGELOG.md#210 --- i18next/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i18next/index.d.ts b/i18next/index.d.ts index b0cb04b267..958bff12a6 100644 --- a/i18next/index.d.ts +++ b/i18next/index.d.ts @@ -63,8 +63,8 @@ declare namespace i18n { lowerCaseLng?: boolean; load?: string preload?: string[]; - keySeparator?: string; - nsSeparator?: string; + keySeparator?: string | false; + nsSeparator?: string | false; pluralSeparator?: string; contextSeparator?: string; saveMissing?: boolean; From ab1d41bcd4200fb0e57995c534ddf5ea2bf95da4 Mon Sep 17 00:00:00 2001 From: Eiji Kitamura Date: Sat, 21 Jan 2017 15:50:12 +0900 Subject: [PATCH 065/248] Follow Payment Request spec updates --- paymentrequest/index.d.ts | 69 ++++++++++++++++---------- paymentrequest/paymentrequest-tests.ts | 15 ++++-- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/paymentrequest/index.d.ts b/paymentrequest/index.d.ts index 50ef94e1e6..5231f53bc3 100644 --- a/paymentrequest/index.d.ts +++ b/paymentrequest/index.d.ts @@ -1,26 +1,33 @@ // Type definitions for PaymentRequest // Project: https://www.w3.org/TR/payment-request/ -// Definitions by: Adam Cmiel +// Definitions by: Adam Cmiel , Eiji Kitamura // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface PaymentRequest extends EventTarget { new (methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; show(): PromiseLike; abort(): PromiseLike; - shippingAddress?: PaymentAddress; - shippingOption?: string; + canMakePayment(): Promise; + readonly paymentRequestID: string; + readonly shippingAddress?: PaymentAddress; + readonly shippingOption?: string; + readonly shippingType?: string; onshippingaddresschange: PaymentUpdateEventListener; onshippingoptionchange: PaymentUpdateEventListener; } interface PaymentMethodData { supportedMethods: string[]; - data?: Object; + data?: { + supportedNetworks: string[]; + supportedTypes: string[]; + }; } interface PaymentCurrencyAmount { currency: string; value: string; + currencySystem?:string; } interface PaymentDetails { @@ -28,55 +35,63 @@ interface PaymentDetails { displayItems?: PaymentItem[]; shippingOptions?: PaymentShippingOption[]; modifiers?: PaymentDetailsModifier[]; + error?: string; } interface PaymentDetailsModifier { supportedMethods: string[]; total?: PaymentItem; - additionalDisplayItems: PaymentItem[]; + additionalDisplayItems?: PaymentItem[]; + data?: Object; } interface PaymentOptions { - requestShipping: boolean; - requestPayerEmail: boolean; - requestPayerPhone: boolean; + requestShipping?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestPayerName?: boolean; + shippingType?: 'shipping' | 'delivery' | 'pickup'; } interface PaymentItem { label: string; - amount: PaymentCurrencyAmount + amount: PaymentCurrencyAmount; + pending?: boolean; } interface PaymentAddress { - country: string; - addressLine: string[]; - region: string; - city: string; - dependentLocality: string; - postalCode: string; - sortingCode: string; - languageCode: string; - organization: string; - recipient: string; - careOf: string; - phone: string; + readonly country: string; + readonly addressLine: string[]; + readonly region: string; + readonly city: string; + readonly dependentLocality: string; + readonly postalCode: string; + readonly sortingCode: string; + readonly languageCode: string; + readonly organization: string; + readonly recipient: string; + readonly phone: string; } interface PaymentShippingOption { id: string; label: string; amount: PaymentCurrencyAmount; + selected?: boolean; } interface PaymentResponse { - methodName: string; - details: Object; - shippingAddress?: PaymentAddress; - shippingOption?: string; - payerEmail?: string; - payerPhone?: string; + readonly paymentRequestID: string; + readonly methodName: string; + readonly details: Object; + readonly shippingAddress?: PaymentAddress; + readonly shippingOption?: string; + readonly payerEmail?: string; + readonly payerPhone?: string; + readonly payerName?: string; complete(result?: '' | 'success' | 'fail'): PromiseLike; + toJSON(): Object; } interface PaymentUpdateEventListener extends EventListener { diff --git a/paymentrequest/paymentrequest-tests.ts b/paymentrequest/paymentrequest-tests.ts index 4c36c3ff76..62c2721bfb 100644 --- a/paymentrequest/paymentrequest-tests.ts +++ b/paymentrequest/paymentrequest-tests.ts @@ -3,7 +3,7 @@ /// Code examples derived from /// https://developers.google.com/web/fundamentals/discovery-and-monetization/payment-request/ -function makeRequest() { +async function makeRequest() { if (!window.PaymentRequest) { return Promise.reject(new Error("PaymentRequest not available")) } @@ -31,10 +31,12 @@ function makeRequest() { } } - const options = { + const options: PaymentOptions = { requestShipping: true, requestPayerEmail: true, - requestPayerPhone: true + requestPayerPhone: true, + requestPayerName: true, + shippingType: 'delivery' } const request = new window.PaymentRequest(methodData, details, options) @@ -72,7 +74,12 @@ function makeRequest() { })(details, request.shippingAddress)); }) - return request.show() + let canMakePayment = await request.canMakePayment() + if (canMakePayment) { + return request.show() + } else { + throw 'can not make payment on this environment.' + } } async function processPayment(): Promise { From 453ffc9e8a24c7404ca2951fa28e9e54da42f20d Mon Sep 17 00:00:00 2001 From: "Angus.Fenying" Date: Sun, 22 Jan 2017 16:17:37 +0800 Subject: [PATCH 066/248] Added methods cork and uncork for RedisClient. --- redis/index.d.ts | 10 ++++++++++ redis/redis-tests.ts | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/redis/index.d.ts b/redis/index.d.ts index 75745b99f4..0e7e2ec4de 100644 --- a/redis/index.d.ts +++ b/redis/index.d.ts @@ -94,6 +94,16 @@ export interface RedisClient extends NodeJS.EventEmitter { end(): void; unref(): void; + /** + * Stop sending commands and queue the commands. + */ + cork(): void; + + /** + * Resume and send the queued commands at once. + */ + uncork(): void; + // Low level command execution send_command(command: string, ...args: any[]): boolean; diff --git a/redis/redis-tests.ts b/redis/redis-tests.ts index d98979f256..e0315a809f 100644 --- a/redis/redis-tests.ts +++ b/redis/redis-tests.ts @@ -112,4 +112,10 @@ client.monitor(resCallback); // Send command client.send_command(str, args, resCallback); // Duplicate -client.duplicate(); \ No newline at end of file +client.duplicate(); + +// Pipeline +client.cork(); +client.set("abc", "fff", strCallback); +client.get("abc", resCallback); +client.uncork(); From 1652209bad56af434c6e9074955002d2cb2bf4b0 Mon Sep 17 00:00:00 2001 From: Chris Barr Date: Sun, 22 Jan 2017 21:00:24 -0500 Subject: [PATCH 067/248] Add missing configuration options & tests to angular-bootstrap-ui --- .../angular-ui-bootstrap-tests.ts | 25 ++++- angular-ui-bootstrap/index.d.ts | 95 +++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts b/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts index 16eaff3b39..b14af506b6 100644 --- a/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts +++ b/angular-ui-bootstrap/angular-ui-bootstrap-tests.ts @@ -7,6 +7,7 @@ testApp.config(( $buttonConfig: ng.ui.bootstrap.IButtonConfig, $datepickerConfig: ng.ui.bootstrap.IDatepickerConfig, $datepickerPopupConfig: ng.ui.bootstrap.IDatepickerPopupConfig, + $dropdownConfig: ng.ui.bootstrap.IDropdownConfig, $modalProvider: ng.ui.bootstrap.IModalProvider, $paginationConfig: ng.ui.bootstrap.IPaginationConfig, $pagerConfig: ng.ui.bootstrap.IPagerConfig, @@ -47,13 +48,18 @@ testApp.config(( $datepickerConfig.showWeeks = false; $datepickerConfig.startingDay = 1; $datepickerConfig.yearRange = 10; - - + $datepickerConfig.monthColumns = 3; + $datepickerConfig.yearColumns = 9; + $datepickerConfig.yearRows = 6; + $datepickerConfig.ngModelOptions.allowInvalid = false; + $datepickerConfig.ngModelOptions.timezone = "EST"; + $datepickerConfig.ngModelOptions.updateOn = "click"; /** * $datepickerPopupConfig tests */ + $datepickerPopupConfig.altInputFormats = ["mm/dd/YYYY", "mm-dd-YY"]; $datepickerPopupConfig.appendToBody = true; $datepickerPopupConfig.currentText = 'Select Today'; $datepickerPopupConfig.clearText = 'Reset Selection'; @@ -63,8 +69,18 @@ testApp.config(( $datepickerPopupConfig.datepickerPopupTemplateUrl = 'template.html'; $datepickerPopupConfig.datepickerTemplateUrl = 'template.html'; $datepickerPopupConfig.html5Types.date = 'MM-dd-yyyy'; + $datepickerPopupConfig.html5Types['datetime-local'] = 'yyyy-MM-ddTHH:mm:ss.sss'; + $datepickerPopupConfig.html5Types.month = 'yyyy-MM'; $datepickerPopupConfig.onOpenFocus = false; $datepickerPopupConfig.showButtonBar = false; + $datepickerPopupConfig.placement = "auto bottom left"; + + + /** + * $dropdownConfig tests + */ + $dropdownConfig.appendToOpenClass = "some-thing"; + $dropdownConfig.openClass = "show"; /** @@ -77,6 +93,7 @@ testApp.config(( * $paginationConfig tests */ $paginationConfig.boundaryLinks = true; + $paginationConfig.boundaryLinkNumbers = true; $paginationConfig.directionLinks = false; $paginationConfig.firstText = 'First Page'; $paginationConfig.itemsPerPage = 25; @@ -88,6 +105,7 @@ testApp.config(( $paginationConfig.rotate = false; $paginationConfig.templateUrl = 'template.html'; $paginationConfig.totalItems = 13; + $paginationConfig.forceEllipses = true; /** @@ -121,11 +139,14 @@ testApp.config(( $timepickerConfig.hourStep = 2; $timepickerConfig.meridians = ['-AM-', '-PM-']; $timepickerConfig.minuteStep = 5; + $timepickerConfig.secondStep = 5; $timepickerConfig.mousewheel = false; $timepickerConfig.readonlyInput = true; $timepickerConfig.showMeridian = false; $timepickerConfig.arrowkeys = false; $timepickerConfig.showSpinners = false; + $timepickerConfig.showSeconds = true; + $timepickerConfig.templateUrl = "template.html"; /** * $tooltipProvider tests diff --git a/angular-ui-bootstrap/index.d.ts b/angular-ui-bootstrap/index.d.ts index 73043c4e7a..b5b4e1a5e6 100644 --- a/angular-ui-bootstrap/index.d.ts +++ b/angular-ui-bootstrap/index.d.ts @@ -11,6 +11,7 @@ export type IAccordionConfig = angular.ui.bootstrap.IAccordionConfig; export type IButtonConfig = angular.ui.bootstrap.IButtonConfig; export type IDatepickerConfig = angular.ui.bootstrap.IDatepickerConfig; export type IDatepickerPopupConfig = angular.ui.bootstrap.IDatepickerPopupConfig; +export type IDropdownConfig = angular.ui.bootstrap.IDropdownConfig; export type IModalProvider = angular.ui.bootstrap.IModalProvider; export type IModalService = angular.ui.bootstrap.IModalService; export type IModalServiceInstance = angular.ui.bootstrap.IModalServiceInstance; @@ -54,6 +55,11 @@ declare module 'angular' { toggleEvent?: string; } + interface IDropdownConfigNgOptions extends angular.INgModelOptions { + allowInvalid?: boolean; + timezone?: string; + } + interface IDatepickerConfig { /** * Format of day in month. @@ -166,9 +172,45 @@ declare module 'angular' { * @default false */ shortcutPropagation?: boolean; + + /** + * The number of columns displayed in month selection. + * + * @default 3 + */ + monthColumns?: number; + + /** + * The number of columns displayed in year selection. + * + * @default 5 + */ + yearColumns?: number; + + /** + * The number of rows displayed in year selection + * + * @default 4 + */ + yearRows?: number; + + /** + * All supported angular ngModelOptions plus some + * + * @default {} + */ + ngModelOptions?: IDropdownConfigNgOptions } interface IDatepickerPopupConfig { + + /** + * A list of alternate formats acceptable for manual entry. + * + * @default [] + */ + altInputFormats?: string[]; + /** * The format for displayed dates. * @@ -247,8 +289,26 @@ declare module 'angular' { * @default true */ onOpenFocus?: boolean; + + /** + * Passing in 'auto' separated by a space before the placement will enable auto positioning, e.g: "auto bottom-left". The popup will attempt to position where it fits in the closest scrollable ancestor. + * + * @default 'auto bottom-left' + */ + placement?: string; } + interface IDropdownConfig { + /** + * @default: 'uib-dropdown-open' + */ + appendToOpenClass?: string; + + /** + * @default: 'open' + */ + openClass?: string; + } interface IModalProvider { /** @@ -543,6 +603,13 @@ declare module 'angular' { */ boundaryLinks?: boolean; + /** + * Whether to always display the first and last page numbers. If max-size is smaller than the number of pages, then the first and last page numbers are still shown with ellipses in-between as necessary. NOTE: max-size refers to the center of the range. This option may add up to 2 more numbers on each side of the displayed range for the end value and what would be an ellipsis but is replaced by a number because it is sequential. + * + * @default false + */ + boundaryLinkNumbers?: boolean; + /** * Text for First button. * @@ -563,6 +630,13 @@ declare module 'angular' { * @default 'template/pagination/pagination.html' */ templateUrl?: string; + + /** + * Also displays ellipses when rotate is true and max-size is smaller than the number of pages. + * + * @default false + */ + forceEllipses?: boolean; } interface IPagerConfig { @@ -679,6 +753,13 @@ declare module 'angular' { */ minuteStep?: number; + /** + * Number of seconds to increase or decrease when using a button. + * + * @default 1 + */ + secondStep?: number; + /** * Whether to display 12H or 24H mode. * @@ -720,6 +801,20 @@ declare module 'angular' { * @default true */ showSpinners?: boolean; + + /** + * Show seconds input. + * + * @default false + */ + showSeconds?: boolean; + + /** + * Add the ability to override the template used on the component. + * + * @default 'uib/template/timepicker/timepicker.html' + */ + templateUrl?: string; } From 02c09ed9d8eefd5cb56c9a02b3c111821a121790 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Mon, 23 Jan 2017 02:19:26 +0000 Subject: [PATCH 068/248] webpack: add missing uglifyjs plugin typings (#14177) --- webpack/index.d.ts | 13 ++++++++++++- webpack/webpack-tests.ts | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 1ef2fa168f..73f575c973 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -472,6 +472,17 @@ declare namespace webpack { apply(thisArg: Webpack, ...args: any[]): void; } + type UglifyCommentFunction = (astNode: any, comment: any) => boolean + + interface UglifyPluginOptions extends UglifyJS.MinifyOptions { + beautify?: boolean; + comments?: boolean | RegExp | UglifyCommentFunction; + sourceMap?: boolean; + test?: Condition | Condition[]; + include?: Condition | Condition[]; + exclude?: Condition | Condition[]; + } + interface Webpack { (config: Configuration, callback?: compiler.CompilerCallback): compiler.Compiler; /** @@ -1020,7 +1031,7 @@ declare namespace webpack { new (preferEntry: boolean): Plugin; } interface UglifyJsPluginStatic { - new (options?: UglifyJS.MinifyOptions): Plugin; + new (options?: UglifyPluginOptions): Plugin; } interface CommonsChunkPluginStatic { new (chunkName: string, filenames?: string | string[]): Plugin; diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 086592b4de..8af08751ed 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -288,11 +288,24 @@ plugin = new webpack.optimize.UglifyJsPlugin({ warnings: false } }); +plugin = new webpack.optimize.UglifyJsPlugin({ + sourceMap: false, + comments: true, + beautify: true, + test: 'foo', + exclude: /node_modules/, + include: 'test' +}); plugin = new webpack.optimize.UglifyJsPlugin({ mangle: { except: ['$super', '$', 'exports', 'require'] } }); +plugin = new webpack.optimize.UglifyJsPlugin({ + comments: function(astNode: any, comment: any) { + return false; + } +}); plugin = new webpack.optimize.CommonsChunkPlugin(options); plugin = new CommonsChunkPlugin({ name: "commons", From 7a2803e589595426d80c92df28b01b0c01d8bd58 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 23 Jan 2017 03:20:03 +0100 Subject: [PATCH 069/248] [mathjs] add missing cosine declarations (#14174) --- mathjs/index.d.ts | 12 +++++++++++- mathjs/mathjs-tests.ts | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mathjs/index.d.ts b/mathjs/index.d.ts index d11a72d97b..bf20869909 100644 --- a/mathjs/index.d.ts +++ b/mathjs/index.d.ts @@ -1036,7 +1036,7 @@ declare namespace mathjs { asech(x: MathArray): MathArray; asech(x: Matrix): Matrix; - /** + /** * Calculate the inverse sine of a value. For matrices, the function is evaluated element wise. */ asin(x: number): number; @@ -1163,6 +1163,16 @@ declare namespace mathjs { sin(x: MathArray): MathArray; sin(x: Matrix): Matrix; + /** + * Calculate the cosine of a value. For matrices, the function is evaluated element wise. + */ + cos(x: number): number; + cos(x: BigNumber): BigNumber; + cos(x: Complex): Complex; + cos(x: Unit): number; + cos(x: MathArray): MathArray; + cos(x: Matrix): Matrix; + /** * Calculate the hyperbolic sine of a value, defined as sinh(x) = 1/2 * (exp(x) - exp(-x)). For matrices, the function is evaluated element wise. */ diff --git a/mathjs/mathjs-tests.ts b/mathjs/mathjs-tests.ts index c174ca1c95..3d4d87d72a 100644 --- a/mathjs/mathjs-tests.ts +++ b/mathjs/mathjs-tests.ts @@ -11,6 +11,8 @@ Basic usage examples math.log(10000, 10); // 4 math.sqrt(-4); // 2i math.pow([[-1, 2], [3, 1]], 2); // [[7, 0], [0, 7]] + var angle = 0.2; + math.add(math.pow(math.sin(angle), 2), math.pow(math.cos(angle), 2)); // returns number ~1 // expressions math.eval('1.2 * (2 + 4.5)'); // 7.8 From 0e3020531c0938d73bbd40f8f5d2fc4711ab8b27 Mon Sep 17 00:00:00 2001 From: Eldin Date: Mon, 23 Jan 2017 03:20:58 +0100 Subject: [PATCH 070/248] Update index.d.tx (#14175) Remove duplicate interface for "PerMessageDeflateOptions" --- ws/index.d.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ws/index.d.ts b/ws/index.d.ts index 733f11f608..172372d286 100644 --- a/ws/index.d.ts +++ b/ws/index.d.ts @@ -107,14 +107,6 @@ declare namespace WebSocket { memLevel?: number; } - export interface IPerMessageDeflateOptions { - serverNoContextTakeover?: boolean; - clientNoContextTakeover?: boolean; - serverMaxWindowBits?: number; - clientMaxWindowBits?: number; - memLevel?: number; - } - export interface IServerOptions { host?: string; port?: number; From db3dfdb4b4be1ea0d1481b54226d01f8b6e9e7c6 Mon Sep 17 00:00:00 2001 From: yohei1126 Date: Mon, 23 Jan 2017 14:02:26 +0900 Subject: [PATCH 071/248] mqtt: add getLastMessageId function to mqtt.Client --- mqtt/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mqtt/index.d.ts b/mqtt/index.d.ts index 256c0a5394..62e622e81d 100644 --- a/mqtt/index.d.ts +++ b/mqtt/index.d.ts @@ -235,6 +235,10 @@ declare namespace mqtt { */ handleMessage(packet: Packet, callback: Function): Client; + /** + * get last message id. This is for sent messages only. + */ + getLastMessageId(): number } /** From 0b89ca3e31eaa9cdf08d210a57e240dd950a56ca Mon Sep 17 00:00:00 2001 From: durad Date: Sun, 22 Jan 2017 21:10:12 -0800 Subject: [PATCH 072/248] Changed definition of lorem-ipsum to allow ES6 style imports (#14166) * Implemented match, isMath and find * Added all functions * Made options optional. * Added tslint.json and fixed lint errors * Fixed definition for mapping function * Fixed issue with strict nulls * Added definition for lorem-ipsum * Added namespace to lorem-ipsum to allow ES6 style imports --- lorem-ipsum/index.d.ts | 2 ++ lorem-ipsum/lorem-ipsum-tests.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lorem-ipsum/index.d.ts b/lorem-ipsum/index.d.ts index 825136f207..0a2210c0d8 100644 --- a/lorem-ipsum/index.d.ts +++ b/lorem-ipsum/index.d.ts @@ -55,6 +55,8 @@ interface LoremIpsumOptions { suffix?: string; } +declare namespace loremIpsum {} + /** * Generate a passage of lorem ipsum text. */ diff --git a/lorem-ipsum/lorem-ipsum-tests.ts b/lorem-ipsum/lorem-ipsum-tests.ts index dd5eb82ba6..697c222257 100644 --- a/lorem-ipsum/lorem-ipsum-tests.ts +++ b/lorem-ipsum/lorem-ipsum-tests.ts @@ -1,4 +1,4 @@ -import loremIpsum = require('lorem-ipsum'); +import * as loremIpsum from 'lorem-ipsum'; let result: string; result = loremIpsum(); From 5b9724a3734c5fa08c1a18c2233cd6d1ca915abd Mon Sep 17 00:00:00 2001 From: Linda_pp Date: Mon, 23 Jan 2017 14:11:34 +0900 Subject: [PATCH 073/248] node: strict platform value (#14134) * node: strict platform value From: https://nodejs.org/api/os.html#os_os_platform > Currently possible values are: > > - 'aix' > - 'darwin' > - 'freebsd' > - 'linux' > - 'openbsd' > - 'sunos' > - 'win32' > > Equivalent to process.platform. * node: add missing 'android' to platforms * node: improve platform strings also in v7 --- node/index.d.ts | 13 +++++++++++-- node/node-tests.ts | 1 - node/v6/index.d.ts | 13 +++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index 1f32030db7..32d3f5a203 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -347,6 +347,15 @@ declare namespace NodeJS { openssl: string; } + type Platform = 'aix' + | 'android' + | 'darwin' + | 'freebsd' + | 'linux' + | 'openbsd' + | 'sunos' + | 'win32'; + export interface Process extends EventEmitter { stdout: WritableStream; stderr: WritableStream; @@ -399,7 +408,7 @@ declare namespace NodeJS { pid: number; title: string; arch: string; - platform: string; + platform: Platform; mainModule?: NodeModule; memoryUsage(): MemoryUsage; cpuUsage(previousValue?: CpuUsage): CpuUsage; @@ -1311,7 +1320,7 @@ declare module "os" { }, }; export function arch(): string; - export function platform(): string; + export function platform(): NodeJS.Platform; export function tmpdir(): string; export var EOL: string; export function endianness(): "BE" | "LE"; diff --git a/node/node-tests.ts b/node/node-tests.ts index adcadb1a60..2844ca8e6e 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -1481,7 +1481,6 @@ namespace os_tests { result = os.endianness(); result = os.hostname(); result = os.type(); - result = os.platform(); result = os.arch(); result = os.release(); result = os.EOL; diff --git a/node/v6/index.d.ts b/node/v6/index.d.ts index ba3a7685fc..ed07d1cad1 100644 --- a/node/v6/index.d.ts +++ b/node/v6/index.d.ts @@ -347,6 +347,15 @@ declare namespace NodeJS { openssl: string; } + type Platform = 'aix' + | 'android' + | 'darwin' + | 'freebsd' + | 'linux' + | 'openbsd' + | 'sunos' + | 'win32'; + export interface Process extends EventEmitter { stdout: WritableStream; stderr: WritableStream; @@ -399,7 +408,7 @@ declare namespace NodeJS { pid: number; title: string; arch: string; - platform: string; + platform: Platform; mainModule?: NodeModule; memoryUsage(): MemoryUsage; cpuUsage(previousValue?: CpuUsage): CpuUsage; @@ -1262,7 +1271,7 @@ declare module "os" { }, }; export function arch(): string; - export function platform(): string; + export function platform(): NodeJS.Platform; export function tmpdir(): string; export var EOL: string; export function endianness(): "BE" | "LE"; From 5f59aa79209b1ca757d0168663daa5cb9af8e67a Mon Sep 17 00:00:00 2001 From: yohei1126 Date: Mon, 23 Jan 2017 14:39:29 +0900 Subject: [PATCH 074/248] add semicolon --- mqtt/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mqtt/index.d.ts b/mqtt/index.d.ts index 62e622e81d..f52aede457 100644 --- a/mqtt/index.d.ts +++ b/mqtt/index.d.ts @@ -238,7 +238,7 @@ declare namespace mqtt { /** * get last message id. This is for sent messages only. */ - getLastMessageId(): number + getLastMessageId(): number; } /** From 392b91f8d5375288f0041d1b6b2c01566c1eae1c Mon Sep 17 00:00:00 2001 From: keika299 Date: Mon, 23 Jan 2017 16:50:02 +0900 Subject: [PATCH 075/248] add autosize method --- autosize/autosize-tests.ts | 18 ++++++++++++++++++ autosize/index.d.ts | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/autosize/autosize-tests.ts b/autosize/autosize-tests.ts index 74be703a94..a7eea57a62 100644 --- a/autosize/autosize-tests.ts +++ b/autosize/autosize-tests.ts @@ -8,3 +8,21 @@ autosize(document.querySelector('textarea')); // from a single element autosize(document.getElementById('my-textarea')); + +// update a NodeList +autosize.update(document.querySelectorAll('textarea')); + +// update a single Node +autosize.update(document.querySelector('textarea')); + +// update a single element +autosize.update(document.getElementById('my-textarea')); + +// destroy a NodeList +autosize.destroy(document.querySelectorAll('textarea')); + +// destroy a single Node +autosize.destroy(document.querySelector('textarea')); + +// destroy a single element +autosize.destroy(document.getElementById('my-textarea')); diff --git a/autosize/index.d.ts b/autosize/index.d.ts index 5ea76d0472..0886904e3f 100644 --- a/autosize/index.d.ts +++ b/autosize/index.d.ts @@ -1,12 +1,16 @@ // Type definitions for jquery.autosize 3.0.7 // Project: http://www.jacklmoore.com/autosize/ -// Definitions by: Aaron T. King +// Definitions by: Aaron T. King , keika299 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace autosize { interface AutosizeStatic { (el: Element): void; (el: NodeList): void; + update(el: Element): void; + update(el: NodeList): void; + destroy(el: Element): void; + destroy(el: NodeList): void; } } From 52ad6adaa2a6dd74c168164c178fe33dd63f21e7 Mon Sep 17 00:00:00 2001 From: Robin maenhaut Date: Mon, 23 Jan 2017 09:05:49 +0100 Subject: [PATCH 076/248] Add support for custom style object in the PNotifyOptions --- jquery.pnotify/index.d.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jquery.pnotify/index.d.ts b/jquery.pnotify/index.d.ts index 668590e4d6..c0ab267b7d 100644 --- a/jquery.pnotify/index.d.ts +++ b/jquery.pnotify/index.d.ts @@ -6,7 +6,7 @@ /// type NoticeTypeOptions = "notice" | "info" | "success" | "error"; -type StylingOptions = "brighttheme" | "jqueryui" | "bootstrap2" | "bootstrap3" | "fontawesome"; +type StylingOptions = "brighttheme" | "jqueryui" | "bootstrap2" | "bootstrap3" | "fontawesome" | PNotifyStyling; type StateOptions = "initializing" | "opening" | "open" | "closing" | "closed"; interface PNotifyStack { @@ -134,7 +134,7 @@ interface PNotifyOptions { */ text_escape?: boolean; /** - * What styling classes to use. (Can be either "brighttheme", "jqueryui", "bootstrap2", "bootstrap3", or "fontawesome".) + * What styling classes to use. (Can be either "brighttheme", "jqueryui", "bootstrap2", "bootstrap3", "fontawesome" or a custom style object) */ styling?: StylingOptions; /** @@ -257,6 +257,18 @@ interface PNotifyOptions { labels?: PNotifyLabel; } +interface PNotifyStyling { + container?: string, + notice?: string, + notice_icon?: string, + info?: string, + info_icon?: string, + success?: string, + success_icon?: string, + error?: string, + error_icon?: string +} + interface PNotify { /** From ad57871fe05c3a46e172a702e91b7ff20a143778 Mon Sep 17 00:00:00 2001 From: Robin maenhaut Date: Mon, 23 Jan 2017 09:33:21 +0100 Subject: [PATCH 077/248] Include pnotify.buttons styling extensions --- jquery.pnotify/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.pnotify/index.d.ts b/jquery.pnotify/index.d.ts index c0ab267b7d..f15150ad20 100644 --- a/jquery.pnotify/index.d.ts +++ b/jquery.pnotify/index.d.ts @@ -266,7 +266,10 @@ interface PNotifyStyling { success?: string, success_icon?: string, error?: string, - error_icon?: string + error_icon?: string, + closer?: string, + pin_down?: string, + pin_up?: string } interface PNotify { From 4ff4f8d4fc9d5266ffbea44bc12391eefbb39695 Mon Sep 17 00:00:00 2001 From: Robin maenhaut Date: Mon, 23 Jan 2017 09:37:27 +0100 Subject: [PATCH 078/248] Add styling extensions for confirm, history and reference --- jquery.pnotify/index.d.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jquery.pnotify/index.d.ts b/jquery.pnotify/index.d.ts index f15150ad20..7600c45a09 100644 --- a/jquery.pnotify/index.d.ts +++ b/jquery.pnotify/index.d.ts @@ -267,9 +267,24 @@ interface PNotifyStyling { success_icon?: string, error?: string, error_icon?: string, + // buttons closer?: string, pin_down?: string, - pin_up?: string + pin_up?: string, + // confirm + btn?: string, + btnhover?: string, + btnactive?: string, + btnfocus?: string, + input?: string, + text?: string, + // history + hi_menu?: string, + hi_btn?: string, + hi_btnhov?: string, + hi_hnd?: string, + // reference + athing?: string } interface PNotify { From 42636ca79f11b05f15bc5e5ceeb15d9ff2cea083 Mon Sep 17 00:00:00 2001 From: Robin maenhaut Date: Mon, 23 Jan 2017 09:51:05 +0100 Subject: [PATCH 079/248] Add test for the new styling object --- jquery.pnotify/index.d.ts | 2 +- jquery.pnotify/jquery.pnotify-tests.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/jquery.pnotify/index.d.ts b/jquery.pnotify/index.d.ts index 7600c45a09..1d222efb26 100644 --- a/jquery.pnotify/index.d.ts +++ b/jquery.pnotify/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for jquery.pnotify 3.x // Project: https://github.com/sciactive/pnotify -// Definitions by: David Sichau +// Definitions by: David Sichau , Robin Maenhaut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// diff --git a/jquery.pnotify/jquery.pnotify-tests.ts b/jquery.pnotify/jquery.pnotify-tests.ts index c9465e0444..41cd7d3fda 100644 --- a/jquery.pnotify/jquery.pnotify-tests.ts +++ b/jquery.pnotify/jquery.pnotify-tests.ts @@ -243,5 +243,24 @@ function test_pnotify() { animation: 'show' }); + new PNotify({ + title: 'Custom styling', + text: 'Test all custom styling properties', + styling: { + container: "alert", + notice: "alert-warning", + notice_icon: "fa fa-exclamation-circle", + info: "alert-info", + info_icon: "fa fa-info", + success: "alert-success", + success_icon: "fa fa-check", + error: "alert-danger", + error_icon: "fa fa-warning", + closer: "fa fa-times", + pin_up: "fa fa-pause", + pin_down: "fa fa-play" + } + }); + PNotify.removeAll(); } From d2be90a50693461d0e2e4dd20c3d578533a779db Mon Sep 17 00:00:00 2001 From: mkollers Date: Mon, 23 Jan 2017 10:26:59 +0100 Subject: [PATCH 080/248] added group to Node http://visjs.org/docs/network/nodes.html# --- vis/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/vis/index.d.ts b/vis/index.d.ts index 92b6ea6a08..3ee00ba03a 100644 --- a/vis/index.d.ts +++ b/vis/index.d.ts @@ -1497,6 +1497,7 @@ export interface Data { } export interface Node { + group?: string; id?: IdType; label?: string; x?: number; From 39772baa2c32da872c8482088c784eb497e303c0 Mon Sep 17 00:00:00 2001 From: SamSchelfhout Date: Mon, 23 Jan 2017 10:37:00 +0100 Subject: [PATCH 081/248] Update index.d.ts to support ajaxTransport Update index.d.ts to jQuery.ajaxTransport(). See https://api.jquery.com/jQuery.ajaxTransport/ --- jquery/index.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jquery/index.d.ts b/jquery/index.d.ts index e0bf072983..3a785530aa 100644 --- a/jquery/index.d.ts +++ b/jquery/index.d.ts @@ -786,6 +786,15 @@ interface JQueryStatic { */ ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + /** + * Creates an object that handles the actual transmission of Ajax data. + * + * @param dataType A string identifying the data type to use. + * @param handler A handler to return the new transport object to use with the data type provided in the first argument. + * @see {@link https://api.jquery.com/jQuery.ajaxTransport/} + */ + ajaxTransport(dataType: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + ajaxSettings: JQueryAjaxSettings; /** From 2e002b40c39a71e25cf438c0303a38740012692e Mon Sep 17 00:00:00 2001 From: Carl Winkler Date: Mon, 23 Jan 2017 18:49:03 +0800 Subject: [PATCH 082/248] Implement types and tests for Dockerode --- dockerode/dockerode-tests.ts | 58 ++++ dockerode/index.d.ts | 643 +++++++++++++++++++++++++++++++++++ dockerode/tsconfig.json | 20 ++ dockerode/tslint.json | 3 + 4 files changed, 724 insertions(+) create mode 100644 dockerode/dockerode-tests.ts create mode 100644 dockerode/index.d.ts create mode 100644 dockerode/tsconfig.json create mode 100644 dockerode/tslint.json diff --git a/dockerode/dockerode-tests.ts b/dockerode/dockerode-tests.ts new file mode 100644 index 0000000000..e1533e91f7 --- /dev/null +++ b/dockerode/dockerode-tests.ts @@ -0,0 +1,58 @@ +import * as Docker from 'dockerode'; + +// Code samples from Dockerode 'Getting started' +const docker = new Docker(); +const docker1 = new Docker({ socketPath: '/var/run/docker.sock' }); +const docker2 = new Docker({ host: 'http://192.168.1.10', port: 3000 }); +const docker3 = new Docker({ protocol: 'http', host: '127.0.0.1', port: 3000 }); +const docker4 = new Docker({ host: '127.0.0.1', port: 3000 }); + +const docker5 = new Docker({ + host: '192.168.1.10', + port: process.env.DOCKER_PORT || 2375, + ca: 'ca', + cert: 'cert', + key: 'key' +}); + +const docker6 = new Docker({ + protocol: 'https', //you can enforce a protocol + host: '192.168.1.10', + port: process.env.DOCKER_PORT || 2375, + ca: 'ca', + cert: 'cert', + key: 'key' +}); + +const container = docker.getContainer('container-id'); +container.inspect((err, data) => { + // NOOP +}); + +container.start((err, data) => { + // NOOP +}); + +container.remove((err, data) => { + // NOOP +}); + +docker.listContainers((err, containers) => { + containers.forEach(container => { + docker + .getContainer(container.Id) + .stop((err, data) => { + // NOOP + }); + }); +}); + +docker.buildImage('archive.tar', { t: 'imageName' }, (err, response) => { + // NOOP +}); + +docker.createContainer({ Tty: true }, (err, container) => { + container.start((err, data) => { + // NOOP + }); +}); \ No newline at end of file diff --git a/dockerode/index.d.ts b/dockerode/index.d.ts new file mode 100644 index 0000000000..2c5caaf9cc --- /dev/null +++ b/dockerode/index.d.ts @@ -0,0 +1,643 @@ +// Type definitions for dockerode 2.3 +// Project: https://github.com/apocas/dockerode +// Definitions by: Carl Winkler +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as stream from 'stream'; +import * as events from 'events'; + + +declare namespace Dockerode { + interface Container { + inspect(options: {}, callback: Callback): void; + inspect(callback: Callback): void; + inspect(options?: {}): { id: string }; + + rename(options: {}, callback: Callback): void; + + update(options: {}, callback: Callback): void; + + top(options: {}, callback: Callback): void; + top(callback: Callback): void; + + changes(callback: Callback): void; + + export(callback: Callback): void; + + start(options: {}, callback: Callback): void; + start(callback: Callback): void; + + pause(options: {}, callback: Callback): void; + pause(callback: Callback): void; + + unpause(options: {}, callback: Callback): void; + unpause(callback: Callback): void; + + exec(options: {}, callback: Callback): void; + + commit(options: {}, callback: Callback): void; + commit(callback: Callback): void; + + stop(options: {}, callback: Callback): void; + stop(callback: Callback): void; + + restart(options: {}, callback: Callback): void; + restart(callback: Callback): void; + + kill(options: {}, callback: Callback): void; + kill(callback: Callback): void; + + resize(options: {}, callback: Callback): void; + resize(callback: Callback): void; + + wait(callback: Callback): void; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + + /** Deprecated since RAPI v1.20 */ + copy(options: {}, callback: Callback): void; + /** Deprecated since RAPI v1.20 */ + copy(callback: Callback): void; + + getArchive(options: {}, callback: Callback): void; + + infoArchive(options: {}, callback: Callback): void; + + /** @param file Filename (will read synchronously), Buffer or stream */ + putArchive(file: string | Buffer | NodeJS.ReadableStream, options: {}, callback: Callback): void; + + logs(options: { stdout?: boolean, stderr?: boolean, follow?: boolean, since?: number, details?: boolean, tail?: number, timestamps?: boolean }, callback: Callback): void; + logs(callback: Callback): void; + + stats(options: {}, callback: Callback): void; + stats(callback: Callback): void; + + attach(options: {}, callback: Callback): void; + + modem: any; + id?: string; + } + + interface Image { + inspect(callback: Callback): void; + + history(callback: Callback): void; + + get(callback: Callback): void; + + push(options: {}, callback: Callback): void; + push(callback: Callback): void; + + tag(options: {}, callback: Callback): void; + tag(callback: Callback): void; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + + modem: any; + id?: string; + } + + interface Volume { + inspect(callback: Callback): void; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + + modem: any; + name?: string; + } + + interface Service { + inspect(callback: Callback): void; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + + update(options: {}, callback: Callback): void; + + modem: any; + id?: string; + } + + interface Task { + inspect(callback: Callback): void; + + modem: any; + id?: string; + } + + interface Node { + inspect(callback: Callback): void; + + modem: any; + id?: string; + } + + interface Network { + inspect(callback: Callback): void; + + remove(options: {}, callback: Callback): void; + remove(callback: Callback): void; + + connect(options: {}, callback: Callback): void; + connect(callback: Callback): void; + + disconnect(options: {}, callback: Callback): void; + disconnect(callback: Callback): void; + + modem: any; + id?: string; + } + + interface Exec { + inspect(callback: Callback): void; + + start(options: {}, callback: Callback): void; + + resize(options: {}, callback: Callback): void; + + modem: any; + id?: string; + } + + interface ImageInfo { + Id: string; + ParentId: string; + RepoTags: string[]; + RepoDigests?: string[]; + Created: number; + Size: number; + VirtualSize: number; + Labels: { [label: string]: string }; + } + + interface ContainerInfo { + Id: string; + Names: string[]; + Image: string; + ImageID: string; + Command: string; + Created: number; + Ports: Port[]; + Labels: { [label: string]: string }; + Status: string; + HostConfig: { + NetworkMode: string; + }; + NetworkSettings: { + Networks: { [networkType: string]: NetworkInfo } + }; + } + + interface Port { + IP: string; + PrivatePort: number; + PublicPort: number; + Type: string; + } + + interface NetworkInfo { + IPAMConfig?: any; + Links?: any; + Aliases?: any; + NetworkID: string; + EndpointID: string; + Gateway: string; + IPAddress: string; + IPPrefixLen: number; + IPv6Gateway: string; + GlobalIPv6Address: string; + GlobalIPv6PrefixLen: number; + MacAddress: string; + } + + interface ContainerInspectInfo { + Id: string; + Created: string; + Path: string; + Args: string[]; + State: { + Status: string; + Running: boolean; + Paused: boolean; + Restarting: boolean; + OOMKilled: boolean; + Dead: boolean; + Pid: number; + ExitCode: number; + Error: string; + StartedAt: string; + FinishedAt: string; + }; + Image: string; + ResolvConfPath: string; + HostnamePath: string; + HostsPath: string; + LogPath: string; + Name: string; + RestartCount: number; + Driver: string; + MountLabel: string; + ProcessLabel: string; + AppArmorProfile: string; + ExecIDs?: any; + HostConfig: HostConfig; + GraphDriver: { + Name: string; + Data: { + DeviceId: string; + DeviceName: string; + DeviceSize: string; + } + }; + Mounts: Array<{ + Source: string; + Destination: string; + Mode: string; + RW: boolean; + Propagation: string; + }>; + Config: { + Hostname: string; + Domainname: string; + User: string; + AttachStdin: boolean; + AttachStdout: boolean; + AttachStderr: boolean; + ExposedPorts: { [portAndProtocol: string]: {} }; + Tty: boolean; + OpenStdin: boolean; + StdinOnce: boolean; + Env: string[]; + Cmd: string[]; + Image: string; + Volumes: { [volume: string]: {} }; + WorkingDir: string; + Entrypoint?: any; + OnBuild?: any; + Labels: { [label: string]: string } + }; + NetworkSettings: { + Bridge: string; + SandboxID: string; + HairpinMode: boolean; + LinkLocalIPv6Address: string; + LinkLocalIPv6PrefixLen: number; + Ports: { + [portAndProtocol: string]: { + HostIp: string; + HostPort: string; + } + }; + SandboxKey: string; + SecondaryIPAddresses?: any; + SecondaryIPv6Addresses?: any; + EndpointID: string; + Gateway: string; + GlobalIPv6Address: string; + GlobalIPv6PrefixLen: number; + IPAddress: string; + IPPrefixLen: number; + IPv6Gateway: string; + MacAddress: string; + Networks: { + [type: string]: { + IPAMConfig?: any; + Links?: any; + Aliases?: any; + NetworkID: string; + EndpointID: string; + Gateway: string; + IPAddress: string; + IPPrefixLen: number; + IPv6Gateway: string; + GlobalIPv6Address: string; + GlobalIPv6PrefixLen: number; + MacAddress: string; + } + } + }; + } + + interface HostConfig { + Binds: string[]; + ContainerIDFile: string; + LogConfig: { + Type: string; + Config: any; + }; + NetworkMode: string; + PortBindings?: any; + RestartPolicy: { + Name: string; + MaximumRetryCount: number; + }; + VolumeDriver: string; + VolumesFrom?: any; + CapAdd?: any; + CapDrop?: any; + Dns: any[]; + DnsOptions: any[]; + DnsSearch: any[]; + ExtraHosts?: any; + IpcMode: string; + Links?: any; + OomScoreAdj: number; + PidMode: string; + Privileged: boolean; + PublishAllPorts: boolean; + ReadonlyRootfs: boolean; + SecurityOpt?: any; + UTSMode: string; + ShmSize: number; + ConsoleSize: number[]; + Isolation: string; + CpuShares: number; + CgroupParent: string; + BlkioWeight: number; + BlkioWeightDevice?: any; + BlkioDeviceReadBps?: any; + BlkioDeviceWriteBps?: any; + BlkioDeviceReadIOps?: any; + BlkioDeviceWriteIOps?: any; + CpuPeriod: number; + CpuQuota: number; + CpusetCpus: string; + CpusetMems: string; + Devices?: any; + KernelMemory: number; + Memory: number; + MemoryReservation: number; + MemorySwap: number; + MemorySwappiness: number; + OomKillDisable: boolean; + PidsLimit: number; + Ulimits?: any; + } + + interface ImageInspectInfo { + Id: string; + RepoTags: string[]; + RepoDigests: string[]; + Parent: string; + Comment: string; + Created: string; + Container: string; + ContainerConfig: + { + Hostname: string; + Domainname: string; + User: string; + AttachStdin: boolean; + AttachStdout: boolean; + AttachStderr: boolean; + ExposedPorts: { [portAndProtocol: string]: {} }; + Tty: boolean; + OpenStdin: boolean; + StdinOnce: boolean; + Env: string[]; + Cmd: string[]; + ArgsEscaped: boolean; + Image: string; + Volumes: { [path: string]: {} }, + WorkingDir: string; + Entrypoint?: any; + OnBuild?: any[]; + Labels: { [label: string]: string } + }; + DockerVersion: string; + Author: string; + Config: + { + Hostname: string; + Domainname: string; + User: string; + AttachStdin: boolean; + AttachStdout: boolean; + AttachStderr: boolean; + ExposedPorts: { [portAndProtocol: string]: {} } + Tty: boolean; + OpenStdin: boolean; + StdinOnce: boolean; + Env: string[]; + Cmd: string[]; + ArgsEscaped: boolean; + Image: string; + Volumes: { [path: string]: {} }, + WorkingDir: string; + Entrypoint?: any; + OnBuild: any[]; + Labels: { [label: string]: string } + }; + Architecture: string; + Os: string; + Size: number; + VirtualSize: number; + GraphDriver: + { + Name: string; + Data: + { + DeviceId: string; + DeviceName: string; + DeviceSize: string; + } + }; + } + + interface ContainerCreateOptions { + name?: string; + Hostname?: string; + Domainname?: string; + User?: string; + AttachStdin?: boolean; + AttachStdout?: boolean; + AttachStderr?: boolean; + Tty?: boolean; + OpenStdin?: boolean; + StdinOnce?: boolean; + Env?: string[]; + Cmd?: string[]; + Entrypoint?: string; + Image?: string; + Labels?: { [label: string]: string }; + Volumes?: { [volume: string]: {} }; + WorkingDir?: string; + NetworkDisabled?: boolean; + MacAddress?: boolean; + ExposedPorts?: { [port: string]: {} }; + StopSignal?: string; + HostConfig?: { + Binds?: string[]; + Links?: string[]; + Memory?: number; + MemorySwap?: number; + MemoryReservation?: number; + KernelMemory?: number; + CpuPercent?: number; + CpuShares?: number; + CpuPeriod?: number; + CpuQuota?: number; + CpusetMems?: string; + MaximumIOps?: number; + MaxmimumIOBps?: number; + BlkioWeightDevice?: Array<{}>; + BlkioDeviceReadBps?: Array<{}>; + BlkioDeviceReadIOps?: Array<{}>; + BlkioDeviceWriteBps?: Array<{}>; + BlkioDeviceWriteIOps?: Array<{}>; + MemorySwappiness?: number; + OomKillDisable?: boolean; + OomScoreAdj?: number; + PidMode?: string; + PidsLimit?: number; + PortBindings?: { [portAndProtocol: string]: Array<{ [index: string]: string }> }; + PublishAllPorts?: boolean; + Privileged?: boolean; + ReadonlyRootfs?: boolean; + Dns?: string[]; + DnsOptions?: string[]; + DnsSearch?: string[]; + ExtraHosts?: any; + VolumesFrom?: string[]; + CapAdd?: string[]; + CapDrop?: string[]; + GroupAdd?: string[]; + RestartPolicy?: { [index: string]: number | string }; + NetworkMode?: string; + Devices?: any[]; + Sysctls?: { [index: string]: string }; + Ulimits?: Array<{}>; + LogConfig?: { [index: string]: string | {} }; + SecurityOpt?: { [index: string]: any }; + CgroupParent?: string; + VolumeDriver?: string; + ShmSize?: number; + }; + NetworkingConfig?: { + EndpointsConfig?: { + [index: string]: any; + isolated_nw?: { + [index: string]: any; + IPAMConfig?: { + IPv4Address?: string; + IPv6Adress?: string; + LinkLocalIPs?: string[]; + } + Links?: string[]; + Aliases?: string[]; + } + } + }; + } + + interface DockerOptions { + socketPath?: string; + host?: string; + port?: number; + ca?: string; + cert?: string; + key?: string; + protocol?: "https" | "http"; + timeout?: number; + } +} + +type Callback = (error?: any, result?: T) => void; + +declare class Dockerode { + constructor(options?: Dockerode.DockerOptions); + + createContainer(options: Dockerode.ContainerCreateOptions, callback: Callback): void; + + createImage(options: {}, callback: Callback): void; + createImage(auth: any, options: {}, callback: Callback): void; + + loadImage(file: string, options: {}, callback: Callback): void; + loadImage(file: string, callback: Callback): void; + + importImage(file: string, options: {}, callback: Callback): void; + importImage(file: string, callback: Callback): void; + + checkAuth(options: any, callback: Callback): void; + + buildImage(file: string | NodeJS.ReadableStream, options: {}, callback: Callback): void; + buildImage(file: string | NodeJS.ReadableStream, callback: Callback): void; + + getContainer(id: string): Dockerode.Container; + + getImage(name: string): Dockerode.Image; + + getVolume(name: string): Dockerode.Volume; + + getService(id: string): Dockerode.Service; + + getTask(id: string): Dockerode.Task; + + getNode(id: string): Node; + + getNetwork(id: string): Dockerode.Network; + + getExec(id: string): Dockerode.Exec; + + listContainers(options: {}, callback: Callback): void; + listContainers(callback: Callback): void; + + listImages(options: {}, callback: Callback): void; + listImages(callback: Callback): void; + + listServices(options: {}, callback: Callback): void; + listServices(callback: Callback): void; + + listNodes(options: {}, callback: Callback): void; + listNodes(callback: Callback): void; + + listTasks(options: {}, callback: Callback): void; + listTasks(callback: Callback): void; + + listVolumes(options: {}, callback: Callback): void; + listVolumes(callback: Callback): void; + + listNetworks(options: {}, callback: Callback): void; + listNetworks(callback: Callback): void; + + createVolume(options: {}, callback: Callback): void; + + createService(options: {}, callback: Callback): void; + + createNetwork(options: {}, callback: Callback): void; + + searchImages(options: {}, callback: Callback): void; + + info(callback: Callback): void; + + version(callback: Callback): void; + + ping(callback: Callback): void; + + getEvents(options: {}, callback: Callback): void; + getEvents(callback: Callback): void; + + pull(repoTag: string, options: {}, callback: Callback, auth?: {}): Dockerode.Image; + + run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, createOptions: {}, startOptions: {}, callback: Callback): events.EventEmitter; + run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, startOptions: {}, callback: Callback): events.EventEmitter; + run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, callback: Callback): events.EventEmitter; + run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, createOptions: {}, callback: Callback): events.EventEmitter; + + swarmInit(options: {}, callback: Callback): void; + + swarmJoin(options: {}, callback: Callback): void; + + swarmLeave(options: {}, callback: Callback): void; + + swarmUpdate(options: {}, callback: Callback): void; + + modem: any; +} + +export = Dockerode; \ No newline at end of file diff --git a/dockerode/tsconfig.json b/dockerode/tsconfig.json new file mode 100644 index 0000000000..a077f02e3c --- /dev/null +++ b/dockerode/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dockerode-tests.ts" + ] +} \ No newline at end of file diff --git a/dockerode/tslint.json b/dockerode/tslint.json new file mode 100644 index 0000000000..785a601162 --- /dev/null +++ b/dockerode/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From ff113b3b1cfb2b7c98e2efd6e10ddb04d43bc031 Mon Sep 17 00:00:00 2001 From: darlin Date: Mon, 23 Jan 2017 20:14:41 +0800 Subject: [PATCH 083/248] add sub module export --- crypto-js/index.d.ts | 237 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 3 deletions(-) diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index 5fdf193254..a2c0ee381d 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -3,9 +3,6 @@ // Definitions by: Michael Zabka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = CryptoJS; -export as namespace CryptoJS; - declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { type Hash = (message: string, key?: string, ...options: any[]) => string; @@ -113,5 +110,239 @@ declare namespace CryptoJS { NoPadding: Padding; }; } + } +declare module "crypto-js" { + var CryptoJS: CryptoJS.Hashes; + export = CryptoJS; +} + +/* --------------------------------- */ +declare module "crypto-js/core" { + var core: any; + export = core; +} + +declare module "crypto-js/x64-core" { + var x64: any; + export = x64; +} + +declare module "crypto-js/lib-typedarrays" { + var libWordArray: any; + export = libWordArray; +} + +/* --------------------------------- */ +declare module "crypto-js/md5" { + var MD5: CryptoJS.Hash; + export = MD5; +} + +declare module "crypto-js/sha1" { + var SHA1: CryptoJS.Hash; + export = SHA1; +} + +declare module "crypto-js/sha256" { + var SHA256: CryptoJS.Hash; + export = SHA256; +} + +declare module "crypto-js/sha224" { + var SHA224: CryptoJS.Hash; + export = SHA224; +} + +declare module "crypto-js/sha512" { + var SHA512: CryptoJS.Hash; + export = SHA512; +} + +declare module "crypto-js/sha384" { + var SHA384: CryptoJS.Hash; + export = SHA384; +} + +declare module "crypto-js/sha3" { + var SHA3: CryptoJS.Hash; + export = SHA3; +} + +declare module "crypto-js/ripemd160" { + var RIPEMD160: CryptoJS.Hash; + export = RIPEMD160; +} + +/* --------------------------------- */ +declare module "crypto-js/hmac-md5" { + var HmacMD5: CryptoJS.Hash; + export = HmacMD5; +} + +declare module "crypto-js/hmac-sha1" { + var HmacSHA1: CryptoJS.Hash; + export = HmacSHA1; +} + +declare module "crypto-js/hmac-sha256" { + var HmacSHA256: CryptoJS.Hash; + export = HmacSHA256; +} + +declare module "crypto-js/hmac-sha224" { + var HmacSHA224: CryptoJS.Hash; + export = HmacSHA224; +} + +declare module "crypto-js/hmac-sha512" { + var HmacSHA512: CryptoJS.Hash; + export = HmacSHA512; +} + +declare module "crypto-js/hmac-sha384" { + var HmacSHA384: CryptoJS.Hash; + export = HmacSHA384; +} + +declare module "crypto-js/hmac-sha3" { + var HmacSHA3: CryptoJS.Hash; + export = HmacSHA3; +} + +declare module "crypto-js/hmac-ripemd160" { + var HmacRIPEMD160: CryptoJS.Hash; + export = HmacRIPEMD160; +} + +/* --------------------------------- */ +declare module "crypto-js/pbkdf2" { + var PBKDF2: CryptoJS.Hash; + export = PBKDF2; +} + +/* --------------------------------- */ +declare module "crypto-js/aes" { + var AES: CryptoJS.Cipher; + export = AES; +} + +declare module "crypto-js/tripledes" { + var TripleDES: CryptoJS.Cipher; + export = TripleDES; +} + +declare module "crypto-js/rc4" { + var RC4: CryptoJS.Cipher; + export = RC4; +} + +declare module "crypto-js/rabbit" { + var Rabbit: CryptoJS.Cipher; + export = Rabbit; +} + +declare module "crypto-js/rabbit-legacy" { + var RabbitLegacy: CryptoJS.Cipher; + export = RabbitLegacy; +} + +declare module "crypto-js/evpkdf" { + var EvpKDF: CryptoJS.Cipher; + export = EvpKDF; +} + +/* --------------------------------- */ +declare module "crypto-js/format-openssl" { + var FormatOpenssl: any; + export = FormatOpenssl; +} + +declare module "crypto-js/format-hex" { + var FormatHex: any; + export = FormatHex; +} + +/* --------------------------------- */ +declare module "crypto-js/enc-latin1" { + var encLatin1: CryptoJS.Encoder; + export = encLatin1; +} + +declare module "crypto-js/enc-utf8" { + var encUtf8: CryptoJS.Encoder; + export = encUtf8; +} + +declare module "crypto-js/enc-hex" { + var encHex: CryptoJS.Encoder; + export = encHex; +} + +declare module "crypto-js/enc-utf16" { + var encUtf16: CryptoJS.Encoder; + export = encUtf16; +} + +declare module "crypto-js/enc-base64" { + var encBase64: CryptoJS.Encoder; + export = encBase64; +} + +/* --------------------------------- */ +declare module "crypto-js/mode-cfb" { + var modeCFB: CryptoJS.Mode; + export = modeCFB; +} + +declare module "crypto-js/mode-ctr" { + var modeCTR: CryptoJS.Mode; + export = modeCTR; +} + +declare module "crypto-js/mode-ctr-gladman" { + var modeCTRGladman: CryptoJS.Mode; + export = modeCTRGladman; +} + +declare module "crypto-js/mode-ofb" { + var modeOFB: CryptoJS.Mode; + export = modeOFB; +} + +declare module "crypto-js/mode-ecb" { + var modeECB: CryptoJS.Mode; + export = modeECB; +} + +/* --------------------------------- */ +declare module "crypto-js/pad-pkcs7" { + var padPkcs7: CryptoJS.Padding; + export = padPkcs7; +} + +declare module "crypto-js/pad-ansix923" { + var padAnsiX923: CryptoJS.Padding; + export = padAnsiX923; +} + +declare module "crypto-js/pad-iso10126" { + var padIso10126: CryptoJS.Padding; + export = padIso10126; +} + +declare module "crypto-js/pad-iso97971" { + var padIso97971: CryptoJS.Padding; + export = padIso97971; +} + +declare module "crypto-js/pad-zeropadding" { + var padZeroPadding: CryptoJS.Padding; + export = padZeroPadding; +} + +declare module "crypto-js/pad-nopadding" { + var padNoPadding: CryptoJS.Padding; + export = padNoPadding; +} From a6d113976a6f759abb85c948eca760722512a658 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 23 Jan 2017 12:20:37 +0000 Subject: [PATCH 084/248] Added @pzavolinsky and @bbenezech as maintainers --- react/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/index.d.ts b/react/index.d.ts index e59234ae6c..9972f80998 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for React v15.0 // Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft , John Reilly +// Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = React; From 7ba0fa586127729532dbe3aad56f6547385745fd Mon Sep 17 00:00:00 2001 From: darlin Date: Mon, 23 Jan 2017 20:35:35 +0800 Subject: [PATCH 085/248] add typescript module export to suport import * as SimpleMDE from 'simplemde' --- simplemde/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/simplemde/index.d.ts b/simplemde/index.d.ts index 6c199f48a7..eb463ae655 100644 --- a/simplemde/index.d.ts +++ b/simplemde/index.d.ts @@ -127,4 +127,8 @@ declare class SimpleMDE { static toggleFullScreen: (editor: SimpleMDE) => void; static undo: (editor: SimpleMDE) => void; static redo: (editor: SimpleMDE) => void; -} \ No newline at end of file +} + +declare module "simplemde" { + export = SimpleMDE; +} From fc6a9729df46769b7a50cffe4414dc913ba6da28 Mon Sep 17 00:00:00 2001 From: Kir Dergachev Date: Mon, 23 Jan 2017 16:14:33 +0300 Subject: [PATCH 086/248] Fixes errors references. Removes references to webrtc --- sip.js/index.d.ts | 68 ++++++++++++++++++++---------------------- sip.js/sip.js-tests.ts | 36 +++++++++++----------- sip.js/tslint.json | 3 +- 3 files changed, 51 insertions(+), 56 deletions(-) diff --git a/sip.js/index.d.ts b/sip.js/index.d.ts index 942a0d22b3..be01cd3682 100644 --- a/sip.js/index.d.ts +++ b/sip.js/index.d.ts @@ -3,21 +3,23 @@ // Definitions by: Kir Dergachev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +declare interface SIP { + UA: { + new (configuration?: sipjs.ConfigurationParameters): sipjs.UA; + }; + URI: { + new (scheme?: string, user?: string, host?: string, port?: number, parameters?: string[], headers?: string[]): sipjs.URI; + parse(uri: string): sipjs.URI; + }; + NameAddrHeader: { + new (uri: string | sipjs.URI, displayName: string, parameters: Array<{ key: string, value: string }>): sipjs.NameAddrHeader; + parse(name_addr_header: string): sipjs.NameAddrHeader; + }; +} -export = SIP; - -declare namespace SIP { - - class URI { - constructor( - scheme?: string, - user?: string, - host?: string, - port?: number, - parameters?: string[], - headers?: string[]); +declare namespace sipjs { + interface URI { scheme?: string; user?: string; host?: string; @@ -35,8 +37,6 @@ declare namespace SIP { clearHeaders(): void; clone(): URI; toString(): string; - - static parse(uri: string): URI; } namespace UA.EventArgs { @@ -45,8 +45,7 @@ declare namespace SIP { interface RegistrationFailedArgs extends UnregisteredArgs { } } - class UA { - constructor(configuration?: ConfigurationParameters); + interface UA { start(): void; stop(): void; register(options?: ExtraHeadersOptions): UA; @@ -59,7 +58,7 @@ declare namespace SIP { request(method: string, target: string | URI, options?: RequestOptions): ClientContext; on(name: 'connected', callback: (args: UA.EventArgs.ConnectedArgs) => void): void; - on(name: 'disconnected' | 'registered', callback: () => void): void; + on(name: 'disconnected' | 'registered' | string, callback: () => void): void; on(name: 'unregistered', callback: (args: UA.EventArgs.UnregisteredArgs) => void): void; on(name: 'registrationFailed', callback: (args: UA.EventArgs.RegistrationFailedArgs) => void): void; on(name: 'invite', callback: (session: Session) => void): void; @@ -81,7 +80,7 @@ declare namespace SIP { } } - class Session { + interface Session { startTime?: Date; endTime?: Date; ua?: UA; @@ -95,8 +94,8 @@ declare namespace SIP { dtmf(tone: string | number, options?: Session.DtmfOptions): Session; terminate(options?: Session.CommonOptions): Session; bye(options?: Session.CommonOptions): Session; - getLocalStreams(): MediaStream[]; - getRemoteStreams(): MediaStream[]; + getLocalStreams(): any[]; + getRemoteStreams(): any[]; refer(target: string | Session, options?: ExtraHeadersOptions): Session; mute(options?: ExtraHeadersOptions): void; unmute(options?: ExtraHeadersOptions): void; @@ -111,7 +110,7 @@ declare namespace SIP { on(name: 'accepted', callback: (data: { code: number, response: IncomingResponse }) => void): void; on(name: 'failed' | 'rejected', callback: (response: IncomingResponse, cause: string) => void): void; on(name: 'terminated', callback: (message: IncomingResponse, cause: string) => void): void; - on(name: 'cancel', callback: () => void): void; + on(name: 'cancel' | string, callback: () => void): void; on(name: 'replaced', callback: (newSession: Session) => void): void; on(name: 'dtmf', callback: (request: IncomingRequest, dtmf: Session.DTMF) => void): void; on(name: 'muted' | 'unmuted', callback: (data: Session.Muted) => void): void; @@ -136,7 +135,7 @@ declare namespace SIP { } interface AcceptOptions { - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; media?: MediaOptions; } @@ -169,21 +168,21 @@ declare namespace SIP { interface Options { stunServers?: string | string[]; turnServers?: TurnServer | TurnServer[]; - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; } type MediaHandlerFactory = (session: Session, options: Options) => MediaHandler; class MediaHandler { - getLocalStreams(): MediaStream[]; - getRemoteStreams(): MediaStream[]; + getLocalStreams(): any[]; + getRemoteStreams(): any[]; render(renderHint: RenderHint): void; on(name: 'userMediaRequest', callback: (constraints: MediaConstraints) => void): void; - on(name: 'addStream' | 'userMedia', callback: (stream: MediaStream) => void): void; + on(name: 'addStream' | 'userMedia', callback: (stream: any) => void): void; on(name: 'userMediaFailed', callback: (error: string) => void): void; - on(name: 'iceCandidate', callback: (candidate: RTCIceCandidate) => void): void; - on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed', callback: () => void): void; + on(name: 'iceCandidate', callback: (candidate: any) => void): void; + on(name: 'iceGathering' | 'iceGatheringComplete' | 'iceConnection' | 'iceConnectionChecking' | 'iceConnectionConnected' | 'iceConnectionCompleted' | 'iceConnectionFailed' | 'iceConnectionDisconnected' | 'iceConnectionClosed' | string, callback: () => void): void; on(name: 'dataChannel' | 'getDescription' | 'setDescription', callback: (sdpWrapper: { type: string, sdp: string }) => void): void; } } @@ -247,7 +246,7 @@ declare namespace SIP { interface MediaOptions { constraints?: MediaConstraints; - stream?: MediaStream; + stream?: any; render?: RenderHint; } @@ -256,7 +255,7 @@ declare namespace SIP { anonymous?: boolean; rel100?: string; inviteWithoutSdp?: boolean; - RTCConstraints?: RTCPeerConnection; + RTCConstraints?: any; } interface RequestOptions extends ExtraHeadersOptions { @@ -290,6 +289,7 @@ declare namespace SIP { data: {}; on(name: 'progress' | 'accepted' | 'rejected' | 'failed', callback: (response: IncomingMessage, cause: string) => void): void; on(name: 'notify', callback: (request: IncomingRequest) => void): void; + on(name: string, callback: () => void): void; } interface ClientContext extends Context { @@ -320,9 +320,7 @@ declare namespace SIP { } /* Header */ - class NameAddrHeader { - constructor(uri: string | URI, displayName: string, parameters: Array<{ key: string, value: string }>); - + interface NameAddrHeader { uri: string | URI; displayName: string; @@ -330,7 +328,5 @@ declare namespace SIP { getParam(key: string): string; deleteParam(key: string): string; clearParams(): void; - - static parse(name_addr_header: string): NameAddrHeader; } } diff --git a/sip.js/sip.js-tests.ts b/sip.js/sip.js-tests.ts index f688fe67ae..524caf1827 100644 --- a/sip.js/sip.js-tests.ts +++ b/sip.js/sip.js-tests.ts @@ -1,11 +1,11 @@ -import SIP = require("./index"); +declare var sip: SIP; -let ua: SIP.UA = new SIP.UA(); +let ua: sipjs.UA = new sip.UA(); -const mediaHandler = (session: SIP.Session, options: SIP.WebRTC.Options) => new SIP.WebRTC.MediaHandler(); +const mediaHandler = (session: sipjs.Session, options: sipjs.WebRTC.Options) => new sipjs.WebRTC.MediaHandler(); const logConnector = (level: string, category: string, label: string, content: string) => null; -const uaWithConfig: SIP.UA = new SIP.UA({ +const uaWithConfig: sipjs.UA = new sip.UA({ uri: "wss://uri", wsServers: ["s1", "s2"], allowLegacyNotifications: true, @@ -38,7 +38,7 @@ const uaWithConfig: SIP.UA = new SIP.UA({ stunServers: ["", ""], turnServers: [ { - password: "", + password: "", username: "", urls: ["", ""] } @@ -61,15 +61,15 @@ ua.unregister({ extraHeaders: [""], all: true }); const isConnected: boolean = ua.isConnected(); const isRegistered: boolean = ua.isRegistered(); -const message: SIP.Message = ua.message("", "", { contentType: "" }); +const message: sipjs.Message = ua.message("", "", { contentType: "" }); -ua.subscribe("", "", { expires: 1, extraHeaders: [""]}); -const subscription: SIP.Subscription = ua.subscribe(new SIP.URI(), "", { expires: 1, extraHeaders: [""]}); +ua.subscribe("", "", { expires: 1, extraHeaders: [""] }); +const subscription: sipjs.Subscription = ua.subscribe(new sip.URI(), "", { expires: 1, extraHeaders: [""] }); let session = ua.invite("", new HTMLVideoElement()); -const inviteOptions: SIP.InviteOptions = { - media: { +const inviteOptions: sipjs.InviteOptions = { + media: { constraints: { audio: true, video: false }, stream: new MediaStream(), render: { remote: new Element(), local: new Element() }, @@ -77,17 +77,17 @@ const inviteOptions: SIP.InviteOptions = { anonymous: true, rel100: "", inviteWithoutSdp: true, - RTCConstraints: new RTCPeerConnection() + RTCConstraints: {} } session = ua.invite("", inviteOptions); -ua.on('connected', (args: SIP.UA.EventArgs.ConnectedArgs) => {}); -ua.on('disconnected', () => {}); -ua.on('registered', () => {}); -ua.on('unregistered', (args: SIP.UA.EventArgs.UnregisteredArgs) => {}); -ua.on('registrationFailed', (args: SIP.UA.EventArgs.RegistrationFailedArgs) => {}); -ua.on('invite', (session: SIP.Session) => { +ua.on('connected', (args: sipjs.UA.EventArgs.ConnectedArgs) => { }); +ua.on('disconnected', () => { }); +ua.on('registered', () => { }); +ua.on('unregistered', (args: sipjs.UA.EventArgs.UnregisteredArgs) => { }); +ua.on('registrationFailed', (args: sipjs.UA.EventArgs.RegistrationFailedArgs) => { }); +ua.on('invite', (session: sipjs.Session) => { session.on('progress', (response) => { }); session.on('accepted', (response) => { @@ -96,4 +96,4 @@ ua.on('invite', (session: SIP.Session) => { }); }); -ua.on('message', (message: SIP.Message) => {}); +ua.on('message', (message: sipjs.Message) => { }); diff --git a/sip.js/tslint.json b/sip.js/tslint.json index c78c443ad2..105f5736e6 100644 --- a/sip.js/tslint.json +++ b/sip.js/tslint.json @@ -1,7 +1,6 @@ { "extends": "../tslint.json", "rules": { - "no-empty-interface": false, - "export-just-namespace": false + "no-empty-interface": false } } From ebf5d7ce980cd6ed58e13894bd957248d50e2c35 Mon Sep 17 00:00:00 2001 From: Jan Varwig Date: Mon, 23 Jan 2017 15:57:31 +0100 Subject: [PATCH 087/248] Add spline property to c3 ChartConfiguration This has been added to C3 in 0.4.11: https://github.com/c3js/c3/commit/bbb6d1c0366164b6c472b87d2cbde7dbc7c4629e --- c3/index.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/c3/index.d.ts b/c3/index.d.ts index aa960b0b60..5edb096395 100644 --- a/c3/index.d.ts +++ b/c3/index.d.ts @@ -248,6 +248,15 @@ declare namespace c3 { */ width?: number; }; + + spline?: { + interpolation?: { + /** + * Set custom spline interpolation + */ + type?: 'linear' | 'linear-closed' | 'basis' | 'basis-open' | 'basis-closed' | 'bundle' | 'cardinal' | 'cardinal-open' | 'cardinal-closed' | 'monotone'; + }; + }; } interface Data { From 63916eca261c67c465508e84ea9f02696e9bc299 Mon Sep 17 00:00:00 2001 From: BingoRUS Date: Mon, 23 Jan 2017 19:47:01 +0300 Subject: [PATCH 088/248] Update DevExtreme definitions to 16.2.4 16.2 is the new major version of DevExtreme. Read more about changes here: https://www.devexpress.com/Support/WhatsNew/DevExtreme/ --- devextreme/index.d.ts | 1819 ++++++++++++++++++++--------------------- 1 file changed, 876 insertions(+), 943 deletions(-) diff --git a/devextreme/index.d.ts b/devextreme/index.d.ts index 6aae49d6cd..e327800618 100644 --- a/devextreme/index.d.ts +++ b/devextreme/index.d.ts @@ -1,10 +1,472 @@ -// Type definitions for DevExtreme 16.1.8 +// Type definitions for DevExtreme 16.2.4 // Project: http://js.devexpress.com/ // Definitions by: DevExpress Inc. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +interface JQuery { + dxAccordion(): JQuery; + dxAccordion(options: "instance"): DevExpress.ui.dxAccordion; + dxAccordion(options: string): any; + dxAccordion(options: string, ...params: any[]): any; + dxAccordion(options: DevExpress.ui.dxAccordionOptions): JQuery; +} +interface JQuery { + dxActionSheet(): JQuery; + dxActionSheet(options: "instance"): DevExpress.ui.dxActionSheet; + dxActionSheet(options: string): any; + dxActionSheet(options: string, ...params: any[]): any; + dxActionSheet(options: DevExpress.ui.dxActionSheetOptions): JQuery; +} +interface JQuery { + dxAutocomplete(): JQuery; + dxAutocomplete(options: "instance"): DevExpress.ui.dxAutocomplete; + dxAutocomplete(options: string): any; + dxAutocomplete(options: string, ...params: any[]): any; + dxAutocomplete(options: DevExpress.ui.dxAutocompleteOptions): JQuery; +} +interface JQuery { + dxBox(): JQuery; + dxBox(options: "instance"): DevExpress.ui.dxBox; + dxBox(options: string): any; + dxBox(options: string, ...params: any[]): any; + dxBox(options: DevExpress.ui.dxBoxOptions): JQuery; +} +interface JQuery { + dxButton(): JQuery; + dxButton(options: "instance"): DevExpress.ui.dxButton; + dxButton(options: string): any; + dxButton(options: string, ...params: any[]): any; + dxButton(options: DevExpress.ui.dxButtonOptions): JQuery; +} +interface JQuery { + dxCalendar(): JQuery; + dxCalendar(options: "instance"): DevExpress.ui.dxCalendar; + dxCalendar(options: string): any; + dxCalendar(options: string, ...params: any[]): any; + dxCalendar(options: DevExpress.ui.dxCalendarOptions): JQuery; +} +interface JQuery { + dxCheckBox(): JQuery; + dxCheckBox(options: "instance"): DevExpress.ui.dxCheckBox; + dxCheckBox(options: string): any; + dxCheckBox(options: string, ...params: any[]): any; + dxCheckBox(options: DevExpress.ui.dxCheckBoxOptions): JQuery; +} +interface JQuery { + dxColorBox(): JQuery; + dxColorBox(options: "instance"): DevExpress.ui.dxColorBox; + dxColorBox(options: string): any; + dxColorBox(options: string, ...params: any[]): any; + dxColorBox(options: DevExpress.ui.dxColorBoxOptions): JQuery; +} +interface JQuery { + dxContextMenu(): JQuery; + dxContextMenu(options: "instance"): DevExpress.ui.dxContextMenu; + dxContextMenu(options: string): any; + dxContextMenu(options: string, ...params: any[]): any; + dxContextMenu(options: DevExpress.ui.dxContextMenuOptions): JQuery; +} +interface JQuery { + dxDataGrid(): JQuery; + dxDataGrid(options: "instance"): DevExpress.ui.dxDataGrid; + dxDataGrid(options: string): any; + dxDataGrid(options: string, ...params: any[]): any; + dxDataGrid(options: DevExpress.ui.dxDataGridOptions): JQuery; +} +interface JQuery { + dxDateBox(): JQuery; + dxDateBox(options: "instance"): DevExpress.ui.dxDateBox; + dxDateBox(options: string): any; + dxDateBox(options: string, ...params: any[]): any; + dxDateBox(options: DevExpress.ui.dxDateBoxOptions): JQuery; +} +interface JQuery { + dxDeferRendering(): JQuery; + dxDeferRendering(options: "instance"): DevExpress.ui.dxDeferRendering; + dxDeferRendering(options: string): any; + dxDeferRendering(options: string, ...params: any[]): any; + dxDeferRendering(options: DevExpress.ui.dxDeferRenderingOptions): JQuery; +} +interface JQuery { + dxFileUploader(): JQuery; + dxFileUploader(options: "instance"): DevExpress.ui.dxFileUploader; + dxFileUploader(options: string): any; + dxFileUploader(options: string, ...params: any[]): any; + dxFileUploader(options: DevExpress.ui.dxFileUploaderOptions): JQuery; +} +interface JQuery { + dxForm(): JQuery; + dxForm(options: "instance"): DevExpress.ui.dxForm; + dxForm(options: string): any; + dxForm(options: string, ...params: any[]): any; + dxForm(options: DevExpress.ui.dxFormOptions): JQuery; +} +interface JQuery { + dxGallery(): JQuery; + dxGallery(options: "instance"): DevExpress.ui.dxGallery; + dxGallery(options: string): any; + dxGallery(options: string, ...params: any[]): any; + dxGallery(options: DevExpress.ui.dxGalleryOptions): JQuery; +} +interface JQuery { + dxList(): JQuery; + dxList(options: "instance"): DevExpress.ui.dxList; + dxList(options: string): any; + dxList(options: string, ...params: any[]): any; + dxList(options: DevExpress.ui.dxListOptions): JQuery; +} +interface JQuery { + dxLoadIndicator(): JQuery; + dxLoadIndicator(options: "instance"): DevExpress.ui.dxLoadIndicator; + dxLoadIndicator(options: string): any; + dxLoadIndicator(options: string, ...params: any[]): any; + dxLoadIndicator(options: DevExpress.ui.dxLoadIndicatorOptions): JQuery; +} +interface JQuery { + dxLoadPanel(): JQuery; + dxLoadPanel(options: "instance"): DevExpress.ui.dxLoadPanel; + dxLoadPanel(options: string): any; + dxLoadPanel(options: string, ...params: any[]): any; + dxLoadPanel(options: DevExpress.ui.dxLoadPanelOptions): JQuery; +} +interface JQuery { + dxLookup(): JQuery; + dxLookup(options: "instance"): DevExpress.ui.dxLookup; + dxLookup(options: string): any; + dxLookup(options: string, ...params: any[]): any; + dxLookup(options: DevExpress.ui.dxLookupOptions): JQuery; +} +interface JQuery { + dxMap(): JQuery; + dxMap(options: "instance"): DevExpress.ui.dxMap; + dxMap(options: string): any; + dxMap(options: string, ...params: any[]): any; + dxMap(options: DevExpress.ui.dxMapOptions): JQuery; +} +interface JQuery { + dxMenu(): JQuery; + dxMenu(options: "instance"): DevExpress.ui.dxMenu; + dxMenu(options: string): any; + dxMenu(options: string, ...params: any[]): any; + dxMenu(options: DevExpress.ui.dxMenuOptions): JQuery; +} +interface JQuery { + dxMultiView(): JQuery; + dxMultiView(options: "instance"): DevExpress.ui.dxMultiView; + dxMultiView(options: string): any; + dxMultiView(options: string, ...params: any[]): any; + dxMultiView(options: DevExpress.ui.dxMultiViewOptions): JQuery; +} +interface JQuery { + dxNavBar(): JQuery; + dxNavBar(options: "instance"): DevExpress.ui.dxNavBar; + dxNavBar(options: string): any; + dxNavBar(options: string, ...params: any[]): any; + dxNavBar(options: DevExpress.ui.dxNavBarOptions): JQuery; +} +interface JQuery { + dxNumberBox(): JQuery; + dxNumberBox(options: "instance"): DevExpress.ui.dxNumberBox; + dxNumberBox(options: string): any; + dxNumberBox(options: string, ...params: any[]): any; + dxNumberBox(options: DevExpress.ui.dxNumberBoxOptions): JQuery; +} +interface JQuery { + dxPanorama(): JQuery; + dxPanorama(options: "instance"): DevExpress.ui.dxPanorama; + dxPanorama(options: string): any; + dxPanorama(options: string, ...params: any[]): any; + dxPanorama(options: DevExpress.ui.dxPanoramaOptions): JQuery; +} +interface JQuery { + dxPivot(): JQuery; + dxPivot(options: "instance"): DevExpress.ui.dxPivot; + dxPivot(options: string): any; + dxPivot(options: string, ...params: any[]): any; + dxPivot(options: DevExpress.ui.dxPivotOptions): JQuery; +} +interface JQuery { + dxPivotGrid(): JQuery; + dxPivotGrid(options: "instance"): DevExpress.ui.dxPivotGrid; + dxPivotGrid(options: string): any; + dxPivotGrid(options: string, ...params: any[]): any; + dxPivotGrid(options: DevExpress.ui.dxPivotGridOptions): JQuery; +} +interface JQuery { + dxPivotGridFieldChooser(): JQuery; + dxPivotGridFieldChooser(options: "instance"): DevExpress.ui.dxPivotGridFieldChooser; + dxPivotGridFieldChooser(options: string): any; + dxPivotGridFieldChooser(options: string, ...params: any[]): any; + dxPivotGridFieldChooser(options: DevExpress.ui.dxPivotGridFieldChooserOptions): JQuery; +} +interface JQuery { + dxPopover(): JQuery; + dxPopover(options: "instance"): DevExpress.ui.dxPopover; + dxPopover(options: string): any; + dxPopover(options: string, ...params: any[]): any; + dxPopover(options: DevExpress.ui.dxPopoverOptions): JQuery; +} +interface JQuery { + dxPopup(): JQuery; + dxPopup(options: "instance"): DevExpress.ui.dxPopup; + dxPopup(options: string): any; + dxPopup(options: string, ...params: any[]): any; + dxPopup(options: DevExpress.ui.dxPopupOptions): JQuery; +} +interface JQuery { + dxProgressBar(): JQuery; + dxProgressBar(options: "instance"): DevExpress.ui.dxProgressBar; + dxProgressBar(options: string): any; + dxProgressBar(options: string, ...params: any[]): any; + dxProgressBar(options: DevExpress.ui.dxProgressBarOptions): JQuery; +} +interface JQuery { + dxRadioGroup(): JQuery; + dxRadioGroup(options: "instance"): DevExpress.ui.dxRadioGroup; + dxRadioGroup(options: string): any; + dxRadioGroup(options: string, ...params: any[]): any; + dxRadioGroup(options: DevExpress.ui.dxRadioGroupOptions): JQuery; +} +interface JQuery { + dxRangeSlider(): JQuery; + dxRangeSlider(options: "instance"): DevExpress.ui.dxRangeSlider; + dxRangeSlider(options: string): any; + dxRangeSlider(options: string, ...params: any[]): any; + dxRangeSlider(options: DevExpress.ui.dxRangeSliderOptions): JQuery; +} +interface JQuery { + dxResizable(): JQuery; + dxResizable(options: "instance"): DevExpress.ui.dxResizable; + dxResizable(options: string): any; + dxResizable(options: string, ...params: any[]): any; + dxResizable(options: DevExpress.ui.dxResizableOptions): JQuery; +} +interface JQuery { + dxResponsiveBox(): JQuery; + dxResponsiveBox(options: "instance"): DevExpress.ui.dxResponsiveBox; + dxResponsiveBox(options: string): any; + dxResponsiveBox(options: string, ...params: any[]): any; + dxResponsiveBox(options: DevExpress.ui.dxResponsiveBoxOptions): JQuery; +} +interface JQuery { + dxScheduler(): JQuery; + dxScheduler(options: "instance"): DevExpress.ui.dxScheduler; + dxScheduler(options: string): any; + dxScheduler(options: string, ...params: any[]): any; + dxScheduler(options: DevExpress.ui.dxSchedulerOptions): JQuery; +} +interface JQuery { + dxScrollView(): JQuery; + dxScrollView(options: "instance"): DevExpress.ui.dxScrollView; + dxScrollView(options: string): any; + dxScrollView(options: string, ...params: any[]): any; + dxScrollView(options: DevExpress.ui.dxScrollViewOptions): JQuery; +} +interface JQuery { + dxSelectBox(): JQuery; + dxSelectBox(options: "instance"): DevExpress.ui.dxSelectBox; + dxSelectBox(options: string): any; + dxSelectBox(options: string, ...params: any[]): any; + dxSelectBox(options: DevExpress.ui.dxSelectBoxOptions): JQuery; +} +interface JQuery { + dxSlideOut(): JQuery; + dxSlideOut(options: "instance"): DevExpress.ui.dxSlideOut; + dxSlideOut(options: string): any; + dxSlideOut(options: string, ...params: any[]): any; + dxSlideOut(options: DevExpress.ui.dxSlideOutOptions): JQuery; +} +interface JQuery { + dxSlideOutView(): JQuery; + dxSlideOutView(options: "instance"): DevExpress.ui.dxSlideOutView; + dxSlideOutView(options: string): any; + dxSlideOutView(options: string, ...params: any[]): any; + dxSlideOutView(options: DevExpress.ui.dxSlideOutViewOptions): JQuery; +} +interface JQuery { + dxSlider(): JQuery; + dxSlider(options: "instance"): DevExpress.ui.dxSlider; + dxSlider(options: string): any; + dxSlider(options: string, ...params: any[]): any; + dxSlider(options: DevExpress.ui.dxSliderOptions): JQuery; +} +interface JQuery { + dxSwitch(): JQuery; + dxSwitch(options: "instance"): DevExpress.ui.dxSwitch; + dxSwitch(options: string): any; + dxSwitch(options: string, ...params: any[]): any; + dxSwitch(options: DevExpress.ui.dxSwitchOptions): JQuery; +} +interface JQuery { + dxTabPanel(): JQuery; + dxTabPanel(options: "instance"): DevExpress.ui.dxTabPanel; + dxTabPanel(options: string): any; + dxTabPanel(options: string, ...params: any[]): any; + dxTabPanel(options: DevExpress.ui.dxTabPanelOptions): JQuery; +} +interface JQuery { + dxTabs(): JQuery; + dxTabs(options: "instance"): DevExpress.ui.dxTabs; + dxTabs(options: string): any; + dxTabs(options: string, ...params: any[]): any; + dxTabs(options: DevExpress.ui.dxTabsOptions): JQuery; +} +interface JQuery { + dxTagBox(): JQuery; + dxTagBox(options: "instance"): DevExpress.ui.dxTagBox; + dxTagBox(options: string): any; + dxTagBox(options: string, ...params: any[]): any; + dxTagBox(options: DevExpress.ui.dxTagBoxOptions): JQuery; +} +interface JQuery { + dxTextArea(): JQuery; + dxTextArea(options: "instance"): DevExpress.ui.dxTextArea; + dxTextArea(options: string): any; + dxTextArea(options: string, ...params: any[]): any; + dxTextArea(options: DevExpress.ui.dxTextAreaOptions): JQuery; +} +interface JQuery { + dxTextBox(): JQuery; + dxTextBox(options: "instance"): DevExpress.ui.dxTextBox; + dxTextBox(options: string): any; + dxTextBox(options: string, ...params: any[]): any; + dxTextBox(options: DevExpress.ui.dxTextBoxOptions): JQuery; +} +interface JQuery { + dxTileView(): JQuery; + dxTileView(options: "instance"): DevExpress.ui.dxTileView; + dxTileView(options: string): any; + dxTileView(options: string, ...params: any[]): any; + dxTileView(options: DevExpress.ui.dxTileViewOptions): JQuery; +} +interface JQuery { + dxToast(): JQuery; + dxToast(options: "instance"): DevExpress.ui.dxToast; + dxToast(options: string): any; + dxToast(options: string, ...params: any[]): any; + dxToast(options: DevExpress.ui.dxToastOptions): JQuery; +} +interface JQuery { + dxToolbar(): JQuery; + dxToolbar(options: "instance"): DevExpress.ui.dxToolbar; + dxToolbar(options: string): any; + dxToolbar(options: string, ...params: any[]): any; + dxToolbar(options: DevExpress.ui.dxToolbarOptions): JQuery; +} +interface JQuery { + dxTooltip(): JQuery; + dxTooltip(options: "instance"): DevExpress.ui.dxTooltip; + dxTooltip(options: string): any; + dxTooltip(options: string, ...params: any[]): any; + dxTooltip(options: DevExpress.ui.dxTooltipOptions): JQuery; +} +interface JQuery { + dxTreeView(): JQuery; + dxTreeView(options: "instance"): DevExpress.ui.dxTreeView; + dxTreeView(options: string): any; + dxTreeView(options: string, ...params: any[]): any; + dxTreeView(options: DevExpress.ui.dxTreeViewOptions): JQuery; +} +interface JQuery { + dxValidationGroup(): JQuery; + dxValidationGroup(options: "instance"): DevExpress.ui.dxValidationGroup; + dxValidationGroup(options: string): any; + dxValidationGroup(options: string, ...params: any[]): any; + dxValidationGroup(options: DevExpress.ui.dxValidationGroupOptions): JQuery; +} +interface JQuery { + dxValidationSummary(): JQuery; + dxValidationSummary(options: "instance"): DevExpress.ui.dxValidationSummary; + dxValidationSummary(options: string): any; + dxValidationSummary(options: string, ...params: any[]): any; + dxValidationSummary(options: DevExpress.ui.dxValidationSummaryOptions): JQuery; +} +interface JQuery { + dxValidator(): JQuery; + dxValidator(options: "instance"): DevExpress.ui.dxValidator; + dxValidator(options: string): any; + dxValidator(options: string, ...params: any[]): any; + dxValidator(options: DevExpress.ui.dxValidatorOptions): JQuery; +} +interface JQuery { + dxBarGauge(): JQuery; + dxBarGauge(options: "instance"): DevExpress.viz.dxBarGauge; + dxBarGauge(options: string): any; + dxBarGauge(options: string, ...params: any[]): any; + dxBarGauge(options: DevExpress.viz.gauges.dxBarGaugeOptions): JQuery; +} +interface JQuery { + dxBullet(): JQuery; + dxBullet(options: "instance"): DevExpress.viz.dxBullet; + dxBullet(options: string): any; + dxBullet(options: string, ...params: any[]): any; + dxBullet(options: DevExpress.viz.sparklines.dxBulletOptions): JQuery; +} +interface JQuery { + dxChart(): JQuery; + dxChart(options: "instance"): DevExpress.viz.dxChart; + dxChart(options: string): any; + dxChart(options: string, ...params: any[]): any; + dxChart(options: DevExpress.viz.charts.dxChartOptions): JQuery; +} +interface JQuery { + dxCircularGauge(): JQuery; + dxCircularGauge(options: "instance"): DevExpress.viz.dxCircularGauge; + dxCircularGauge(options: string): any; + dxCircularGauge(options: string, ...params: any[]): any; + dxCircularGauge(options: DevExpress.viz.gauges.dxCircularGaugeOptions): JQuery; +} +interface JQuery { + dxLinearGauge(): JQuery; + dxLinearGauge(options: "instance"): DevExpress.viz.dxLinearGauge; + dxLinearGauge(options: string): any; + dxLinearGauge(options: string, ...params: any[]): any; + dxLinearGauge(options: DevExpress.viz.gauges.dxLinearGaugeOptions): JQuery; +} +interface JQuery { + dxPieChart(): JQuery; + dxPieChart(options: "instance"): DevExpress.viz.dxPieChart; + dxPieChart(options: string): any; + dxPieChart(options: string, ...params: any[]): any; + dxPieChart(options: DevExpress.viz.charts.dxPieChartOptions): JQuery; +} +interface JQuery { + dxPolarChart(): JQuery; + dxPolarChart(options: "instance"): DevExpress.viz.dxPolarChart; + dxPolarChart(options: string): any; + dxPolarChart(options: string, ...params: any[]): any; + dxPolarChart(options: DevExpress.viz.charts.dxPolarChartOptions): JQuery; +} +interface JQuery { + dxRangeSelector(): JQuery; + dxRangeSelector(options: "instance"): DevExpress.viz.dxRangeSelector; + dxRangeSelector(options: string): any; + dxRangeSelector(options: string, ...params: any[]): any; + dxRangeSelector(options: DevExpress.viz.rangeSelector.dxRangeSelectorOptions): JQuery; +} +interface JQuery { + dxSparkline(): JQuery; + dxSparkline(options: "instance"): DevExpress.viz.dxSparkline; + dxSparkline(options: string): any; + dxSparkline(options: string, ...params: any[]): any; + dxSparkline(options: DevExpress.viz.sparklines.dxSparklineOptions): JQuery; +} +interface JQuery { + dxTreeMap(): JQuery; + dxTreeMap(options: "instance"): DevExpress.viz.dxTreeMap; + dxTreeMap(options: string): any; + dxTreeMap(options: string, ...params: any[]): any; + dxTreeMap(options: DevExpress.viz.treeMap.dxTreeMapOptions): JQuery; +} +interface JQuery { + dxVectorMap(): JQuery; + dxVectorMap(options: "instance"): DevExpress.viz.dxVectorMap; + dxVectorMap(options: string): any; + dxVectorMap(options: string, ...params: any[]): any; + dxVectorMap(options: DevExpress.viz.map.dxVectorMapOptions): JQuery; +} declare module DevExpress { /** Formats values. */ export interface Format { @@ -68,9 +530,9 @@ declare module DevExpress { export function resetGroup(): void; /** Validates the rules that are defined within the dxValidator objects that are registered for the specified ViewModel. */ export function validateModel(model: Object): ValidationGroupValidationResult; - /** Registers all the dxValidator objects extending fields of the specified ViewModel. */ + /** Registers all the Validator objects extending fields of the specified ViewModel. */ export function registerModelForValidation(model: Object): void; - /** Unregisters all the dxValidator objects extending fields of the specified ViewModel. */ + /** Unregisters all the Validator objects extending fields of the specified ViewModel. */ export function unregisterModelForValidation(model: Object): void; } export var hardwareBackButton: JQueryCallback; @@ -78,10 +540,7 @@ declare module DevExpress { export function processHardwareBackButton(): void; /** Hides the last displayed overlay widget. */ export function hideTopOverlay(): boolean; - /** - * Specifies whether or not the entire application/site supports right-to-left representation. - * @deprecated Use the config(config) method instead. - */ + /** * Specifies whether or not the entire application/site supports right-to-left representation. * @deprecated Use the config(config) method instead. */ export var rtlEnabled: boolean; /** Gets the current global configuration object. */ export function config(): Object; @@ -265,6 +724,8 @@ declare module DevExpress { height?: any; /** Specifies the width of the widget. */ width?: any; + /** Specifies the attributes to be attached to the widget's root element. */ + elementAttr?: Object; /** A bag for holding any options that require two-way binding (Angular approach specific) */ bindingOptions?: { [key: string]: any; }; } @@ -312,6 +773,9 @@ declare module DevExpress { key?: any; } export interface LoadOptions { + searchValue?: Object; + searchExpr?: Object; + searchOperation?: Object; filter?: Object; sort?: Object; select?: Object; @@ -682,25 +1146,34 @@ declare module DevExpress { /** Creates a Query instance for accessing the remote service specified by a URL. */ export function query(url: string, queryOptions: Object): Query; /** This section describes the utility objects provided by the DevExtreme data layer. */ - export var utils: { + export module utils { /** Compiles a getter function from the getter expression. */ - compileGetter(expr: any): Function; + export function compileGetter(expr: any): Function; /** Compiles a setter function from the setter expression. */ - compileSetter(expr: any): Function; - odata: { + export function compileSetter(expr: any): Function; + export module odata { /** Holds key value converters for OData. */ - keyConverters: { - String(value: any): string; - Int32(value: any): number; - Int64(value: any): EdmLiteral; - Guid(value: any): Guid; - Boolean(value: any): boolean; - Single(value: any): EdmLiteral; - Decimal(value: any): EdmLiteral; - }; + export module keyConverters { + export function String(value: any): string; + export function Int32(value: any): number; + export function Int64(value: any): EdmLiteral; + export function Guid(value: any): Guid; + export function Boolean(value: any): boolean; + export function Single(value: any): EdmLiteral; + export function Decimal(value: any): EdmLiteral; + } } } } + /** An object that serves as a namespace for the methods that are used to localize an application. */ + export module localization { + /** Gets the current locale identifier. */ + export function locale(): string; + /** Sets the current locale identifier. */ + export function locale(locale: string): void; + /** Loads DevExtreme messages. */ + export function loadMessages(messages: any): void; + } /** An object that serves as a namespace for DevExtreme UI widgets as well as for methods implementing UI logic in DevExtreme sites/applications. */ export module ui { export interface WidgetOptions extends DOMComponentOptions { @@ -760,6 +1233,10 @@ declare module DevExpress { selectedItem?: Object; /** An array of currently selected item objects. */ selectedItems?: Array; + /** Specifies an array of currently selected item keys. */ + selectedItemKeys?: Array; + /** Specifies which data field provides keys for widget items. */ + keyExpr?: any; /** A handler for the itemDeleting event. */ onItemDeleting?: Function; /** A handler for the itemDeleted event. */ @@ -767,8 +1244,13 @@ declare module DevExpress { /** A handler for the itemReordered event. */ onItemReordered?: Function; } + export interface DataHelperMixin { + /** Allows you to get the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; + } /** The base class for widgets containing an item collection. */ - export class CollectionWidget extends Widget { + export class CollectionWidget extends Widget implements DataHelperMixin + { constructor(element: JQuery, options?: CollectionWidgetOptions); constructor(element: HTMLElement, options?: CollectionWidgetOptions); selectItem(itemElement: any): void; @@ -776,6 +1258,7 @@ declare module DevExpress { deleteItem(itemElement: any): JQueryPromise; isItemSelected(itemElement: any): boolean; reorderItem(itemElement: any, toItemElement: any): JQueryPromise; + getDataSource(): DevExpress.data.DataSource; } export interface DataExpressionMixinOptions { /** A data source used to fetch data to be displayed by the widget. */ @@ -794,6 +1277,8 @@ declare module DevExpress { export interface EditorOptions extends WidgetOptions { /** The currently specified value. */ value?: Object; + /** The value to be assigned to the name attribute of the underlying `` element. */ + name?: string; /** A handler for the valueChanged event. */ onValueChanged?: Function; /** A Boolean value specifying whether or not the widget is read-only. */ @@ -840,14 +1325,14 @@ declare module DevExpress { export function setTemplateEngine(options: Object): void; } /** An object that serves as a namespace for utility methods that can be helpful when working with the DevExtreme framework and UI widgets. */ - export var utils: { + export module utils { /** Sets parameters for the viewport meta tag. */ - initMobileViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void; + export function initMobileViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void; /** Requests that the browser call a specified function to update animation before the next repaint. */ - requestAnimationFrame(callback: Function): number; + export function requestAnimationFrame(callback: Function): number; /** Cancels an animation frame request scheduled with the requestAnimationFrame method. */ - cancelAnimationFrame(requestID: number): void; - }; + export function cancelAnimationFrame(requestID: number): void; + } /** An object that serves as a namespace for DevExtreme Data Visualization Widgets. */ export module viz { /** Applies a theme for the entire page with several DevExtreme visualization widgets. */ @@ -897,15 +1382,18 @@ declare module DevExpress.ui { export class dxValidator extends DOMComponent implements validationEngine.IValidator { constructor(element: JQuery, options?: dxValidatorOptions); constructor(element: Element, options?: dxValidatorOptions); - /** Validates the value of the editor that is controlled by the current dxValidator object against the list of the specified validation rules. */ + /** Validates the value of the editor that is controlled by the current Validator object against the list of the specified validation rules. */ validate(): validationEngine.ValidatorValidationResult; - /** Resets the value and validation result of the editor associated with the current dxValidator object. */ + /** Resets the value and validation result of the editor associated with the current Validator object. */ reset(): void; + /** Sets focus to the editor associated with the current Validator object. */ + focus(): void; } + export interface dxValidationGroupOptions extends DOMComponentOptions { } /** The widget that is used in the Knockout and AngularJS approaches to combine the editors to be validated. */ export class dxValidationGroup extends DOMComponent { - constructor(element: JQuery); - constructor(element: Element); + constructor(element: JQuery, options?: dxValidationGroupOptions); + constructor(element: Element, options?: dxValidationGroupOptions); /** Validates rules of the validators that belong to the current validation group. */ validate(): validationEngine.ValidationGroupValidationResult; /** Resets the value and validation result of the editors that are included to the current validation group. */ @@ -969,10 +1457,7 @@ declare module DevExpress.ui { valueChangeEvent?: string; /** Specifies whether or not the widget supports searching. */ searchEnabled?: boolean; - /** - * Specifies whether or not the widget displays items by pages. - * @deprecated Use the DataSource paging opportunities instead. - */ + /** * Specifies whether or not the widget displays items by pages. * @deprecated Use the DataSource paging opportunities instead. */ pagingEnabled?: boolean; /** The text or HTML markup displayed by the widget if the item collection is empty. */ noDataText?: string; @@ -983,9 +1468,10 @@ declare module DevExpress.ui { onContentReady?: Function; } /** A base class for drop-down list widgets. */ - export class dxDropDownList extends dxDropDownEditor { + export class dxDropDownList extends dxDropDownEditor implements DataHelperMixin { constructor(element: JQuery, options?: dxDropDownListOptions); constructor(element: Element, options?: dxDropDownListOptions); + getDataSource(): DevExpress.data.DataSource; } export interface dxToolbarOptions extends CollectionWidgetOptions { /** The template used to render menu items. */ @@ -1059,8 +1545,9 @@ declare module DevExpress.ui { valueChangeEvent?: string; /** Specifies whether or not the widget checks the inner text for spelling mistakes. */ spellcheck?: boolean; - /** Specifies HTML attributes applied to the inner input element of the widget. */ attr?: Object; + /** Specifies the attributes to be passed on to the underlying `` element. */ + inputAttr?: Object; /** The read-only option that holds the text displayed by the widget input element. */ text?: string; focusStateEnabled?: boolean; @@ -1075,6 +1562,7 @@ declare module DevExpress.ui { maskInvalidMessage?: string; /** Specifies whether the value option holds only characters entered by a user or prompt characters as well. */ useMaskedValue?: boolean; + name?: string; } /** A base class for text editing widgets. */ export class dxTextEditor extends Editor { @@ -1278,6 +1766,7 @@ declare module DevExpress.ui { activeStateEnabled?: boolean; /** Specifies the radio group layout. */ layout?: string; + name?: string; } /** A widget that enables a user to select one item within a list of items represented by radio buttons. */ export class dxRadioGroup extends CollectionWidget { @@ -1356,6 +1845,20 @@ declare module DevExpress.ui { target?: any; /** Specifies the width of the widget. */ width?: any; + /** Specifies options for displaying the widget. */ + showEvent?: { + /** Specifies the event names on which the widget is shown. */ + name?: String; + /** The time span after which the widget is shown. */ + delay?: Number; + }; + /** Specifies options of popover hiding. */ + hideEvent?: { + /** Specifies the event names on which the widget is hidden. */ + name?: String; + /** The time span after which the popover is hidden. */ + delay?: Number; + }; } /** A widget that displays the required content in a popup window. */ export class dxPopover extends dxPopup { @@ -1628,10 +2131,7 @@ declare module DevExpress.ui { shading?: boolean; /** Specifies whether to display the Cancel button in the lookup window. */ showCancelButton?: boolean; - /** - * A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. - * @deprecated Use the pageLoadMode option instead. - */ + /** * A Boolean value specifying whether the widget loads the next page automatically when you reach the bottom of the list or when a button is clicked. * @deprecated Use the pageLoadMode option instead. */ showNextButton?: boolean; /** The title of the lookup window. */ title?: string; @@ -1751,6 +2251,8 @@ declare module DevExpress.ui { showSelectionControls?: boolean; /** Specifies item selection mode. */ selectionMode?: string; + /** Specifies the mode in which all items are selected. */ + selectAllMode?: string; selectAllText?: string; /** A handler for the selectAllValueChanged event. */ onSelectAllValueChanged?: Function; @@ -1898,17 +2400,11 @@ declare module DevExpress.ui { min?: any; /** The text displayed by the widget when the widget value is not yet specified. This text is also used as a title of the date picker. */ placeholder?: string; - /** - * Specifies whether or not a user can pick out a date using the drop-down calendar. - * @deprecated Use the pickerType option instead. - */ + /** * Specifies whether or not a user can pick out a date using the drop-down calendar. * @deprecated Use the pickerType option instead. */ useCalendar?: boolean; /** An object or a value, specifying the date and time currently selected using the date box. */ value?: any; - /** - * Specifies whether or not the widget uses the native HTML input element. - * @deprecated Use the pickerType option instead. - */ + /** * Specifies whether or not the widget uses the native HTML input element. * @deprecated Use the pickerType option instead. */ useNative?: boolean; /** Specifies the interval between neighboring values in the popup list in minutes. */ interval?: number; @@ -1940,6 +2436,7 @@ declare module DevExpress.ui { value?: boolean; /** Specifies the text displayed by the check box. */ text?: string; + name?: string; } /** A check box widget. */ export class dxCheckBox extends Editor { @@ -1968,6 +2465,7 @@ declare module DevExpress.ui { minZoomLevel?: string; /** The template to be used for rendering calendar cells. */ cellTemplate?: any; + name?: string; } /** A calendar widget. */ export class dxCalendar extends Editor { @@ -1990,6 +2488,8 @@ declare module DevExpress.ui { type?: string; /** Specifies the name of the validation group to be accessed in the click event handler. */ validationGroup?: string; + /** Specifies whether the button must submit an HTML form. */ + useSubmitBehavior?: boolean; } /** A button widget. */ export class dxButton extends Widget { @@ -2134,8 +2634,6 @@ declare module DevExpress.ui { min?: number; /** The maximum value the widget can accept. */ max?: number; - /** The current widget value. */ - value?: number; } /** A base class for track bar widgets. */ export class dxTrackBar extends Editor { @@ -2149,18 +2647,18 @@ declare module DevExpress.ui { showStatus?: boolean; /** A handler for the complete event. */ onComplete?: Function; + /** The current widget value. */ + value?: number; } /** A widget used to indicate progress. */ export class dxProgressBar extends dxTrackBar { constructor(element: JQuery, options?: dxProgressBarOptions); constructor(element: Element, options?: dxProgressBarOptions); } - export interface dxSliderOptions extends dxTrackBarOptions { + export interface dxSliderBaseOptions extends dxTrackBarOptions { activeStateEnabled?: boolean; /** The slider step size. */ step?: number; - /** The current slider value. */ - value?: number; /** Specifies whether or not to highlight a range selected within the widget. */ showRange?: boolean; /** Specifies the size of a step by which a slider handle is moved when a user uses the Page up or Page down keyboard shortcuts. */ @@ -2185,17 +2683,27 @@ declare module DevExpress.ui { /** Specifies a format for labels. */ format?: any; }; + name?: string; + } + export interface dxSliderOptions extends dxSliderBaseOptions { + /** The current slider value. */ + value?: number; } /** A widget that allows a user to select a numeric value within a given range. */ export class dxSlider extends dxTrackBar { constructor(element: JQuery, options?: dxSliderOptions); constructor(element: Element, options?: dxSliderOptions); } - export interface dxRangeSliderOptions extends dxSliderOptions { + export interface dxRangeSliderOptions extends dxSliderBaseOptions { /** The left edge of the interval currently selected using the range slider. */ start?: number; /** The right edge of the interval currently selected using the range slider. */ end?: number; + /** The value to be assigned to the name attribute of the underlying `` element. */ + startName?: string; + /** The value to be assigned to the name attribute of the underlying `` element. */ + endName?: string; + value?: Array; } /** A widget that enables a user to select a range of numeric values. */ export class dxRangeSlider extends dxSlider { @@ -2226,10 +2734,12 @@ declare module DevExpress.ui { /** Specifies the number of columns spanned by the item. */ colSpan?: number; } + /** This article describes configuration options of an empty form item. */ export interface dxFormEmptyItem extends dxFormItem { /** Specifies the form item name. */ name?: string; } + /** This article describes configuration options of a simple form item. */ export interface dxFormSimpleItem extends dxFormItem { /** Specifies the path to the formData object field bound to the current form item. */ dataField?: string; @@ -2261,6 +2771,7 @@ declare module DevExpress.ui { /** The count of columns for a large screen size. */ lg?: number; } + /** This article describes configuration options of a group form item. */ export interface dxFormGroupItem extends dxFormItem { /** Specifies the group caption. */ caption?: string; @@ -2297,6 +2808,7 @@ declare module DevExpress.ui { /** The template to be used for rendering the tab content. */ template?: any; } + /** This article describes configuration options of a tabbed form item. */ export interface dxFormTabbedItem extends dxFormItem { /** Holds a configuration object for the TabPanel widget used to display the current form item. */ tabPanelOptions?: Object; @@ -2346,6 +2858,8 @@ declare module DevExpress.ui { items?: Array; /** A Boolean value specifying whether to enable or disable form scrolling. */ scrollingEnabled?: boolean; + /** Gives a name to the internal validation group. */ + validationGroup?: string; onContentReady?: Function; } /** A form widget used to display and edit values of object fields. */ @@ -2391,228 +2905,34 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxDeferRenderingOptions); } } +/* Private plugins. To be removed */ interface JQuery { - dxProgressBar(): JQuery; - dxProgressBar(options: "instance"): DevExpress.ui.dxProgressBar; - dxProgressBar(options: string): any; - dxProgressBar(options: string, ...params: any[]): any; - dxProgressBar(options: DevExpress.ui.dxProgressBarOptions): JQuery; - dxSlider(): JQuery; - dxSlider(options: "instance"): DevExpress.ui.dxSlider; - dxSlider(options: string): any; - dxSlider(options: string, ...params: any[]): any; - dxSlider(options: DevExpress.ui.dxSliderOptions): JQuery; - dxRangeSlider(): JQuery; - dxRangeSlider(options: "instance"): DevExpress.ui.dxRangeSlider; - dxRangeSlider(options: string): any; - dxRangeSlider(options: string, ...params: any[]): any; - dxRangeSlider(options: DevExpress.ui.dxRangeSliderOptions): JQuery; - dxFileUploader(): JQuery; - dxFileUploader(options: "instance"): DevExpress.ui.dxFileUploader; - dxFileUploader(options: string): any; - dxFileUploader(options: string, ...params: any[]): any; - dxFileUploader(options: DevExpress.ui.dxFileUploaderOptions): JQuery; - dxValidator(): JQuery; - dxValidator(options: "instance"): DevExpress.ui.dxValidator; - dxValidator(options: string): any; - dxValidator(options: string, ...params: any[]): any; - dxValidator(options: DevExpress.ui.dxValidatorOptions): JQuery; - dxValidationGroup(): JQuery; - dxValidationGroup(options: "instance"): DevExpress.ui.dxValidationGroup; - dxValidationGroup(options: string): any; - dxValidationGroup(options: string, ...params: any[]): any; - dxValidationSummary(): JQuery; - dxValidationSummary(options: "instance"): DevExpress.ui.dxValidationSummary; - dxValidationSummary(options: string): any; - dxValidationSummary(options: string, ...params: any[]): any; - dxValidationSummary(options: DevExpress.ui.dxValidationSummaryOptions): JQuery; - dxTooltip(): JQuery; - dxTooltip(options: "instance"): DevExpress.ui.dxTooltip; - dxTooltip(options: string): any; - dxTooltip(options: string, ...params: any[]): any; - dxTooltip(options: DevExpress.ui.dxTooltipOptions): JQuery; - dxResizable(): JQuery; - dxResizable(options: "instance"): DevExpress.ui.dxResizable; - dxResizable(options: string): any; - dxResizable(options: string, ...params: any[]): any; - dxResizable(options: DevExpress.ui.dxResizableOptions): JQuery; dxDropDownList(): JQuery; dxDropDownList(options: "instance"): DevExpress.ui.dxDropDownList; dxDropDownList(options: string): any; dxDropDownList(options: string, ...params: any[]): any; dxDropDownList(options: DevExpress.ui.dxDropDownListOptions): JQuery; - dxToolbar(): JQuery; - dxToolbar(options: "instance"): DevExpress.ui.dxToolbar; - dxToolbar(options: string): any; - dxToolbar(options: string, ...params: any[]): any; - dxToolbar(options: DevExpress.ui.dxToolbarOptions): JQuery; - dxToast(): JQuery; - dxToast(options: "instance"): DevExpress.ui.dxToast; - dxToast(options: string): any; - dxToast(options: string, ...params: any[]): any; - dxToast(options: DevExpress.ui.dxToastOptions): JQuery; dxTextEditor(): JQuery; dxTextEditor(options: "instance"): DevExpress.ui.dxTextEditor; dxTextEditor(options: string): any; dxTextEditor(options: string, ...params: any[]): any; dxTextEditor(options: DevExpress.ui.dxTextEditorOptions): JQuery; - dxTextBox(): JQuery; - dxTextBox(options: "instance"): DevExpress.ui.dxTextBox; - dxTextBox(options: string): any; - dxTextBox(options: string, ...params: any[]): any; - dxTextBox(options: DevExpress.ui.dxTextBoxOptions): JQuery; - dxTextArea(): JQuery; - dxTextArea(options: "instance"): DevExpress.ui.dxTextArea; - dxTextArea(options: string): any; - dxTextArea(options: string, ...params: any[]): any; - dxTextArea(options: DevExpress.ui.dxTextAreaOptions): JQuery; - dxTabs(): JQuery; - dxTabs(options: "instance"): DevExpress.ui.dxTabs; - dxTabs(options: string): any; - dxTabs(options: string, ...params: any[]): any; - dxTabs(options: DevExpress.ui.dxTabsOptions): JQuery; - dxTabPanel(): JQuery; - dxTabPanel(options: "instance"): DevExpress.ui.dxTabPanel; - dxTabPanel(options: string): any; - dxTabPanel(options: string, ...params: any[]): any; - dxTabPanel(options: DevExpress.ui.dxTabPanelOptions): JQuery; - dxSelectBox(): JQuery; - dxSelectBox(options: "instance"): DevExpress.ui.dxSelectBox; - dxSelectBox(options: string): any; - dxSelectBox(options: string, ...params: any[]): any; - dxSelectBox(options: DevExpress.ui.dxSelectBoxOptions): JQuery; - dxTagBox(): JQuery; - dxTagBox(options: "instance"): DevExpress.ui.dxTagBox; - dxTagBox(options: string): any; - dxTagBox(options: string, ...params: any[]): any; - dxTagBox(options: DevExpress.ui.dxTagBoxOptions): JQuery; - dxScrollView(): JQuery; - dxScrollView(options: "instance"): DevExpress.ui.dxScrollView; - dxScrollView(options: string): any; - dxScrollView(options: string, ...params: any[]): any; - dxScrollView(options: DevExpress.ui.dxScrollViewOptions): JQuery; dxScrollable(): JQuery; dxScrollable(options: "instance"): DevExpress.ui.dxScrollable; dxScrollable(options: string): any; dxScrollable(options: string, ...params: any[]): any; dxScrollable(options: DevExpress.ui.dxScrollableOptions): JQuery; - dxRadioGroup(): JQuery; - dxRadioGroup(options: "instance"): DevExpress.ui.dxRadioGroup; - dxRadioGroup(options: string): any; - dxRadioGroup(options: string, ...params: any[]): any; - dxRadioGroup(options: DevExpress.ui.dxRadioGroupOptions): JQuery; - dxPopup(): JQuery; - dxPopup(options: "instance"): DevExpress.ui.dxPopup; - dxPopup(options: string): any; - dxPopup(options: string, ...params: any[]): any; - dxPopup(options: DevExpress.ui.dxPopupOptions): JQuery; - dxPopover(): JQuery; - dxPopover(options: "instance"): DevExpress.ui.dxPopover; - dxPopover(options: string): any; - dxPopover(options: string, ...params: any[]): any; - dxPopover(options: DevExpress.ui.dxPopoverOptions): JQuery; dxOverlay(): JQuery; dxOverlay(options: "instance"): DevExpress.ui.dxOverlay; dxOverlay(options: string): any; dxOverlay(options: string, ...params: any[]): any; dxOverlay(options: DevExpress.ui.dxOverlayOptions): JQuery; - dxNumberBox(): JQuery; - dxNumberBox(options: "instance"): DevExpress.ui.dxNumberBox; - dxNumberBox(options: string): any; - dxNumberBox(options: string, ...params: any[]): any; - dxNumberBox(options: DevExpress.ui.dxNumberBoxOptions): JQuery; - dxNavBar(): JQuery; - dxNavBar(options: "instance"): DevExpress.ui.dxNavBar; - dxNavBar(options: string): any; - dxNavBar(options: string, ...params: any[]): any; - dxNavBar(options: DevExpress.ui.dxNavBarOptions): JQuery; - dxMultiView(): JQuery; - dxMultiView(options: "instance"): DevExpress.ui.dxMultiView; - dxMultiView(options: string): any; - dxMultiView(options: string, ...params: any[]): any; - dxMultiView(options: DevExpress.ui.dxMultiViewOptions): JQuery; - dxMap(): JQuery; - dxMap(options: "instance"): DevExpress.ui.dxMap; - dxMap(options: string): any; - dxMap(options: string, ...params: any[]): any; - dxMap(options: DevExpress.ui.dxMapOptions): JQuery; - dxLookup(): JQuery; - dxLookup(options: "instance"): DevExpress.ui.dxLookup; - dxLookup(options: string): any; - dxLookup(options: string, ...params: any[]): any; - dxLookup(options: DevExpress.ui.dxLookupOptions): JQuery; - dxLoadPanel(): JQuery; - dxLoadPanel(options: "instance"): DevExpress.ui.dxLoadPanel; - dxLoadPanel(options: string): any; - dxLoadPanel(options: string, ...params: any[]): any; - dxLoadPanel(options: DevExpress.ui.dxLoadPanelOptions): JQuery; - dxLoadIndicator(): JQuery; - dxLoadIndicator(options: "instance"): DevExpress.ui.dxLoadIndicator; - dxLoadIndicator(options: string): any; - dxLoadIndicator(options: string, ...params: any[]): any; - dxLoadIndicator(options: DevExpress.ui.dxLoadIndicatorOptions): JQuery; - dxList(): JQuery; - dxList(options: "instance"): DevExpress.ui.dxList; - dxList(options: string): any; - dxList(options: string, ...params: any[]): any; - dxList(options: DevExpress.ui.dxListOptions): JQuery; - dxGallery(): JQuery; - dxGallery(options: "instance"): DevExpress.ui.dxGallery; - dxGallery(options: string): any; - dxGallery(options: string, ...params: any[]): any; - dxGallery(options: DevExpress.ui.dxGalleryOptions): JQuery; dxDropDownEditor(): JQuery; dxDropDownEditor(options: "instance"): DevExpress.ui.dxDropDownEditor; dxDropDownEditor(options: string): any; dxDropDownEditor(options: string, ...params: any[]): any; dxDropDownEditor(options: DevExpress.ui.dxDropDownEditorOptions): JQuery; - dxDateBox(): JQuery; - dxDateBox(options: "instance"): DevExpress.ui.dxDateBox; - dxDateBox(options: string): any; - dxDateBox(options: string, ...params: any[]): any; - dxDateBox(options: DevExpress.ui.dxDateBoxOptions): JQuery; - dxCheckBox(): JQuery; - dxCheckBox(options: "instance"): DevExpress.ui.dxCheckBox; - dxCheckBox(options: string): any; - dxCheckBox(options: string, ...params: any[]): any; - dxCheckBox(options: DevExpress.ui.dxCheckBoxOptions): JQuery; - dxBox(): JQuery; - dxBox(options: "instance"): DevExpress.ui.dxBox; - dxBox(options: string): any; - dxBox(options: string, ...params: any[]): any; - dxBox(options: DevExpress.ui.dxBoxOptions): JQuery; - dxButton(): JQuery; - dxButton(options: "instance"): DevExpress.ui.dxButton; - dxButton(options: string): any; - dxButton(options: string, ...params: any[]): any; - dxButton(options: DevExpress.ui.dxButtonOptions): JQuery; - dxCalendar(): JQuery; - dxCalendar(options: "instance"): DevExpress.ui.dxCalendar; - dxCalendar(options: string): any; - dxCalendar(options: string, ...params: any[]): any; - dxCalendar(options: DevExpress.ui.dxCalendarOptions): JQuery; - dxAccordion(): JQuery; - dxAccordion(options: "instance"): DevExpress.ui.dxAccordion; - dxAccordion(options: string): any; - dxAccordion(options: string, ...params: any[]): any; - dxAccordion(options: DevExpress.ui.dxAccordionOptions): JQuery; - dxResponsiveBox(): JQuery; - dxResponsiveBox(options: "instance"): DevExpress.ui.dxResponsiveBox; - dxResponsiveBox(options: string): any; - dxResponsiveBox(options: string, ...params: any[]): any; - dxResponsiveBox(options: DevExpress.ui.dxResponsiveBoxOptions): JQuery; - dxAutocomplete(): JQuery; - dxAutocomplete(options: "instance"): DevExpress.ui.dxAutocomplete; - dxAutocomplete(options: string): any; - dxAutocomplete(options: string, ...params: any[]): any; - dxAutocomplete(options: DevExpress.ui.dxAutocompleteOptions): JQuery; - dxForm(): JQuery; - dxForm(options: "instance"): DevExpress.ui.dxForm; - dxForm(options: string): any; - dxForm(options: string, ...params: any[]): any; - dxForm(options: DevExpress.ui.dxFormOptions): JQuery; } - declare module DevExpress.ui { export interface dxTileViewOptions extends CollectionWidgetOptions { /** A Boolean value specifying whether or not the widget changes its state when interacting with a user. */ @@ -2645,6 +2965,7 @@ declare module DevExpress.ui { onText?: string; /** A Boolean value specifying whether the current switch state is "On" or "Off". */ value?: boolean; + name?: string; } /** A switch widget. */ export class dxSwitch extends Editor { @@ -2812,43 +3133,6 @@ declare module DevExpress.ui { toggle(showing: boolean): JQueryPromise; } } -interface JQuery { - dxTileView(): JQuery; - dxTileView(options: "instance"): DevExpress.ui.dxTileView; - dxTileView(options: string): any; - dxTileView(options: string, ...params: any[]): any; - dxTileView(options: DevExpress.ui.dxTileViewOptions): JQuery; - dxSwitch(): JQuery; - dxSwitch(options: "instance"): DevExpress.ui.dxSwitch; - dxSwitch(options: string): any; - dxSwitch(options: string, ...params: any[]): any; - dxSwitch(options: DevExpress.ui.dxSwitchOptions): JQuery; - dxSlideOut(): JQuery; - dxSlideOut(options: "instance"): DevExpress.ui.dxSlideOut; - dxSlideOut(options: string): any; - dxSlideOut(options: string, ...params: any[]): any; - dxSlideOut(options: DevExpress.ui.dxSlideOutOptions): JQuery; - dxPivot(): JQuery; - dxPivot(options: "instance"): DevExpress.ui.dxPivot; - dxPivot(options: string): any; - dxPivot(options: string, ...params: any[]): any; - dxPivot(options: DevExpress.ui.dxPivotOptions): JQuery; - dxPanorama(): JQuery; - dxPanorama(options: "instance"): DevExpress.ui.dxPanorama; - dxPanorama(options: string): any; - dxPanorama(options: string, ...params: any[]): any; - dxPanorama(options: DevExpress.ui.dxPanoramaOptions): JQuery; - dxActionSheet(): JQuery; - dxActionSheet(options: "instance"): DevExpress.ui.dxActionSheet; - dxActionSheet(options: string): any; - dxActionSheet(options: string, ...params: any[]): any; - dxActionSheet(options: DevExpress.ui.dxActionSheetOptions): JQuery; - dxDropDownMenu(): JQuery; - dxDropDownMenu(options: "instance"): DevExpress.ui.dxDropDownMenu; - dxDropDownMenu(options: string): any; - dxDropDownMenu(options: string, ...params: any[]): any; - dxDropDownMenu(options: DevExpress.ui.dxDropDownMenuOptions): JQuery; -} declare module DevExpress.data { export interface XmlaStoreOptions { /** The HTTP address to an XMLA OLAP server. */ @@ -2884,7 +3168,7 @@ declare module DevExpress.data { value?: any; totalValue?: any; }) => void; - /** Specifies the function that determines how to split data from the data source into ranges for header items. Cannot be used for the XmlaStore store type. */ + /** Specifies the function that determines how to split data from the data source into ranges for header items. Cannot be used for the XmlaStore store type and along with remote operations. */ selector?: (data: Object) => any; /** Type of the area where the field is located. */ area?: string; @@ -2918,10 +3202,7 @@ declare module DevExpress.data { format?: any; /** Specifies a callback function that returns the text to be displayed in the cells of a field. */ customizeText?: (cellInfo: { value: any; valueText: string }) => string; - /** - * Specifies a precision for formatted field values. - * @deprecated Use the format | precision option instead. - */ + /** * Specifies a precision for formatted field values. * @deprecated Use the format | precision option instead. */ precision?: number; /** Specifies how to sort the header items. */ sortingMethod?: (a: Object, b: Object) => number; @@ -2989,6 +3270,8 @@ declare module DevExpress.data { filter?: Object; /** An array of pivot grid fields. */ fields?: Array; + /** Specifies whether or not all the operations (filtering, grouping and summary calculation) are performed remotely. */ + remoteOperations?: boolean; /** A handler for the changed event. */ onChanged?: () => void; /** A handler for the loadingChanged event. */ @@ -3052,6 +3335,34 @@ declare module DevExpress.data { } } declare module DevExpress.ui { + export interface dxSchedulerViewOptions { + /** The name of the view. */ + type?: string; + /** The first day of a week. */ + firstDayOfWeek?: number; + /** The resource kinds by which appointments are grouped. */ + groups?: Array; + /** The start hour of the view time scale. */ + startDayHour?: number; + /** The end hour of the view time scale. */ + endDayHour?: number; + /** The cell duration in minutes. */ + cellDuration?: number; + /** Specifies the number of dates that can be shown at a time in the agenda view. */ + agendaDuration?: number; + /** The template to be used for rendering appointments. */ + appointmentTemplate?: any; + /** The template to be used for rendering an appointment tooltip. */ + appointmentTooltipTemplate?: any; + /** The template to be used for rendering table cells. */ + dataCellTemplate?: any; + /** The template to be used for rendering time scale items. */ + timeCellTemplate?: any; + /** The template to be used for rendering date scale items. */ + dateCellTemplate?: any; + /** The template to be used for rendering resource headers. */ + resourceCellTemplate?: any; + } export interface dxSchedulerOptions extends WidgetOptions { /** Specifies a date displayed on the current scheduler view by default. */ currentDate?: any; @@ -3069,8 +3380,16 @@ declare module DevExpress.ui { appointmentTemplate?: any; /** The template to be used for rendering an appointment tooltip. */ appointmentTooltipTemplate?: any; + /** The template to be used for rendering table cells. */ + dataCellTemplate?: any; + /** The template to be used for rendering time scale items. */ + timeCellTemplate?: any; + /** The template to be used for rendering date scale items. */ + dateCellTemplate?: any; + /** The template to be used for rendering resource headers. */ + resourceCellTemplate?: any; /** Lists the views to be available within the scheduler's View Selector. */ - views?: Array; + views?: Array; /** Specifies the resource kinds by which the scheduler's appointments are grouped in a timetable. */ groups?: Array; /** Specifies a start hour in the scheduler view's time interval. */ @@ -3100,10 +3419,7 @@ declare module DevExpress.ui { resources?: Array<{ /** Indicates whether or not several resources of this kind can be assigned to an appointment. */ allowMultiple?: boolean; - /** - * Indicates whether or not resources of this kind have priority in the color identification of the appointments that have resources of different kinds assigned. - * @deprecated Use the useColorAsDefault option instead. - */ + /** * Indicates whether or not resources of this kind have priority in the color identification of the appointments that have resources of different kinds assigned. * @deprecated Use the useColorAsDefault option instead. */ mainColor?: boolean; /** Indicates whether or not resources of this kind have priority in the color identification of the appointments that have resources of different kinds assigned. */ useColorAsDefault?: boolean; @@ -3113,13 +3429,12 @@ declare module DevExpress.ui { displayExpr?: any; /** Specifies the resource object field that is used as a value of the Resource editor in the Appointment popup window. */ valueExpr?: any; - /** - * The name of the appointment object field that specifies a resource of this kind. - * @deprecated Use the fieldExpr option instead. - */ + /** * The name of the appointment object field that specifies a resource of this kind. * @deprecated Use the fieldExpr option instead. */ field?: string; /** The name of the appointment object field that specifies a resource of this kind. */ fieldExpr?: string; + /** Specifies the resource object field that is used as a resource color. */ + colorExpr?: string; /** Specifies the label of the Appointment popup window field that allows end users to assign a resource of this kind. */ label?: string; }>; @@ -3178,7 +3493,9 @@ declare module DevExpress.ui { noDataText?: string; } /** A widget that displays scheduled data using different views and provides the capability to load, add and edit appointments. */ - export class dxScheduler extends Widget { + export class dxScheduler extends Widget + implements DataHelperMixin + { constructor(element: JQuery, options?: dxSchedulerOptions); constructor(element: Element, options?: dxSchedulerOptions); /** Add the appointment defined by the object passed as a parameter to the data associated with the widget. */ @@ -3189,12 +3506,21 @@ declare module DevExpress.ui { deleteAppointment(appointment: Object): void; /** Scrolls the scheduler work space to the specified time of the specified day. */ scrollToTime(hours: number, minutes: number, date: Date): void; - /** Displayes the Appointment Details popup. */ + /** Displays the Appointment Details popup. */ showAppointmentPopup(appointmentData: Object, createNewAppointment?: boolean, currentAppointmentData?: Object): void; + /** Hides an appointment details popup. */ + hideAppointmentPopup(saveChanges?: boolean): void; + /** Displays the appointment tooltip for the specified target element. */ + showAppointmentTooltip(appointmentData: Object, target?: JQuery, currentAppointmentData?: Object): void; + showAppointmentTooltip(appointmentData: Object, target?: Element, currentAppointmentData?: Object): void; + showAppointmentTooltip(appointmentData: Object, target?: string, currentAppointmentData?: Object): void; + /** Hides an appointment tooltip. */ + hideAppointmentTooltip(): void; /** Returns the start date of the current view. */ getStartViewDate(): Date; /** Returns the end date of the current view. */ getEndViewDate(): Date; + getDataSource(): DevExpress.data.DataSource; } export interface dxColorBoxOptions extends dxDropDownEditorOptions { /** Specifies the text displayed on the button that applies changes and closes the drop-down editor. */ @@ -3215,7 +3541,7 @@ declare module DevExpress.ui { export interface HierarchicalCollectionWidgetOptions extends CollectionWidgetOptions { /** Specifies the name of the data source item field whose value is displayed by the widget. */ displayExpr?: any; - /** Specifies the name of the data source item field used as a key. */ + /** Specifies which data field provides keys for TreeView items. */ keyExpr?: any; /** Specifies the name of the data source item field whose value defines whether or not the corresponding widget items is selected. */ selectedExpr?: any; @@ -3235,10 +3561,7 @@ declare module DevExpress.ui { dataStructure?: string; /** Specifies whether or not a user can expand all tree view items by the "*" hot key. */ expandAllEnabled?: boolean; - /** - * Specifies whether or not a check box is displayed at each tree view item. - * @deprecated Use the showCheckBoxesMode options instead. - */ + /** * Specifies whether or not a check box is displayed at each tree view item. * @deprecated Use the showCheckBoxesMode options instead. */ showCheckBoxes?: boolean; /** Specifies the current check boxes display mode. */ showCheckBoxesMode?: string; @@ -3248,10 +3571,7 @@ declare module DevExpress.ui { selectNodesRecursive?: boolean; /** Specifies whether or not all parent nodes of an initially expanded node are displayed expanded. */ expandNodesRecursive?: boolean; - /** - * Specifies whether the "Select All" check box is displayed over the tree view. - * @deprecated Use the showCheckBoxesMode options instead. - */ + /** * Specifies whether the "Select All" check box is displayed over the tree view. * @deprecated Use the showCheckBoxesMode options instead. */ selectAllEnabled?: boolean; /** Specifies whether or not an item becomes selected if a user clicks it. */ selectByClick?: boolean; @@ -3281,6 +3601,18 @@ declare module DevExpress.ui { onItemContextMenu?: Function; onItemRendered?: Function; onItemHold?: Function; + /** Allows you to load nodes manually. */ + createChildren?: Function; + } + export interface dxTreeViewNode { + children: Array; + disabled: boolean; + expanded: boolean; + itemData: Object; + key: any; + parent: dxTreeViewNode; + selected: boolean; + text: string; } /** A widget displaying specified data items as a tree. */ export class dxTreeView extends HierarchicalCollectionWidget { @@ -3317,11 +3649,8 @@ declare module DevExpress.ui { cssClass?: string; /** Holds an array of menu items. */ items?: Array; - /** - * Specifies whether or not an item becomes selected if an end-user clicks it. - * @deprecated Use the selectByClick option instead. - */ - selectionByClick?: boolean; + /** * Specifies whether or not an item becomes selected if an end-user clicks it. * @deprecated Use the selectByClick option instead. */ + selectionByClick?: boolean; /** Specifies whether or not an item becomes selected if a user clicks it. */ selectByClick?: boolean; /** Specifies the selection mode supported by the menu. */ @@ -3383,13 +3712,15 @@ declare module DevExpress.ui { constructor(element: Element, options?: dxMenuOptions); } export interface dxContextMenuOptions extends dxMenuBaseOptions { - /** Holds an object that specifies options of alternative menu invocation. */ - alternativeInvocationMode?: { - /** Specifies whether or not an alternative invocation mode is enabled. */ - enabled?: Boolean; - /** Specifies the element used to invoke the context menu. */ - invokingElement?: any; + /** Specifies options for displaying the widget. */ + showEvent?: { + /** Specifies the event names on which the widget is shown. */ + name?: String; + /** The time span after which the widget is shown. */ + delay?: Number; }; + /** A Boolean value specifying whether or not the widget is closed if a user clicks outside of the context menu. */ + closeOnOutsideClick?: any; /** A handler for the hidden event. */ onHidden?: Function; /** A handler for the hiding event. */ @@ -3429,6 +3760,8 @@ declare module DevExpress.ui { sorting?: boolean; /** Specifies whether or not grouping must be performed on the server side. */ grouping?: boolean; + /** Specifies whether or not paging by groups must be peformed on the server side. */ + groupPaging?: boolean; /** Specifies whether or not summaries calculation must be performed on the server side. */ summary?: boolean; } @@ -3440,6 +3773,7 @@ declare module DevExpress.ui { groupIndex: number; isExpanded: boolean; isSelected: boolean; + isEditing: boolean; values: Array; } export interface dxDataGridColumn { @@ -3472,7 +3806,7 @@ declare module DevExpress.ui { /** Specifies a callback function to be invoked after the cell value is edited by an end-user and before the new value is saved to the data source. */ setCellValue?: (rowData: Object, value: any) => void; /** Specifies a callback function that defines filters for customary calculated grid cells. */ - calculateFilterExpression?: (filterValue: any, selectedFilterOperation: string, target: string) => Array; + calculateFilterExpression?: (filterValue: any, selectedFilterOperation: string, target: string) => any; /** Specifies a caption for a column. */ caption?: string; /** Specifies a custom template for grid column cells. */ @@ -3539,10 +3873,7 @@ declare module DevExpress.ui { /** Specifies how header filter values should be combined into groups. */ groupInterval?: any; }; - /** - * Specifies a precision for formatted values displayed in a column. - * @deprecated Use the format | precision option instead. - */ + /** * Specifies a precision for formatted values displayed in a column. * @deprecated Use the format | precision option instead. */ precision?: number; /** Specifies the default filter operation of a column. */ selectedFilterOperation?: string; @@ -3586,6 +3917,8 @@ declare module DevExpress.ui { onRowValidating?: (e: Object) => void; /** A handler for the contextMenuPreparing event. */ onContextMenuPreparing?: (e: Object) => void; + /** A handler for the toolbarPreparing event. */ + onToolbarPreparing?: (e: Object) => void; /** A handler for the initNewRow event. */ onInitNewRow?: (e: { data: Object }) => void; /** A handler for the rowInserted event. */ @@ -3742,16 +4075,28 @@ declare module DevExpress.ui { applyFilterText?: string; /** Specifies descriptions for filter operations. */ operationDescriptions?: { - "=": string; - "<>": string; - "<": string; - "<=": string; - ">": string; - ">=": string; - "startswith": string; - "contains": string; - "notcontains": string; - "endswith": string; + /** Description for the '=' operation. */ + equal?: string; + /** Description for the '<>' operation. */ + notEqual?: string; + /** Description for the '<' operation. */ + lessThan?: string; + /** Description for the '<=' operation. */ + lessThanOrEqual?: string; + /** Description for the '>' operation. */ + greaterThan?: string; + /** Description for the '>=' operation. */ + greaterThanOrEqual?: string; + /** Description for the 'startswith' operation. */ + startsWith?: string; + /** Description for the 'contains' operation. */ + contains?: string; + /** Description for the 'notcontains' operation. */ + notContains?: string; + /** Description for the 'endswith' operation. */ + endsWith?: string; + /** Description for the 'between' operation. */ + between?: string; }; /** Specifies text for the reset operation in a filter list. */ resetOperationText?: string; @@ -3884,7 +4229,7 @@ declare module DevExpress.ui { /** Sets a search string for the search panel. */ text?: string; }; - /** Specifies the operations that must be performed on the server side. */ + /** Specifies the operations that must be performed server side. */ remoteOperations?: any; /** Allows you to sort groups according to the values of group summary items. */ sortByGroupSummaryInfo?: Array<{ @@ -3931,8 +4276,10 @@ declare module DevExpress.ui { exportSelectedRows?: string; } }; - /** Specifies the keys of the records that must appear selected initially. */ + /** Specifies the keys of the records that must appear initially selected. */ selectedRowKeys?: Array; + /** Specifies filters for the records that must appear initially selected. */ + selectionFilter?: Object; /** Specifies options of runtime selection. */ selection?: { /** Specifies the checkbox row display policy in the multiple mode. */ @@ -3941,6 +4288,11 @@ declare module DevExpress.ui { allowSelectAll?: boolean; /** Specifies the selection mode. */ mode?: string; + maxFilterLengthInRequest?: number; + /** Specifies the mode in which all the records are selected. */ + selectAllMode?: string; + /** Specifies whether or not deferred row selection is enabled. */ + deferred?: boolean; }; /** A handler for the dataErrorOccured event. */ onDataErrorOccurred?: (e: { error: Error }) => void; @@ -4043,10 +4395,7 @@ declare module DevExpress.ui { }) => string; /** Specifies a pattern for the summary item text. */ displayFormat?: string; - /** - * Specifies a precision for the summary item value of a numeric format. - * @deprecated Use the valueFormat | precision option instead. - */ + /** * Specifies a precision for the summary item value of a numeric format. * @deprecated Use the valueFormat | precision option instead. */ precision?: number; /** Specifies whether or not a summary item must be displayed in the group footer. */ showInGroupFooter?: boolean; @@ -4078,10 +4427,7 @@ declare module DevExpress.ui { }) => string; /** Specifies a pattern for the summary item text. */ displayFormat?: string; - /** - * Specifies a precision for the summary item value of a numeric format. - * @deprecated Use the valueFormat | precision option instead. - */ + /** * Specifies a precision for the summary item value of a numeric format. * @deprecated Use the valueFormat | precision option instead. */ precision?: number; /** Specifies the column that must hold the summary item. */ showInColumn?: string; @@ -4107,7 +4453,7 @@ declare module DevExpress.ui { wordWrapEnabled?: boolean; } /** A data grid widget. */ - export class dxDataGrid extends Widget { + export class dxDataGrid extends Widget implements DataHelperMixin { constructor(element: JQuery, options?: dxDataGridOptions); constructor(element: Element, options?: dxDataGridOptions); /** Ungroups grid records. */ @@ -4118,6 +4464,8 @@ declare module DevExpress.ui { getCellElement(rowIndex: number, dataField: string): any; /** Allows you to obtain a cell by its row index and the visible index of its column. */ getCellElement(rowIndex: number, visibleColumnIndex: number): any; + /** Allows you to obtain a row element by its index. */ + getRowElement(rowIndex: number): any; /** Returns the current state of the grid. */ state(): Object; /** Sets the grid state. */ @@ -4154,6 +4502,12 @@ declare module DevExpress.ui { columnOption(id: any): Object; /** Sets several options of a column at once. */ columnOption(id: any, options: Object): void; + /** Gets an array of visible columns. */ + getVisibleColumns(): Array; + /** Gets an array of visible columns at a specific hierarchical level of column headers. */ + getVisibleColumns(headerLevel?: number): Array; + /** Gets an array of visible rows. */ + getVisibleRows(): Array; /** Sets a specific cell into the editing state. */ editCell(rowIndex: number, visibleColumnIndex: number): void; /** Sets a specific cell into the editing state. */ @@ -4188,20 +4542,19 @@ declare module DevExpress.ui { filter(filterExpr?: any): void; /** Returns a filter expression applied to the grid's data source using the filter(filterExpr) method. */ filter(): any; - /** Returns a filter expression applied to the grid using all possible scenarious. */ + /** Returns a filter expression applied to the grid using all possible scenarios. */ getCombinedFilter(): any; + /** Returns a filter expression applied to the grid using all possible scenarios. */ + getCombinedFilter(returnDataField?: boolean): any; /** Gets the keys of currently selected grid records. */ - getSelectedRowKeys(): Array; - /** Gets the data objects of currently selected grid records. */ - getSelectedRowsData(): Array; + getSelectedRowKeys(): any; + /** Gets the data objects of the currently selected grid records. */ + getSelectedRowsData(): any; /** Hides the column chooser panel. */ hideColumnChooser(): void; /** Adds a new data row to a grid. */ addRow(): void; - /** - * Adds a new data row to a grid. - * @deprecated Use the addRow() method instead. - */ + /** * Adds a new data row to a grid. * @deprecated Use the addRow() method instead. */ insertRow(): void; /** Returns the key corresponding to the passed data object. */ keyOf(obj: Object): any; @@ -4217,10 +4570,7 @@ declare module DevExpress.ui { refresh(): JQueryPromise; /** Removes a specific row from a grid. */ deleteRow(rowIndex: number): void; - /** - * Removes a specific row from a grid. - * @deprecated Use the deleteRow(rowIndex) method instead. - */ + /** * Removes a specific row from a grid. * @deprecated Use the deleteRow(rowIndex) method instead. */ removeRow(rowIndex: number): void; /** Saves changes made in a grid. */ saveEditData(): JQueryPromise; @@ -4228,7 +4578,7 @@ declare module DevExpress.ui { searchByText(text: string): void; /** Selects all grid records. */ selectAll(): void; - /** Deselects the rows that are currently selected within the applied filter. */ + /** Deselects the currently selected rows. */ deselectAll(): void; /** Selects specific grid records. */ selectRows(keys: Array, preserve: boolean): void; @@ -4236,8 +4586,8 @@ declare module DevExpress.ui { deselectRows(keys: Array): void; /** Selects grid rows by indexes. */ selectRowsByIndexes(indexes: Array): void; - /** Allows you to find out whether a row is selected or not. */ - isRowSelected(key: any): boolean; + /** Allows you to find out whether or not the row with a specified data object is selected. */ + isRowSelected(arg: any): boolean; /** Invokes the column chooser panel. */ showColumnChooser(): void; startSelectionWithCheckboxes(): boolean; @@ -4257,6 +4607,11 @@ declare module DevExpress.ui { updateDimensions(): void; /** Focuses the specified cell element in the grid. */ focus(element?: JQuery): void; + getDataSource(): DevExpress.data.DataSource; + /** Gets instance of the Scrollable widget. */ + getScrollable(): dxScrollable; + /** Redraws the specified rows. */ + repaintRows(rowIndexes: Array): void; } export interface dxPivotGridOptions extends WidgetOptions { onContentReady?: Function; @@ -4492,53 +4847,6 @@ declare module DevExpress.ui { getDataSource(): DevExpress.data.PivotGridDataSource; } } -interface JQuery { - dxTreeView(): JQuery; - dxTreeView(options: "instance"): DevExpress.ui.dxTreeView; - dxTreeView(options: string): any; - dxTreeView(options: string, ...params: any[]): any; - dxTreeView(options: DevExpress.ui.dxTreeViewOptions): JQuery; - dxMenuBase(): JQuery; - dxMenuBase(options: "instance"): DevExpress.ui.dxMenuBase; - dxMenuBase(options: string): any; - dxMenuBase(options: string, ...params: any[]): any; - dxMenuBase(options: DevExpress.ui.dxMenuBaseOptions): JQuery; - dxMenu(): JQuery; - dxMenu(options: "instance"): DevExpress.ui.dxMenu; - dxMenu(options: string): any; - dxMenu(options: string, ...params: any[]): any; - dxMenu(options: DevExpress.ui.dxMenuOptions): JQuery; - dxContextMenu(): JQuery; - dxContextMenu(options: "instance"): DevExpress.ui.dxContextMenu; - dxContextMenu(options: string): any; - dxContextMenu(options: string, ...params: any[]): any; - dxContextMenu(options: DevExpress.ui.dxContextMenuOptions): JQuery; - dxColorBox(): JQuery; - dxColorBox(options: "instance"): DevExpress.ui.dxColorBox; - dxColorBox(options: string): any; - dxColorBox(options: string, ...params: any[]): any; - dxColorBox(options: DevExpress.ui.dxColorBoxOptions): JQuery; - dxDataGrid(): JQuery; - dxDataGrid(options: "instance"): DevExpress.ui.dxDataGrid; - dxDataGrid(options: string): any; - dxDataGrid(options: string, ...params: any[]): any; - dxDataGrid(options: DevExpress.ui.dxDataGridOptions): JQuery; - dxPivotGrid(): JQuery; - dxPivotGrid(options: "instance"): DevExpress.ui.dxPivotGrid; - dxPivotGrid(options: string): any; - dxPivotGrid(options: string, ...params: any[]): any; - dxPivotGrid(options: DevExpress.ui.dxPivotGridOptions): JQuery; - dxPivotGridFieldChooser(): JQuery; - dxPivotGridFieldChooser(options: "instance"): DevExpress.ui.dxPivotGridFieldChooser; - dxPivotGridFieldChooser(options: string): any; - dxPivotGridFieldChooser(options: string, ...params: any[]): any; - dxPivotGridFieldChooser(options: DevExpress.ui.dxPivotGridFieldChooserOptions): JQuery; - dxScheduler(): JQuery; - dxScheduler(options: "instance"): DevExpress.ui.dxScheduler; - dxScheduler(options: string): any; - dxScheduler(options: string, ...params: any[]): any; - dxScheduler(options: DevExpress.ui.dxSchedulerOptions): JQuery; -} declare module DevExpress.framework { /** An object used to store information on the views displayed in an application. */ export class ViewCache { @@ -4960,10 +5268,7 @@ declare module DevExpress.viz.core { paddingLeftRight?: number; /** Generates space above and below the text displayed by a tooltip. */ paddingTopBottom?: number; - /** - * Specifies the precision of formatted values in a tooltip. - * @deprecated Use the tooltip | format | precision option instead. - */ + /** * Specifies the precision of formatted values in a tooltip. * @deprecated Use the tooltip | format | precision option instead. */ precision?: number; /** Specifies the appearance of the tooltip's shadow. */ shadow?: { @@ -5092,35 +5397,17 @@ declare module DevExpress.viz.core { } } declare module DevExpress.viz { - /** - * Applies a theme for the entire page with several DevExtreme visualization widgets. - * @deprecated Use the DevExpress.viz.currentTheme(theme) method instead. - */ + /** * Applies a theme for the entire page with several DevExtreme visualization widgets. * @deprecated Use the DevExpress.viz.currentTheme(theme) method instead. */ export function currentTheme(theme: string): void; - /** - * Applies a new theme (with the color scheme defined separately) for the entire page with several DevExtreme visualization widgets. - * @deprecated Use the DevExpress.viz.currentTheme(platform, colorScheme) method instead. - */ + /** * Applies a new theme (with the color scheme defined separately) for the entire page with several DevExtreme visualization widgets. * @deprecated Use the DevExpress.viz.currentTheme(platform, colorScheme) method instead. */ export function currentTheme(platform: string, colorScheme: string): void; - /** - * Registers a new theme based on the existing one. - * @deprecated Use the DevExpress.viz.registerTheme(customTheme, baseTheme) method instead. - */ + /** * Registers a new theme based on the existing one. * @deprecated Use the DevExpress.viz.registerTheme(customTheme, baseTheme) method instead. */ export function registerTheme(customTheme: Object, baseTheme: string): void; - /** - * Applies a predefined or registered custom palette to all visualization widgets at once. - * @deprecated Use the DevExpress.viz.currentPalette(paletteName) method instead. - */ + /** * Applies a predefined or registered custom palette to all visualization widgets at once. * @deprecated Use the DevExpress.viz.currentPalette(paletteName) method instead. */ export function currentPalette(paletteName: string): void; - /** - * Obtains the color sets of a predefined or registered palette. - * @deprecated Use the DevExpress.viz.getPalette(paletteName) method instead. - */ + /** * Obtains the color sets of a predefined or registered palette. * @deprecated Use the DevExpress.viz.getPalette(paletteName) method instead. */ export function getPalette(paletteName: string): Object; - /** - * Registers a new palette. - * @deprecated Use the DevExpress.viz.registerPalette(paletteName, palette) method instead. - */ + /** * Registers a new palette. * @deprecated Use the DevExpress.viz.registerPalette(paletteName, palette) method instead. */ export function registerPalette(paletteName: string, palette: Object): void; } declare module DevExpress.viz.charts { @@ -5277,10 +5564,7 @@ declare module DevExpress.viz.charts { export interface BaseSeriesConfigLabel { /** Specifies a format for arguments displayed by point labels. */ argumentFormat?: any; - /** - * Specifies a precision for formatted point arguments displayed in point labels. - * @deprecated Use the series | label | argumentFormat | precision instead. - */ + /** * Specifies a precision for formatted point arguments displayed in point labels. * @deprecated Use the series | label | argumentFormat | precision instead. */ argumentPrecision?: number; /** Specifies a background color for point labels. */ backgroundColor?: string; @@ -5302,10 +5586,7 @@ declare module DevExpress.viz.charts { /** Specifies a format for the text displayed by point labels. */ format?: any; position?: string; - /** - * Specifies a precision for formatted point values displayed in point labels. - * @deprecated Use the series | label | format | precision option instead. - */ + /** * Specifies a precision for formatted point values displayed in point labels. * @deprecated Use the series | label | format | precision option instead. */ precision?: number; /** Specifies the angle used to rotate point labels from their initial position. */ rotationAngle?: number; @@ -5323,10 +5604,7 @@ declare module DevExpress.viz.charts { horizontalOffset?: number; /** Along with horizontalOffset, shifts point labels from their initial positions. */ verticalOffset?: number; - /** - * Specifies a precision for the percentage values displayed in the labels of a full-stacked-like series. - * @deprecated Use the series | label | format | percentPrecision instead. - */ + /** * Specifies a precision for the percentage values displayed in the labels of a full-stacked-like series. * @deprecated Use the series | label | format | percentPrecision instead. */ percentPrecision?: number; } export interface BaseCommonSeriesConfig { @@ -5580,10 +5858,7 @@ declare module DevExpress.viz.charts { export interface PieSeriesConfigLabel extends BaseSeriesConfigLabel { /** Specifies how to shift labels from their initial position in a radial direction in pixels. */ radialOffset?: number; - /** - * Specifies a precision for the percentage values displayed in labels. - * @deprecated Use the series | label | format | percentPrecision instead. - */ + /** * Specifies a precision for the percentage values displayed in labels. * @deprecated Use the series | label | format | percentPrecision instead. */ percentPrecision?: number; } /** An object that defines configuration options for chart series. */ @@ -5607,10 +5882,7 @@ declare module DevExpress.viz.charts { /** Specifies the hatching options to be applied when a point is hovered over. */ hatching?: viz.core.Hatching; }; - /** - * Specifies the fraction of the inner radius relative to the total radius in the series of the 'doughnut' type. - * @deprecated Use the innerRadius option instead. - */ + /** * Specifies the fraction of the inner radius relative to the total radius in the series of the 'doughnut' type. * @deprecated Use the innerRadius option instead. */ innerRadius?: number; /** An object defining the label configuration options. */ label?: PieSeriesConfigLabel; @@ -5618,10 +5890,7 @@ declare module DevExpress.viz.charts { maxLabelCount?: number; /** Specifies a minimal size of a displayed pie segment. */ minSegmentSize?: number; - /** - * Specifies the direction in which the PieChart series points are located. - * @deprecated Use the segmentsDirection option instead. - */ + /** * Specifies the direction in which the PieChart series points are located. * @deprecated Use the segmentsDirection option instead. */ segmentsDirection?: string; /**

Specifies the chart elements to highlight when the series is selected.

*/ selectionMode?: string; @@ -5645,10 +5914,7 @@ declare module DevExpress.viz.charts { /** Specifies how many segments must not be grouped. */ topCount?: number; }; - /** - * Specifies a start angle for a pie chart in arc degrees. - * @deprecated Use the startAngle option instead. - */ + /** * Specifies a start angle for a pie chart in arc degrees. * @deprecated Use the startAngle option instead. */ startAngle?: number; /**

Specifies the name of the data source field that provides data about a point.

*/ tagField?: string; @@ -5656,17 +5922,11 @@ declare module DevExpress.viz.charts { valueField?: string; } export interface CommonPieSeriesSettings extends CommonPieSeriesConfig { - /** - * Specifies the type of the pie chart series. - * @deprecated Use the type option instead. - */ + /** * Specifies the type of the pie chart series. * @deprecated Use the type option instead. */ type?: string; } export interface PieSeriesConfig extends CommonPieSeriesConfig { - /** - * Sets the series type. - * @deprecated Use the type option instead. - */ + /** * Sets the series type. * @deprecated Use the type option instead. */ type?: string; /** Specifies the name that identifies the series. */ name?: string; @@ -5879,10 +6139,7 @@ declare module DevExpress.viz.charts { customizeText?: (argument: { value: any; valueText: string }) => string; /** Specifies a format for the text displayed by axis labels. */ format?: any; - /** - * Specifies a precision for the formatted value displayed in the axis labels. - * @deprecated Use the valueAxis | label | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed in the axis labels. * @deprecated Use the valueAxis | label | format | precision option instead. */ precision?: number; } export interface ChartAxisLabel extends ChartCommonAxisLabel, AxisLabel { } @@ -6018,15 +6275,9 @@ declare module DevExpress.viz.charts { export interface BaseChartTooltip extends viz.core.Tooltip { /** Specifies a format for arguments of the chart's series points. */ argumentFormat?: any; - /** - * Specifies a precision for formatted arguments displayed in tooltips. - * @deprecated Use the tooltip | argumentFormat | precision option instead. - */ + /** * Specifies a precision for formatted arguments displayed in tooltips. * @deprecated Use the tooltip | argumentFormat | precision option instead. */ argumentPrecision?: number; - /** - * Specifies a precision for a percent value displayed in tooltips for stacked series and PieChart series. - * @deprecated Use the tooltip | format | percentPrecision option instead. - */ + /** * Specifies a precision for a percent value displayed in tooltips for stacked series and PieChart series. * @deprecated Use the tooltip | format | percentPrecision option instead. */ percentPrecision?: number; } export interface BaseChartOptions extends viz.core.BaseWidgetOptions, viz.core.MarginOptions, viz.core.RedrawOnResizeOptions, viz.core.TitleOptions, viz.core.LoadingIndicatorOptions, viz.core.ExportOptions { @@ -6047,7 +6298,7 @@ declare module DevExpress.viz.charts { customizePoint?: (pointInfo: Object) => Object; /** Specifies the origin of data for the widget. */ dataSource?: any; - /** Specifies options of a Chart's or PieChart's legend. */ + /** Specifies options of a Chart's (PieChart's) legend. */ legend?: core.BaseLegend; /** Sets the name of the palette to be used in the chart. Alternatively, an array of colors can be set as a custom palette to be used within this chart. */ palette?: any; @@ -6101,6 +6352,8 @@ declare module DevExpress.viz.charts { getSeriesByName(seriesName: string): BaseSeries; /** Gets a series within the chart's series collection by its position number. */ getSeriesByPos(seriesIndex: number): BaseSeries; + /** Returns the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; /** Hides all widget tooltips. */ hideTooltip(): void; showLoadingIndicator(): void; @@ -6199,9 +6452,9 @@ declare module DevExpress.viz.charts { /** Specifies the width of the crosshair lines. */ width?: number; /** Configures the horizontal crosshair line individually. */ - horizontalLine?: CrosshaierWithLabel; + horizontalLine?: CrosshairWithLabel; /** Configures the vertical crosshair line individually. */ - verticalLine?: CrosshaierWithLabel; + verticalLine?: CrosshairWithLabel; /** Configures the crosshair labels. */ label?: { /** Paints the background of the crosshair labels. */ @@ -6212,10 +6465,7 @@ declare module DevExpress.viz.charts { font?: viz.core.Font; /** Formats the point value/argument before it will be displayed in the crosshair label. */ format?: any; - /** - * Specifies a precision for formatted values. - * @deprecated Use the crosshair | label | format | precision option instead. - */ + /** * Specifies a precision for formatted values. * @deprecated Use the crosshair | label | format | precision option instead. */ precision?: number; /** Customizes the text displayed by the crosshair labels. */ customizeText?: (info: { value: any; valueText: string; point: ChartPoint; }) => string; @@ -6272,7 +6522,7 @@ declare module DevExpress.viz.charts { position?: string; }; } - interface CrosshaierWithLabel extends viz.core.DashedBorderWithOpacity { + interface CrosshairWithLabel extends viz.core.DashedBorderWithOpacity { /** Configures the label that belongs to the horizontal crosshair line. */ label?: { /** Paints the background of the label that belongs to the horizontal crosshair line. */ @@ -6283,10 +6533,7 @@ declare module DevExpress.viz.charts { font?: viz.core.Font; /** Formats the point value before it will be displayed in the crosshair label. */ format?: any; - /** - * Specifies a precision for formatted values. - * @deprecated Use the crosshair | horizontalLine | label | format | precision option instead. - */ + /** * Specifies a precision for formatted values. * @deprecated Use the crosshair | horizontalLine | label | format | precision option instead. */ precision?: number; /** Customizes the text displayed by the label that belongs to the horizontal crosshair line. */ customizeText?: (info: { value: any; valueText: string; point: ChartPoint; }) => string; @@ -6367,10 +6614,7 @@ declare module DevExpress.viz { export class dxPieChart extends DevExpress.viz.charts.BaseChart { constructor(element: JQuery, options?: DevExpress.viz.charts.dxPieChartOptions); constructor(element: Element, options?: DevExpress.viz.charts.dxPieChartOptions); - /** - * Provides access to the PieChart series. - * @deprecated Use the getAllSeries() method instead. - */ + /** * Provides access to the PieChart series. * @deprecated Use the getAllSeries() method instead. */ getSeries(): DevExpress.viz.charts.PieSeries; } /** A chart widget displaying data in a polar coordinate system. */ @@ -6379,17 +6623,6 @@ declare module DevExpress.viz { constructor(element: Element, options?: DevExpress.viz.charts.dxPolarChartOptions); } } -interface JQuery { - dxChart(options?: DevExpress.viz.charts.dxChartOptions): JQuery; - dxChart(methodName: string, ...params: any[]): any; - dxChart(methodName: "instance"): DevExpress.viz.dxChart; - dxPieChart(options?: DevExpress.viz.charts.dxPieChartOptions): JQuery; - dxPieChart(methodName: string, ...params: any[]): any; - dxPieChart(methodName: "instance"): DevExpress.viz.dxPieChart; - dxPolarChart(options?: DevExpress.viz.charts.dxPolarChartOptions): JQuery; - dxPolarChart(methodName: string, ...params: any[]): any; - dxPolarChart(methodName: "instance"): DevExpress.viz.dxPolarChart; -} declare module DevExpress.viz.gauges { export interface BaseRangeContainer { /** Specifies a range container's background color. */ @@ -6410,22 +6643,13 @@ declare module DevExpress.viz.gauges { export interface ScaleTick { /** Specifies the color of the scale's minor ticks. */ color?: string; - /** - * Specifies an array of custom minor ticks. - * @deprecated Use the scale | customMinorTicks option instead. - */ + /** * Specifies an array of custom minor ticks. * @deprecated Use the scale | customMinorTicks option instead. */ customTickValues?: Array; /** Specifies the length of the scale's minor ticks. */ length?: number; - /** - * Indicates whether automatically calculated minor ticks are visible or not. - * @deprecated This feature is no longer available. - */ + /** * Indicates whether automatically calculated minor ticks are visible or not. * @deprecated This feature is no longer available. */ showCalculatedTicks?: boolean; - /** - * Specifies an interval between minor ticks. - * @deprecated Use the scale | minorTickInterval option instead. - */ + /** * Specifies an interval between minor ticks. * @deprecated Use the scale | minorTickInterval option instead. */ tickInterval?: number; /** Indicates whether scale minor ticks are visible or not. */ visible?: boolean; @@ -6433,10 +6657,7 @@ declare module DevExpress.viz.gauges { width?: number; } export interface ScaleMajorTick extends ScaleTick { - /** - * Specifies whether or not to expand the current major tick interval if labels overlap each other. - * @deprecated Use the overlappingBehavior | useAutoArrangement option instead. - */ + /** * Specifies whether or not to expand the current major tick interval if labels overlap each other. * @deprecated Use the overlappingBehavior | useAutoArrangement option instead. */ useTicksAutoArrangement?: boolean; } export interface ScaleMinorTick extends ScaleTick { @@ -6459,10 +6680,7 @@ declare module DevExpress.viz.gauges { font?: viz.core.Font; /** Specifies a format for the text displayed in scale labels. */ format?: any; - /** - * Specifies a precision for the formatted value displayed in the scale labels. - * @deprecated Use the scale | label | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed in the scale labels. * @deprecated Use the scale | label | format | precision option instead. */ precision?: number; /** Specifies whether or not scale labels are visible on the gauge. */ visible?: boolean; @@ -6470,25 +6688,13 @@ declare module DevExpress.viz.gauges { export interface BaseScale { /** Specifies the end value for the scale of the gauge. */ endValue?: number; - /** - * Specifies whether or not to hide the first scale label. - * @deprecated This feature is no longer available. - */ + /** * Specifies whether or not to hide the first scale label. * @deprecated This feature is no longer available. */ hideFirstLabel?: boolean; - /** - * Specifies whether or not to hide the first major tick on the scale. - * @deprecated This feature is no longer available. - */ + /** * Specifies whether or not to hide the first major tick on the scale. * @deprecated This feature is no longer available. */ hideFirstTick?: boolean; - /** - * Specifies whether or not to hide the last scale label. - * @deprecated This feature is no longer available. - */ + /** * Specifies whether or not to hide the last scale label. * @deprecated This feature is no longer available. */ hideLastLabel?: boolean; - /** - * Specifies whether or not to hide the last major tick on the scale. - * @deprecated This feature is no longer available. - */ + /** * Specifies whether or not to hide the last major tick on the scale. * @deprecated This feature is no longer available. */ hideLastTick?: boolean; /** Specifies an interval between major ticks. */ tickInterval?: number; @@ -6500,10 +6706,7 @@ declare module DevExpress.viz.gauges { customMinorTicks?: Array; /** Specifies common options for scale labels. */ label?: BaseScaleLabel; - /** - * Specifies options of the gauge's major ticks. - * @deprecated Use the tick option instead. - */ + /** * Specifies options of the gauge's major ticks. * @deprecated Use the tick option instead. */ majorTick?: ScaleMajorTick; /** Specifies options of the gauge's major ticks. */ tick?: { @@ -6542,10 +6745,7 @@ declare module DevExpress.viz.gauges { format?: any; /** Specifies the range bar's label indent in pixels. */ indent?: number; - /** - * Specifies a precision for the formatted value displayed by an indicator. - * @deprecated Use the text | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed by an indicator. * @deprecated Use the text | format | precision option instead. */ precision?: number; }; offset?: number; @@ -6573,20 +6773,11 @@ declare module DevExpress.viz.gauges { export interface SharedGaugeOptions extends viz.core.MarginOptions, viz.core.RedrawOnResizeOptions, viz.core.TitleOptions, viz.core.LoadingIndicatorOptions, viz.core.ExportOptions { /** Specifies animation options. */ animation?: viz.core.Animation; - /** - * Specifies a subtitle for the widget. - * @deprecated Use the title | subtitle option instead. - */ + /** * Specifies a subtitle for the widget. * @deprecated Use the title | subtitle option instead. */ subtitle?: { - /** - * Specifies font options for the subtitle. - * @deprecated Use the title | subtitle | font option instead. - */ + /** * Specifies font options for the subtitle. * @deprecated Use the title | subtitle | font option instead. */ font?: viz.core.Font; - /** - * Specifies a text for the subtitle. - * @deprecated Use the title | subtitle | text option instead. - */ + /** * Specifies a text for the subtitle. * @deprecated Use the title | subtitle | text option instead. */ text?: string; }; /** Configures tooltips. */ @@ -6723,10 +6914,7 @@ declare module DevExpress.viz.gauges { format?: any; /** Specifies the distance between the upper bar and bar labels in pixels. */ indent?: number; - /** - * Specifies a precision for the formatted value displayed by labels. - * @deprecated Use the label | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed by labels. * @deprecated Use the label | format | precision option instead. */ precision?: number; /** Specifies whether bar labels appear on a gauge or not. */ visible?: boolean; @@ -6764,17 +6952,6 @@ declare module DevExpress.viz { values(values: Array): void; } } -interface JQuery { - dxLinearGauge(options?: DevExpress.viz.gauges.dxLinearGaugeOptions): JQuery; - dxLinearGauge(methodName: string, ...params: any[]): any; - dxLinearGauge(methodName: "instance"): DevExpress.viz.dxLinearGauge; - dxCircularGauge(options?: DevExpress.viz.gauges.dxCircularGaugeOptions): JQuery; - dxCircularGauge(methodName: string, ...params: any[]): any; - dxCircularGauge(methodName: "instance"): DevExpress.viz.dxCircularGauge; - dxBarGauge(options?: DevExpress.viz.gauges.dxBarGaugeOptions): JQuery; - dxBarGauge(methodName: string, ...params: any[]): any; - dxBarGauge(methodName: "instance"): DevExpress.viz.dxBarGauge; -} declare module DevExpress.viz.rangeSelector { export interface dxRangeSelectorOptions extends viz.core.BaseWidgetOptions, viz.core.MarginOptions, viz.core.RedrawOnResizeOptions, viz.core.TitleOptions, viz.core.LoadingIndicatorOptions, viz.core.ExportOptions { /** Specifies the options for the range selector's background. */ @@ -6797,8 +6974,10 @@ declare module DevExpress.viz.rangeSelector { allowSlidersSwap?: boolean; /** Indicates whether or not animation is enabled. */ animationEnabled?: boolean; - /** Specifies when to call the onSelectedRangeChanged function. */ + /** * Specifies when to call the onSelectedRangeChanged function. * @deprecated Use the callValueChanged option instead. */ callSelectedRangeChanged?: string; + /** Specifies when to call the onValueChanged function. */ + callValueChanged?: string; /** Indicates whether or not an end user can specify the range using a mouse, without the use of sliders. */ manualRangeSelectionEnabled?: boolean; /** Indicates whether or not an end user can shift the selected range to the required location on a scale by clicking. */ @@ -6871,10 +7050,7 @@ declare module DevExpress.viz.rangeSelector { font?: viz.core.Font; /** Specifies a format for the text displayed in scale labels. */ format?: any; - /** - * Specifies a precision for the formatted value displayed in the scale labels. - * @deprecated Use the scale | label | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed in the scale labels. * @deprecated Use the scale | label | format | precision option instead. */ precision?: number; /** Specifies a spacing between scale labels and the background bottom edge. */ topIndent?: number; @@ -6883,10 +7059,7 @@ declare module DevExpress.viz.rangeSelector { }; /** Specifies the value to be raised to a power when generating ticks for a logarithmic scale. */ logarithmBase?: number; - /** - * Specifies an interval between major ticks. - * @deprecated Use the tickInterval option instead. - */ + /** * Specifies an interval between major ticks. * @deprecated Use the tickInterval option instead. */ majorTickInterval?: any; /** Specifies an interval between axis ticks. */ tickInterval?: any; @@ -6924,10 +7097,7 @@ declare module DevExpress.viz.rangeSelector { setTicksAtUnitBeginning?: boolean; /** Specifies whether or not to show ticks for the boundary scale values, when neither major ticks nor minor ticks are created for these values. */ showCustomBoundaryTicks?: boolean; - /** - * Indicates whether or not to show minor ticks on the scale. - * @deprecated Use the minorTick | visible option instead. - */ + /** * Indicates whether or not to show minor ticks on the scale. * @deprecated Use the minorTick | visible option instead. */ showMinorTicks?: boolean; /** Specifies the scale's start value. */ startValue?: any; @@ -6957,16 +7127,18 @@ declare module DevExpress.viz.rangeSelector { useTicksAutoArrangement?: boolean; /** Specifies the type of values on the scale. */ valueType?: string; - /** Specifies the order of arguments on a discrete scale. */ - categories?: Array; + /** Specifies the order of arguments on a discrete scale. */ + categories?: Array; }; - /** Specifies the range to be selected when displaying the RangeSelector. */ + /** * Specifies the range to be selected when displaying the RangeSelector. * @deprecated Use the value option instead. */ selectedRange?: { /** Specifies the start value of the range to be selected when displaying the RangeSelector widget on a page. */ startValue?: any; /** Specifies the end value of the range to be selected when displaying the RangeSelector widget on a page. */ endValue?: any; }; + /** The selected range, initial or current. */ + value?: Array; /** Specifies the color of the selected range. */ selectedRangeColor?: string; /** Range selector's indent options. */ @@ -6976,13 +7148,20 @@ declare module DevExpress.viz.rangeSelector { /** Specifies range selector's right indent. */ right?: number; }; - /** A handler for the selectedRangeChanged event. */ + /** * A handler for the selectedRangeChanged event. * @deprecated Use the onValueChanged option instead. */ onSelectedRangeChanged?: (e: { startValue: any; endValue: any; component: dxRangeSelector; element: Element; }) => void; + /** A handler for the valueChanged event. */ + onValueChanged?: (e: { + value: Array; + previousValue: Array; + component: dxRangeSelector; + element: Element; + }) => void; /** Specifies range selector shutter options. */ shutter?: { /** Specifies shutter color. */ @@ -7011,10 +7190,7 @@ declare module DevExpress.viz.rangeSelector { format?: any; /** Specifies the color used for the slider marker text when the currently selected range does not match the minRange and maxRange values. */ invalidRangeColor?: string; - /** - * Specifies the empty space between the marker's border and the marker’s text. - * @deprecated Use the paddingTopBottom and paddingLeftRight options instead. - */ + /** * Specifies the empty space between the marker's border and the marker’s text. * @deprecated Use the paddingTopBottom and paddingLeftRight options instead. */ padding?: number; /** Specifies the empty space between the marker's top and bottom borders and the marker's text. */ paddingTopBottom?: number; @@ -7022,10 +7198,7 @@ declare module DevExpress.viz.rangeSelector { paddingLeftRight?: number; /** Specifies the placeholder height of the slider marker. */ placeholderHeight?: number; - /** - * Specifies in pixels the height and width of the space reserved for the range selector slider markers. - * @deprecated Use the placeholderHeight and indent options instead. - */ + /** * Specifies in pixels the height and width of the space reserved for the range selector slider markers. * @deprecated Use the placeholderHeight and indent options instead. */ placeholderSize?: { /** Specifies the height of the placeholder for the left and right slider markers. */ height?: number; @@ -7037,10 +7210,7 @@ declare module DevExpress.viz.rangeSelector { right?: number; }; }; - /** - * Specifies a precision for the formatted value displayed in slider markers. - * @deprecated Use the sliderMarker | format | precision option instead. - */ + /** * Specifies a precision for the formatted value displayed in slider markers. * @deprecated Use the sliderMarker | format | precision option instead. */ precision?: number; /** Indicates whether or not the slider markers are visible. */ visible?: boolean; @@ -7056,17 +7226,18 @@ declare module DevExpress.viz { hideLoadingIndicator(): void; /** Redraws a widget. */ render(skipChartAnimation?: boolean): void; - /** Returns the currently selected range. */ + /** * Returns the currently selected range. * @deprecated Use the getValue() method instead. */ getSelectedRange(): { startValue: any; endValue: any; }; - /** Sets a specified range. */ + /** * Sets a specified range. * @deprecated Use the setValue(value) method instead. */ setSelectedRange(selectedRange: { startValue: any; endValue: any; }): void; + /** Gets the currently selected range. */ + getValue(): Array; + /** Selects a specific range. */ + setValue(value: Array): void; + /** Returns the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; } } -interface JQuery { - dxRangeSelector(options?: DevExpress.viz.rangeSelector.dxRangeSelectorOptions): JQuery; - dxRangeSelector(methodName: string, ...params: any[]): any; - dxRangeSelector(methodName: "instance"): DevExpress.viz.dxRangeSelector; -} declare module DevExpress.viz.map { /** This section describes the fields and methods that can be used in code to manipulate the Layer object. */ export interface MapLayer { @@ -7082,6 +7253,8 @@ declare module DevExpress.viz.map { getElements(): Array; /** Deselects all layer elements. */ clearSelection(): void; + /** Returns the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; } /** This section describes the fields and methods that can be used in code to manipulate the Layer Element object. */ export interface MapLayerElement { @@ -7100,91 +7273,40 @@ declare module DevExpress.viz.map { /** Applies the layer element settings and updates element appearance. */ applySettings(settings: any): void; } - /** - * This section describes the fields and methods that can be used in code to manipulate the Area object. - * @deprecated Use the Layer Element instead. - */ + /** * This section describes the fields and methods that can be used in code to manipulate the Area object. * @deprecated Use the Layer Element instead. */ export interface Area { - /** - * Contains the element type. - * @deprecated Use the Layer | type instead. - */ + /** * Contains the element type. * @deprecated Use the Layer | type instead. */ type: string; - /** - * Return the value of an attribute. - * @deprecated Use the Layer Element | attribute(name, value) method instead. - */ + /** * Return the value of an attribute. * @deprecated Use the Layer Element | attribute(name, value) method instead. */ attribute(name: string): any; - /** - * Provides information about the selection state of an area. - * @deprecated Use the Layer Element | selected() method instead. - */ + /** * Provides information about the selection state of an area. * @deprecated Use the Layer Element | selected() method instead. */ selected(): boolean; - /** - * Sets a new selection state for an area. - * @deprecated Use the Layer Element | selected(state) method instead. - */ + /** * Sets a new selection state for an area. * @deprecated Use the Layer Element | selected(state) method instead. */ selected(state: boolean): void; - /** - * Applies the area settings specified as a parameter and updates the area appearance. - * @deprecated Use the Layer Element | applySettings(settings) method instead. - */ + /** * Applies the area settings specified as a parameter and updates the area appearance. * @deprecated Use the Layer Element | applySettings(settings) method instead. */ applySettings(settings: any): void; } - /** - * This section describes the fields and methods that can be used in code to manipulate the Markers object. - * @deprecated Use the Layer Element instead. - */ + /** * This section describes the fields and methods that can be used in code to manipulate the Markers object. * @deprecated Use the Layer Element instead. */ export interface Marker { - /** - * Contains the descriptive text accompanying the map marker. - * @deprecated Get the text using the Layer Element | attribute(name) method. The name parameter value for text is set at the dataField option. - */ + /** * Contains the descriptive text accompanying the map marker. * @deprecated Get the text using the Layer Element | attribute(name) method. The name parameter value for text is set at the dataField option. */ text: string; - /** - * Contains the type of the element. - * @deprecated Use the Layer | type instead. - */ + /** * Contains the type of the element. * @deprecated Use the Layer | type instead. */ type: string; - /** - * Contains the URL of an image map marker. - * @deprecated Get the image URL using the Layer Element | attribute(name) method. The name parameter value for the image URL is set at the dataField option. - */ + /** * Contains the URL of an image map marker. * @deprecated Get the image URL using the Layer Element | attribute(name) method. The name parameter value for the image URL is set at the dataField option. */ url: string; - /** - * Contains the value of a bubble map marker. - * @deprecated Get the bubble value using the Layer Element | attribute(name) method. The name parameter for the bubble value is set at the dataField option. - */ + /** * Contains the value of a bubble map marker. * @deprecated Get the bubble value using the Layer Element | attribute(name) method. The name parameter for the bubble value is set at the dataField option. */ value: number; - /** - * Contains the values of a pie map marker. - * @deprecated Get the pie values using the Layer Element | attribute(name) method. The name parameter for pie values is set at the dataField option. - */ + /** * Contains the values of a pie map marker. * @deprecated Get the pie values using the Layer Element | attribute(name) method. The name parameter for pie values is set at the dataField option. */ values: Array; - /** - * Returns the value of an attribute. - * @deprecated Use the Layer Element | attribute(name, value) method instead. - */ + /** * Returns the value of an attribute. * @deprecated Use the Layer Element | attribute(name, value) method instead. */ attribute(name: string): any; - /** - * Returns the coordinates of a specific marker. - * @deprecated Use the Layer Element | coordinates() method instead. - */ + /** * Returns the coordinates of a specific marker. * @deprecated Use the Layer Element | coordinates() method instead. */ coordinates(): Array; - /** - * Provides information about the selection state of a marker. - * @deprecated Use the Layer Element | selected() method instead. - */ + /** * Provides information about the selection state of a marker. * @deprecated Use the Layer Element | selected() method instead. */ selected(): boolean; - /** - * Sets a new selection state for a marker. - * @deprecated Use the Layer Element | selected(state) method instead. - */ + /** * Sets a new selection state for a marker. * @deprecated Use the Layer Element | selected(state) method instead. */ selected(state: boolean): void; - /** - * Applies the marker settings specified as a parameter and updates marker appearance. - * @deprecated Use the Layer Element | applySettings(settings) method instead. - */ + /** * Applies the marker settings specified as a parameter and updates marker appearance. * @deprecated Use the Layer Element | applySettings(settings) method instead. */ applySettings(settings: any): void; } export interface MapLayerSettings { @@ -7253,241 +7375,103 @@ declare module DevExpress.viz.map { }; } export interface AreaSettings { - /** - * Specifies the width of the area border in pixels. - * @deprecated Use the layers | borderWidth option instead. - */ + /** * Specifies the width of the area border in pixels. * @deprecated Use the layers | borderWidth option instead. */ borderWidth?: number; - /** - * Specifies a color for the area border. - * @deprecated Use the layers | borderColor option instead. - */ + /** * Specifies a color for the area border. * @deprecated Use the layers | borderColor option instead. */ borderColor?: string; - /** - * Specifies a color for an area. - * @deprecated Use the layers | color option instead. - */ + /** * Specifies a color for an area. * @deprecated Use the layers | color option instead. */ color?: string; - /** - * Specifies the function that customizes each area individually. - * @deprecated Use the layers | customize option instead. - */ + /** * Specifies the function that customizes each area individually. * @deprecated Use the layers | customize option instead. */ customize?: (areaInfo: Area) => AreaSettings; - /** - * Specifies a color for the area border when the area is hovered over. - * @deprecated Use the layers | hoveredBorderColor option instead. - */ + /** * Specifies a color for the area border when the area is hovered over. * @deprecated Use the layers | hoveredBorderColor option instead. */ hoveredBorderColor?: string; - /** - * Specifies the pixel-measured width of the area border when the area is hovered over. - * @deprecated Use the layers | hoveredBorderWidth option instead. - */ + /** * Specifies the pixel-measured width of the area border when the area is hovered over. * @deprecated Use the layers | hoveredBorderWidth option instead. */ hoveredBorderWidth?: number; - /** - * Specifies a color for an area when this area is hovered over. - * @deprecated Use the layers | hoveredColor option instead. - */ + /** * Specifies a color for an area when this area is hovered over. * @deprecated Use the layers | hoveredColor option instead. */ hoveredColor?: string; - /** - * Specifies whether or not to change the appearance of an area when it is hovered over. - * @deprecated Use the layers | hoverEnabled option instead. - */ + /** * Specifies whether or not to change the appearance of an area when it is hovered over. * @deprecated Use the layers | hoverEnabled option instead. */ hoverEnabled?: boolean; - /** - * Configures area labels. - * @deprecated Use the layers | label option instead. - */ + /** * Configures area labels. * @deprecated Use the layers | label option instead. */ label?: { - /** - * Specifies the data field that provides data for area labels. - * @deprecated Use the layers | label | dataField option instead. - */ + /** * Specifies the data field that provides data for area labels. * @deprecated Use the layers | label | dataField option instead. */ dataField?: string; - /** - * Enables area labels. - * @deprecated Use the layers | label | enabled option instead. - */ + /** * Enables area labels. * @deprecated Use the layers | label | enabled option instead. */ enabled?: boolean; - /** - * Specifies font options for area labels. - * @deprecated Use the layers | label | font option instead. - */ + /** * Specifies font options for area labels. * @deprecated Use the layers | label | font option instead. */ font?: viz.core.Font; }; - /** - * Specifies the name of the palette or a custom range of colors to be used for coloring a map. - * @deprecated Use the layers | palette option instead. - */ + /** * Specifies the name of the palette or a custom range of colors to be used for coloring a map. * @deprecated Use the layers | palette option instead. */ palette?: any; - /** - * Specifies the number of colors in a palette. - * @deprecated Use the layers | paletteSize option instead. - */ + /** * Specifies the number of colors in a palette. * @deprecated Use the layers | paletteSize option instead. */ paletteSize?: number; - /** - * Allows you to paint areas with similar attributes in the same color. - * @deprecated Use the layers | colorGroups option instead. - */ + /** * Allows you to paint areas with similar attributes in the same color. * @deprecated Use the layers | colorGroups option instead. */ colorGroups?: Array; - /** - * Specifies the field that provides data to be used for coloring areas. - * @deprecated Use the layers | colorGroupingField option instead. - */ + /** * Specifies the field that provides data to be used for coloring areas. * @deprecated Use the layers | colorGroupingField option instead. */ colorGroupingField?: string; - /** - * Specifies a color for the area border when the area is selected. - * @deprecated Use the layers | selectedBorderColor option instead. - */ + /** * Specifies a color for the area border when the area is selected. * @deprecated Use the layers | selectedBorderColor option instead. */ selectedBorderColor?: string; - /** - * Specifies a color for an area when this area is selected. - * @deprecated Use the layers | selectedColor option instead. - */ + /** * Specifies a color for an area when this area is selected. * @deprecated Use the layers | selectedColor option instead. */ selectedColor?: string; - /** - * Specifies the pixel-measured width of the area border when the area is selected. - * @deprecated Use the layers | selectedBorderWidth option instead. - */ + /** * Specifies the pixel-measured width of the area border when the area is selected. * @deprecated Use the layers | selectedBorderWidth option instead. */ selectedBorderWidth?: number; - /** - * Specifies whether single or multiple areas can be selected on a vector map. - * @deprecated Use the layers | selectionMode option instead. - */ + /** * Specifies whether single or multiple areas can be selected on a vector map. * @deprecated Use the layers | selectionMode option instead. */ selectionMode?: string; } export interface MarkerSettings { - /** - * Specifies a color for the marker border. - * @deprecated Use the layers | borderColor option instead. - */ + /** * Specifies a color for the marker border. * @deprecated Use the layers | borderColor option instead. */ borderColor?: string; - /** - * Specifies the width of the marker border in pixels. - * @deprecated Use the layers | borderWidth option instead. - */ + /** * Specifies the width of the marker border in pixels. * @deprecated Use the layers | borderWidth option instead. */ borderWidth?: number; - /** - * Specifies a color for a marker of the dot or bubble type. - * @deprecated Use the layers | color option instead. - */ + /** * Specifies a color for a marker of the dot or bubble type. * @deprecated Use the layers | color option instead. */ color?: string; - /** - * Specifies the function that customizes each marker individually. - * @deprecated Use the layers | customize option instead. - */ + /** * Specifies the function that customizes each marker individually. * @deprecated Use the layers | customize option instead. */ customize?: (markerInfo: Marker) => MarkerSettings; - /** - * Specifies the pixel-measured width of the marker border when the marker is hovered over. - * @deprecated Use the layers | hoveredBorderWidth option instead. - */ + /** * Specifies the pixel-measured width of the marker border when the marker is hovered over. * @deprecated Use the layers | hoveredBorderWidth option instead. */ hoveredBorderWidth?: number; - /** - * Specifies a color for the marker border when the marker is hovered over. - * @deprecated Use the layers | hoveredBorderColor option instead. - */ + /** * Specifies a color for the marker border when the marker is hovered over. * @deprecated Use the layers | hoveredBorderColor option instead. */ hoveredBorderColor?: string; - /** - * Specifies a color for a marker of the dot or bubble type when this marker is hovered over. - * @deprecated Use the layers | hoveredColor option instead. - */ + /** * Specifies a color for a marker of the dot or bubble type when this marker is hovered over. * @deprecated Use the layers | hoveredColor option instead. */ hoveredColor?: string; - /** - * Specifies whether or not to change the appearance of a marker when it is hovered over. - * @deprecated Use the layers | hoverEnabled option instead. - */ + /** * Specifies whether or not to change the appearance of a marker when it is hovered over. * @deprecated Use the layers | hoverEnabled option instead. */ hoverEnabled?: boolean; - /** - * Specifies marker label options. - * @deprecated Use the layers | label option instead. - */ + /** * Specifies marker label options. * @deprecated Use the layers | label option instead. */ label?: { - /** - * Enables marker labels. - * @deprecated Use the layers | label | enabled option instead. - */ + /** * Enables marker labels. * @deprecated Use the layers | label | enabled option instead. */ enabled?: boolean; - /** - * Specifies font options for marker labels. - * @deprecated Use the layers | label | font option instead. - */ + /** * Specifies font options for marker labels. * @deprecated Use the layers | label | font option instead. */ font?: viz.core.Font; }; - /** - * Specifies the pixel-measured diameter of the marker that represents the biggest value. Setting this option makes sense only if you use markers of the bubble type. - * @deprecated Use the layers | maxSize option instead. - */ + /** * Specifies the pixel-measured diameter of the marker that represents the biggest value. Setting this option makes sense only if you use markers of the bubble type. * @deprecated Use the layers | maxSize option instead. */ maxSize?: number; - /** - * Specifies the pixel-measured diameter of the marker that represents the smallest value. Setting this option makes sense only if you use markers of the bubble type. - * @deprecated Use the layers | minSize option instead. - */ + /** * Specifies the pixel-measured diameter of the marker that represents the smallest value. Setting this option makes sense only if you use markers of the bubble type. * @deprecated Use the layers | minSize option instead. */ minSize?: number; - /** - * Specifies the opacity of markers. Setting this option makes sense only if you use markers of the bubble type. - * @deprecated Use the layers | opacity option instead. - */ + /** * Specifies the opacity of markers. Setting this option makes sense only if you use markers of the bubble type. * @deprecated Use the layers | opacity option instead. */ opacity?: number; - /** - * Specifies the pixel-measured width of the marker border when the marker is selected. - * @deprecated Use the layers | selectedBorderWidth option instead. - */ + /** * Specifies the pixel-measured width of the marker border when the marker is selected. * @deprecated Use the layers | selectedBorderWidth option instead. */ selectedBorderWidth?: number; - /** - * Specifies a color for the marker border when the marker is selected. - * @deprecated Use the layers | selectedBorderColor option instead. - */ + /** * Specifies a color for the marker border when the marker is selected. * @deprecated Use the layers | selectedBorderColor option instead. */ selectedBorderColor?: string; - /** - * Specifies a color for a marker of the dot or bubble type when this marker is selected. - * @deprecated Use the layers | selectedColor option instead. - */ + /** * Specifies a color for a marker of the dot or bubble type when this marker is selected. * @deprecated Use the layers | selectedColor option instead. */ selectedColor?: string; - /** - * Specifies whether a single or multiple markers can be selected on a vector map. - * @deprecated Use the layers | selectionMode option instead. - */ + /** * Specifies whether a single or multiple markers can be selected on a vector map. * @deprecated Use the layers | selectionMode option instead. */ selectionMode?: string; - /** - * Specifies the size of markers. Setting this option makes sense for any type of marker except bubble. - * @deprecated Use the layers | size option instead. - */ + /** * Specifies the size of markers. Setting this option makes sense for any type of marker except bubble. * @deprecated Use the layers | size option instead. */ size?: number; - /** - * Specifies the type of markers to be used on the map. - * @deprecated Use the layers | elementType option instead. - */ + /** * Specifies the type of markers to be used on the map. * @deprecated Use the layers | elementType option instead. */ type?: string; - /** - * Specifies the name of a palette or a custom set of colors to be used for coloring markers of the pie type. - * @deprecated Use the layers | palette option instead. - */ + /** * Specifies the name of a palette or a custom set of colors to be used for coloring markers of the pie type. * @deprecated Use the layers | palette option instead. */ palette?: any; - /** - * Allows you to paint markers with similar attributes in the same color. - * @deprecated Use the layers | colorGroups option instead. - */ + /** * Allows you to paint markers with similar attributes in the same color. * @deprecated Use the layers | colorGroups option instead. */ colorGroups?: Array; - /** - * Specifies the field that provides data to be used for coloring markers. - * @deprecated Use the layers | colorGroupingField option instead. - */ + /** * Specifies the field that provides data to be used for coloring markers. * @deprecated Use the layers | colorGroupingField option instead. */ colorGroupingField?: string; - /** - * Allows you to display bubbles with similar attributes in the same size. - * @deprecated Use the layers | sizeGroups option instead. - */ + /** * Allows you to display bubbles with similar attributes in the same size. * @deprecated Use the layers | sizeGroups option instead. */ sizeGroups?: Array; - /** - * Specifies the field that provides data to be used for sizing bubble markers. - * @deprecated Use the layers | sizeGroupingField option instead. - */ + /** * Specifies the field that provides data to be used for sizing bubble markers. * @deprecated Use the layers | sizeGroupingField option instead. */ sizeGroupingField?: string; } export interface dxVectorMapOptions extends viz.core.BaseWidgetOptions, viz.core.RedrawOnResizeOptions, viz.core.TitleOptions, viz.core.LoadingIndicatorOptions, viz.core.ExportOptions { - /** - * An object specifying options for the map areas. - * @deprecated Use the "area" type element of the layers array. - */ + /** * An object specifying options for the map areas. * @deprecated Use the "area" type element of the layers array. */ areaSettings?: AreaSettings; /** Specifies the options for the map background. */ background?: { @@ -7519,20 +7503,11 @@ declare module DevExpress.viz.map { /** Specifies the opacity of the control bar. */ opacity?: number; }; - /** - * Specifies a data source for the map area. - * @deprecated Use the layers | dataSource option instead. - */ + /** * Specifies a data source for the map area. * @deprecated Use the layers | dataSource option instead. */ mapData?: any; - /** - * Specifies a data source for the map markers. - * @deprecated Use the layers | dataSource option instead. - */ + /** * Specifies a data source for the map markers. * @deprecated Use the layers | dataSource option instead. */ markers?: any; - /** - * An object specifying options for the map markers. - * @deprecated Use the "marker" type element of the layers array. - */ + /** * An object specifying options for the map markers. * @deprecated Use the "marker" type element of the layers array. */ markerSettings?: MarkerSettings; /** Configures tooltips. */ tooltip?: viz.core.Tooltip; @@ -7582,29 +7557,17 @@ declare module DevExpress.viz.map { element: Element; target: MapLayerElement; }) => void; - /** - * A handler for the areaClick event. - * @deprecated Use the onClick option instead. - */ + /** * A handler for the areaClick event. * @deprecated Use the onClick option instead. */ onAreaClick?: any; - /** - * A handler for the areaSelectionChanged event. - * @deprecated Use the onSelectionChanged option instead. - */ + /** * A handler for the areaSelectionChanged event. * @deprecated Use the onSelectionChanged option instead. */ onAreaSelectionChanged?: (e: { target: Area; component: dxVectorMap; element: Element; }) => void; - /** - * A handler for the markerClick event. - * @deprecated Use the onClick option instead. - */ + /** * A handler for the markerClick event. * @deprecated Use the onClick option instead. */ onMarkerClick?: any; - /** - * A handler for the markerSelectionChanged event. - * @deprecated Use the onSelecitonChanged option instead. - */ + /** * A handler for the markerSelectionChanged event. * @deprecated Use the onSelecitonChanged option instead. */ onMarkerSelectionChanged?: (e: { target: Marker; component: dxVectorMap; @@ -7644,7 +7607,7 @@ declare module DevExpress.viz.map { add(name: string, projection: Object): void; } } -declare module DevExpress.viz{ +declare module DevExpress.viz { /** A vector map widget. */ export class dxVectorMap extends viz.core.BaseWidget implements viz.core.LoadingIndicatorMethods { constructor(element: JQuery, options?: DevExpress.viz.map.dxVectorMapOptions); @@ -7655,15 +7618,9 @@ declare module DevExpress.viz{ center(): Array; /** Sets the coordinates of the map center. */ center(centerCoordinates: Array): void; - /** - * Deselects all the selected areas on a map. The areas are displayed in their initial style after. - * @deprecated Use the layer's clearSelection() method instead. - */ + /** * Deselects all the selected areas on a map. The areas are displayed in their initial style after. * @deprecated Use the layer's clearSelection() method instead. */ clearAreaSelection(): void; - /** - * Deselects all the selected markers on a map. The markers are displayed in their initial style after. - * @deprecated Use the layer's clearSelection() method instead. - */ + /** * Deselects all the selected markers on a map. The markers are displayed in their initial style after. * @deprecated Use the layer's clearSelection() method instead. */ clearMarkerSelection(): void; /** Deselects all the selected area and markers on a map at once. The areas and markers are displayed in their initial style after. */ clearSelection(): void; @@ -7675,15 +7632,9 @@ declare module DevExpress.viz{ getLayerByIndex(index: number): DevExpress.viz.map.MapLayer; /** Gets the layer by its name. */ getLayerByName(name: string): DevExpress.viz.map.MapLayer; - /** - * Returns an array with all the map areas. - * @deprecated Use the layer's getElements() method instead. - */ + /** * Returns an array with all the map areas. * @deprecated Use the layer's getElements() method instead. */ getAreas(): Array; - /** - * Returns an array with all the map markers. - * @deprecated Use the layer's getElements() method instead. - */ + /** * Returns an array with all the map markers. * @deprecated Use the layer's getElements() method instead. */ getMarkers(): Array; /** Gets the current coordinates of the map viewport. */ viewport(): Array; @@ -7695,22 +7646,11 @@ declare module DevExpress.viz{ zoomFactor(zoomFactor: number): void; } } -interface JQuery { - dxVectorMap(options?: DevExpress.viz.map.dxVectorMapOptions): JQuery; - dxVectorMap(methodName: string, ...params: any[]): any; - dxVectorMap(methodName: "instance"): DevExpress.viz.dxVectorMap; -} declare module DevExpress.viz.sparklines { export interface SparklineTooltip extends viz.core.Tooltip { - /** - * Specifies how a tooltip is horizontally aligned relative to the graph. - * @deprecated Tooltip alignment is no longer useful because the tooltips are aligned automatically. - */ + /** * Specifies how a tooltip is horizontally aligned relative to the graph. * @deprecated Tooltip alignment is no longer useful because the tooltips are aligned automatically. */ horizontalAlignment?: string; - /** - * Specifies how a tooltip is vertically aligned relative to the graph. - * @deprecated Tooltip alignment is no longer useful because the tooltips are aligned automatically. - */ + /** * Specifies how a tooltip is vertically aligned relative to the graph. * @deprecated Tooltip alignment is no longer useful because the tooltips are aligned automatically. */ verticalAlignment?: string; } export interface BaseSparklineOptions extends viz.core.BaseWidgetOptions, viz.core.MarginOptions { @@ -7807,16 +7747,10 @@ declare module DevExpress.viz { export class dxSparkline extends DevExpress.viz.sparklines.BaseSparkline { constructor(element: JQuery, options?: DevExpress.viz.sparklines.dxSparklineOptions); constructor(element: Element, options?: DevExpress.viz.sparklines.dxSparklineOptions); + /** Returns the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; } } -interface JQuery { - dxBullet(options?: DevExpress.viz.sparklines.dxBulletOptions): JQuery; - dxBullet(methodName: string, ...params: any[]): any; - dxBullet(methodName: "instance"): DevExpress.viz.dxBullet; - dxSparkline(options?: DevExpress.viz.sparklines.dxSparklineOptions): JQuery; - dxSparkline(methodName: string, ...params: any[]): any; - dxSparkline(methodName: "instance"): DevExpress.viz.dxSparkline; -} declare module DevExpress.viz.treeMap { export interface dxTreeMapOptions extends viz.core.BaseWidgetOptions, viz.core.RedrawOnResizeOptions, viz.core.TitleOptions, viz.core.LoadingIndicatorOptions, viz.core.ExportOptions { /** Specifies the origin of data for the widget. */ @@ -7837,6 +7771,8 @@ declare module DevExpress.viz.treeMap { layoutAlgorithm?: any; /** Specifies the direction in which the items will be laid out. */ layoutDirection?: string; + /** Decides whether those labels that overflow their tile/group should be hidden or truncated with ellipsis. */ + resolveLabelOverflow?: string; /** Configures tiles. */ tile?: { /** Configures the tile borders. */ @@ -8043,10 +7979,7 @@ declare module DevExpress.viz { resetDrillDown(): void; showLoadingIndicator(): void; hideLoadingIndicator(): void; + /** Returns the DataSource instance. */ + getDataSource(): DevExpress.data.DataSource; } } -interface JQuery { - dxTreeMap(options?: DevExpress.viz.treeMap.dxTreeMapOptions): JQuery; - dxTreeMap(methodName: string, ...params: any[]): any; - dxTreeMap(methodName: "instance"): DevExpress.viz.dxTreeMap; -} From 2bde4f64d0acdb1212281225665249d73876b25d Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Mon, 23 Jan 2017 12:39:51 -0500 Subject: [PATCH 089/248] Revise node.js definition to respond to feedback on PR #13877 --- node/index.d.ts | 6 ++---- node/node-tests.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index 32d3f5a203..6e4fbce84e 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -4016,10 +4016,8 @@ declare module "v8" { physical_space_size: number; } - enum DoesZapCodeSpaceFlag { - Disabled = 0, - Enabled = 1 - } + //** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */ + type DoesZapCodeSpaceFlag = 0 | 1; interface HeapInfo { total_heap_size: number; diff --git a/node/node-tests.ts b/node/node-tests.ts index 2844ca8e6e..03c3e9a1b6 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -24,6 +24,7 @@ import * as string_decoder from "string_decoder"; import * as stream from "stream"; import * as timers from "timers"; import * as repl from "repl"; +import * as v8 from "v8"; // Specifically test buffer module regression. import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer"; @@ -2071,6 +2072,21 @@ namespace constants_tests { str = constants.defaultCipherList } + +//////////////////////////////////////////////////// +/// v8 tests : https://nodejs.org/api/v8.html +//////////////////////////////////////////////////// + +namespace v8_tests { + + const heapStats = v8.getHeapStatistics(); + const heapSpaceStats = v8.getHeapSpaceStatistics(); + + const zapsGarbage: number = heapStats.does_zap_garbage; + + v8.setFlagsFromString('--collect_maps'); +} + /////////////////////////////////////////////////////////// /// Debugger Tests /// /////////////////////////////////////////////////////////// From 9b5329839558a78550bf078c3e5f323c2f0f3b86 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 23 Jan 2017 15:36:53 -0500 Subject: [PATCH 090/248] Support Pick<> on setState now that TS 2.1 is out (#13155) * Support Partial<> on setState now that TS 2.1 is out * Update readme to reflect setState being typed correctly * Switch setState to Pick * Restore cloneELement portion of readme * Use Pick<> | S for setState due to cast issue * state and props should be readonly * Fix nit + document why we * Add typescript compiler header * Update to properly order headers * Update readme to reflect 2.1.5 fixing stPick * Update readme now that 2.1.5 is out * All that depend on react now require 2.1 * Fix definition that fails due to readonly state --- 3d-bin-packing/index.d.ts | 1 + alt/index.d.ts | 1 + antd/index.d.ts | 1 + aphrodite/index.d.ts | 1 + chai-enzyme/index.d.ts | 1 + enzyme/index.d.ts | 1 + fixed-data-table/index.d.ts | 1 + flux/index.d.ts | 1 + fluxxor/index.d.ts | 1 + gaea-model/index.d.ts | 2 ++ halogen/index.d.ts | 1 + jsnox/index.d.ts | 1 + material-ui/index.d.ts | 1 + mobservable-react/index.d.ts | 1 + navigation-react/index.d.ts | 2 ++ ngreact/index.d.ts | 1 + radium/index.d.ts | 1 + rc-select/index.d.ts | 1 + rc-tooltip/index.d.ts | 1 + react-addons-create-fragment/index.d.ts | 1 + react-addons-css-transition-group/index.d.ts | 1 + react-addons-linked-state-mixin/index.d.ts | 1 + react-addons-pure-render-mixin/index.d.ts | 1 + react-addons-shallow-compare/index.d.ts | 1 + react-addons-test-utils/index.d.ts | 1 + react-addons-transition-group/index.d.ts | 1 + react-addons-update/index.d.ts | 1 + react-autosuggest/index.d.ts | 1 + react-big-calendar/index.d.ts | 1 + react-body-classname/index.d.ts | 1 + react-bootstrap-date-picker/index.d.ts | 1 + react-bootstrap-daterangepicker/index.d.ts | 1 + react-bootstrap-table/index.d.ts | 1 + react-bootstrap/index.d.ts | 1 + react-breadcrumbs/index.d.ts | 1 + react-bytesize-icons/index.d.ts | 1 + react-calendar-timeline/index.d.ts | 1 + react-codemirror/index.d.ts | 1 + react-color/index.d.ts | 1 + react-cropper/index.d.ts | 1 + react-css-transition-replace/index.d.ts | 1 + react-data-grid/index.d.ts | 1 + react-datagrid/index.d.ts | 1 + react-datepicker/index.d.ts | 1 + react-daterange-picker/index.d.ts | 1 + react-day-picker/index.d.ts | 2 +- react-dnd-html5-backend/index.d.ts | 1 + react-dnd/index.d.ts | 1 + react-dom/index.d.ts | 1 + react-dropzone/index.d.ts | 2 +- react-easy-chart/index.d.ts | 1 + react-event-listener/index.d.ts | 1 + react-fa/index.d.ts | 1 + react-facebook-login/index.d.ts | 1 + react-file-input/index.d.ts | 1 + react-file-reader-input/index.d.ts | 1 + react-flex/index.d.ts | 1 + react-flexr/index.d.ts | 1 + react-fontawesome/index.d.ts | 1 + react-gravatar/index.d.ts | 1 + react-helmet/index.d.ts | 1 + react-highlight-words/index.d.ts | 1 + react-holder/index.d.ts | 1 + react-hot-loader/index.d.ts | 1 + react-i18next/index.d.ts | 1 + react-imageloader/index.d.ts | 1 + react-infinite/index.d.ts | 1 + react-input-calendar/index.d.ts | 1 + react-input-mask/index.d.ts | 1 + react-intl-redux/index.d.ts | 1 + react-intl/index.d.ts | 1 + react-intl/v1/index.d.ts | 1 + react-is-deprecated/index.d.ts | 1 + react-joyride/index.d.ts | 1 + react-json-tree/index.d.ts | 1 + react-jsonschema-form/index.d.ts | 1 + .../react-jsonschema-form-tests.tsx | 11 +++++--- react-maskedinput/index.d.ts | 1 + react-mdl/index.d.ts | 1 + react-measure/index.d.ts | 1 + react-mixin/index.d.ts | 1 + react-modal/index.d.ts | 1 + react-motion-slider/index.d.ts | 1 + react-motion/index.d.ts | 1 + react-native-fs/index.d.ts | 1 + react-native-scrollable-tab-view/index.d.ts | 1 + react-native-sortable-list/index.d.ts | 1 + react-native-swiper/index.d.ts | 1 + react-native/index.d.ts | 1 + react-notification-system-redux/index.d.ts | 1 + react-notification-system/index.d.ts | 1 + react-onclickoutside/index.d.ts | 1 + react-overlays/index.d.ts | 1 + react-paginate/index.d.ts | 1 + react-props-decorators/index.d.ts | 1 + react-recaptcha/index.d.ts | 1 + react-redux-i18n/index.d.ts | 1 + react-redux-toastr/index.d.ts | 1 + react-redux/index.d.ts | 1 + react-relay/index.d.ts | 1 + react-responsive/index.d.ts | 1 + react-router-bootstrap/index.d.ts | 1 + react-router-redux/index.d.ts | 1 + react-router/index.d.ts | 1 + react-scroll/index.d.ts | 1 + react-scrollbar/index.d.ts | 1 + react-select/index.d.ts | 1 + react-side-effect/index.d.ts | 1 + react-slick/index.d.ts | 1 + react-smooth-scrollbar/index.d.ts | 1 + react-sortable-hoc/index.d.ts | 1 + react-spinkit/index.d.ts | 1 + react-split-pane/index.d.ts | 1 + react-swf/index.d.ts | 1 + react-swipeable-views/index.d.ts | 1 + react-swipeable/index.d.ts | 1 + react-syntax-highlighter/index.d.ts | 1 + react-tabs/index.d.ts | 1 + react-tagcloud/index.d.ts | 1 + react-test-renderer/index.d.ts | 1 + react-textarea-autosize/index.d.ts | 1 + react-toggle/index.d.ts | 1 + react-user-tour/index.d.ts | 1 + react-virtualized/index.d.ts | 1 + react-widgets/index.d.ts | 1 + react/README.md | 27 +++++++++++++++++-- react/index.d.ts | 9 ++++--- reactcss/index.d.ts | 1 + rebass/index.d.ts | 1 + recompose/index.d.ts | 1 + redux-bootstrap/index.d.ts | 1 + redux-devtools-dock-monitor/index.d.ts | 1 + redux-devtools-log-monitor/index.d.ts | 1 + redux-devtools/index.d.ts | 1 + redux-form/v4/index.d.ts | 1 + redux-router/index.d.ts | 1 + spectacle/index.d.ts | 1 + victory/index.d.ts | 1 + why-did-you-update/index.d.ts | 1 + 139 files changed, 175 insertions(+), 12 deletions(-) diff --git a/3d-bin-packing/index.d.ts b/3d-bin-packing/index.d.ts index 2461538194..14228f3141 100644 --- a/3d-bin-packing/index.d.ts +++ b/3d-bin-packing/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/betterwaysystems/packer // Definitions by: Jeongho Nam // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/alt/index.d.ts b/alt/index.d.ts index 561de28ac3..00e171484b 100644 --- a/alt/index.d.ts +++ b/alt/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/goatslacker/alt // Definitions by: Michael Shearer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/antd/index.d.ts b/antd/index.d.ts index e2865c6927..f262eda45f 100644 --- a/antd/index.d.ts +++ b/antd/index.d.ts @@ -2,6 +2,7 @@ // Project: http://ant.design // Definitions by: bang88 , Bruce Mitchener // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/aphrodite/index.d.ts b/aphrodite/index.d.ts index 2f53e133fd..63eba46927 100644 --- a/aphrodite/index.d.ts +++ b/aphrodite/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Khan/aphrodite // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/chai-enzyme/index.d.ts b/chai-enzyme/index.d.ts index 72842332ad..23e9058ef6 100644 --- a/chai-enzyme/index.d.ts +++ b/chai-enzyme/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/producthunt/chai-enzyme // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 94b60fc199..5502b0eb85 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/airbnb/enzyme // Definitions by: Marian Palkus , Cap3 , Ivo Stratev , Tom Crockett // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react"; diff --git a/fixed-data-table/index.d.ts b/fixed-data-table/index.d.ts index cb5809bf5a..a131501348 100644 --- a/fixed-data-table/index.d.ts +++ b/fixed-data-table/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/facebook/fixed-data-table // Definitions by: Petar Paar , Stephen Jelfs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/flux/index.d.ts b/flux/index.d.ts index 4b9c261040..54fecd3a4e 100644 --- a/flux/index.d.ts +++ b/flux/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/flux/ // Definitions by: Steve Baker , Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/fluxxor/index.d.ts b/fluxxor/index.d.ts index 4c8f773b1d..64c917cdf5 100644 --- a/fluxxor/index.d.ts +++ b/fluxxor/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/BinaryMuse/fluxxor // Definitions by: Yuichi Murata // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/gaea-model/index.d.ts b/gaea-model/index.d.ts index 769a1658d0..ec2ebe9976 100644 --- a/gaea-model/index.d.ts +++ b/gaea-model/index.d.ts @@ -2,6 +2,8 @@ // Project: https://github.com/ascoders/gaea-model // Definitions by: ascoders // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + import * as React from 'react'; export as namespace GaeaModel; diff --git a/halogen/index.d.ts b/halogen/index.d.ts index 72d57ace51..5735737f41 100644 --- a/halogen/index.d.ts +++ b/halogen/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/yuanyan/halogen // Definitions by: Vincent Rouffiat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as react from "react"; diff --git a/jsnox/index.d.ts b/jsnox/index.d.ts index f49cef58c4..9587afc8f1 100644 --- a/jsnox/index.d.ts +++ b/jsnox/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/af/jsnox // Definitions by: Steve Baker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/material-ui/index.d.ts b/material-ui/index.d.ts index 716505987d..665cdc6a24 100644 --- a/material-ui/index.d.ts +++ b/material-ui/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/callemall/material-ui // Definitions by: Nathan Brown , Oliver Herrmann // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/mobservable-react/index.d.ts b/mobservable-react/index.d.ts index a5f77cf5d4..4c035c2b5f 100644 --- a/mobservable-react/index.d.ts +++ b/mobservable-react/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mweststrate/mobservable-react // Definitions by: Michel Weststrate // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/navigation-react/index.d.ts b/navigation-react/index.d.ts index 131ce29735..32ee6570f3 100644 --- a/navigation-react/index.d.ts +++ b/navigation-react/index.d.ts @@ -2,6 +2,8 @@ // Project: http://grahammendick.github.io/navigation/ // Definitions by: Graham Mendick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + import { StateNavigator } from 'navigation'; import { Component, HTMLProps } from 'react'; diff --git a/ngreact/index.d.ts b/ngreact/index.d.ts index f9df0f694f..b20a35cad2 100644 --- a/ngreact/index.d.ts +++ b/ngreact/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ngReact/ngReact // Definitions by: Vicky Lai // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/radium/index.d.ts b/radium/index.d.ts index 89ee64dc45..8345b9516f 100644 --- a/radium/index.d.ts +++ b/radium/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/formidablelabs/radium // Definitions by: Alex Gorbatchev , Philipp Holzer , Alexey Svetliakov , Mikael Hermansson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import React = require('react'); import ReactComponent = React.Component; diff --git a/rc-select/index.d.ts b/rc-select/index.d.ts index f85e9c1e4e..d9d9723b5b 100644 --- a/rc-select/index.d.ts +++ b/rc-select/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/react-component/select // Definitions by: Denis Tirilis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/rc-tooltip/index.d.ts b/rc-tooltip/index.d.ts index 91904c623a..3916c8cfd6 100644 --- a/rc-tooltip/index.d.ts +++ b/rc-tooltip/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/react-component/tooltip // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-addons-create-fragment/index.d.ts b/react-addons-create-fragment/index.d.ts index 247d82618c..928ddc3a5d 100644 --- a/react-addons-create-fragment/index.d.ts +++ b/react-addons-create-fragment/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-addons-css-transition-group/index.d.ts b/react-addons-css-transition-group/index.d.ts index c8ccf83ebe..b74c38e264 100644 --- a/react-addons-css-transition-group/index.d.ts +++ b/react-addons-css-transition-group/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import 'react-addons-transition-group'; import { ComponentClass, TransitionGroupProps, CSSTransitionGroupProps } from 'react'; diff --git a/react-addons-linked-state-mixin/index.d.ts b/react-addons-linked-state-mixin/index.d.ts index a689ca35a0..d1b0a1b6c7 100644 --- a/react-addons-linked-state-mixin/index.d.ts +++ b/react-addons-linked-state-mixin/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Mixin } from 'react'; diff --git a/react-addons-pure-render-mixin/index.d.ts b/react-addons-pure-render-mixin/index.d.ts index 5265eb4ff2..73c87ed592 100644 --- a/react-addons-pure-render-mixin/index.d.ts +++ b/react-addons-pure-render-mixin/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Mixin } from 'react'; diff --git a/react-addons-shallow-compare/index.d.ts b/react-addons-shallow-compare/index.d.ts index dfaf03b873..9d16c35de1 100644 --- a/react-addons-shallow-compare/index.d.ts +++ b/react-addons-shallow-compare/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component } from 'react'; diff --git a/react-addons-test-utils/index.d.ts b/react-addons-test-utils/index.d.ts index b2aa5d97f6..3b5ec31bf6 100644 --- a/react-addons-test-utils/index.d.ts +++ b/react-addons-test-utils/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { AbstractView, Component, ComponentClass, ReactElement, ReactInstance, ClassType, diff --git a/react-addons-transition-group/index.d.ts b/react-addons-transition-group/index.d.ts index 9ccb4440bb..bfadb6850c 100644 --- a/react-addons-transition-group/index.d.ts +++ b/react-addons-transition-group/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { ReactElement, ComponentClass, ReactType, TransitionGroupProps } from 'react'; diff --git a/react-addons-update/index.d.ts b/react-addons-update/index.d.ts index ad3bbf43e1..76f5b32d3c 100644 --- a/react-addons-update/index.d.ts +++ b/react-addons-update/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-autosuggest/index.d.ts b/react-autosuggest/index.d.ts index ed12888833..d0d6bec839 100644 --- a/react-autosuggest/index.d.ts +++ b/react-autosuggest/index.d.ts @@ -2,6 +2,7 @@ // Project: http://react-autosuggest.js.org/ // Definitions by: Nicolas Schmitt , Philip Ottesen , Robert Essig // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-big-calendar/index.d.ts b/react-big-calendar/index.d.ts index 5cfbebb65e..c55a3c126c 100644 --- a/react-big-calendar/index.d.ts +++ b/react-big-calendar/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/intljusticemission/react-big-calendar // Definitions by: Piotr Witek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-big-calendar' { import * as React from 'react'; diff --git a/react-body-classname/index.d.ts b/react-body-classname/index.d.ts index 91c0ccd668..e20bffdc73 100644 --- a/react-body-classname/index.d.ts +++ b/react-body-classname/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/PactCoffee/react-body-classname // Definitions by: Mohamed Hegazy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import React = require("react"); diff --git a/react-bootstrap-date-picker/index.d.ts b/react-bootstrap-date-picker/index.d.ts index 59aac6683f..f905dc77a7 100644 --- a/react-bootstrap-date-picker/index.d.ts +++ b/react-bootstrap-date-picker/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/pushtell/react-bootstrap-date-picker#readme // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { ComponentClass, StatelessComponent, ReactNode, FocusEventHandler, HTMLAttributes } from "react"; diff --git a/react-bootstrap-daterangepicker/index.d.ts b/react-bootstrap-daterangepicker/index.d.ts index 793886cb11..e2ac7d49c6 100644 --- a/react-bootstrap-daterangepicker/index.d.ts +++ b/react-bootstrap-daterangepicker/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/skratchdot/react-bootstrap-daterangepicker // Definitions by: Ian Ker-Seymer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-bootstrap-table/index.d.ts b/react-bootstrap-table/index.d.ts index 72db1aaf40..566019ab94 100644 --- a/react-bootstrap-table/index.d.ts +++ b/react-bootstrap-table/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/AllenFang/react-bootstrap-table // Definitions by: Frank Laub , Aleksander Lode // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-bootstrap/index.d.ts b/react-bootstrap/index.d.ts index 76d046e10d..3e5c69c034 100644 --- a/react-bootstrap/index.d.ts +++ b/react-bootstrap/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/react-bootstrap/react-bootstrap // Definitions by: Walker Burgin , Vincent Siao , Danilo Barros , Batbold Gansukh , Raymond May Jr. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; export = ReactBootstrap; diff --git a/react-breadcrumbs/index.d.ts b/react-breadcrumbs/index.d.ts index 1d247f215d..af35bccaa1 100644 --- a/react-breadcrumbs/index.d.ts +++ b/react-breadcrumbs/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/svenanders/react-breadcrumbs // Definitions by: Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-bytesize-icons/index.d.ts b/react-bytesize-icons/index.d.ts index 99339d1b18..b2e5a3b8ae 100644 --- a/react-bytesize-icons/index.d.ts +++ b/react-bytesize-icons/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/abdelhai/react-bytesize-icons // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-calendar-timeline/index.d.ts b/react-calendar-timeline/index.d.ts index 029ea8b65b..c8269f9cf1 100644 --- a/react-calendar-timeline/index.d.ts +++ b/react-calendar-timeline/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/namespace-ee/react-calendar-timeline // Definitions by: Rajab Shakirov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-codemirror/index.d.ts b/react-codemirror/index.d.ts index 20176c2ae3..841fc34a0e 100644 --- a/react-codemirror/index.d.ts +++ b/react-codemirror/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/JedWatson/react-codemirror // Definitions by: Vicky Lai // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-color/index.d.ts b/react-color/index.d.ts index cdf723d33b..bed3ae46ff 100644 --- a/react-color/index.d.ts +++ b/react-color/index.d.ts @@ -2,6 +2,7 @@ // Project: https://casesandberg.github.io/react-color/ // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-cropper/index.d.ts b/react-cropper/index.d.ts index cfdd359148..aa29c6d4dc 100644 --- a/react-cropper/index.d.ts +++ b/react-cropper/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/roadmanfong/react-cropper // Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-css-transition-replace/index.d.ts b/react-css-transition-replace/index.d.ts index 88a8d11ffd..ce09917fbe 100644 --- a/react-css-transition-replace/index.d.ts +++ b/react-css-transition-replace/index.d.ts @@ -2,6 +2,7 @@ // Project: http://marnusw.github.io/react-css-transition-replace/ // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; import * as CSSTransitionGroup from "react-addons-css-transition-group"; diff --git a/react-data-grid/index.d.ts b/react-data-grid/index.d.ts index d378476670..3ec11776f9 100644 --- a/react-data-grid/index.d.ts +++ b/react-data-grid/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/adazzle/react-data-grid.git // Definitions by: Simon Gellis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-datagrid/index.d.ts b/react-datagrid/index.d.ts index 31462d2619..eddd5701fa 100644 --- a/react-datagrid/index.d.ts +++ b/react-datagrid/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/zippyui/react-datagrid.git // Definitions by: Stephen Jelfs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-datepicker/index.d.ts b/react-datepicker/index.d.ts index aec8b61b72..895dcac4ce 100644 --- a/react-datepicker/index.d.ts +++ b/react-datepicker/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Hacker0x01/react-datepicker // Definitions by: Rajab Shakirov , Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-daterange-picker/index.d.ts b/react-daterange-picker/index.d.ts index 102b8bac16..280c730df1 100644 --- a/react-daterange-picker/index.d.ts +++ b/react-daterange-picker/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/onefinestay/react-daterange-picker // Definitions by: UNCOVER TRUTH Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; import * as moment from "moment-range"; diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index f1a987cab3..01c5492922 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/gpbl/react-day-picker // Definitions by: Giampaolo Bellavite , Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.0 +// TypeScript Version: 2.1 /// diff --git a/react-dnd-html5-backend/index.d.ts b/react-dnd-html5-backend/index.d.ts index f9f3ad1a2c..299e47dbae 100644 --- a/react-dnd-html5-backend/index.d.ts +++ b/react-dnd-html5-backend/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/react-dnd // Definitions by: Pedro Pereira // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as ReactDnd from "react-dnd"; diff --git a/react-dnd/index.d.ts b/react-dnd/index.d.ts index 41b0e33eb6..0b98006be3 100644 --- a/react-dnd/index.d.ts +++ b/react-dnd/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/react-dnd // Definitions by: Asana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-dom/index.d.ts b/react-dom/index.d.ts index 45f62060ff..00520fc6ed 100644 --- a/react-dom/index.d.ts +++ b/react-dom/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export as namespace ReactDOM; export = ReactDOM; diff --git a/react-dropzone/index.d.ts b/react-dropzone/index.d.ts index b4ed4ded43..f6627c26d7 100644 --- a/react-dropzone/index.d.ts +++ b/react-dropzone/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/okonet/react-dropzone // Definitions by: Mathieu Larouche Dube , Ivo Jesus , Luís Rodrigues // Definitions: https://github.com/Vooban/DefinitelyTyped - +// TypeScript Version: 2.1 /// declare module "react-dropzone" { diff --git a/react-easy-chart/index.d.ts b/react-easy-chart/index.d.ts index 8728ad0eaf..66914c9cd5 100644 --- a/react-easy-chart/index.d.ts +++ b/react-easy-chart/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rma-consulting/react-easy-chart // Definitions by: Dave Leaver // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-event-listener/index.d.ts b/react-event-listener/index.d.ts index 7fefddbe7b..c6d05b313b 100644 --- a/react-event-listener/index.d.ts +++ b/react-event-listener/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/oliviertassinari/react-event-listener // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-fa/index.d.ts b/react-fa/index.d.ts index 1335f0a918..bab8fec196 100644 --- a/react-fa/index.d.ts +++ b/react-fa/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/andreypopp/react-fa // Definitions by: Frank Laub , Pat Sissons , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component, ComponentClass, HTMLProps, StatelessComponent } from "react"; diff --git a/react-facebook-login/index.d.ts b/react-facebook-login/index.d.ts index 3b95e684e4..8716b03217 100644 --- a/react-facebook-login/index.d.ts +++ b/react-facebook-login/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/keppelen/react-facebook-login // Definitions by: Alexandre Paré // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-file-input/index.d.ts b/react-file-input/index.d.ts index 9ec64fc1ec..3ae22e055f 100644 --- a/react-file-input/index.d.ts +++ b/react-file-input/index.d.ts @@ -2,6 +2,7 @@ // Project: https://www.npmjs.com/package/react-file-input // Definitions by: Dmitry Rogozhny // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-file-reader-input/index.d.ts b/react-file-reader-input/index.d.ts index 649f0f688c..37f9357f5c 100644 --- a/react-file-reader-input/index.d.ts +++ b/react-file-reader-input/index.d.ts @@ -2,6 +2,7 @@ // Project: https://www.npmjs.com/package/react-file-reader-input // Definitions by: Dmitry Rogozhny // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-flex/index.d.ts b/react-flex/index.d.ts index 3bd87f1493..5cfd68da2b 100644 --- a/react-flex/index.d.ts +++ b/react-flex/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/zippyui/react-flex // Definitions by: Jeffery Grajkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-flexr/index.d.ts b/react-flexr/index.d.ts index ad89e2c775..a0ec7128c0 100644 --- a/react-flexr/index.d.ts +++ b/react-flexr/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/kodyl/react-flexr // Definitions by: Jeffery Grajkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-fontawesome/index.d.ts b/react-fontawesome/index.d.ts index 0950d66d95..76568cc43e 100644 --- a/react-fontawesome/index.d.ts +++ b/react-fontawesome/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/danawoodman/react-fontawesome // Definitions by: Timur Rustamov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-fontawesome" { diff --git a/react-gravatar/index.d.ts b/react-gravatar/index.d.ts index 804fe440bc..3e33584a4b 100644 --- a/react-gravatar/index.d.ts +++ b/react-gravatar/index.d.ts @@ -2,6 +2,7 @@ // Project: http://kyleamathews.github.io/react-gravatar/ // Definitions by: invliD // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-helmet/index.d.ts b/react-helmet/index.d.ts index d38c23f27d..730bfb6df3 100644 --- a/react-helmet/index.d.ts +++ b/react-helmet/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/nfl/react-helmet // Definitions by: Evan Bremer , Isman Usoh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-highlight-words/index.d.ts b/react-highlight-words/index.d.ts index a9ccc36fc6..aae2eff04e 100644 --- a/react-highlight-words/index.d.ts +++ b/react-highlight-words/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/bvaughn/react-highlight-words#readme // Definitions by: Mohamed Hegazy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import React = require("react"); diff --git a/react-holder/index.d.ts b/react-holder/index.d.ts index ea2cf79945..1f4f773783 100644 --- a/react-holder/index.d.ts +++ b/react-holder/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Moeriki/react-holder // Definitions by: Isman Usoh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-hot-loader/index.d.ts b/react-hot-loader/index.d.ts index 9987a4f28f..3355ec47e6 100644 --- a/react-hot-loader/index.d.ts +++ b/react-hot-loader/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/react-hot-loader // Definitions by: Jacek Jagiello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react" diff --git a/react-i18next/index.d.ts b/react-i18next/index.d.ts index 41daf14c4a..7114087cd6 100644 --- a/react-i18next/index.d.ts +++ b/react-i18next/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/i18next/react-i18next // Definitions by: Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as I18next from "i18next"; import * as React from "react"; diff --git a/react-imageloader/index.d.ts b/react-imageloader/index.d.ts index 8132058aa0..8f39d72aa9 100644 --- a/react-imageloader/index.d.ts +++ b/react-imageloader/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/hzdg/react-imageloader // Definitions by: Stephen Jelfs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-infinite/index.d.ts b/react-infinite/index.d.ts index 20105017e5..b8999b0817 100644 --- a/react-infinite/index.d.ts +++ b/react-infinite/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/seatgeek/react-infinite // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-input-calendar/index.d.ts b/react-input-calendar/index.d.ts index 8684b9b4a5..11e6fd6fe8 100644 --- a/react-input-calendar/index.d.ts +++ b/react-input-calendar/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Rudeg/react-input-calendar // Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-input-mask/index.d.ts b/react-input-mask/index.d.ts index 3764b61122..6fc8c6008f 100644 --- a/react-input-mask/index.d.ts +++ b/react-input-mask/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/sanniassin/react-input-mask // Definitions by: Alexandre Paré // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-intl-redux/index.d.ts b/react-intl-redux/index.d.ts index 79ab678c33..6182c38cab 100644 --- a/react-intl-redux/index.d.ts +++ b/react-intl-redux/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ratson/react-intl-redux // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Action } from "redux" import { Provider as ReduxProvider } from "react-redux" diff --git a/react-intl/index.d.ts b/react-intl/index.d.ts index e0d9d3f623..a9629c4009 100644 --- a/react-intl/index.d.ts +++ b/react-intl/index.d.ts @@ -2,6 +2,7 @@ // Project: http://formatjs.io/react/ // Definitions by: Bruno Grieder , Christian Droulers , Fedor Nezhivoi , Till Wolff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-intl/v1/index.d.ts b/react-intl/v1/index.d.ts index 1ba7481a84..e5f2c7e906 100644 --- a/react-intl/v1/index.d.ts +++ b/react-intl/v1/index.d.ts @@ -2,6 +2,7 @@ // Project: http://formatjs.io/react/ // Definitions by: Bruno Grieder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-is-deprecated/index.d.ts b/react-is-deprecated/index.d.ts index a896b68619..78b69921cd 100644 --- a/react-is-deprecated/index.d.ts +++ b/react-is-deprecated/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Aweary/react-is-deprecated // Definitions by: Sean Kelley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-is-deprecated' { import { Validator, Requireable, ValidationMap, ReactPropTypes } from 'react'; diff --git a/react-joyride/index.d.ts b/react-joyride/index.d.ts index 3e8e1e58ed..1a6d674ed4 100644 --- a/react-joyride/index.d.ts +++ b/react-joyride/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gilbarbara/react-joyride // Definitions by: Daniel Rosenwasser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import React = require("react"); diff --git a/react-json-tree/index.d.ts b/react-json-tree/index.d.ts index dd20fdb6e6..5939638495 100644 --- a/react-json-tree/index.d.ts +++ b/react-json-tree/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/alexkuz/react-json-tree/ // Definitions by: Grant Nestor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component, diff --git a/react-jsonschema-form/index.d.ts b/react-jsonschema-form/index.d.ts index 1ff2487144..6786862ea8 100644 --- a/react-jsonschema-form/index.d.ts +++ b/react-jsonschema-form/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/mozilla-services/react-jsonschema-form // Definitions by: Dan Fox // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-jsonschema-form" { import * as React from "react"; diff --git a/react-jsonschema-form/react-jsonschema-form-tests.tsx b/react-jsonschema-form/react-jsonschema-form-tests.tsx index b5fdfff1c9..9f2c05086d 100644 --- a/react-jsonschema-form/react-jsonschema-form-tests.tsx +++ b/react-jsonschema-form/react-jsonschema-form-tests.tsx @@ -57,15 +57,18 @@ interface IExampleState { } export class Example extends React.Component { - constructor(props: any) { - super(props); - this.state.formData = { + public state: IExampleState = { + formData: { firstName: "Chuck", lastName: "Norris", age: 75, bio: "Roundhouse kicking asses since 1940", password: "noneed" - }; + } + } + + constructor(props: any) { + super(props); } public render() { diff --git a/react-maskedinput/index.d.ts b/react-maskedinput/index.d.ts index 3ef7333e77..6602240c67 100644 --- a/react-maskedinput/index.d.ts +++ b/react-maskedinput/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/insin/react-maskedinput // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { ComponentClass, HTMLAttributes } from "react"; diff --git a/react-mdl/index.d.ts b/react-mdl/index.d.ts index 48a38ac342..9f962d0156 100644 --- a/react-mdl/index.d.ts +++ b/react-mdl/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/tleunen/react-mdl // Definitions by: Brad Zacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-measure/index.d.ts b/react-measure/index.d.ts index 8735747bac..be96956dfd 100644 --- a/react-measure/index.d.ts +++ b/react-measure/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/souporserious/react-measure // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-measure" { import * as React from "react"; diff --git a/react-mixin/index.d.ts b/react-mixin/index.d.ts index 64bcd99869..03781e659d 100644 --- a/react-mixin/index.d.ts +++ b/react-mixin/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/brigand/react-mixin // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index 59842fe99a..e5db7d66f0 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/reactjs/react-modal // Definitions by: Rajab Shakirov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-motion-slider/index.d.ts b/react-motion-slider/index.d.ts index e6046079b7..49c8caedd7 100644 --- a/react-motion-slider/index.d.ts +++ b/react-motion-slider/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/souporserious/react-motion-slider // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-motion-slider" { import * as React from "react"; diff --git a/react-motion/index.d.ts b/react-motion/index.d.ts index 1384f6c2df..8254ad78aa 100644 --- a/react-motion/index.d.ts +++ b/react-motion/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/chenglou/react-motion // Definitions by: Stepan Mikhaylyuk , Alexey Svetliakov // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.1 import { Component, ReactElement } from 'react'; diff --git a/react-native-fs/index.d.ts b/react-native-fs/index.d.ts index 934d684a74..398657967c 100644 --- a/react-native-fs/index.d.ts +++ b/react-native-fs/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/johanneslumpe/react-native-fs // Definitions by: Paulo Cesar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-native-scrollable-tab-view/index.d.ts b/react-native-scrollable-tab-view/index.d.ts index b2d447c23c..2f22f1bcf4 100644 --- a/react-native-scrollable-tab-view/index.d.ts +++ b/react-native-scrollable-tab-view/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/brentvatne/react-native-scrollable-tab-view#readme // Definitions by: CaiHuan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import { diff --git a/react-native-sortable-list/index.d.ts b/react-native-sortable-list/index.d.ts index f0349e12e5..777f26369b 100644 --- a/react-native-sortable-list/index.d.ts +++ b/react-native-sortable-list/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gitim/react-native-sortable-list // Definitions by: Michael Sivolobov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import { ViewStyle } from 'react-native'; diff --git a/react-native-swiper/index.d.ts b/react-native-swiper/index.d.ts index f1ff914346..f41a771caf 100644 --- a/react-native-swiper/index.d.ts +++ b/react-native-swiper/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/leecade/react-native-swiper#readme // Definitions by: CaiHuan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import { diff --git a/react-native/index.d.ts b/react-native/index.d.ts index d63a339d0a..c46db449f8 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/facebook/react-native // Definitions by: Needs A Maintainer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // diff --git a/react-notification-system-redux/index.d.ts b/react-notification-system-redux/index.d.ts index da071f6142..5820a48da5 100644 --- a/react-notification-system-redux/index.d.ts +++ b/react-notification-system-redux/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gor181/react-notification-system-redux // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component } from "react"; import { Action } from "redux"; diff --git a/react-notification-system/index.d.ts b/react-notification-system/index.d.ts index 046677e8f2..fcf5f41120 100644 --- a/react-notification-system/index.d.ts +++ b/react-notification-system/index.d.ts @@ -2,6 +2,7 @@ // Project: https://www.npmjs.com/package/react-notification-system // Definitions by: Giedrius Grabauskas , Deividas Bakanas , Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-onclickoutside/index.d.ts b/react-onclickoutside/index.d.ts index 8f1192496e..98bef683ad 100644 --- a/react-onclickoutside/index.d.ts +++ b/react-onclickoutside/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Pomax/react-onclickoutside // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-overlays/index.d.ts b/react-overlays/index.d.ts index 5d132a0ecd..10b67d9d51 100644 --- a/react-overlays/index.d.ts +++ b/react-overlays/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/react-bootstrap/react-overlays // Definitions by: Aaron Beall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-paginate/index.d.ts b/react-paginate/index.d.ts index 982f2fd65b..aaa3931b74 100644 --- a/react-paginate/index.d.ts +++ b/react-paginate/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/AdeleD/react-paginate // Definitions by: Simon Hartcher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; diff --git a/react-props-decorators/index.d.ts b/react-props-decorators/index.d.ts index 96280fd86b..d577f7b175 100644 --- a/react-props-decorators/index.d.ts +++ b/react-props-decorators/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/popkirby/react-props-decorators // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-recaptcha/index.d.ts b/react-recaptcha/index.d.ts index d17ed8ef34..39cca4037c 100644 --- a/react-recaptcha/index.d.ts +++ b/react-recaptcha/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/appleboy/react-recaptcha // Definitions by: Mohamed Hegazy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component } from "react"; export = Recaptcha; diff --git a/react-redux-i18n/index.d.ts b/react-redux-i18n/index.d.ts index d7851b23dc..a8ea035511 100644 --- a/react-redux-i18n/index.d.ts +++ b/react-redux-i18n/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/zoover/react-redux-i18n // Definitions by: Clément Devos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-redux-i18n' { import * as react from "react" diff --git a/react-redux-toastr/index.d.ts b/react-redux-toastr/index.d.ts index 8853924fce..af40ec724a 100644 --- a/react-redux-toastr/index.d.ts +++ b/react-redux-toastr/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/diegoddox/react-redux-toastr // Definitions by: Aleksandar Ivanov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-redux-toastr" { import * as React from "react"; diff --git a/react-redux/index.d.ts b/react-redux/index.d.ts index 3303908a01..2d76aaac00 100644 --- a/react-redux/index.d.ts +++ b/react-redux/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rackt/react-redux // Definitions by: Qubo , Sean Kelley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import * as Redux from 'redux'; diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index 8e7a06d010..b238b53f77 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/facebook/relay // Definitions by: Johannes Schickling // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-relay" { import * as React from "react"; diff --git a/react-responsive/index.d.ts b/react-responsive/index.d.ts index 126a27f5b7..b88f33697a 100644 --- a/react-responsive/index.d.ts +++ b/react-responsive/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/contra/react-responsive // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-responsive" { import * as React from "react"; diff --git a/react-router-bootstrap/index.d.ts b/react-router-bootstrap/index.d.ts index b4b36006ec..7cf6ebaafc 100644 --- a/react-router-bootstrap/index.d.ts +++ b/react-router-bootstrap/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/react-bootstrap/react-router-bootstrap // Definitions by: Vincent Lesierse // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// /// diff --git a/react-router-redux/index.d.ts b/react-router-redux/index.d.ts index 16438f9452..62c6137a7a 100644 --- a/react-router-redux/index.d.ts +++ b/react-router-redux/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rackt/react-router-redux // Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 80b1b97154..b1a577c617 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rackt/react-router // Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-scroll/index.d.ts b/react-scroll/index.d.ts index 93e09acc2b..1f31f5f4c3 100644 --- a/react-scroll/index.d.ts +++ b/react-scroll/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/fisshy/react-scroll // Definitions by: Ioannis Kokkinidis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-scrollbar/index.d.ts b/react-scrollbar/index.d.ts index dcfc90d02e..8d5628f4a5 100644 --- a/react-scrollbar/index.d.ts +++ b/react-scrollbar/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/souhe/reactScrollbar // Definitions by: Stephen Jelfs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-select/index.d.ts b/react-select/index.d.ts index 336eb5460b..e59322d0dc 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/JedWatson/react-select // Definitions by: ESQUIBET Hugo , Gilad Gray , Izaak Baker , Tadas Dailyda , Mark Vujevits // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-side-effect/index.d.ts b/react-side-effect/index.d.ts index ed76d56af4..10f25ae1e3 100644 --- a/react-side-effect/index.d.ts +++ b/react-side-effect/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/react-side-effect // Definitions by: Remo H. Jansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import React = require("react"); diff --git a/react-slick/index.d.ts b/react-slick/index.d.ts index 9bd267cad1..07179c4daa 100644 --- a/react-slick/index.d.ts +++ b/react-slick/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/akiran/react-slick // Definitions by: Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-smooth-scrollbar/index.d.ts b/react-smooth-scrollbar/index.d.ts index df5746f9d4..6aea289136 100644 --- a/react-smooth-scrollbar/index.d.ts +++ b/react-smooth-scrollbar/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/idiotWu/react-smooth-scrollbar // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react"; import SmoothScrollbar, { ScrollbarOptions, ScrollStatusObject } from "smooth-scrollbar"; diff --git a/react-sortable-hoc/index.d.ts b/react-sortable-hoc/index.d.ts index b65bae7641..64a17f4800 100644 --- a/react-sortable-hoc/index.d.ts +++ b/react-sortable-hoc/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/clauderic/react-sortable-hoc // Definitions by: Ivo Stratev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-sortable-hoc' { import React = require('react'); diff --git a/react-spinkit/index.d.ts b/react-spinkit/index.d.ts index 13c3542af6..9a14db213a 100644 --- a/react-spinkit/index.d.ts +++ b/react-spinkit/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/KyleAMathews/react-spinkit // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-split-pane/index.d.ts b/react-split-pane/index.d.ts index 3a6bc7bc6e..cdbb05d4c1 100644 --- a/react-split-pane/index.d.ts +++ b/react-split-pane/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/tomkp/react-split-pane // Definitions by: Roger Chen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-swf/index.d.ts b/react-swf/index.d.ts index ba300908ba..c03f2748b2 100644 --- a/react-swf/index.d.ts +++ b/react-swf/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/syranide/react-swf // Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; export as namespace ReactSWF; diff --git a/react-swipeable-views/index.d.ts b/react-swipeable-views/index.d.ts index 745ebb4582..91b0cfa45b 100644 --- a/react-swipeable-views/index.d.ts +++ b/react-swipeable-views/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/oliviertassinari/react-swipeable-views // Definitions by: Michael Ledin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-swipeable/index.d.ts b/react-swipeable/index.d.ts index 52d0e9c178..fadf0f057f 100644 --- a/react-swipeable/index.d.ts +++ b/react-swipeable/index.d.ts @@ -2,6 +2,7 @@ // Project: https://www.npmjs.com/package/react-swipeable // Definitions by: Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-syntax-highlighter/index.d.ts b/react-syntax-highlighter/index.d.ts index 35019a7b7e..57d81c9d6d 100644 --- a/react-syntax-highlighter/index.d.ts +++ b/react-syntax-highlighter/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/conorhastings/react-syntax-highlighter // Definitions by: Ivo Stratev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-syntax-highlighter' { import SyntaxHighlighter from 'react-syntax-highlighter/dist/light'; diff --git a/react-tabs/index.d.ts b/react-tabs/index.d.ts index ebb5ae644b..9e8abce3cb 100644 --- a/react-tabs/index.d.ts +++ b/react-tabs/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/reactjs/react-tabs/ // Definitions by: Yuu Igarashi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react-tagcloud/index.d.ts b/react-tagcloud/index.d.ts index 9759e99094..c1e8990bf6 100644 --- a/react-tagcloud/index.d.ts +++ b/react-tagcloud/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/madox2/react-tagcloud // Definitions by: wassname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-test-renderer/index.d.ts b/react-test-renderer/index.d.ts index e3c27a057a..9908394888 100644 --- a/react-test-renderer/index.d.ts +++ b/react-test-renderer/index.d.ts @@ -2,6 +2,7 @@ // Project: https://facebook.github.io/react/ // Definitions by: Arvitaly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { ReactElement } from "react"; diff --git a/react-textarea-autosize/index.d.ts b/react-textarea-autosize/index.d.ts index ebf589f873..647d19c6ac 100644 --- a/react-textarea-autosize/index.d.ts +++ b/react-textarea-autosize/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/andreypopp/react-textarea-autosize // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "react-textarea-autosize" { import * as React from "react"; diff --git a/react-toggle/index.d.ts b/react-toggle/index.d.ts index af00deac09..29b3a547fd 100644 --- a/react-toggle/index.d.ts +++ b/react-toggle/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/aaronshaf/react-toggle // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import { Component, HTMLAttributes, ReactNode } from "react"; diff --git a/react-user-tour/index.d.ts b/react-user-tour/index.d.ts index f1a0de4d46..2753a6f8b6 100644 --- a/react-user-tour/index.d.ts +++ b/react-user-tour/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/socialtables/react-user-tour // Definitions by: Carlo Cancellieri // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-virtualized/index.d.ts b/react-virtualized/index.d.ts index cff271ae5f..963af32a27 100644 --- a/react-virtualized/index.d.ts +++ b/react-virtualized/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/bvaughn/react-virtualized // Definitions by: Andrew de Waal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/react-widgets/index.d.ts b/react-widgets/index.d.ts index 04b63d8a95..9db30eb706 100644 --- a/react-widgets/index.d.ts +++ b/react-widgets/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jquense/react-widgets // Definitions by: Rogier Schouten // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; diff --git a/react/README.md b/react/README.md index 7d2b3d80ab..c09dc060c2 100644 --- a/react/README.md +++ b/react/README.md @@ -1,8 +1,31 @@ ## Known Problems & Workarounds -### **The type of `setState` is incorrect.** -The `setState(state)` method on `React.Component` takes an object with a subset of the properties on `S`, but there's no way to express this in TypeScript currently. The workaround is simple: make all properties on `S` optional. There are a number of [proposals](https://github.com/Microsoft/TypeScript/issues/2710) on [ways](https://github.com/Microsoft/TypeScript/issues/4889) to [solve](https://github.com/Microsoft/TypeScript/issues/7355) this problem, but nothing seems to have been approved yet. +### **The type of `setState` is will be overly strict prior to TS 2.1.5** +Starting with TypeScript 2.1, its more correct than it used to be, with a caveat: optional parameters on state interfaces are no longer valid. This issue is corrected in 2.1.5 (and beyond) and thus `Pick` becomes ideal. +```ts +interface FooState { + bar: string; + foo?: string; +} + +const defaultFooState: FooState = { + bar: "Hi", + foo: undefined, +}; + +class Foo extends React.Component<{}, FooState> { + public doStuff() { + this.setState(defaultFooState); + } +} +``` + +Prior to 2.1.5, this code will produce an error. The other way the types could be written (using `Partial<>` instead of `Pick<>`) would allow for you to set `undefined` to a parameter that is not allowed +to be `undefined`, which could lead to bugs. Users who want to keep optional state parameters should continue to use the hack of `setState({...} as any);` in versions prior to 2.1.5. + +(This caveat should be dropped after no later than March 2017, maybe sooner.) + ### **The type of `cloneElement` is incorrect.** This is similar to the `setState` problem, in that `cloneElement(element, props)` should should accept a `props` object with a subset of the properties on `element.props`. There is an additional complication, however—React attributes, such as `key` and `ref`, should also be accepted in `props`, but should not exist on `element.props`. The "correct" way to model this, then, is with ```ts diff --git a/react/index.d.ts b/react/index.d.ts index 9972f80998..a840e4b64d 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2,6 +2,7 @@ // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 export = React; export as namespace React; @@ -165,8 +166,8 @@ declare namespace React { class Component implements ComponentLifecycle { constructor(props?: P, context?: any); constructor(...args: any[]); - setState(f: (prevState: S, props: P) => S, callback?: () => any): void; - setState(state: S, callback?: () => any): void; + setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void; + setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; render(): JSX.Element | null; @@ -175,8 +176,8 @@ declare namespace React { // always pass children as variadic arguments to `createElement`. // In the future, if we can define its call signature conditionally // on the existence of `children` in `P`, then we should remove this. - props: { children?: ReactNode } & P; - state: S; + props: Readonly<{ children?: ReactNode }> & Readonly

; + state: Readonly; context: any; refs: { [key: string]: ReactInstance diff --git a/reactcss/index.d.ts b/reactcss/index.d.ts index 19faf7e9fa..2d571674f7 100644 --- a/reactcss/index.d.ts +++ b/reactcss/index.d.ts @@ -2,6 +2,7 @@ // Project: http://reactcss.com/ // Definitions by: Karol Janyst // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from "react" diff --git a/rebass/index.d.ts b/rebass/index.d.ts index 17708ae115..ae37b9fa2a 100644 --- a/rebass/index.d.ts +++ b/rebass/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/jxnblk/rebass // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/recompose/index.d.ts b/recompose/index.d.ts index 5668d773d5..e72302415f 100644 --- a/recompose/index.d.ts +++ b/recompose/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/redux-bootstrap/index.d.ts b/redux-bootstrap/index.d.ts index 6a539853b7..171cf4d764 100644 --- a/redux-bootstrap/index.d.ts +++ b/redux-bootstrap/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/remojansen/redux-bootstrap // Definitions by: Remo H. Jansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module "redux-bootstrap" { import * as Redux from "redux"; diff --git a/redux-devtools-dock-monitor/index.d.ts b/redux-devtools-dock-monitor/index.d.ts index c1f8743292..de90f9a36e 100644 --- a/redux-devtools-dock-monitor/index.d.ts +++ b/redux-devtools-dock-monitor/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/redux-devtools-dock-monitor // Definitions by: Petryshyn Sergii // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/redux-devtools-log-monitor/index.d.ts b/redux-devtools-log-monitor/index.d.ts index cc6f8cc7df..32062607c2 100644 --- a/redux-devtools-log-monitor/index.d.ts +++ b/redux-devtools-log-monitor/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/redux-devtools-log-monitor // Definitions by: Petryshyn Sergii // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react' import {ColorScheme} from 'base16' diff --git a/redux-devtools/index.d.ts b/redux-devtools/index.d.ts index 28a551313f..f94239ff2e 100644 --- a/redux-devtools/index.d.ts +++ b/redux-devtools/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/gaearon/redux-devtools // Definitions by: Petryshyn Sergii // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import { GenericStoreEnhancer } from 'redux'; diff --git a/redux-form/v4/index.d.ts b/redux-form/v4/index.d.ts index 77a3004710..fa4cd9dbaa 100644 --- a/redux-form/v4/index.d.ts +++ b/redux-form/v4/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/erikras/redux-form // Definitions by: Daniel Lytkin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import { Component, SyntheticEvent, FormEventHandler } from 'react'; diff --git a/redux-router/index.d.ts b/redux-router/index.d.ts index 144f53c048..0c0f0ff29b 100644 --- a/redux-router/index.d.ts +++ b/redux-router/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rackt/redux-router // Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as React from 'react'; import * as ReactRouter from 'react-router'; diff --git a/spectacle/index.d.ts b/spectacle/index.d.ts index 55227fbb2c..41095a5839 100644 --- a/spectacle/index.d.ts +++ b/spectacle/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/FormidableLabs/victory // Definitions by: Zachary Maybury // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/victory/index.d.ts b/victory/index.d.ts index 9be6990469..70d1ecb6f1 100644 --- a/victory/index.d.ts +++ b/victory/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/FormidableLabs/victory // Definitions by: Alexey Svetliakov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// diff --git a/why-did-you-update/index.d.ts b/why-did-you-update/index.d.ts index 09b2754438..4cd4567223 100644 --- a/why-did-you-update/index.d.ts +++ b/why-did-you-update/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/garbles/why-did-you-update // Definitions by: rhysd // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// From ef8a64d27c4036fe9e1103736aaedd5890aa347d Mon Sep 17 00:00:00 2001 From: Oleg Solomka Date: Mon, 23 Jan 2017 16:14:41 -0600 Subject: [PATCH 091/248] rename `createBrowserHistory` to `createHistory ` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `createBrowserHistory ` was only introduced in the `history@4.0.0-1` prior to that the `createHistory` was used. So if you will install `@types/history@^2.0.0` and `history@^2.0.0`(or even `^3.x.x`) it will break with the next error: ``` ./src/client/history.ts (1,10): error TS2305: Module ‘”/@types/history/index"' has no exported member 'createHistory'. ``` This commit brings the `createHistory` back thus solves the issue for `history@^2.x.x` and `history@^3.x.x`. --- history/v2/history-tests.ts | 20 ++++++++++---------- history/v2/index.d.ts | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/history/v2/history-tests.ts b/history/v2/history-tests.ts index 454b223e09..598d934e8d 100644 --- a/history/v2/history-tests.ts +++ b/history/v2/history-tests.ts @@ -1,4 +1,4 @@ -import { createBrowserHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' +import { createHistory, createLocation, useBasename, useBeforeUnload, useQueries } from 'history' import { getUserConfirmation } from 'history/lib/DOMUtils' @@ -10,7 +10,7 @@ let doSomethingAsync: () => Promise; let input = { value: "" }; { - let history = createBrowserHistory() + let history = createHistory() // Listen for changes to the current location. The // listener is called once immediately. @@ -46,7 +46,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() // Pushing a path string. history.push('/the/path') @@ -63,7 +63,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory() + let history = createHistory() history.listenBefore(function(location) { if (input.value !== '') return 'Are you sure you want to leave this page?' @@ -75,7 +75,7 @@ let input = { value: "" }; } { - let history = createBrowserHistory({ + let history = createHistory({ getUserConfirmation(message, callback) { callback(window.confirm(message)) // The default behavior } @@ -83,7 +83,7 @@ let input = { value: "" }; } { - let history = useBeforeUnload(createBrowserHistory)() + let history = useBeforeUnload(createHistory)() history.listenBeforeUnload(function() { return 'Are you sure you want to leave this page?' @@ -91,7 +91,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)() + let history = useQueries(createHistory)() history.listen(function(location) { console.log(location.query) @@ -99,7 +99,7 @@ let input = { value: "" }; } { - let history = useQueries(createBrowserHistory)({ + let history = useQueries(createHistory)({ parseQueryString: function(queryString) { // TODO: return a parsed version of queryString return {}; @@ -116,7 +116,7 @@ let input = { value: "" }; { // Run our app under the /base URL. - let history = useBasename(createBrowserHistory)({ + let history = useBasename(createHistory)({ basename: '/base' }) @@ -128,4 +128,4 @@ let input = { value: "" }; history.createPath('/the/path') // /base/the/path history.push('/the/path') // push /base/the/path -} \ No newline at end of file +} diff --git a/history/v2/index.d.ts b/history/v2/index.d.ts index 5f719c2f0b..6b61fa1b77 100644 --- a/history/v2/index.d.ts +++ b/history/v2/index.d.ts @@ -127,7 +127,7 @@ export interface Module { }; } -export { default as createBrowserHistory } from "./lib/createBrowserHistory"; +export { default as createHistory } from "./lib/createBrowserHistory"; export { default as createHashHistory } from "./lib/createHashHistory"; export { default as createMemoryHistory } from "./lib/createMemoryHistory"; export { default as createLocation } from "./lib/createLocation"; From 1f4489bff8ff00fbc82e2c4f92c51a458830e1f7 Mon Sep 17 00:00:00 2001 From: Craig Nishina Date: Thu, 19 Jan 2017 12:00:10 -0800 Subject: [PATCH 092/248] types(jasminewd): add new typings for jasminewd --- jasminewd2/index.d.ts | 73 +++++++++++++++++++ jasminewd2/jasminewd2-tests.ts | 123 +++++++++++++++++++++++++++++++++ jasminewd2/tsconfig.json | 20 ++++++ jasminewd2/tslint.json | 6 ++ 4 files changed, 222 insertions(+) create mode 100644 jasminewd2/index.d.ts create mode 100644 jasminewd2/jasminewd2-tests.ts create mode 100644 jasminewd2/tsconfig.json create mode 100644 jasminewd2/tslint.json diff --git a/jasminewd2/index.d.ts b/jasminewd2/index.d.ts new file mode 100644 index 0000000000..cff5236b50 --- /dev/null +++ b/jasminewd2/index.d.ts @@ -0,0 +1,73 @@ +// Type definitions for jasminewd2 2.0 +// Project: https://github.com/angular/jasminewd +// Definitions by: Sammy Jelin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function it(expectation: string, assertion?: () => Promise, timeout?: number): void; +declare function fit(expectation: string, assertion?: () => Promise, timeout?: number): void; +declare function xit(expectation: string, assertion?: () => Promise, timeout?: number): void; +declare function beforeEach(action: () => Promise, timeout?: number): void; +declare function afterEach(action: () => Promise, timeout?: number): void; +declare function beforeAll(action: () => Promise, timeout?: number): void; +declare function afterAll(action: () => Promise, timeout?: number): void; + +declare namespace jasmine { + // The global `Promise` type is too strict and kinda wrong + interface Promise { + then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; + } + + interface Matchers { + toBe(expected: any, expectationFailOutput?: any): Promise; + toEqual(expected: any, expectationFailOutput?: any): Promise; + toMatch(expected: string | RegExp | Promise, expectationFailOutput?: any): Promise; + toBeDefined(expectationFailOutput?: any): Promise; + toBeUndefined(expectationFailOutput?: any): Promise; + toBeNull(expectationFailOutput?: any): Promise; + toBeNaN(): Promise; + toBeTruthy(expectationFailOutput?: any): Promise; + toBeFalsy(expectationFailOutput?: any): Promise; + toHaveBeenCalled(): Promise; + toHaveBeenCalledWith(...params: any[]): Promise; + toHaveBeenCalledTimes(expected: number | Promise): Promise; + toContain(expected: any, expectationFailOutput?: any): Promise; + toBeLessThan(expected: number | Promise, expectationFailOutput?: any): Promise; + toBeLessThanOrEqual(expected: number | Promise, expectationFailOutput?: any): Promise; + toBeGreaterThan(expected: number | Promise, expectationFailOutput?: any): Promise; + toBeGreaterThanOrEqual(expected: number | Promise, expectationFailOutput?: any): Promise; + toBeCloseTo(expected: number | Promise, precision?: any, expectationFailOutput?: any): Promise; + toThrow(expected?: any): Promise; + toThrowError(message?: string | RegExp | Promise): Promise; + toThrowError(expected?: new (...args: any[]) => Error | Promise Error>, message?: string | RegExp | Promise): Promise; + } + + function addMatchers(matchers: AsyncCustomMatcherFactories): void; + + interface Env { + addMatchers(matchers: AsyncCustomMatcherFactories): void; + } + + interface Spec { + addMatchers(matchers: AsyncCustomMatcherFactories): void; + } + + interface AsyncCustomMatcherFactories { + [index: string]: AsyncCustomMatcherFactory; + } + + interface AsyncCustomMatcherFactory { + (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher; + } + + interface AsyncCustomMatcher { + compare(actual: T, expected: T): AsyncCustomMatcherResult; + compare(actual: any, expected: any): AsyncCustomMatcherResult; + } + + interface AsyncCustomMatcherResult { + pass: boolean | Promise; + message?: string; + } +} diff --git a/jasminewd2/jasminewd2-tests.ts b/jasminewd2/jasminewd2-tests.ts new file mode 100644 index 0000000000..c6612ae422 --- /dev/null +++ b/jasminewd2/jasminewd2-tests.ts @@ -0,0 +1,123 @@ +let promise = new Promise((resolve, reject) => { + resolve(); +}); + +describe('jasminewd', () => { + describe('global it, fit, xit, before and after', () => { + it('should be able to return promises', () => { + return promise; + }); + + fit('should be able to return promises', () => { + return promise; + }); + + xit('should be able to return promises', () => { + return promise; + }); + + beforeEach(() => { + return promise; + }); + + afterEach(() => { + return promise; + }); + + beforeAll(() => { + return promise; + }); + + afterAll(() => { + return promise; + }); + }); + + describe('matchers', () => { + it('should work', () => { + let expectedAny: any; + let expectationFailOutputAny: any; + let expectedString: string; + let expectedNumber: number; + let expectedRegExp: RegExp; + let expectedPromiseString: Promise; + let expectedPromiseNumber: Promise; + let expectedPromiseRegExp: Promise; + let paramsAny: any[]; + let error: Error; + let errorPromise: Promise; + + expect(expectedAny).toBe(expectationFailOutputAny); + expect(expectedAny).toEqual(expectationFailOutputAny); + expect(expectedString).toMatch(expectationFailOutputAny); + expect(expectedRegExp).toMatch(expectationFailOutputAny); + expect(expectedPromiseString).toMatch(expectationFailOutputAny); + expect(expectedPromiseRegExp).toMatch(expectationFailOutputAny); + expect(expectationFailOutputAny).toBeDefined(); + expect(expectationFailOutputAny).toBeUndefined(); + expect(expectationFailOutputAny).toBeNull(); + expect(expectedAny).toBeNaN(); + expect(expectedAny).toBeTruthy(); + expect(expectedAny).toBeFalsy(); + expect(expectedAny).toHaveBeenCalled(); + expect(expectedAny).toHaveBeenCalledWith(paramsAny); + expect(expectedAny).toHaveBeenCalledTimes(expectedNumber); + expect(expectedAny).toHaveBeenCalledTimes(expectedPromiseNumber); + expect(expectedAny).toContain(expectationFailOutputAny); + expect(expectedNumber).toBeLessThan(expectedNumber); + expect(expectedNumber).toBeLessThan(expectedPromiseNumber); + expect(expectedNumber).toBeLessThanOrEqual(expectedNumber); + expect(expectedNumber).toBeLessThanOrEqual(expectedPromiseNumber); + expect(expectedNumber).toBeGreaterThan(expectedNumber); + expect(expectedNumber).toBeGreaterThan(expectedPromiseNumber); + expect(expectedNumber).toBeGreaterThanOrEqual(expectedNumber); + expect(expectedNumber).toBeGreaterThanOrEqual(expectedPromiseNumber); + expect(expectedNumber).toBeCloseTo(expectedNumber, expectedNumber); + expect(expectedPromiseNumber).toBeCloseTo(expectationFailOutputAny, expectedNumber); + expect(expectedAny).toThrow(expectationFailOutputAny); + expect(expectedAny).toThrowError(expectedString); + expect(expectedAny).toThrowError(expectedRegExp); + expect(expectedAny).toThrowError(expectedPromiseString); + expect(expectedAny).toThrowError(expectedPromiseRegExp); + expect(error).toThrowError(expectedString); + expect(error).toThrowError(expectedRegExp); + expect(error).toThrowError(expectedPromiseString); + expect(error).toThrowError(expectedPromiseRegExp); + expect(error).toThrowError(expectedString); + expect(errorPromise).toThrowError(expectedString); + expect(errorPromise).toThrowError(expectedRegExp); + expect(errorPromise).toThrowError(expectedPromiseString); + expect(errorPromise).toThrowError(expectedPromiseRegExp); + expect(errorPromise).toThrowError(expectedString); + }); + }); + + describe('jasmine matchers', () => { + it('should be able to add matchers', () => { + let matchers = { + toBeLotsMoreThan: function() { + return { + compare: function(actual: number, expected: number) { + return { + pass: actual > expected + 100 + }; + } + }; + }, + // Example custom matcher returning a promise that resolves to true/false. + toBeDisplayed: function() { + return { + compare: function(actual: any, expected: void) { + return { + pass: (actual.isDisplayed() as Promise) + }; + } + }; + } + }; + jasmine.addMatchers(matchers); + jasmine.getEnv().addMatchers(matchers); + jasmine.getEnv().currentSpec.addMatchers(matchers); + }); + }); +}); diff --git a/jasminewd2/tsconfig.json b/jasminewd2/tsconfig.json new file mode 100644 index 0000000000..81aa80fe8e --- /dev/null +++ b/jasminewd2/tsconfig.json @@ -0,0 +1,20 @@ +{ + "files": [ + "index.d.ts", + "jasminewd2-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ "es6" ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/jasminewd2/tslint.json b/jasminewd2/tslint.json new file mode 100644 index 0000000000..9ca86427bd --- /dev/null +++ b/jasminewd2/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "callable-types": false + } +} From 4a2ed872c1f2228bc8d76b4007fe42484c500031 Mon Sep 17 00:00:00 2001 From: YYC <395976266@qq.com> Date: Tue, 24 Jan 2017 07:45:49 +0800 Subject: [PATCH 093/248] fix: cannon add version (#14201) * fix: cannon add version * fix: fix version --- cannon/index.d.ts | 2 +- wonder-commonlib/index.d.ts | 2 +- wonder-frp/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cannon/index.d.ts b/cannon/index.d.ts index 6551e07b32..45e005d53d 100644 --- a/cannon/index.d.ts +++ b/cannon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cannon +// Type definitions for cannon 0.1 // Project: https://github.com/clark-stevenson/cannon.d.ts // Definitions by: Clark Stevenson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/wonder-commonlib/index.d.ts b/wonder-commonlib/index.d.ts index 3421de0125..464b6ada4e 100644 --- a/wonder-commonlib/index.d.ts +++ b/wonder-commonlib/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wonder-commonlib v0.1.0 +// Type definitions for wonder-commonlib 0.1 // Project: https://github.com/yyc-git/Wonder-CommonLib // Definitions by: YYC // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/wonder-frp/index.d.ts b/wonder-frp/index.d.ts index c5e69d2dd9..c7459d6690 100644 --- a/wonder-frp/index.d.ts +++ b/wonder-frp/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for wonder-frp v0.1.0 +// Type definitions for wonder-frp 0.1 // Project: https://github.com/yyc-git/Wonder-FRP // Definitions by: YYC // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 1001a8eae92aff3d95aee7082459a36a51f2ca45 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 23 Jan 2017 19:33:00 -0500 Subject: [PATCH 094/248] Revert 80e4d8b/#11612. Fixes #14176 --- react/index.d.ts | 1 - react/test/index.ts | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index a840e4b64d..4a19ec723c 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -165,7 +165,6 @@ declare namespace React { // Base component for plain JS classes class Component implements ComponentLifecycle { constructor(props?: P, context?: any); - constructor(...args: any[]); setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void; setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; diff --git a/react/test/index.ts b/react/test/index.ts index 0900926cf6..b575055514 100644 --- a/react/test/index.ts +++ b/react/test/index.ts @@ -659,20 +659,6 @@ React.createFactory(TransitionGroup)({ component: "div" }); let newObjShallow = update(obj, { $merge: { b: 6, c: 7 } }); // => {a: 5, b: 6, c: 7} } -// -// React Component classes super spread arguments -// -------------------------------------------------------------------------- -class ConstructorSpreadArgsComponent extends React.Component<{}, {}> { - constructor(...args: any[]) { - super(...args); - } -} -class ConstructorSpreadArgsPureComponent extends React.PureComponent<{}, {}> { - constructor(...args: any[]) { - super(...args); - } -} - // // The SyntheticEvent.target.value should be accessible for onChange // -------------------------------------------------------------------------- From 99d41f818c2de87790ce1f02956cbc39bce40f40 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 23 Jan 2017 17:22:52 -0800 Subject: [PATCH 095/248] Add UMD namespace declaration to 'roslib'. (#14203) --- roslib/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/roslib/index.d.ts b/roslib/index.d.ts index fbb6deff6e..c195387901 100644 --- a/roslib/index.d.ts +++ b/roslib/index.d.ts @@ -11,6 +11,7 @@ ---------------------------------- */ export = ROSLIB; +export as namespace ROSLIB; declare namespace ROSLIB { export class Ros { From 59b9f7939c60302143d6d499392260a09315e46c Mon Sep 17 00:00:00 2001 From: Eiji Kitamura Date: Tue, 24 Jan 2017 10:23:47 +0900 Subject: [PATCH 096/248] [paymentrequest] Added `target: "es6"` --- paymentrequest/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/paymentrequest/tsconfig.json b/paymentrequest/tsconfig.json index 221e0618af..e5754a139a 100644 --- a/paymentrequest/tsconfig.json +++ b/paymentrequest/tsconfig.json @@ -5,6 +5,7 @@ "es6", "dom" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, From 24c9f897f0f17c9cdcdf11184a25c33ee94aac3a Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 23 Jan 2017 22:08:03 -0500 Subject: [PATCH 097/248] Fix react-router-redux v3 --- react-router-redux/v3/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-router-redux/v3/index.d.ts b/react-router-redux/v3/index.d.ts index 83c9313e1e..e0b3a62698 100644 --- a/react-router-redux/v3/index.d.ts +++ b/react-router-redux/v3/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/rackt/react-router-redux // Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 import * as Redux from "redux"; import * as History from "history"; From 12b8c9de5fd892dff77280988b7d40c542675b4f Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 23 Jan 2017 22:17:24 -0500 Subject: [PATCH 098/248] Try adding a package for redux --- react-router-redux/v3/package.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 react-router-redux/v3/package.json diff --git a/react-router-redux/v3/package.json b/react-router-redux/v3/package.json new file mode 100644 index 0000000000..36ce503807 --- /dev/null +++ b/react-router-redux/v3/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "redux": "^3.6.0" + } +} From 7e3ebd00f0ece65fc556713c5fad39c7253d7a90 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Mon, 23 Jan 2017 19:58:07 -0800 Subject: [PATCH 099/248] raw-body: conditional return type based on options --- raw-body/index.d.ts | 21 ++++++++++++--------- raw-body/raw-body-tests.ts | 6 +++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/raw-body/index.d.ts b/raw-body/index.d.ts index a99f2c51c2..94131c5764 100644 --- a/raw-body/index.d.ts +++ b/raw-body/index.d.ts @@ -4,13 +4,16 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// + import { Readable } from "stream"; declare namespace getRawBody { + export type Encoding = string | true; + export interface Options { length?: number; limit?: number; - encoding?: string; + encoding?: Encoding; } export interface RawBodyError extends Error { @@ -19,18 +22,18 @@ declare namespace getRawBody { expected?: number; received?: number; encoding?: string; - status?: number; - statusCode?: number; - type?: string; + status: number; + statusCode: number; + type: string; } - - export type Callback = (err: RawBodyError, res: string | Buffer) => void; } -declare function getRawBody(stream: Readable, callback: getRawBody.Callback): void; -declare function getRawBody(stream: Readable, options: getRawBody.Options | string, callback: getRawBody.Callback): void; +declare function getRawBody(stream: Readable, callback: (err: getRawBody.RawBodyError, body: Buffer) => void): void; +declare function getRawBody(stream: Readable, options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding, callback: (err: getRawBody.RawBodyError, body: string) => void): void; +declare function getRawBody(stream: Readable, options: getRawBody.Options, callback: (err: getRawBody.RawBodyError, body: Buffer) => void): void; -declare function getRawBody(stream: Readable, options?: getRawBody.Options | string): Promise; +declare function getRawBody(stream: Readable, options: (getRawBody.Options & { encoding: getRawBody.Encoding }) | getRawBody.Encoding): Promise; +declare function getRawBody(stream: Readable, options?: getRawBody.Options): Promise; export = getRawBody; diff --git a/raw-body/raw-body-tests.ts b/raw-body/raw-body-tests.ts index f23160c876..ad6065537d 100644 --- a/raw-body/raw-body-tests.ts +++ b/raw-body/raw-body-tests.ts @@ -2,11 +2,11 @@ import getRawBody = require("raw-body"); const stream: any = {}; -const simple = getRawBody(stream); +const simple: Promise = getRawBody(stream); -const withEncoding = getRawBody(stream, "utf-8"); +const withEncoding: Promise = getRawBody(stream, "utf-8"); -const withOptions = getRawBody(stream, { +const withOptions: Promise = getRawBody(stream, { encoding: "utf-8", length: 1024, limit: 512 From 928c0be342b96390221e1cc69d8c85031f945704 Mon Sep 17 00:00:00 2001 From: Fredrik Nicol Date: Sat, 21 Jan 2017 11:58:33 +0100 Subject: [PATCH 100/248] Add constructor arguments in `ClassType` --- react/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index a840e4b64d..bfc41b609a 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -230,8 +230,8 @@ declare namespace React { */ type ClassType, C extends ComponentClass

> = C & - (new () => T) & - (new () => { props: P }); + (new (props?: P, context?: any) => T) & + (new (props?: P, context?: any) => { props: P }); // // Component Specs and Lifecycle From 8829f99d006174525b8e4d00f7720722690cbda5 Mon Sep 17 00:00:00 2001 From: Steven Liekens Date: Tue, 24 Jan 2017 10:43:42 +0100 Subject: [PATCH 101/248] Mark optional properties as such --- jquery.datatables/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.datatables/index.d.ts b/jquery.datatables/index.d.ts index c7c4bd8682..5d1bbd50c9 100644 --- a/jquery.datatables/index.d.ts +++ b/jquery.datatables/index.d.ts @@ -908,7 +908,7 @@ declare namespace DataTables { * @param d Data to use for the row. */ data(d: any[] | Object): DataTable; - + /** * Get the id of the selected row. Since: 1.10.8 @@ -1456,9 +1456,9 @@ declare namespace DataTables { } export interface AjaxData { - draw: number; - recordsTotal: number; - recordsFiltered: number; + draw?: number; + recordsTotal?: number; + recordsFiltered?: number; data: any; error?: string; } From 0e50ed4cc33b26a7f3396cd61ed6e6d4ad9206ec Mon Sep 17 00:00:00 2001 From: Takenaka Simon Date: Tue, 24 Jan 2017 20:13:02 +0900 Subject: [PATCH 102/248] [storejs] Add forEach to type defintion --- storejs/index.d.ts | 3 ++- storejs/storejs-tests.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/storejs/index.d.ts b/storejs/index.d.ts index ad5d8e979c..0068d94722 100644 --- a/storejs/index.d.ts +++ b/storejs/index.d.ts @@ -16,10 +16,11 @@ interface StoreJSStatic { getAll(): any; serialize(value: any): string; deserialize(value: string): any; + forEach(command: (key: string, value: any) => void): void; } declare var store: StoreJSStatic; declare module 'store' { - export = store; + export = store; } diff --git a/storejs/storejs-tests.ts b/storejs/storejs-tests.ts index 19e0ae898b..13c937c3c9 100644 --- a/storejs/storejs-tests.ts +++ b/storejs/storejs-tests.ts @@ -5,7 +5,7 @@ import * as store from 'store'; store.set('username', 'marcus'); // Get 'username' -var userName:any = store.get('username'); +var userName: any = store.get('username'); var all: Object = store.getAll(); @@ -22,3 +22,10 @@ store.set('user', { name: 'marcus', likes: 'javascript' }); var user: any = store.get('user'); alert(user.name + ' likes ' + user.likes); +// Get all stored values +store.getAll().user.name; + +// Loop over all stored values +store.forEach(function(key, val) { + console.log(key, '==', val); +}); From 35c3b91e095b7a5aa4cfd6d51e9bfbbda3b5a3b6 Mon Sep 17 00:00:00 2001 From: a8775 Date: Tue, 24 Jan 2017 14:48:02 +0100 Subject: [PATCH 103/248] detailing declaration for dgram socket.close () --- node/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/index.d.ts b/node/index.d.ts index 6e4fbce84e..93c0d7c709 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -2124,7 +2124,7 @@ declare module "dgram" { send(msg: Buffer | String | any[], offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; bind(port?: number, address?: string, callback?: () => void): void; bind(options: BindOptions, callback?: Function): void; - close(callback?: any): void; + close(callback?: () => void): void; address(): AddressInfo; setBroadcast(flag: boolean): void; setTTL(ttl: number): void; From f0cbff79a4ed0b58d50b5a6475726cf02d2cc6a7 Mon Sep 17 00:00:00 2001 From: Peter Keuter Date: Tue, 24 Jan 2017 15:17:08 +0100 Subject: [PATCH 104/248] importDocument declaration --- xmlbuilder/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/xmlbuilder/index.d.ts b/xmlbuilder/index.d.ts index 4367a7fb10..20dabf97ca 100644 --- a/xmlbuilder/index.d.ts +++ b/xmlbuilder/index.d.ts @@ -62,6 +62,7 @@ declare class XMLElementOrXMLNode { declaration(version: string, encoding: string, standalone: boolean): XMLElementOrXMLNode; doctype(pubID: string, sysID: string): XMLDocType; up(): XMLElementOrXMLNode; + importDocument(input: XMLElementOrXMLNode): XMLElementOrXMLNode; root(): XMLElementOrXMLNode; document(): any; end(options?: Object): string; From 6d81c90395104ca52bfd30e3574bd13f4b39861a Mon Sep 17 00:00:00 2001 From: denis Date: Tue, 24 Jan 2017 15:18:31 +0100 Subject: [PATCH 105/248] MetisMenu: add missing types for 2.6.1 Add events types, preventDefault properties, and 'dispose' option. --- metismenu/index.d.ts | 8 ++++++-- metismenu/metismenu-tests.ts | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/metismenu/index.d.ts b/metismenu/index.d.ts index 43faa279c7..1816090f87 100644 --- a/metismenu/index.d.ts +++ b/metismenu/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for metisMenu 2.0.3 +// Type definitions for metisMenu 2.6.1 // Project: http://github.com/onokumus/metisMenu // Definitions by: onokums // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,8 +12,12 @@ interface MetisMenuOptions { collapseClass?: string; collapseInClass?: string; collapsingClass?: string; + preventDefault?: boolean; } +type MetisMenuEvents = "show.metisMenu" | "shown.metisMenu" | "hide.metisMenu" | "hidden.metisMenu"; + interface JQuery { - metisMenu(options?: MetisMenuOptions): JQuery; + metisMenu(options?: MetisMenuOptions | "dispose"): JQuery; + on(events: MetisMenuEvents, handler: (eventObject: JQueryEventObject) => any): JQuery; } diff --git a/metismenu/metismenu-tests.ts b/metismenu/metismenu-tests.ts index b2e36f1d53..625a4877ab 100644 --- a/metismenu/metismenu-tests.ts +++ b/metismenu/metismenu-tests.ts @@ -1,12 +1,29 @@ /// $('#menu').metisMenu(); + $('.metismenu').metisMenu({toggle: false}); + $('.test').metisMenu({ toggle: false, doubleTapToGo: true, activeClass: 'active', collapseClass: 'collapse', collapseInClass: 'in', - collapsingClass: 'collapsing' + collapsingClass: 'collapsing', + preventDefault: true }); + +$('.metismenu').metisMenu('dispose'); + +$('.metismenu') + .metisMenu() + .on('show.metisMenu', function(e) { + // empty logic + }).on('shown.metisMenu', function(e) { + // empty logic + }).on('hide.metisMenu', function(e) { + // empty logic + }).on('hidden.metisMenu', function(e) { + // empty logic + }); From 2c380af908a2e6261078153598170b1fd84bd39f Mon Sep 17 00:00:00 2001 From: Sergei Dorogin Date: Tue, 24 Jan 2017 17:44:31 +0300 Subject: [PATCH 106/248] jquery.fileupload added `add` callback signature (was `any`) changed `fail` callback signature (JQueryFileInputOptions => JQueryFileUploadDone) added JQueryFileUploadXhr.errorThrown field --- jquery.fileupload/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.fileupload/index.d.ts b/jquery.fileupload/index.d.ts index 54ebb89c5c..e113d2733c 100644 --- a/jquery.fileupload/index.d.ts +++ b/jquery.fileupload/index.d.ts @@ -198,7 +198,7 @@ interface JQueryFileInputOptions { * handlers using jQuery's Deferred callbacks: * data.submit().done(func).fail(func).always(func); */ - add?: any; + add?: (e: JQueryEventObject, data: JQueryFileInputOptions) => void; // The plugin options are used as settings object for the ajax calls. // The following are jQuery ajax settings required for the file uploads: @@ -228,7 +228,7 @@ interface JQueryFileInputOptions { // Other callbacks: submit?: Function; done?: (e: JQueryEventObject, data: JQueryFileUploadDone) => void; - fail?: (e: JQueryEventObject, data: JQueryFileInputOptions) => void; + fail?: (e: JQueryEventObject, data: JQueryFileUploadDone) => void; always?: (e: JQueryEventObject, data: JQueryFileInputOptions) => void; progressall?: (e: JQueryEventObject, data: JQueryFileUploadProgressAllObject) => void; start?: (e: JQueryEventObject) => void; @@ -284,6 +284,7 @@ interface JQueryFileUploadXhr { jqXHR: JQueryXHR; result: any; textStatus: string; + errorThrown: any; headers: {[key: string]: any}; } From 940a72926dd0b003374e1deb425652aa8e04744c Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Tue, 24 Jan 2017 16:50:07 +0100 Subject: [PATCH 107/248] redux-immutable: improve typings Current available typings for `redux-immutable` do only allow to have a `Reducer` and allow to be pass an arbitrary object to `combineReducers`. This patch updates the typings and brings them in-sync with the official `redux` typings. --- redux-immutable/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/redux-immutable/index.d.ts b/redux-immutable/index.d.ts index 2c378f02d8..386a3a1613 100644 --- a/redux-immutable/index.d.ts +++ b/redux-immutable/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for redux-immutable v3.0.5 +// Type definitions for redux-immutable v3.0.10 // Project: https://github.com/gajus/redux-immutable -// Definitions by: Pedro Pereira +// Definitions by: Sebastian Sebald // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Redux from 'redux'; -export declare function combineReducers(reducers: Object): Redux.Reducer; +export declare function combineReducers(reducers: Redux.ReducersMapObject): Redux.Reducer; From e22fc912b9109557b2878001055b66a52374d1c0 Mon Sep 17 00:00:00 2001 From: Joshua Sheard Date: Tue, 24 Jan 2017 18:15:13 +0000 Subject: [PATCH 108/248] Fix typo in TrianglesDrawModes enum --- three/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/three/index.d.ts b/three/index.d.ts index 3b0917f577..36263993c7 100644 --- a/three/index.d.ts +++ b/three/index.d.ts @@ -217,7 +217,7 @@ declare namespace THREE { // Triangle Draw modes export enum TrianglesDrawModes { } - export const TrianglesDrawModesMode: TrianglesDrawModes; + export const TrianglesDrawMode: TrianglesDrawModes; export const TriangleStripDrawMode: TrianglesDrawModes; export const TriangleFanDrawMode: TrianglesDrawModes; From fbbdd4fa3c62077b1829fe1850c20ffb50c7044c Mon Sep 17 00:00:00 2001 From: Chris Scribner Date: Tue, 24 Jan 2017 10:41:26 -0800 Subject: [PATCH 109/248] Add promise-based interceptor definitions --- axios/axios-tests.ts | 20 +++++++++++++++++++- axios/index.d.ts | 20 ++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/axios/axios-tests.ts b/axios/axios-tests.ts index eb98e2710c..2587222b36 100644 --- a/axios/axios-tests.ts +++ b/axios/axios-tests.ts @@ -13,6 +13,13 @@ interface Issue { title: string; } +function makePromise(val: any) { + return >{ + then: () => val, + catch: () => val + }; +} + axios.interceptors.request.use(config => { console.log("Method:" + config.method + " Url:" +config.url); return config; @@ -30,12 +37,23 @@ const requestId: number = axios.interceptors.request.use( axios.interceptors.request.eject(requestId); axios.interceptors.request.eject(7); +const requestId2: number = axios.interceptors.request.use( + (config) => { + console.log("Method:" + config.method + " Url:" +config.url); + return makePromise(config); + }, + (error: any) => error); axios.interceptors.response.use(config => { console.log("Status:" + config.status); return config; }); +axios.interceptors.response.use(config => { + console.log("Status:" + config.status); + return makePromise(config); +}); + const responseId: number = axios.interceptors.response.use( config => { console.log("Status:" + config.status); @@ -104,4 +122,4 @@ axios.defaults.baseURL = 'https://api.example.com'; axios.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; -axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; \ No newline at end of file +axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN"; diff --git a/axios/index.d.ts b/axios/index.d.ts index 681fefc806..b32a78ebe0 100644 --- a/axios/index.d.ts +++ b/axios/index.d.ts @@ -99,10 +99,10 @@ declare namespace Axios { * change the response data to be made before it is passed to then/catch */ transformResponse?: (data: T) => U; - - /** - * defines whether to resolve or reject the promise for a given HTTP response status code. - * If returns `true` (or is set to `null` or `undefined`), the promise will be resolved; + + /** + * defines whether to resolve or reject the promise for a given HTTP response status code. + * If returns `true` (or is set to `null` or `undefined`), the promise will be resolved; * otherwise, the promise will be rejected */ validateStatus?: (status: number) => boolean | undefined; @@ -199,6 +199,12 @@ declare namespace Axios { rejectedFn: (error: any) => any) : InterceptorId; + use(fulfilledFn: (config: AxiosXHRConfig) => IPromise>): InterceptorId; + + use(fulfilledFn: (config: AxiosXHRConfig) => IPromise>, + rejectedFn: (error: any) => any) + : InterceptorId; + eject(interceptorId: InterceptorId): void; } @@ -209,10 +215,16 @@ declare namespace Axios { use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR): InterceptorId; + use(fulfilledFn: (config: Axios.AxiosXHR) => IPromise>): InterceptorId; + use(fulfilledFn: (config: Axios.AxiosXHR) => Axios.AxiosXHR, rejectedFn: (error: any) => any) : InterceptorId; + use(fulfilledFn: (config: Axios.AxiosXHR) => IPromise>, + rejectedFn: (error: any) => any) + : InterceptorId; + eject(interceptorId: InterceptorId): void; } From 8d5006eaf0676765863624e059884e1ac066c5a4 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Tue, 24 Jan 2017 20:20:56 +0100 Subject: [PATCH 110/248] Use original author --- redux-immutable/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux-immutable/index.d.ts b/redux-immutable/index.d.ts index 386a3a1613..c8b2276c22 100644 --- a/redux-immutable/index.d.ts +++ b/redux-immutable/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for redux-immutable v3.0.10 // Project: https://github.com/gajus/redux-immutable -// Definitions by: Sebastian Sebald +// Definitions by: Pedro Pereira // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Redux from 'redux'; From b435dd3c8bfa4ad23cb34246c777e7d0f8db39dd Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Mon, 23 Jan 2017 18:14:36 -0600 Subject: [PATCH 111/248] auth0-js v8.1.3 --- auth0-js/auth0-js-tests.ts | 160 +++++++++- auth0-js/index.d.ts | 584 ++++++++++++++++++++++++++-------- auth0-js/v7/auth0-js-tests.ts | 22 ++ auth0-js/v7/index.d.ts | 136 ++++++++ auth0-js/v7/tsconfig.json | 28 ++ 5 files changed, 782 insertions(+), 148 deletions(-) create mode 100644 auth0-js/v7/auth0-js-tests.ts create mode 100644 auth0-js/v7/index.d.ts create mode 100644 auth0-js/v7/tsconfig.json diff --git a/auth0-js/auth0-js-tests.ts b/auth0-js/auth0-js-tests.ts index 197256ddd5..68d4e1797b 100644 --- a/auth0-js/auth0-js-tests.ts +++ b/auth0-js/auth0-js-tests.ts @@ -1,23 +1,151 @@ /// -var auth0 = new Auth0({ +let webAuth = new auth0.WebAuth({ domain: 'mine.auth0.com', - clientID: 'dsa7d77dsa7d7', - callbackURL: 'http://my-app.com/callback', - callbackOnLocationHash: true + clientID: 'dsa7d77dsa7d7' }); -auth0.login({ - connection: 'google-oauth2', - popup: true, - popupOptions: { - width: 450, - height: 800 +webAuth.authorize({ + audience: 'https://mystore.com/api/v2', + scope: 'read:order write:order', + responseType: 'token', + redirectUri: 'https://example.com/auth/callback' +}); + +webAuth.parseHash(window.location.hash, (err, authResult) => { + if (err) { + return console.log(err); } -}, (err, profile, idToken, accessToken, state) => { - if (err) { - alert("something went wrong: " + err.message); - return; - } - alert('hello ' + profile.name); + + // The contents of authResult depend on which authentication parameters were used. + // It can include the following: + // authResult.accessToken - access token for the API specified by `audience` + // authResult.expiresIn - string with the access token's expiration time in seconds + // authResult.idToken - ID token JWT containing user profile information + + webAuth.client.userInfo(authResult.accessToken, (err, user) => { + // Now you have the user's information }); +}); + +webAuth.renewAuth({ + audience: 'https://mystore.com/api/v2', + scope: 'read:order write:order', + redirectUri: 'https://example.com/auth/silent-callback', + + // this will use postMessage to comunicate between the silent callback + // and the SPA. When false the SDK will attempt to parse the url hash + // should ignore the url hash and no extra behaviour is needed. + usePostMessage: true +}, function (err, authResult) { + // Renewed tokens or error +}); + +webAuth.changePassword({connection: 'the_connection', + email: 'me@example.com', + password: '123456' +}, (err) => {}); + +webAuth.passwordlessStart({ + connection: 'the_connection', + email: 'me@example.com', + send: 'code' +}, (err, data) => {}); + +webAuth.signupAndAuthorize({ + connection: 'the_connection', + email: 'me@example.com', + password: '123456', + scope: 'openid' +}, function (err, data) { + +}); + + + +webAuth.client.login({ + ealm: 'Username-Password-Authentication', //connection name or HRD domain + username: 'info@auth0.com', + password: 'areallystrongpassword', + audience: 'https://mystore.com/api/v2', + scope: 'read:order write:order', +}, function(err, authResult) { + // Auth tokens in the result or an error +}); + +let authentication = new auth0.Authentication({ + domain: 'me.auth0.com', + clientID: '...', + redirectUri: 'http://page.com/callback', + responseType: 'code', + _sendTelemetry: false +}); + +authentication.buildAuthorizeUrl({state:'1234'}); +authentication.buildAuthorizeUrl({ + responseType: 'token', + redirectUri: 'http://anotherpage.com/callback2', + prompt: 'none', + state: '1234', + connection_scope: 'scope1,scope2' +}); + +authentication.buildLogoutUrl('asdfasdfds'); +authentication.buildLogoutUrl(); +authentication.userInfo('abcd1234', (err, data) => { + //user info retrieved +}); + +authentication.delegation({ + grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', + refresh_token: 'your_refresh_token', + api_type: 'app' +}, (err, data) => { + +}); + +authentication.loginWithDefaultDirectory({ + username: 'someUsername', + password: '123456' +}, (err, data) => { + +}); + +authentication.oauthToken({ + username: 'someUsername', + password: '123456', + grantType: 'password' +}, (err, data) => { + +}); + +authentication.getUserCountry((err, data) => { + +}); + +authentication.getSSOData(); +authentication.getSSOData(true, (err, data) => {}); + +authentication.dbConnection.signup({connection: 'bla', email: 'blabla', password: '123456'}, () => {}); +authentication.dbConnection.changePassword({connection: 'bla', email: 'blabla', password: '123456'}, () => {}); + +authentication.passwordless.start({ connection: 'bla', send: 'blabla' }, () => {}); +authentication.passwordless.verify({ connection: 'bla', send: 'link', verificationCode: 'asdfasd', email: 'me@example.com' }, () => {}); + +authentication.loginWithResourceOwner({ + username: 'the username', + password: 'the password', + connection: 'the_connection', + scope: 'openid' +}, (err, data) => {}); + +let management = new auth0.Management({ + domain: 'me.auth0.com', + token: 'token' +}); + +management.getUser('asd', (err, user) => {}); + +management.patchUserMetadata('asd', {role: 'admin'}, (err, user) => {}); + +management.linkUser('asd', 'eqwe', (err, user) => {}); diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index bd97fed1cc..6def04ab89 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -1,136 +1,456 @@ -// Type definitions for Auth0.js +// Type definitions for Auth0.js v8.1.3 // Project: https://github.com/auth0/auth0.js -// Definitions by: Robert McLaws +// Definitions by: Adrian Chia // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** Extensions to the browser Window object. */ -interface Window { - /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */ - token: string; -} - -/** This is the interface for the main Auth0 client. */ -interface Auth0Static { - - new(options: Auth0ClientOptions): Auth0Static; - changePassword(options: any, callback?: Function): void; - decodeJwt(jwt: string): any; - login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; - loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; - loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void; - loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; - logout(query: string): void; - getConnections(callback?: Function): void; - refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; - getDelegationToken(options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; - getProfile(id_token: string, callback?: Function): Auth0UserProfile; - getSSOData(withActiveDirectories: any, callback?: Function): void; - parseHash(hash: string): Auth0DecodedHash; - signup(options: Auth0SignupOptions, callback: Function): void; - validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void; -} - -/** Represents constructor options for the Auth0 client. */ -interface Auth0ClientOptions { - clientID: string; - callbackURL: string; - callbackOnLocationHash?: boolean; - responseType?: string; - domain: string; - forceJSONP?: boolean; -} - -/** Represents a normalized UserProfile. */ -interface Auth0UserProfile { - email: string; - email_verified: boolean; - family_name: string; - gender: string; - given_name: string; - locale: string; - name: string; - nickname: string; - picture: string; - user_id: string; - /** Represents one or more Identities that may be associated with the User. */ - identities: Auth0Identity[]; - user_metadata?: any; - app_metadata?: any; -} - -/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */ -interface MicrosoftUserProfile extends Auth0UserProfile { - emails: string[]; -} - -/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */ -interface Office365UserProfile extends Auth0UserProfile { - tenantid: string; - upn: string; -} - -/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */ -interface AdfsUserProfile extends Auth0UserProfile { - issuer: string; -} - -/** Represents multiple identities assigned to a user. */ -interface Auth0Identity { - access_token: string; - connection: string; - isSocial: boolean; - provider: string; - user_id: string; -} - -interface Auth0DecodedHash { - access_token: string; - idToken: string; - profile: Auth0UserProfile; - state: any; - error: string; -} - -interface Auth0PopupOptions { - width: number; - height: number; -} - -interface Auth0LoginOptions { - auto_login?: boolean; - responseType?: string; - connection?: string; - email?: string; - username?: string; - password?: string; - popup?: boolean; - popupOptions?: Auth0PopupOptions; -} - -interface Auth0SignupOptions extends Auth0LoginOptions { - auto_login: boolean; -} - -interface Auth0Error { - code: any; - details: any; - name: string; - message: string; - status: any; -} - -/** Represents the response from an API Token Delegation request. */ -interface Auth0DelegationToken { - /** The length of time in seconds the token is valid for. */ - expires_in: string; - /** The JWT for delegated access. */ - id_token: string; - /** The type of token being returned. Possible values: "Bearer" */ - token_type: string; -} - -declare const Auth0: Auth0Static; - -declare module "auth0-js" { - export = Auth0 +declare namespace auth0 { + + export class Authentication { + constructor(options: AuthOptions); + + passwordless: PasswordlessAuthentication; + dbConnection: DBConnection; + + /** + * Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction + * + * @method buildAuthorizeUrl + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + */ + buildAuthorizeUrl(options: any): string; + + /** + * Builds and returns the Logout url in order to initialize a new authN/authZ transaction + * + * @method buildLogoutUrl + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout + */ + buildLogoutUrl(options?: any): string; + + /** + * Makes a call to the `oauth/token` endpoint with `password` grant type + * + * @method loginWithDefaultDirectory + * @param {Object} options: https://auth0.com/docs/api-auth/grant/password + * @param {Function} callback + */ + loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `/ro` endpoint + * @param {any} options + * @param {Function} callback + * @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead. + */ + loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `oauth/token` endpoint with `password-realm` grant type + * @param {any} options + * @param {Function} callback + */ + login(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `oauth/token` endpoint + * @param {any} options + * @param {Function} callback + */ + oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `/ssodata` endpoint + * + * @method getSSOData + * @param {Boolean} withActiveDirectories + * @param {Function} callback + * @deprecated `getSSOData` will be soon deprecated. + */ + getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `/ssodata` endpoint + * + * @method getSSOData + * @param {Boolean} withActiveDirectories + * @param {Function} callback + * @deprecated `getSSOData` will be soon deprecated. + */ + getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Makes a call to the `/userinfo` endpoint and returns the user profile + * + * @method userInfo + * @param {String} accessToken + * @param {Function} callback + */ + userInfo(token: string, callback: (error?: Auth0Error, user?: any) => any): void; + + /** + * Makes a call to the `/delegation` endpoint + * + * @method delegation + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation + * @param {Function} callback + * @deprecated `delegation` will be soon deprecated. + */ + delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any; + + /** + * Fetches the user country based on the ip. + * + * @method getUserCountry + * @param {Function} callback + */ + getUserCountry(callback: (error?: Auth0Error, result?: any) => any): void; + } + + export class PasswordlessAuthentication { + constructor(request: any, option: any); + + /** + * Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction + * + * @method buildVerifyUrl + * @param {Object} options + * @param {Function} callback + */ + buildVerifyUrl(options: any): string; + + /** + * Initializes a new passwordless authN/authZ transaction + * + * @method start + * @param {Object} options: https://auth0.com/docs/api/authentication#passwordless + * @param {Function} callback + */ + start(options: PasswordlessStartOptions, callback: any): void; + + /** + * Verifies the passwordless TOTP and returns an error if any. + * + * @method buildVerifyUrl + * @param {Object} options + * @param {Function} callback + */ + verify(options: any, callback: any): void; + } + + export class DBConnection { + constructor(request: any, option: any); + + /** + * Signup a new user + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} calback + */ + signup(options: any, callback: any): void; + + /** + * Initializes the change password flow + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password + * @param {Function} callback + */ + changePassword(options: ChangePasswordOptions, callback: any): void; + } + + export class Management { + constructor(options: ManagementOptions); + + /** + * Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id + * + * @method getUser + * @param {String} userId + * @param {Function} callback + */ + getUser(userId: string, callback: (error?: Auth0Error, user?: any) => any): void; + + /** + * Updates the user metdata. It will patch the user metdata with the attributes sent. + * https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id + * + * @method patchUserMetadata + * @param {String} userId + * @param {Object} userMetadata + * @param {Function} callback + */ + patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => any): void; + + /** + * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities + * + * @method linkUser + * @param {String} userId + * @param {String} secondaryUserToken + * @param {Function} callback + */ + linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => any): void; + } + + export class WebAuth { + constructor(options: AuthOptions); + client: Authentication; + popup: Popup; + redirect: Redirect; + + /** + * Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction + * + * @method authorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + */ + authorize(options: any): void; + + /** + * Parse the url hash and extract the returned tokens depending on the transaction. + * + * Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed + * by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be + * accepted. + * + * @method parseHash + * @param {Object} options: + * @param {String} options.state [OPTIONAL] to verify the response + * @param {String} options.nonce [OPTIONAL] to verify the id_token + * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash + * @param {Function} callback: any(err, token_payload) + */ + parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Decodes the id_token and verifies the nonce. + * + * @method validateToken + * @param {String} token + * @param {String} state + * @param {String} nonce + * @param {Function} callback: function(err, {payload, transaction}) + */ + validateToken(token: string, state: string, nonce: string, callback: any): void; + + /** + * Executes a silent authentication transaction under the hood in order to fetch a new token. + * + * @method renewAuth + * @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint + * @param {Function} callback + */ + renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Initialices a change password transaction + * + * @method changePassword + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password + * @param {Function} callback + */ + changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Signs up a new user + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signup(options: any, callback: any): void; + + /** + * Signs up a new user, automatically logs the user in after the signup and returns the user token. + * The login will be done using /oauth/token with password-realm grant type. + * + * @method signupAndAuthorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + + /** + * Redirects to the auth0 logout page + * + * @method logout + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout + */ + logout(options: any): void; + + passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => any): void; + + /** + * Verifies the passwordless TOTP and redirects to finish the passwordless transaction + * + * @method passwordlessVerify + * @param {Object} options: + * @param {Object} options.type: `sms` or `email` + * @param {Object} options.phoneNumber: only if type = sms + * @param {Object} options.email: only if type = email + * @param {Object} options.connection: the connection name + * @param {Object} options.verificationCode: the TOTP code + * @param {Function} callback + */ + passwordlessVerify(options: any, callback: any): void; + } + + export class Redirect { + constructor(client: any, options: any); + + /** + * Initializes the legacy Lock login flow in a popup + * + * @method loginWithCredentials + * @param {Object} options + * @param {Function} callback + * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. + */ + loginWithCredentials(options: any, callback: any): void; + + /** + * Signs up a new user and automatically logs the user in after the signup. + * + * @method signupAndLogin + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndLogin(options: any, callback: any): void; + } + + export class Popup { + constructor(client: any, options: any); + + /** + * Initializes the popup window and returns the instance to be used later in order to avoid being blocked by the browser. + * + * @method preload + * @param {Object} options: receives the window height and width and any other window feature to be sent to window.open + */ + preload(options: any): any; + + /** + * Internal use. + * + * @method getPopupHandler + */ + getPopupHandler(options: any, preload: boolean): any; + /** + * Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction + * + * @method authorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + * @param {Function} callback + */ + authorize(options: any, callback: any): void; + + /** + * Initializes the legacy Lock login flow in a popup + * + * @method loginWithCredentials + * @param {Object} options + * @param {Function} callback + * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. + */ + loginWithCredentials(options: any, callback: any): void; + + /** + * Verifies the passwordless TOTP and returns the requested token + * + * @method passwordlessVerify + * @param {Object} options: + * @param {Object} options.type: `sms` or `email` + * @param {Object} options.phoneNumber: only if type = sms + * @param {Object} options.email: only if type = email + * @param {Object} options.connection: the connection name + * @param {Object} options.verificationCode: the TOTP code + * @param {Function} callback + */ + passwordlessVerify(options: any, callback: any): void; + + /** + * Signs up a new user and automatically logs the user in after the signup. + * + * @method signupAndLogin + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndLogin(options: any, callback: any): void; + } + + interface ManagementOptions { + domain: string; + token: string; + _sendTelemetry?: boolean; + _telemetryInfo?: any; + } + + interface AuthOptions { + domain: string; + clientID: string; + responseType?: string; + responseMode?: string; + redirectUri?: string; + scope?: string; + audience?: string; + leeway?: number; + _disableDeprecationWarnings?: boolean; + _sendTelemetry?: boolean; + _telemetryInfo?: any; + } + + interface PasswordlessAuthOptions { + connection: string; + verificationCode: string; + phoneNumber: string; + email: string; + } + + interface Auth0Error { + error: any; + errorDescription: string + } + + interface Auth0DecodedHash { + accessToken?: string; + idToken?: string; + idTokenPayload?: any; + refreshToken?: string; + state?: string; + expiresIn?: number; + tokenType?: string; + } + + /** Represents the response from an API Token Delegation request. */ + interface Auth0DelegationToken { + /** The length of time in seconds the token is valid for. */ + ExpiresIn: number; + /** The JWT for delegated access. */ + idToken: string; + /** The type of token being returned. Possible values: "Bearer" */ + tokenType: string; + } + + interface ChangePasswordOptions { + connection: string; + email: string; + password?: string; + } + + interface PasswordlessStartOptions { + connection: string; + send: string; + phoneNumber?: string; + email?: string, + authParams?: any; + } + + interface PasswordlessVerifyOptions { + connection: string; + verificationCode: string; + phoneNumber?: string; + email?: string; + } + } diff --git a/auth0-js/v7/auth0-js-tests.ts b/auth0-js/v7/auth0-js-tests.ts new file mode 100644 index 0000000000..d5ca0250d4 --- /dev/null +++ b/auth0-js/v7/auth0-js-tests.ts @@ -0,0 +1,22 @@ +/// +var auth0 = new Auth0({ + domain: 'mine.auth0.com', + clientID: 'dsa7d77dsa7d7', + callbackURL: 'http://my-app.com/callback', + callbackOnLocationHash: true +}); + +auth0.login({ + connection: 'google-oauth2', + popup: true, + popupOptions: { + width: 450, + height: 800 + } +}, (err, profile, idToken, accessToken, state) => { + if (err) { + alert("something went wrong: " + err.message); + return; + } + alert('hello ' + profile.name); + }); diff --git a/auth0-js/v7/index.d.ts b/auth0-js/v7/index.d.ts new file mode 100644 index 0000000000..ee834d5c61 --- /dev/null +++ b/auth0-js/v7/index.d.ts @@ -0,0 +1,136 @@ +// Type definitions for Auth0.js v7.x +// Project: https://github.com/auth0/auth0.js +// Definitions by: Robert McLaws +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** Extensions to the browser Window object. */ +interface Window { + /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */ + token: string; +} + +/** This is the interface for the main Auth0 client. */ +interface Auth0Static { + + new(options: Auth0ClientOptions): Auth0Static; + changePassword(options: any, callback?: Function): void; + decodeJwt(jwt: string): any; + login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; + loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; + loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void; + loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; + logout(query: string): void; + getConnections(callback?: Function): void; + refreshToken(refreshToken: string, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; + getDelegationToken(options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; + getProfile(id_token: string, callback?: Function): Auth0UserProfile; + getSSOData(withActiveDirectories: any, callback?: Function): void; + parseHash(hash: string): Auth0DecodedHash; + signup(options: Auth0SignupOptions, callback: Function): void; + validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void; +} + +/** Represents constructor options for the Auth0 client. */ +interface Auth0ClientOptions { + clientID: string; + callbackURL: string; + callbackOnLocationHash?: boolean; + responseType?: string; + domain: string; + forceJSONP?: boolean; +} + +/** Represents a normalized UserProfile. */ +interface Auth0UserProfile { + email: string; + email_verified: boolean; + family_name: string; + gender: string; + given_name: string; + locale: string; + name: string; + nickname: string; + picture: string; + user_id: string; + /** Represents one or more Identities that may be associated with the User. */ + identities: Auth0Identity[]; + user_metadata?: any; + app_metadata?: any; +} + +/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */ +interface MicrosoftUserProfile extends Auth0UserProfile { + emails: string[]; +} + +/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */ +interface Office365UserProfile extends Auth0UserProfile { + tenantid: string; + upn: string; +} + +/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */ +interface AdfsUserProfile extends Auth0UserProfile { + issuer: string; +} + +/** Represents multiple identities assigned to a user. */ +interface Auth0Identity { + access_token: string; + connection: string; + isSocial: boolean; + provider: string; + user_id: string; +} + +interface Auth0DecodedHash { + access_token: string; + idToken: string; + profile: Auth0UserProfile; + state: any; + error: string; +} + +interface Auth0PopupOptions { + width: number; + height: number; +} + +interface Auth0LoginOptions { + auto_login?: boolean; + responseType?: string; + connection?: string; + email?: string; + username?: string; + password?: string; + popup?: boolean; + popupOptions?: Auth0PopupOptions; +} + +interface Auth0SignupOptions extends Auth0LoginOptions { + auto_login: boolean; +} + +interface Auth0Error { + code: any; + details: any; + name: string; + message: string; + status: any; +} + +/** Represents the response from an API Token Delegation request. */ +interface Auth0DelegationToken { + /** The length of time in seconds the token is valid for. */ + expires_in: string; + /** The JWT for delegated access. */ + id_token: string; + /** The type of token being returned. Possible values: "Bearer" */ + token_type: string; +} + +declare const Auth0: Auth0Static; + +declare module "auth0-js" { + export = Auth0 +} diff --git a/auth0-js/v7/tsconfig.json b/auth0-js/v7/tsconfig.json new file mode 100644 index 0000000000..7413e97f44 --- /dev/null +++ b/auth0-js/v7/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "auth0-js": [ + "auth0-js/v7" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "auth0-js-tests.ts" + ] +} From 961480480b66dc34420b8f997e97d79d9d6ef899 Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Tue, 24 Jan 2017 14:21:46 -0600 Subject: [PATCH 112/248] Update references to auth0-js/v7 --- auth0-lock/auth0-lock-tests.ts | 2 +- auth0-lock/index.d.ts | 2 +- auth0.widget/auth0.widget-tests.ts | 2 +- auth0.widget/index.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/auth0-lock/auth0-lock-tests.ts b/auth0-lock/auth0-lock-tests.ts index deb046f3e7..4b72edcfa1 100644 --- a/auth0-lock/auth0-lock-tests.ts +++ b/auth0-lock/auth0-lock-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// const CLIENT_ID = "YOUR_AUTH0_APP_CLIENTID"; diff --git a/auth0-lock/index.d.ts b/auth0-lock/index.d.ts index fc9a047115..09c3f4fedd 100644 --- a/auth0-lock/index.d.ts +++ b/auth0-lock/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Brian Caruso // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// interface Auth0LockAdditionalSignUpFieldOption { value: string; diff --git a/auth0.widget/auth0.widget-tests.ts b/auth0.widget/auth0.widget-tests.ts index ec5502ca7e..6277d4cc3a 100644 --- a/auth0.widget/auth0.widget-tests.ts +++ b/auth0.widget/auth0.widget-tests.ts @@ -1,4 +1,4 @@ -/// +/// var widget: Auth0WidgetStatic = new Auth0Widget({ diff --git a/auth0.widget/index.d.ts b/auth0.widget/index.d.ts index 1c30d83b6f..cdefd9e0fd 100644 --- a/auth0.widget/index.d.ts +++ b/auth0.widget/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Robert McLaws // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +/// interface Auth0WidgetStatic { From da84c6d42b1b7c9d28de48c7115767682b513c8f Mon Sep 17 00:00:00 2001 From: Adrian Chia Date: Tue, 24 Jan 2017 14:50:59 -0600 Subject: [PATCH 113/248] Convert tab to spaces for consistency --- auth0-js/index.d.ts | 790 ++++++++++++++++++++++---------------------- 1 file changed, 395 insertions(+), 395 deletions(-) diff --git a/auth0-js/index.d.ts b/auth0-js/index.d.ts index 6def04ab89..0a0e004303 100644 --- a/auth0-js/index.d.ts +++ b/auth0-js/index.d.ts @@ -5,452 +5,452 @@ declare namespace auth0 { - export class Authentication { - constructor(options: AuthOptions); + export class Authentication { + constructor(options: AuthOptions); - passwordless: PasswordlessAuthentication; - dbConnection: DBConnection; + passwordless: PasswordlessAuthentication; + dbConnection: DBConnection; - /** - * Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction - * - * @method buildAuthorizeUrl - * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db - */ - buildAuthorizeUrl(options: any): string; + /** + * Builds and returns the `/authorize` url in order to initialize a new authN/authZ transaction + * + * @method buildAuthorizeUrl + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + */ + buildAuthorizeUrl(options: any): string; - /** - * Builds and returns the Logout url in order to initialize a new authN/authZ transaction - * - * @method buildLogoutUrl - * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout - */ - buildLogoutUrl(options?: any): string; + /** + * Builds and returns the Logout url in order to initialize a new authN/authZ transaction + * + * @method buildLogoutUrl + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout + */ + buildLogoutUrl(options?: any): string; - /** - * Makes a call to the `oauth/token` endpoint with `password` grant type - * - * @method loginWithDefaultDirectory - * @param {Object} options: https://auth0.com/docs/api-auth/grant/password - * @param {Function} callback - */ - loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `oauth/token` endpoint with `password` grant type + * + * @method loginWithDefaultDirectory + * @param {Object} options: https://auth0.com/docs/api-auth/grant/password + * @param {Function} callback + */ + loginWithDefaultDirectory(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `/ro` endpoint - * @param {any} options - * @param {Function} callback - * @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead. - */ - loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `/ro` endpoint + * @param {any} options + * @param {Function} callback + * @deprecated `loginWithResourceOwner` will be soon deprecated, user `login` instead. + */ + loginWithResourceOwner(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `oauth/token` endpoint with `password-realm` grant type - * @param {any} options - * @param {Function} callback - */ - login(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `oauth/token` endpoint with `password-realm` grant type + * @param {any} options + * @param {Function} callback + */ + login(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `oauth/token` endpoint - * @param {any} options - * @param {Function} callback - */ - oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `oauth/token` endpoint + * @param {any} options + * @param {Function} callback + */ + oauthToken(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `/ssodata` endpoint - * - * @method getSSOData - * @param {Boolean} withActiveDirectories - * @param {Function} callback - * @deprecated `getSSOData` will be soon deprecated. - */ - getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `/ssodata` endpoint + * + * @method getSSOData + * @param {Boolean} withActiveDirectories + * @param {Function} callback + * @deprecated `getSSOData` will be soon deprecated. + */ + getSSOData(callback?: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `/ssodata` endpoint - * - * @method getSSOData - * @param {Boolean} withActiveDirectories - * @param {Function} callback - * @deprecated `getSSOData` will be soon deprecated. - */ - getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Makes a call to the `/ssodata` endpoint + * + * @method getSSOData + * @param {Boolean} withActiveDirectories + * @param {Function} callback + * @deprecated `getSSOData` will be soon deprecated. + */ + getSSOData(withActiveDirectories: boolean, callback?: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Makes a call to the `/userinfo` endpoint and returns the user profile - * - * @method userInfo - * @param {String} accessToken - * @param {Function} callback - */ - userInfo(token: string, callback: (error?: Auth0Error, user?: any) => any): void; + /** + * Makes a call to the `/userinfo` endpoint and returns the user profile + * + * @method userInfo + * @param {String} accessToken + * @param {Function} callback + */ + userInfo(token: string, callback: (error?: Auth0Error, user?: any) => any): void; - /** - * Makes a call to the `/delegation` endpoint - * - * @method delegation - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation - * @param {Function} callback - * @deprecated `delegation` will be soon deprecated. - */ - delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any; + /** + * Makes a call to the `/delegation` endpoint + * + * @method delegation + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--delegation + * @param {Function} callback + * @deprecated `delegation` will be soon deprecated. + */ + delegation(options: any, callback: (error?: Auth0Error, authResult?: Auth0DelegationToken) => any): any; - /** - * Fetches the user country based on the ip. - * - * @method getUserCountry - * @param {Function} callback - */ - getUserCountry(callback: (error?: Auth0Error, result?: any) => any): void; - } + /** + * Fetches the user country based on the ip. + * + * @method getUserCountry + * @param {Function} callback + */ + getUserCountry(callback: (error?: Auth0Error, result?: any) => any): void; + } - export class PasswordlessAuthentication { - constructor(request: any, option: any); + export class PasswordlessAuthentication { + constructor(request: any, option: any); - /** - * Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction - * - * @method buildVerifyUrl - * @param {Object} options - * @param {Function} callback - */ - buildVerifyUrl(options: any): string; + /** + * Builds and returns the passwordless TOTP verify url in order to initialize a new authN/authZ transaction + * + * @method buildVerifyUrl + * @param {Object} options + * @param {Function} callback + */ + buildVerifyUrl(options: any): string; - /** - * Initializes a new passwordless authN/authZ transaction - * - * @method start - * @param {Object} options: https://auth0.com/docs/api/authentication#passwordless - * @param {Function} callback - */ - start(options: PasswordlessStartOptions, callback: any): void; + /** + * Initializes a new passwordless authN/authZ transaction + * + * @method start + * @param {Object} options: https://auth0.com/docs/api/authentication#passwordless + * @param {Function} callback + */ + start(options: PasswordlessStartOptions, callback: any): void; - /** - * Verifies the passwordless TOTP and returns an error if any. - * - * @method buildVerifyUrl - * @param {Object} options - * @param {Function} callback - */ - verify(options: any, callback: any): void; - } + /** + * Verifies the passwordless TOTP and returns an error if any. + * + * @method buildVerifyUrl + * @param {Object} options + * @param {Function} callback + */ + verify(options: any, callback: any): void; + } - export class DBConnection { - constructor(request: any, option: any); + export class DBConnection { + constructor(request: any, option: any); - /** - * Signup a new user - * - * @method signup - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup - * @param {Function} calback - */ - signup(options: any, callback: any): void; + /** + * Signup a new user + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} calback + */ + signup(options: any, callback: any): void; - /** - * Initializes the change password flow - * - * @method signup - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password - * @param {Function} callback - */ - changePassword(options: ChangePasswordOptions, callback: any): void; - } + /** + * Initializes the change password flow + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password + * @param {Function} callback + */ + changePassword(options: ChangePasswordOptions, callback: any): void; + } - export class Management { - constructor(options: ManagementOptions); + export class Management { + constructor(options: ManagementOptions); - /** - * Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id - * - * @method getUser - * @param {String} userId - * @param {Function} callback - */ - getUser(userId: string, callback: (error?: Auth0Error, user?: any) => any): void; + /** + * Returns the user profile. https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id + * + * @method getUser + * @param {String} userId + * @param {Function} callback + */ + getUser(userId: string, callback: (error?: Auth0Error, user?: any) => any): void; - /** - * Updates the user metdata. It will patch the user metdata with the attributes sent. - * https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id - * - * @method patchUserMetadata - * @param {String} userId - * @param {Object} userMetadata - * @param {Function} callback - */ - patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => any): void; + /** + * Updates the user metdata. It will patch the user metdata with the attributes sent. + * https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id + * + * @method patchUserMetadata + * @param {String} userId + * @param {Object} userMetadata + * @param {Function} callback + */ + patchUserMetadata(userId: string, userMetadata: any, callback: (error?: Auth0Error, user?: any) => any): void; - /** - * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities - * - * @method linkUser - * @param {String} userId - * @param {String} secondaryUserToken - * @param {Function} callback - */ - linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => any): void; - } + /** + * Link two users. https://auth0.com/docs/api/management/v2#!/Users/post_identities + * + * @method linkUser + * @param {String} userId + * @param {String} secondaryUserToken + * @param {Function} callback + */ + linkUser(userId: string, secondaryUserToken: string, callback: (error?: Auth0Error, user?: any) => any): void; + } - export class WebAuth { - constructor(options: AuthOptions); - client: Authentication; - popup: Popup; - redirect: Redirect; + export class WebAuth { + constructor(options: AuthOptions); + client: Authentication; + popup: Popup; + redirect: Redirect; - /** - * Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction - * - * @method authorize - * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db - */ - authorize(options: any): void; + /** + * Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction + * + * @method authorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + */ + authorize(options: any): void; - /** - * Parse the url hash and extract the returned tokens depending on the transaction. - * - * Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed - * by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be - * accepted. - * - * @method parseHash - * @param {Object} options: - * @param {String} options.state [OPTIONAL] to verify the response - * @param {String} options.nonce [OPTIONAL] to verify the id_token - * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash - * @param {Function} callback: any(err, token_payload) - */ - parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Parse the url hash and extract the returned tokens depending on the transaction. + * + * Only validates id_tokens signed by Auth0 using the RS256 algorithm using the public key exposed + * by the `/.well-known/jwks.json` endpoint. Id tokens signed with other algorithms will not be + * accepted. + * + * @method parseHash + * @param {Object} options: + * @param {String} options.state [OPTIONAL] to verify the response + * @param {String} options.nonce [OPTIONAL] to verify the id_token + * @param {String} options.hash [OPTIONAL] the url hash. If not provided it will extract from window.location.hash + * @param {Function} callback: any(err, token_payload) + */ + parseHash(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Decodes the id_token and verifies the nonce. - * - * @method validateToken - * @param {String} token - * @param {String} state - * @param {String} nonce - * @param {Function} callback: function(err, {payload, transaction}) - */ - validateToken(token: string, state: string, nonce: string, callback: any): void; + /** + * Decodes the id_token and verifies the nonce. + * + * @method validateToken + * @param {String} token + * @param {String} state + * @param {String} nonce + * @param {Function} callback: function(err, {payload, transaction}) + */ + validateToken(token: string, state: string, nonce: string, callback: any): void; - /** - * Executes a silent authentication transaction under the hood in order to fetch a new token. - * - * @method renewAuth - * @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint - * @param {Function} callback - */ - renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Executes a silent authentication transaction under the hood in order to fetch a new token. + * + * @method renewAuth + * @param {Object} options: any valid oauth2 parameter to be sent to the `/authorize` endpoint + * @param {Function} callback + */ + renewAuth(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Initialices a change password transaction - * - * @method changePassword - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password - * @param {Function} callback - */ - changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Initialices a change password transaction + * + * @method changePassword + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-change_password + * @param {Function} callback + */ + changePassword(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Signs up a new user - * - * @method signup - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup - * @param {Function} callback - */ - signup(options: any, callback: any): void; + /** + * Signs up a new user + * + * @method signup + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signup(options: any, callback: any): void; - /** - * Signs up a new user, automatically logs the user in after the signup and returns the user token. - * The login will be done using /oauth/token with password-realm grant type. - * - * @method signupAndAuthorize - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup - * @param {Function} callback - */ - signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; + /** + * Signs up a new user, automatically logs the user in after the signup and returns the user token. + * The login will be done using /oauth/token with password-realm grant type. + * + * @method signupAndAuthorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndAuthorize(options: any, callback: (error?: Auth0Error, authResult?: any) => any): void; - /** - * Redirects to the auth0 logout page - * - * @method logout - * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout - */ - logout(options: any): void; + /** + * Redirects to the auth0 logout page + * + * @method logout + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--v2-logout + */ + logout(options: any): void; - passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => any): void; + passwordlessStart(options: PasswordlessStartOptions, callback: (error?: Auth0Error, data?: any) => any): void; - /** - * Verifies the passwordless TOTP and redirects to finish the passwordless transaction - * - * @method passwordlessVerify - * @param {Object} options: - * @param {Object} options.type: `sms` or `email` - * @param {Object} options.phoneNumber: only if type = sms - * @param {Object} options.email: only if type = email - * @param {Object} options.connection: the connection name - * @param {Object} options.verificationCode: the TOTP code - * @param {Function} callback - */ - passwordlessVerify(options: any, callback: any): void; - } + /** + * Verifies the passwordless TOTP and redirects to finish the passwordless transaction + * + * @method passwordlessVerify + * @param {Object} options: + * @param {Object} options.type: `sms` or `email` + * @param {Object} options.phoneNumber: only if type = sms + * @param {Object} options.email: only if type = email + * @param {Object} options.connection: the connection name + * @param {Object} options.verificationCode: the TOTP code + * @param {Function} callback + */ + passwordlessVerify(options: any, callback: any): void; + } - export class Redirect { - constructor(client: any, options: any); + export class Redirect { + constructor(client: any, options: any); - /** - * Initializes the legacy Lock login flow in a popup - * - * @method loginWithCredentials - * @param {Object} options - * @param {Function} callback - * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. - */ - loginWithCredentials(options: any, callback: any): void; + /** + * Initializes the legacy Lock login flow in a popup + * + * @method loginWithCredentials + * @param {Object} options + * @param {Function} callback + * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. + */ + loginWithCredentials(options: any, callback: any): void; - /** - * Signs up a new user and automatically logs the user in after the signup. - * - * @method signupAndLogin - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup - * @param {Function} callback - */ - signupAndLogin(options: any, callback: any): void; - } + /** + * Signs up a new user and automatically logs the user in after the signup. + * + * @method signupAndLogin + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndLogin(options: any, callback: any): void; + } - export class Popup { - constructor(client: any, options: any); + export class Popup { + constructor(client: any, options: any); - /** - * Initializes the popup window and returns the instance to be used later in order to avoid being blocked by the browser. - * - * @method preload - * @param {Object} options: receives the window height and width and any other window feature to be sent to window.open - */ - preload(options: any): any; + /** + * Initializes the popup window and returns the instance to be used later in order to avoid being blocked by the browser. + * + * @method preload + * @param {Object} options: receives the window height and width and any other window feature to be sent to window.open + */ + preload(options: any): any; - /** - * Internal use. - * - * @method getPopupHandler - */ - getPopupHandler(options: any, preload: boolean): any; - /** - * Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction - * - * @method authorize - * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db - * @param {Function} callback - */ - authorize(options: any, callback: any): void; + /** + * Internal use. + * + * @method getPopupHandler + */ + getPopupHandler(options: any, preload: boolean): any; + /** + * Opens in a popup the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction + * + * @method authorize + * @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db + * @param {Function} callback + */ + authorize(options: any, callback: any): void; - /** - * Initializes the legacy Lock login flow in a popup - * - * @method loginWithCredentials - * @param {Object} options - * @param {Function} callback - * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. - */ - loginWithCredentials(options: any, callback: any): void; + /** + * Initializes the legacy Lock login flow in a popup + * + * @method loginWithCredentials + * @param {Object} options + * @param {Function} callback + * @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead. + */ + loginWithCredentials(options: any, callback: any): void; - /** - * Verifies the passwordless TOTP and returns the requested token - * - * @method passwordlessVerify - * @param {Object} options: - * @param {Object} options.type: `sms` or `email` - * @param {Object} options.phoneNumber: only if type = sms - * @param {Object} options.email: only if type = email - * @param {Object} options.connection: the connection name - * @param {Object} options.verificationCode: the TOTP code - * @param {Function} callback - */ - passwordlessVerify(options: any, callback: any): void; + /** + * Verifies the passwordless TOTP and returns the requested token + * + * @method passwordlessVerify + * @param {Object} options: + * @param {Object} options.type: `sms` or `email` + * @param {Object} options.phoneNumber: only if type = sms + * @param {Object} options.email: only if type = email + * @param {Object} options.connection: the connection name + * @param {Object} options.verificationCode: the TOTP code + * @param {Function} callback + */ + passwordlessVerify(options: any, callback: any): void; - /** - * Signs up a new user and automatically logs the user in after the signup. - * - * @method signupAndLogin - * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup - * @param {Function} callback - */ - signupAndLogin(options: any, callback: any): void; - } + /** + * Signs up a new user and automatically logs the user in after the signup. + * + * @method signupAndLogin + * @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup + * @param {Function} callback + */ + signupAndLogin(options: any, callback: any): void; + } - interface ManagementOptions { - domain: string; - token: string; - _sendTelemetry?: boolean; - _telemetryInfo?: any; - } + interface ManagementOptions { + domain: string; + token: string; + _sendTelemetry?: boolean; + _telemetryInfo?: any; + } - interface AuthOptions { - domain: string; - clientID: string; - responseType?: string; - responseMode?: string; - redirectUri?: string; - scope?: string; - audience?: string; - leeway?: number; - _disableDeprecationWarnings?: boolean; - _sendTelemetry?: boolean; - _telemetryInfo?: any; - } + interface AuthOptions { + domain: string; + clientID: string; + responseType?: string; + responseMode?: string; + redirectUri?: string; + scope?: string; + audience?: string; + leeway?: number; + _disableDeprecationWarnings?: boolean; + _sendTelemetry?: boolean; + _telemetryInfo?: any; + } - interface PasswordlessAuthOptions { - connection: string; - verificationCode: string; - phoneNumber: string; - email: string; - } + interface PasswordlessAuthOptions { + connection: string; + verificationCode: string; + phoneNumber: string; + email: string; + } - interface Auth0Error { - error: any; - errorDescription: string - } + interface Auth0Error { + error: any; + errorDescription: string + } - interface Auth0DecodedHash { - accessToken?: string; - idToken?: string; - idTokenPayload?: any; - refreshToken?: string; - state?: string; - expiresIn?: number; - tokenType?: string; - } + interface Auth0DecodedHash { + accessToken?: string; + idToken?: string; + idTokenPayload?: any; + refreshToken?: string; + state?: string; + expiresIn?: number; + tokenType?: string; + } - /** Represents the response from an API Token Delegation request. */ - interface Auth0DelegationToken { - /** The length of time in seconds the token is valid for. */ - ExpiresIn: number; - /** The JWT for delegated access. */ - idToken: string; - /** The type of token being returned. Possible values: "Bearer" */ - tokenType: string; - } + /** Represents the response from an API Token Delegation request. */ + interface Auth0DelegationToken { + /** The length of time in seconds the token is valid for. */ + ExpiresIn: number; + /** The JWT for delegated access. */ + idToken: string; + /** The type of token being returned. Possible values: "Bearer" */ + tokenType: string; + } - interface ChangePasswordOptions { - connection: string; - email: string; - password?: string; - } + interface ChangePasswordOptions { + connection: string; + email: string; + password?: string; + } - interface PasswordlessStartOptions { - connection: string; - send: string; - phoneNumber?: string; - email?: string, - authParams?: any; - } + interface PasswordlessStartOptions { + connection: string; + send: string; + phoneNumber?: string; + email?: string, + authParams?: any; + } - interface PasswordlessVerifyOptions { - connection: string; - verificationCode: string; - phoneNumber?: string; - email?: string; - } + interface PasswordlessVerifyOptions { + connection: string; + verificationCode: string; + phoneNumber?: string; + email?: string; + } } From 4184a8342abde8c56c2ee137b5184044a6727002 Mon Sep 17 00:00:00 2001 From: "Smith, Blake (bs557j)" Date: Tue, 24 Jan 2017 15:00:33 -0600 Subject: [PATCH 114/248] Adding Filter as a type to Request.filter(filter) --- elastic.js/elastic.js-tests.ts | 9 ++++++++- elastic.js/index.d.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/elastic.js/elastic.js-tests.ts b/elastic.js/elastic.js-tests.ts index e7bd65ea16..b683559490 100644 --- a/elastic.js/elastic.js-tests.ts +++ b/elastic.js/elastic.js-tests.ts @@ -1,6 +1,13 @@ import * as elasticjs from 'elastic.js'; -let body = new elasticjs.Request({}) +new elasticjs.Request({}) .query(new elasticjs.MatchQuery('title_field', 'testQuery')) .facet(new elasticjs.TermsFacet('tags').field('tags')) .toJSON(); + +new elasticjs.Request({}) + .query(new elasticjs.MatchAllQuery()) + .filter(new elasticjs.BoolFilter().must([ + new elasticjs.TermFilter('a', 'b'), + new elasticjs.TermFilter('c', 'd')])) + .toJSON(); diff --git a/elastic.js/index.d.ts b/elastic.js/index.d.ts index adb0db6950..9e25076906 100644 --- a/elastic.js/index.d.ts +++ b/elastic.js/index.d.ts @@ -6765,7 +6765,7 @@ declare module elasticjs { /* Allows you to set a specified filter on this request object. */ - filter(filter: Object): Request; + filter(filter: Object | Filter): Request; /* A search result set could be very large (think Google). Setting the From 386cc89aa9abc7775600e80096e22787253d82ef Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Tue, 24 Jan 2017 22:34:26 +0100 Subject: [PATCH 115/248] Add myself as author --- redux-immutable/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redux-immutable/index.d.ts b/redux-immutable/index.d.ts index c8b2276c22..483de7c9bf 100644 --- a/redux-immutable/index.d.ts +++ b/redux-immutable/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for redux-immutable v3.0.10 // Project: https://github.com/gajus/redux-immutable -// Definitions by: Pedro Pereira +// Definitions by: Pedro Pereira , Sebastian Sebald // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Redux from 'redux'; From 1989ed4c5a8f0cfea032a30220afb81dab98ca88 Mon Sep 17 00:00:00 2001 From: Simon Ramsay Date: Tue, 24 Jan 2017 16:33:36 -0500 Subject: [PATCH 116/248] added additional typing for assigning result of dot-object conversion - bumped version number --- dot-object/dot-object-tests.ts | 23 ++++++++++++++--------- dot-object/index.d.ts | 25 ++++++++++++++++--------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/dot-object/dot-object-tests.ts b/dot-object/dot-object-tests.ts index 603a66c57e..a553c6c68d 100644 --- a/dot-object/dot-object-tests.ts +++ b/dot-object/dot-object-tests.ts @@ -16,10 +16,10 @@ var src = { } }; -var tgt = {name: 'Brandon'}; +var tgt = { name: 'Brandon' }; dot.copy('stuff.phone', 'wanna.haves.phone', src, tgt, [(arg: any) => { - return arg; + return arg; }]); dot.transfer('stuff.phone', 'wanna.haves.phone', src, tgt); @@ -37,17 +37,17 @@ var row = { }; dot.object(row, (arg: any) => { - return arg; + return arg; }); dot.str('this.is.my.string', 'value', tgt); var newObj = { - some: { - nested: { - value: 'Hi there!' - } - } + some: { + nested: { + value: 'Hi there!' + } + } }; var val = dot.pick('some.nested.value', newObj); @@ -62,4 +62,9 @@ val = dot.remove('some.nested.value', newObj); // or use the alias `del` val = dot.del('some.nested.value', newObj); -var dotWithArrow = new dot('=>'); \ No newline at end of file +// convert object to dot object +var result = {}; +dot.dot({ test: 'something' }, result); +result = dot.dot({ test: 'something' }); + +var dotWithArrow = new dot('=>'); diff --git a/dot-object/index.d.ts b/dot-object/index.d.ts index 953291c631..176e1c0daf 100644 --- a/dot-object/index.d.ts +++ b/dot-object/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Dot-Object v1.4.1 +// Type definitions for Dot-Object v1.4.2 // Project: https://github.com/rhalff/dot-object // Definitions by: Niko Kovačič // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,14 +6,14 @@ declare namespace DotObject { interface DotConstructor extends Dot { - new(separator: string): Dot; + new (separator: string): Dot; } interface ModifierFunctionWrapper { (arg: any): any; } - interface Dot { + interface Dot { /** * * Copy a property from one object to another object. @@ -34,11 +34,6 @@ declare namespace DotObject { * Convert object to dotted-key/value pair * * Usage: - * - * var tgt = dot.dot(obj) - * - * or - * * var tgt = {} * dot.dot(obj, tgt) * @@ -46,6 +41,18 @@ declare namespace DotObject { * @param {Object} tgt target object */ dot(obj: any, tgt: any): void + /** + * + * Convert object to dotted-key/value pair + * + * Usage: + * + * var tgt = dot.dot(obj) + * @param {Object} obj source object + * @return {Object} result + */ + dot(obj: any): any + /** * * Remove value from an object using dot notation. @@ -166,4 +173,4 @@ declare var dot: DotObject.DotConstructor; declare module 'dot-object' { export = dot; -} \ No newline at end of file +} From c960430ff9a47bb94ef53ad79fbb759343ea3abb Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Tue, 24 Jan 2017 13:43:22 -0800 Subject: [PATCH 117/248] Fix typo in webpack PerformanceOptions s/maxEntryPointSize/maxEntrypointSize --- webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 73f575c973..a557034131 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -1146,7 +1146,7 @@ declare namespace webpack { /** * An entrypoint represents all assets that would be utilized during initial load time for a specific entry. This option controls when webpack should emit performance hints based on the maximum entrypoint size. The default value is 250000 (bytes). */ - maxEntryPointSize?: number; + maxEntrypointSize?: number; /** * An asset is any emitted file from webpack. This option controls when webpack emits a performance hint based on individual asset size. The default value is 250000 (bytes). */ From a70e784fec04cf50367ebcd11d88c67a66058614 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Tue, 24 Jan 2017 14:59:01 -0800 Subject: [PATCH 118/248] fix test --- webpack/webpack-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 8af08751ed..7c1f109a2d 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -544,7 +544,7 @@ const resolve: webpack.Resolve = { const performance: webpack.PerformanceOptions = { hints: 'error', - maxEntryPointSize: 400000, + maxEntrypointSize: 400000, maxAssetSize: 100000, assetFilter: function(assetFilename) { return assetFilename.endsWith('.js'); From ae3b2e73d3045104dc0ba279f2363ec7746dce00 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Tue, 24 Jan 2017 16:29:09 -0800 Subject: [PATCH 119/248] Update index.d.ts --- redux-logger/index.d.ts | 78 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/redux-logger/index.d.ts b/redux-logger/index.d.ts index edcb2b9152..2c02273d60 100644 --- a/redux-logger/index.d.ts +++ b/redux-logger/index.d.ts @@ -5,46 +5,46 @@ import * as Redux from "redux"; -type LoggerPredicate = (getState: () => any, action: any) => boolean; - -type StateToString = (state: any) => string; -type ActionToString = (action: any) => string; -type ErrorToString = (error: any, prevState: any) => string; - -interface ColorsObject { - title?: boolean | ActionToString; - prevState?: boolean | StateToString; - action?: boolean | ActionToString; - nextState?: boolean | StateToString; - error?: boolean | ErrorToString; -} - -interface LevelObject { - prevState?: string | boolean | StateToString; - action?: string | boolean | ActionToString; - nextState?: string | boolean | StateToString; - error?: string | boolean | ErrorToString; -} - -interface ReduxLoggerOptions { - level?: string | ActionToString | LevelObject; - duration?: boolean; - timestamp?: boolean; - colors?: ColorsObject; - logger?: any; - logErrors?: boolean; - collapsed?: boolean | LoggerPredicate; - predicate?: LoggerPredicate; - stateTransformer?: (state: any) => any; - actionTransformer?: (action: any) => any; - errorTransformer?: (error: any) => any; - diff?: boolean; - diffPredicate?: LoggerPredicate; -} - // Trickery to get TypeScript to accept that our anonymous, non-default export is a function. // see https://github.com/Microsoft/TypeScript/issues/3612 for more -declare namespace createLogger { } -declare function createLogger(options?: ReduxLoggerOptions): Redux.Middleware; +declare namespace createLogger { + export type LoggerPredicate = (getState: () => any, action: any) => boolean; + + export type StateToString = (state: any) => string; + export type ActionToString = (action: any) => string; + export type ErrorToString = (error: any, prevState: any) => string; + + export interface ColorsObject { + title?: boolean | ActionToString; + prevState?: boolean | StateToString; + action?: boolean | ActionToString; + nextState?: boolean | StateToString; + error?: boolean | ErrorToString; + } + + export interface LevelObject { + prevState?: string | boolean | StateToString; + action?: string | boolean | ActionToString; + nextState?: string | boolean | StateToString; + error?: string | boolean | ErrorToString; + } + + export interface ReduxLoggerOptions { + level?: string | ActionToString | LevelObject; + duration?: boolean; + timestamp?: boolean; + colors?: ColorsObject; + logger?: any; + logErrors?: boolean; + collapsed?: boolean | LoggerPredicate; + predicate?: LoggerPredicate; + stateTransformer?: (state: any) => any; + actionTransformer?: (action: any) => any; + errorTransformer?: (error: any) => any; + diff?: boolean; + diffPredicate?: LoggerPredicate; + } +} +declare function createLogger(options?: createLogger.ReduxLoggerOptions): Redux.Middleware; export = createLogger; From afa6e180c8cd8ab091b4f38a885df70633e937ba Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Tue, 24 Jan 2017 16:35:38 -0800 Subject: [PATCH 120/248] Update index.d.ts --- redux-logger/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/redux-logger/index.d.ts b/redux-logger/index.d.ts index 2c02273d60..257f070d44 100644 --- a/redux-logger/index.d.ts +++ b/redux-logger/index.d.ts @@ -5,7 +5,6 @@ import * as Redux from "redux"; - // Trickery to get TypeScript to accept that our anonymous, non-default export is a function. // see https://github.com/Microsoft/TypeScript/issues/3612 for more declare namespace createLogger { From 8698554563f4acdf0942ffe9f74b6cce394f9f10 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 10:13:32 +0800 Subject: [PATCH 121/248] use appropriate export --- simplemde/index.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/simplemde/index.d.ts b/simplemde/index.d.ts index eb463ae655..c78d4fb408 100644 --- a/simplemde/index.d.ts +++ b/simplemde/index.d.ts @@ -129,6 +129,5 @@ declare class SimpleMDE { static redo: (editor: SimpleMDE) => void; } -declare module "simplemde" { - export = SimpleMDE; -} +export = SimpleMDE; +export as namespace SimpleMDE; From 95bd599bc879a80a389b3f43fd132737a004ce72 Mon Sep 17 00:00:00 2001 From: Alvaro Dias Date: Tue, 24 Jan 2017 20:47:04 -0800 Subject: [PATCH 122/248] documentdb: Add typings for user-defined functions --- documentdb/documentdb-tests.ts | 25 +++++++++++++++++++++++++ documentdb/index.d.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/documentdb/documentdb-tests.ts b/documentdb/documentdb-tests.ts index 34d6b5236b..f4a06d3fb7 100644 --- a/documentdb/documentdb-tests.ts +++ b/documentdb/documentdb-tests.ts @@ -55,6 +55,31 @@ docDBClient.createStoredProcedure('collection', procedure, undefined, (error, re } }); +var userDefinedFunction: docDB.UserDefinedFunction = { + id: 'udf1', + body: function () { + console.log('foo'); + } +}; + +docDBClient.createUserDefinedFunction('collection', userDefinedFunction, undefined, (error, result) => { + if (error) { + throw new Error(error.body); + } + else { + console.log('Created function: ' + result.id); + } +}); + +docDBClient.queryUserDefinedFunctions('collection', "SELECT * FROM root", undefined).toArray((error, results) => { + if (error) { + throw new Error(error.body); + } + else { + console.log('Number of functions in collection: ' + results.length); + } +}); + var trigger: docDB.Trigger = { id: 'trigger-one', body: function () { diff --git a/documentdb/index.d.ts b/documentdb/index.d.ts index 406affe2c8..048825b492 100644 --- a/documentdb/index.d.ts +++ b/documentdb/index.d.ts @@ -154,6 +154,10 @@ interface ProcedureMeta extends AbstractMeta { body: string; } +/** Represents the meta data for a user-defined function. */ +interface UserDefinedFunctionMeta extends AbstractMeta { +} + /** Represents the meta data for a trigger. */ interface TriggerMeta extends AbstractMeta { body: string; @@ -181,6 +185,13 @@ export interface Procedure extends UniqueId { body(...params: any[]): void; } +/** Represents a DocumentDB user-defined function. */ +export interface UserDefinedFunction extends UniqueId { + + /** The function representing the user-defined function. */ + body(...params: any[]): void; +} + /** Represents a DocumentDB trigger. */ export interface Trigger extends UniqueId { /** The type of the trigger. Should be either 'pre' or 'post'. */ @@ -290,6 +301,19 @@ export declare class DocumentClient { */ public createStoredProcedure(collectionLink: string, procedure: Procedure, options: RequestOptions, callback: RequestCallback): void; + /** + * Create a UserDefinedFunction. + *

+ * DocumentDB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.
+ * For additional details, refer to the server-side JavaScript API documentation. + *

+ * @param collectionLink - The self-link of the collection. + * @param udf - Represents the body of the userDefinedFunction. + * @param [options] - The request options. + * @param callback - The callback for the request. + */ + public createUserDefinedFunction(collectionLink: string, udf: UserDefinedFunction, options: RequestOptions, callback: RequestCallback): void; + /** * Create a trigger. *

@@ -349,6 +373,15 @@ export declare class DocumentClient { */ public queryStoredProcedures(collectionLink: string, query: string | SqlQuerySpec): QueryIterator; + /** + * Query the user-defined functions for the collection. + * @param collectionLink - The self-link of the collection. + * @param query - A SQL query string. + * @param [options] - Represents the feed options. + * @returns - An instance of queryIterator to handle reading feed. + */ + public queryUserDefinedFunctions(collectionLink: string, query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** * Query the documents for the collection. * @param collectionLink - The self-link of the collection. From a6e94fdb0a80fbeacea1786d60cc0a67deaf9d6b Mon Sep 17 00:00:00 2001 From: Shun Date: Tue, 24 Jan 2017 21:54:20 -0800 Subject: [PATCH 123/248] Add module --- forever-monitor/forever-monitor-tests.ts | 0 forever-monitor/index.d.ts | 104 +++++++++++++++++++++++ forever-monitor/tsconfig.json | 20 +++++ forever-monitor/tslint.json | 1 + 4 files changed, 125 insertions(+) create mode 100644 forever-monitor/forever-monitor-tests.ts create mode 100644 forever-monitor/index.d.ts create mode 100644 forever-monitor/tsconfig.json create mode 100644 forever-monitor/tslint.json diff --git a/forever-monitor/forever-monitor-tests.ts b/forever-monitor/forever-monitor-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/forever-monitor/index.d.ts b/forever-monitor/index.d.ts new file mode 100644 index 0000000000..b22905cae2 --- /dev/null +++ b/forever-monitor/index.d.ts @@ -0,0 +1,104 @@ +// Type definitions for forever-monitor 1.7 +// Project: https://github.com/nodejitsu/forever-monitor#readme +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +interface spawnWith { + customFds: number[]; + setsid: boolean; + uid: number; + gid: number; +} + +interface parserArgs { + command: string; + args: string[]; +} + +interface Options { + silent?: boolean; + uid?: "autogen" | string; + pidFile?: string; + max?: number; + killTree?: boolean; + minUptime?: number; + spinSleepTime?: number; + command?: "node" | string; + args?: string[]; + sourceDir?: string; + watch?: boolean; + watchIgnoreDotFiles?: boolean; + watchIgnorePatters?: string[]; + watchDirectory?: string; + spawnWith?: spawnWith; + env?: { [envKey: string]: string; }; + cwd?: string; + logFile?: string; + outFile?: string; + errFile?: string; + parser?: (command: string, args: string[]) => { command: string, args: string[] }; +} + + +export declare class Monitor extends NodeJS.EventEmitter { + + /** + * @param script - Location of the target script to run. + * @param [options] - Configuration for this instance. + */ + constructor(script: string, options?: Options); + + /** + * @description Start the process that this instance is configured for + * @param [restart] - Value indicating whether this is a restart. + */ + public start(restart?: boolean): this; + + /** + * @description Tries to spawn the target Forever child process. + */ + public trySpawn(): boolean; + + /** + * @description Restarts the target script associated with this instance. + */ + public restart(): this; + + /** + * @description Stops the target script associated with this instance. Prevents it from auto-respawning + */ + public stop(): this; + + /** + * @description Kills the ChildProcess object associated with this instance + * @param [forceStop] - Value indicating whether short circuit forever auto-restart + */ + public kill(forceStop?: boolean): this; + + /** + * @description Sends a message to a forked ChildProcess object associated with this instance + */ + public send(msg?: any): this; + + /** + * respond with JSON for this instance + */ + public toString(): string; + + /** + * @param command - Command string to parse + * @param args - Additional default arguments + */ + public parseCommand(command: string, args?: string[]): (false | { command: string, args?: string[]}); +} + +interface forever { + Monitor: Monitor; + start: (script: string, options: Options) => Monitor; + kill: (pid: number, killTree?: boolean, signal?: string, callback?: () => any) => void; + checkProcess: (pid: number) => boolean; + version: string; +} + +export default forever; diff --git a/forever-monitor/tsconfig.json b/forever-monitor/tsconfig.json new file mode 100644 index 0000000000..8c6d4986b5 --- /dev/null +++ b/forever-monitor/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "forever-monitor-tests.ts" + ] +} diff --git a/forever-monitor/tslint.json b/forever-monitor/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/forever-monitor/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 1ca0a1b3f98ad5ce8713543791b97014d5250bd6 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 14:26:11 +0800 Subject: [PATCH 124/248] update submodule --- crypto-js/aes/index.d.ts | 3 + crypto-js/core/index.d.ts | 3 + crypto-js/enc-base64/index.d.ts | 4 + crypto-js/enc-hex/index.d.ts | 4 + crypto-js/enc-latin1/index.d.ts | 4 + crypto-js/enc-utf16/index.d.ts | 4 + crypto-js/enc-utf8/index.d.ts | 4 + crypto-js/evpkdf/index.d.ts | 3 + crypto-js/format-hex/index.d.ts | 4 + crypto-js/format-openssl/index.d.ts | 4 + crypto-js/hmac-md5/index.d.ts | 3 + crypto-js/hmac-ripemd160/index.d.ts | 3 + crypto-js/hmac-sha1/index.d.ts | 3 + crypto-js/hmac-sha224/index.d.ts | 3 + crypto-js/hmac-sha256/index.d.ts | 3 + crypto-js/hmac-sha3/index.d.ts | 3 + crypto-js/hmac-sha384/index.d.ts | 3 + crypto-js/hmac-sha512/index.d.ts | 3 + crypto-js/index.d.ts | 237 +------------------------- crypto-js/lib-typedarrays/index.d.ts | 2 + crypto-js/md5/index.d.ts | 3 + crypto-js/mode-cfb/index.d.ts | 4 + crypto-js/mode-ctr-gladman/index.d.ts | 4 + crypto-js/mode-ctr/index.d.ts | 4 + crypto-js/mode-ecb/index.d.ts | 4 + crypto-js/mode-ofb/index.d.ts | 4 + crypto-js/pad-ansix923/index.d.ts | 4 + crypto-js/pad-iso10126/index.d.ts | 4 + crypto-js/pad-iso97971/index.d.ts | 4 + crypto-js/pad-nopadding/index.d.ts | 4 + crypto-js/pad-pkcs7/index.d.ts | 4 + crypto-js/pad-zeropadding/index.d.ts | 4 + crypto-js/pbkdf2/index.d.ts | 3 + crypto-js/rabbit-legacy/index.d.ts | 3 + crypto-js/rabbit/index.d.ts | 3 + crypto-js/rc4/index.d.ts | 3 + crypto-js/ripemd160/index.d.ts | 3 + crypto-js/sha1/index.d.ts | 3 + crypto-js/sha224/index.d.ts | 3 + crypto-js/sha256/index.d.ts | 3 + crypto-js/sha3/index.d.ts | 3 + crypto-js/sha384/index.d.ts | 3 + crypto-js/sha512/index.d.ts | 3 + crypto-js/tripledes/index.d.ts | 3 + crypto-js/x64-core/index.d.ts | 3 + 45 files changed, 152 insertions(+), 234 deletions(-) create mode 100644 crypto-js/aes/index.d.ts create mode 100644 crypto-js/core/index.d.ts create mode 100644 crypto-js/enc-base64/index.d.ts create mode 100644 crypto-js/enc-hex/index.d.ts create mode 100644 crypto-js/enc-latin1/index.d.ts create mode 100644 crypto-js/enc-utf16/index.d.ts create mode 100644 crypto-js/enc-utf8/index.d.ts create mode 100644 crypto-js/evpkdf/index.d.ts create mode 100644 crypto-js/format-hex/index.d.ts create mode 100644 crypto-js/format-openssl/index.d.ts create mode 100644 crypto-js/hmac-md5/index.d.ts create mode 100644 crypto-js/hmac-ripemd160/index.d.ts create mode 100644 crypto-js/hmac-sha1/index.d.ts create mode 100644 crypto-js/hmac-sha224/index.d.ts create mode 100644 crypto-js/hmac-sha256/index.d.ts create mode 100644 crypto-js/hmac-sha3/index.d.ts create mode 100644 crypto-js/hmac-sha384/index.d.ts create mode 100644 crypto-js/hmac-sha512/index.d.ts create mode 100644 crypto-js/lib-typedarrays/index.d.ts create mode 100644 crypto-js/md5/index.d.ts create mode 100644 crypto-js/mode-cfb/index.d.ts create mode 100644 crypto-js/mode-ctr-gladman/index.d.ts create mode 100644 crypto-js/mode-ctr/index.d.ts create mode 100644 crypto-js/mode-ecb/index.d.ts create mode 100644 crypto-js/mode-ofb/index.d.ts create mode 100644 crypto-js/pad-ansix923/index.d.ts create mode 100644 crypto-js/pad-iso10126/index.d.ts create mode 100644 crypto-js/pad-iso97971/index.d.ts create mode 100644 crypto-js/pad-nopadding/index.d.ts create mode 100644 crypto-js/pad-pkcs7/index.d.ts create mode 100644 crypto-js/pad-zeropadding/index.d.ts create mode 100644 crypto-js/pbkdf2/index.d.ts create mode 100644 crypto-js/rabbit-legacy/index.d.ts create mode 100644 crypto-js/rabbit/index.d.ts create mode 100644 crypto-js/rc4/index.d.ts create mode 100644 crypto-js/ripemd160/index.d.ts create mode 100644 crypto-js/sha1/index.d.ts create mode 100644 crypto-js/sha224/index.d.ts create mode 100644 crypto-js/sha256/index.d.ts create mode 100644 crypto-js/sha3/index.d.ts create mode 100644 crypto-js/sha384/index.d.ts create mode 100644 crypto-js/sha512/index.d.ts create mode 100644 crypto-js/tripledes/index.d.ts create mode 100644 crypto-js/x64-core/index.d.ts diff --git a/crypto-js/aes/index.d.ts b/crypto-js/aes/index.d.ts new file mode 100644 index 0000000000..4f435688c5 --- /dev/null +++ b/crypto-js/aes/index.d.ts @@ -0,0 +1,3 @@ +import { AES } from '../index'; + +export = AES; diff --git a/crypto-js/core/index.d.ts b/crypto-js/core/index.d.ts new file mode 100644 index 0000000000..c5d6e00410 --- /dev/null +++ b/crypto-js/core/index.d.ts @@ -0,0 +1,3 @@ +import * as Core from '../index'; + +export = Core; diff --git a/crypto-js/enc-base64/index.d.ts b/crypto-js/enc-base64/index.d.ts new file mode 100644 index 0000000000..55001a7115 --- /dev/null +++ b/crypto-js/enc-base64/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Base64: typeof enc.Base64; +export = Base64; diff --git a/crypto-js/enc-hex/index.d.ts b/crypto-js/enc-hex/index.d.ts new file mode 100644 index 0000000000..3718860123 --- /dev/null +++ b/crypto-js/enc-hex/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Hex: typeof enc.Hex; +export = Hex; diff --git a/crypto-js/enc-latin1/index.d.ts b/crypto-js/enc-latin1/index.d.ts new file mode 100644 index 0000000000..7f27822daf --- /dev/null +++ b/crypto-js/enc-latin1/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Latin1: typeof enc.Latin1; +export = Latin1; diff --git a/crypto-js/enc-utf16/index.d.ts b/crypto-js/enc-utf16/index.d.ts new file mode 100644 index 0000000000..76fa98774a --- /dev/null +++ b/crypto-js/enc-utf16/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Utf16: typeof enc.Utf16; +export = Utf16; diff --git a/crypto-js/enc-utf8/index.d.ts b/crypto-js/enc-utf8/index.d.ts new file mode 100644 index 0000000000..828dcb9391 --- /dev/null +++ b/crypto-js/enc-utf8/index.d.ts @@ -0,0 +1,4 @@ +import { enc } from '../index'; + +declare const Utf8: typeof enc.Utf8; +export = Utf8; diff --git a/crypto-js/evpkdf/index.d.ts b/crypto-js/evpkdf/index.d.ts new file mode 100644 index 0000000000..8946b9d3a1 --- /dev/null +++ b/crypto-js/evpkdf/index.d.ts @@ -0,0 +1,3 @@ +import { EvpKDF } from '../index'; + +export = EvpKDF; diff --git a/crypto-js/format-hex/index.d.ts b/crypto-js/format-hex/index.d.ts new file mode 100644 index 0000000000..1b0f573824 --- /dev/null +++ b/crypto-js/format-hex/index.d.ts @@ -0,0 +1,4 @@ +import { format } from '../index'; + +declare const Hex: typeof format.Hex; +export = Hex; diff --git a/crypto-js/format-openssl/index.d.ts b/crypto-js/format-openssl/index.d.ts new file mode 100644 index 0000000000..02c35a3688 --- /dev/null +++ b/crypto-js/format-openssl/index.d.ts @@ -0,0 +1,4 @@ +import { format } from '../index'; + +declare const OpenSSL: typeof format.OpenSSL; +export = OpenSSL; diff --git a/crypto-js/hmac-md5/index.d.ts b/crypto-js/hmac-md5/index.d.ts new file mode 100644 index 0000000000..7240576710 --- /dev/null +++ b/crypto-js/hmac-md5/index.d.ts @@ -0,0 +1,3 @@ +import { HmacMD5 } from '../index'; + +export = HmacMD5; diff --git a/crypto-js/hmac-ripemd160/index.d.ts b/crypto-js/hmac-ripemd160/index.d.ts new file mode 100644 index 0000000000..6c371e9435 --- /dev/null +++ b/crypto-js/hmac-ripemd160/index.d.ts @@ -0,0 +1,3 @@ +import { HmacRIPEMD160 } from '../index'; + +export = HmacRIPEMD160; diff --git a/crypto-js/hmac-sha1/index.d.ts b/crypto-js/hmac-sha1/index.d.ts new file mode 100644 index 0000000000..1995cf87f6 --- /dev/null +++ b/crypto-js/hmac-sha1/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA1 } from '../index'; + +export = HmacSHA1; diff --git a/crypto-js/hmac-sha224/index.d.ts b/crypto-js/hmac-sha224/index.d.ts new file mode 100644 index 0000000000..f25334c64c --- /dev/null +++ b/crypto-js/hmac-sha224/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA224 } from '../index'; + +export = HmacSHA224; diff --git a/crypto-js/hmac-sha256/index.d.ts b/crypto-js/hmac-sha256/index.d.ts new file mode 100644 index 0000000000..ca1a1ca267 --- /dev/null +++ b/crypto-js/hmac-sha256/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA256 } from '../index'; + +export = HmacSHA256; diff --git a/crypto-js/hmac-sha3/index.d.ts b/crypto-js/hmac-sha3/index.d.ts new file mode 100644 index 0000000000..0fa0db9321 --- /dev/null +++ b/crypto-js/hmac-sha3/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA3 } from '../index'; + +export = HmacSHA3; diff --git a/crypto-js/hmac-sha384/index.d.ts b/crypto-js/hmac-sha384/index.d.ts new file mode 100644 index 0000000000..2e17420c1b --- /dev/null +++ b/crypto-js/hmac-sha384/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA384 } from '../index'; + +export = HmacSHA384; diff --git a/crypto-js/hmac-sha512/index.d.ts b/crypto-js/hmac-sha512/index.d.ts new file mode 100644 index 0000000000..439b2ffd5e --- /dev/null +++ b/crypto-js/hmac-sha512/index.d.ts @@ -0,0 +1,3 @@ +import { HmacSHA512 } from '../index'; + +export = HmacSHA512; diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index a2c0ee381d..a8068161e1 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -3,6 +3,9 @@ // Definitions by: Michael Zabka // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = CryptoJS; +export as namespace CryptoJS; + declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { type Hash = (message: string, key?: string, ...options: any[]) => string; @@ -112,237 +115,3 @@ declare namespace CryptoJS { } } - -declare module "crypto-js" { - var CryptoJS: CryptoJS.Hashes; - export = CryptoJS; -} - -/* --------------------------------- */ -declare module "crypto-js/core" { - var core: any; - export = core; -} - -declare module "crypto-js/x64-core" { - var x64: any; - export = x64; -} - -declare module "crypto-js/lib-typedarrays" { - var libWordArray: any; - export = libWordArray; -} - -/* --------------------------------- */ -declare module "crypto-js/md5" { - var MD5: CryptoJS.Hash; - export = MD5; -} - -declare module "crypto-js/sha1" { - var SHA1: CryptoJS.Hash; - export = SHA1; -} - -declare module "crypto-js/sha256" { - var SHA256: CryptoJS.Hash; - export = SHA256; -} - -declare module "crypto-js/sha224" { - var SHA224: CryptoJS.Hash; - export = SHA224; -} - -declare module "crypto-js/sha512" { - var SHA512: CryptoJS.Hash; - export = SHA512; -} - -declare module "crypto-js/sha384" { - var SHA384: CryptoJS.Hash; - export = SHA384; -} - -declare module "crypto-js/sha3" { - var SHA3: CryptoJS.Hash; - export = SHA3; -} - -declare module "crypto-js/ripemd160" { - var RIPEMD160: CryptoJS.Hash; - export = RIPEMD160; -} - -/* --------------------------------- */ -declare module "crypto-js/hmac-md5" { - var HmacMD5: CryptoJS.Hash; - export = HmacMD5; -} - -declare module "crypto-js/hmac-sha1" { - var HmacSHA1: CryptoJS.Hash; - export = HmacSHA1; -} - -declare module "crypto-js/hmac-sha256" { - var HmacSHA256: CryptoJS.Hash; - export = HmacSHA256; -} - -declare module "crypto-js/hmac-sha224" { - var HmacSHA224: CryptoJS.Hash; - export = HmacSHA224; -} - -declare module "crypto-js/hmac-sha512" { - var HmacSHA512: CryptoJS.Hash; - export = HmacSHA512; -} - -declare module "crypto-js/hmac-sha384" { - var HmacSHA384: CryptoJS.Hash; - export = HmacSHA384; -} - -declare module "crypto-js/hmac-sha3" { - var HmacSHA3: CryptoJS.Hash; - export = HmacSHA3; -} - -declare module "crypto-js/hmac-ripemd160" { - var HmacRIPEMD160: CryptoJS.Hash; - export = HmacRIPEMD160; -} - -/* --------------------------------- */ -declare module "crypto-js/pbkdf2" { - var PBKDF2: CryptoJS.Hash; - export = PBKDF2; -} - -/* --------------------------------- */ -declare module "crypto-js/aes" { - var AES: CryptoJS.Cipher; - export = AES; -} - -declare module "crypto-js/tripledes" { - var TripleDES: CryptoJS.Cipher; - export = TripleDES; -} - -declare module "crypto-js/rc4" { - var RC4: CryptoJS.Cipher; - export = RC4; -} - -declare module "crypto-js/rabbit" { - var Rabbit: CryptoJS.Cipher; - export = Rabbit; -} - -declare module "crypto-js/rabbit-legacy" { - var RabbitLegacy: CryptoJS.Cipher; - export = RabbitLegacy; -} - -declare module "crypto-js/evpkdf" { - var EvpKDF: CryptoJS.Cipher; - export = EvpKDF; -} - -/* --------------------------------- */ -declare module "crypto-js/format-openssl" { - var FormatOpenssl: any; - export = FormatOpenssl; -} - -declare module "crypto-js/format-hex" { - var FormatHex: any; - export = FormatHex; -} - -/* --------------------------------- */ -declare module "crypto-js/enc-latin1" { - var encLatin1: CryptoJS.Encoder; - export = encLatin1; -} - -declare module "crypto-js/enc-utf8" { - var encUtf8: CryptoJS.Encoder; - export = encUtf8; -} - -declare module "crypto-js/enc-hex" { - var encHex: CryptoJS.Encoder; - export = encHex; -} - -declare module "crypto-js/enc-utf16" { - var encUtf16: CryptoJS.Encoder; - export = encUtf16; -} - -declare module "crypto-js/enc-base64" { - var encBase64: CryptoJS.Encoder; - export = encBase64; -} - -/* --------------------------------- */ -declare module "crypto-js/mode-cfb" { - var modeCFB: CryptoJS.Mode; - export = modeCFB; -} - -declare module "crypto-js/mode-ctr" { - var modeCTR: CryptoJS.Mode; - export = modeCTR; -} - -declare module "crypto-js/mode-ctr-gladman" { - var modeCTRGladman: CryptoJS.Mode; - export = modeCTRGladman; -} - -declare module "crypto-js/mode-ofb" { - var modeOFB: CryptoJS.Mode; - export = modeOFB; -} - -declare module "crypto-js/mode-ecb" { - var modeECB: CryptoJS.Mode; - export = modeECB; -} - -/* --------------------------------- */ -declare module "crypto-js/pad-pkcs7" { - var padPkcs7: CryptoJS.Padding; - export = padPkcs7; -} - -declare module "crypto-js/pad-ansix923" { - var padAnsiX923: CryptoJS.Padding; - export = padAnsiX923; -} - -declare module "crypto-js/pad-iso10126" { - var padIso10126: CryptoJS.Padding; - export = padIso10126; -} - -declare module "crypto-js/pad-iso97971" { - var padIso97971: CryptoJS.Padding; - export = padIso97971; -} - -declare module "crypto-js/pad-zeropadding" { - var padZeroPadding: CryptoJS.Padding; - export = padZeroPadding; -} - -declare module "crypto-js/pad-nopadding" { - var padNoPadding: CryptoJS.Padding; - export = padNoPadding; -} diff --git a/crypto-js/lib-typedarrays/index.d.ts b/crypto-js/lib-typedarrays/index.d.ts new file mode 100644 index 0000000000..91c5a7933b --- /dev/null +++ b/crypto-js/lib-typedarrays/index.d.ts @@ -0,0 +1,2 @@ +declare const libWordArray: any; +export = libWordArray; diff --git a/crypto-js/md5/index.d.ts b/crypto-js/md5/index.d.ts new file mode 100644 index 0000000000..faa064511e --- /dev/null +++ b/crypto-js/md5/index.d.ts @@ -0,0 +1,3 @@ +import { MD5 } from '../index'; + +export = MD5; diff --git a/crypto-js/mode-cfb/index.d.ts b/crypto-js/mode-cfb/index.d.ts new file mode 100644 index 0000000000..74c5c6e3d1 --- /dev/null +++ b/crypto-js/mode-cfb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CFB: typeof mode.CFB; +export = CFB; diff --git a/crypto-js/mode-ctr-gladman/index.d.ts b/crypto-js/mode-ctr-gladman/index.d.ts new file mode 100644 index 0000000000..3ca8f8b367 --- /dev/null +++ b/crypto-js/mode-ctr-gladman/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CTRGladman: typeof mode.CTRGladman; +export = CTRGladman; diff --git a/crypto-js/mode-ctr/index.d.ts b/crypto-js/mode-ctr/index.d.ts new file mode 100644 index 0000000000..6007a4ca88 --- /dev/null +++ b/crypto-js/mode-ctr/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const CTR: typeof mode.CTR; +export = CTR; diff --git a/crypto-js/mode-ecb/index.d.ts b/crypto-js/mode-ecb/index.d.ts new file mode 100644 index 0000000000..569d2b2286 --- /dev/null +++ b/crypto-js/mode-ecb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const ECB: typeof mode.ECB; +export = ECB; diff --git a/crypto-js/mode-ofb/index.d.ts b/crypto-js/mode-ofb/index.d.ts new file mode 100644 index 0000000000..484406979d --- /dev/null +++ b/crypto-js/mode-ofb/index.d.ts @@ -0,0 +1,4 @@ +import { mode } from '../index'; + +declare const OFB: typeof mode.OFB; +export = OFB; diff --git a/crypto-js/pad-ansix923/index.d.ts b/crypto-js/pad-ansix923/index.d.ts new file mode 100644 index 0000000000..2bb6c2dffb --- /dev/null +++ b/crypto-js/pad-ansix923/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const AnsiX923: typeof pad.AnsiX923; +export = AnsiX923; diff --git a/crypto-js/pad-iso10126/index.d.ts b/crypto-js/pad-iso10126/index.d.ts new file mode 100644 index 0000000000..6e52e96197 --- /dev/null +++ b/crypto-js/pad-iso10126/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Iso10126: typeof pad.Iso10126; +export = Iso10126; diff --git a/crypto-js/pad-iso97971/index.d.ts b/crypto-js/pad-iso97971/index.d.ts new file mode 100644 index 0000000000..0ab1cecbfb --- /dev/null +++ b/crypto-js/pad-iso97971/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Iso97971: typeof pad.Iso97971; +export = Iso97971; diff --git a/crypto-js/pad-nopadding/index.d.ts b/crypto-js/pad-nopadding/index.d.ts new file mode 100644 index 0000000000..f71bb2de73 --- /dev/null +++ b/crypto-js/pad-nopadding/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const NoPadding: typeof pad.NoPadding; +export = NoPadding; diff --git a/crypto-js/pad-pkcs7/index.d.ts b/crypto-js/pad-pkcs7/index.d.ts new file mode 100644 index 0000000000..1b194673a2 --- /dev/null +++ b/crypto-js/pad-pkcs7/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const Pkcs7: typeof pad.Pkcs7; +export = Pkcs7; diff --git a/crypto-js/pad-zeropadding/index.d.ts b/crypto-js/pad-zeropadding/index.d.ts new file mode 100644 index 0000000000..cf481402ab --- /dev/null +++ b/crypto-js/pad-zeropadding/index.d.ts @@ -0,0 +1,4 @@ +import { pad } from '../index'; + +declare const ZeroPadding: typeof pad.ZeroPadding; +export = ZeroPadding; diff --git a/crypto-js/pbkdf2/index.d.ts b/crypto-js/pbkdf2/index.d.ts new file mode 100644 index 0000000000..e242e6fe05 --- /dev/null +++ b/crypto-js/pbkdf2/index.d.ts @@ -0,0 +1,3 @@ +import { PBKDF2 } from '../index'; + +export = PBKDF2; diff --git a/crypto-js/rabbit-legacy/index.d.ts b/crypto-js/rabbit-legacy/index.d.ts new file mode 100644 index 0000000000..6befe37563 --- /dev/null +++ b/crypto-js/rabbit-legacy/index.d.ts @@ -0,0 +1,3 @@ +import { RabbitLegacy } from '../index'; + +export = RabbitLegacy; diff --git a/crypto-js/rabbit/index.d.ts b/crypto-js/rabbit/index.d.ts new file mode 100644 index 0000000000..f708a6f20b --- /dev/null +++ b/crypto-js/rabbit/index.d.ts @@ -0,0 +1,3 @@ +import { Rabbit } from '../index'; + +export = Rabbit; diff --git a/crypto-js/rc4/index.d.ts b/crypto-js/rc4/index.d.ts new file mode 100644 index 0000000000..38a929f490 --- /dev/null +++ b/crypto-js/rc4/index.d.ts @@ -0,0 +1,3 @@ +import { RC4 } from '../index'; + +export = RC4; diff --git a/crypto-js/ripemd160/index.d.ts b/crypto-js/ripemd160/index.d.ts new file mode 100644 index 0000000000..90e3e770ce --- /dev/null +++ b/crypto-js/ripemd160/index.d.ts @@ -0,0 +1,3 @@ +import { RIPEMD160 } from '../index'; + +export = RIPEMD160; diff --git a/crypto-js/sha1/index.d.ts b/crypto-js/sha1/index.d.ts new file mode 100644 index 0000000000..14fb4d2a6b --- /dev/null +++ b/crypto-js/sha1/index.d.ts @@ -0,0 +1,3 @@ +import { SHA1 } from '../index'; + +export = SHA1; diff --git a/crypto-js/sha224/index.d.ts b/crypto-js/sha224/index.d.ts new file mode 100644 index 0000000000..3ff1ff4596 --- /dev/null +++ b/crypto-js/sha224/index.d.ts @@ -0,0 +1,3 @@ +import { SHA224 } from '../index'; + +export = SHA224; diff --git a/crypto-js/sha256/index.d.ts b/crypto-js/sha256/index.d.ts new file mode 100644 index 0000000000..59781b01f3 --- /dev/null +++ b/crypto-js/sha256/index.d.ts @@ -0,0 +1,3 @@ +import { SHA256 } from '../index'; + +export = SHA256; diff --git a/crypto-js/sha3/index.d.ts b/crypto-js/sha3/index.d.ts new file mode 100644 index 0000000000..241574a711 --- /dev/null +++ b/crypto-js/sha3/index.d.ts @@ -0,0 +1,3 @@ +import { SHA3 } from '../index'; + +export = SHA3; diff --git a/crypto-js/sha384/index.d.ts b/crypto-js/sha384/index.d.ts new file mode 100644 index 0000000000..5bad55498a --- /dev/null +++ b/crypto-js/sha384/index.d.ts @@ -0,0 +1,3 @@ +import { SHA384 } from '../index'; + +export = SHA384; diff --git a/crypto-js/sha512/index.d.ts b/crypto-js/sha512/index.d.ts new file mode 100644 index 0000000000..0f764329e2 --- /dev/null +++ b/crypto-js/sha512/index.d.ts @@ -0,0 +1,3 @@ +import { SHA512 } from '../index'; + +export = SHA512; diff --git a/crypto-js/tripledes/index.d.ts b/crypto-js/tripledes/index.d.ts new file mode 100644 index 0000000000..ea22173d98 --- /dev/null +++ b/crypto-js/tripledes/index.d.ts @@ -0,0 +1,3 @@ +import { TripleDES } from '../index'; + +export = TripleDES; diff --git a/crypto-js/x64-core/index.d.ts b/crypto-js/x64-core/index.d.ts new file mode 100644 index 0000000000..1ef7a67477 --- /dev/null +++ b/crypto-js/x64-core/index.d.ts @@ -0,0 +1,3 @@ +import * as X64Core from '../index'; + +export = X64Core; From 9be29e7b530932ecc1b0165713a1e49936de78a1 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 15:10:10 +0800 Subject: [PATCH 125/248] add files in tsconfig --- crypto-js/lib-typedarrays/index.d.ts | 4 +-- crypto-js/tsconfig.json | 48 ++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/crypto-js/lib-typedarrays/index.d.ts b/crypto-js/lib-typedarrays/index.d.ts index 91c5a7933b..761e38b1cd 100644 --- a/crypto-js/lib-typedarrays/index.d.ts +++ b/crypto-js/lib-typedarrays/index.d.ts @@ -1,2 +1,2 @@ -declare const libWordArray: any; -export = libWordArray; +declare const LibTypedarrays: any; +export = LibTypedarrays; diff --git a/crypto-js/tsconfig.json b/crypto-js/tsconfig.json index 94793c83ae..7fc335c24a 100644 --- a/crypto-js/tsconfig.json +++ b/crypto-js/tsconfig.json @@ -18,6 +18,50 @@ }, "files": [ "index.d.ts", - "crypto-js-tests.ts" + "crypto-js-tests.ts", + "core/index.d.ts", + "x64-core/index.d.ts", + "lib-typedarrays/index.d.ts", + "md5/index.d.ts", + "sha1/index.d.ts", + "sha256/index.d.ts", + "sha224/index.d.ts", + "sha512/index.d.ts", + "sha384/index.d.ts", + "sha3/index.d.ts", + "ripemd160/index.d.ts", + "hmac-md5/index.d.ts", + "hmac-sha1/index.d.ts", + "hmac-sha256/index.d.ts", + "hmac-sha224/index.d.ts", + "hmac-sha512/index.d.ts", + "hmac-sha384/index.d.ts", + "hmac-sha3/index.d.ts", + "hmac-ripemd160/index.d.ts", + "pbkdf2/index.d.ts", + "aes/index.d.ts", + "tripledes/index.d.ts", + "rc4/index.d.ts", + "rabbit/index.d.ts", + "rabbit-legacy/index.d.ts", + "evpkdf/index.d.ts", + "format-openssl/index.d.ts", + "format-hex/index.d.ts", + "enc-latin1/index.d.ts", + "enc-utf8/index.d.ts", + "enc-hex/index.d.ts", + "enc-utf16/index.d.ts", + "enc-base64/index.d.ts", + "mode-cfb/index.d.ts", + "mode-ctr/index.d.ts", + "mode-ctr-gladman/index.d.ts", + "mode-ofb/index.d.ts", + "mode-ecb/index.d.ts", + "pad-pkcs7/index.d.ts", + "pad-ansix923/index.d.ts", + "pad-iso10126/index.d.ts", + "pad-iso97971/index.d.ts", + "pad-zeropadding/index.d.ts", + "pad-nopadding/index.d.ts" ] -} \ No newline at end of file +} From d2febcc480606fab9d8564fd6e2d77f576ae39d7 Mon Sep 17 00:00:00 2001 From: darlin Date: Wed, 25 Jan 2017 16:03:50 +0800 Subject: [PATCH 126/248] add submodule tests --- crypto-js/index.d.ts | 1 - crypto-js/test/submodule-tests.ts | 184 ++++++++++++++++++++++++++++++ crypto-js/tsconfig.json | 1 + 3 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 crypto-js/test/submodule-tests.ts diff --git a/crypto-js/index.d.ts b/crypto-js/index.d.ts index a8068161e1..07a8d18dfc 100644 --- a/crypto-js/index.d.ts +++ b/crypto-js/index.d.ts @@ -113,5 +113,4 @@ declare namespace CryptoJS { NoPadding: Padding; }; } - } diff --git a/crypto-js/test/submodule-tests.ts b/crypto-js/test/submodule-tests.ts new file mode 100644 index 0000000000..0cfd8cd83f --- /dev/null +++ b/crypto-js/test/submodule-tests.ts @@ -0,0 +1,184 @@ +import Core = require('../core'); +import X64Core = require('../x64-core'); +import LibTypedarrays = require('../lib-typedarrays'); +// --- +import MD5 = require('../md5'); +import SHA1 = require('../sha1'); +import SHA256 = require('../sha256'); +import SHA224 = require('../sha224'); +import SHA512 = require('../sha512'); +import SHA384 = require('../sha384'); +import SHA3 = require('../sha3'); +import RIPEMD160 = require('../ripemd160'); +// --- +import HmacMD5 = require('../hmac-md5'); +import HmacSHA1 = require('../hmac-sha1'); +import HmacSHA256 = require('../hmac-sha256'); +import HmacSHA224 = require('../hmac-sha224'); +import HmacSHA512 = require('../hmac-sha512'); +import HmacSHA384 = require('../hmac-sha384'); +import HmacSHA3 = require('../hmac-sha3'); +import HmacRIPEMD160 = require('../hmac-ripemd160'); +// --- +import PBKDF2 = require('../pbkdf2'); +// --- +import AES = require('../aes'); +import TripleDES = require('../tripledes'); +import RC4 = require('../rc4'); +import Rabbit = require('../rabbit'); +import RabbitLegacy = require('../rabbit-legacy'); +import EvpKDF = require('../evpkdf'); +// --- +import FormatOpenSSL = require('../format-openssl'); +import FormatHex = require('../format-hex'); +// --- +import EncLatin1 = require('../enc-latin1'); +import EncUtf8 = require('../enc-utf8'); +import EncHex = require('../enc-hex'); +import EncUtf16 = require('../enc-utf16'); +import EncBase64 = require('../enc-base64'); +// --- +import ModeCFB = require('../mode-cfb'); +import ModeCTR = require('../mode-ctr'); +import ModeCTRGladman = require('../mode-ctr-gladman'); +import ModeOFB = require('../mode-ofb'); +import ModeECB = require('../mode-ecb'); +// --- +import PadPkcs7 = require('../pad-pkcs7'); +import PadAnsiX923 = require('../pad-ansix923'); +import PadIso10126 = require('../pad-iso10126'); +import PadIso97971 = require('../pad-iso97971'); +import PadZeroPadding = require('../pad-zeropadding'); +import PadNoPadding = require('../pad-nopadding'); + +// Hashers +var str: string; +str = MD5('some message'); +str = MD5('some message', 'some key'); + +str = SHA1('some message'); +str = SHA1('some message', 'some key', { any: true }); + +str = FormatOpenSSL('some message'); +str = FormatOpenSSL('some message', 'some key'); + + +// Ciphers +var encrypted: CryptoJS.WordArray; +var decrypted: CryptoJS.DecryptedMessage; + +encrypted = AES.encrypt("Message", "Secret Passphrase"); +decrypted = AES.decrypt(encrypted, "Secret Passphrase"); + +encrypted = Core.DES.encrypt("Message", "Secret Passphrase"); +decrypted = Core.DES.decrypt(encrypted, "Secret Passphrase"); + +encrypted = TripleDES.encrypt("Message", "Secret Passphrase"); +decrypted = TripleDES.decrypt(encrypted, "Secret Passphrase"); + + +encrypted = Rabbit.encrypt("Message", "Secret Passphrase"); +decrypted = Rabbit.decrypt(encrypted, "Secret Passphrase"); + +encrypted = RC4.encrypt("Message", "Secret Passphrase"); +decrypted = RC4.decrypt(encrypted, "Secret Passphrase"); + +encrypted = Core.RC4Drop.encrypt("Message", "Secret Passphrase"); +encrypted = Core.RC4Drop.encrypt("Message", "Secret Passphrase", { drop: 3072 / 4 }); +decrypted = Core.RC4Drop.decrypt(encrypted, "Secret Passphrase", { drop: 3072 / 4 }); + +var key = EncHex.parse('000102030405060708090a0b0c0d0e0f'); +var iv = EncHex.parse('101112131415161718191a1b1c1d1e1f'); +encrypted = AES.encrypt("Message", key, { iv: iv }); + +encrypted = AES.encrypt("Message", "Secret Passphrase", { + mode: ModeCFB, + padding: PadAnsiX923 +}); + + +// The Cipher Output +encrypted = AES.encrypt("Message", "Secret Passphrase"); +alert(encrypted.key); +// 74eb593087a982e2a6f5dded54ecd96d1fd0f3d44a58728cdcd40c55227522223 +alert(encrypted.iv); +// 7781157e2629b094f0e3dd48c4d786115 +alert(encrypted.salt); +// 7a25f9132ec6a8b34 +alert(encrypted.ciphertext); +// 73e54154a15d1beeb509d9e12f1e462a0 +alert(encrypted); +// U2FsdGVkX1+iX5Ey7GqLND5UFUoV0b7rUJ2eEvHkYqA= + +var JsonFormatter = { + stringify: function(cipherParams: any) { + // create json object with ciphertext + var jsonObj: any = { + ct: cipherParams.ciphertext.toString(EncBase64) + }; + // optionally add iv and salt + if (cipherParams.iv) { + jsonObj.iv = cipherParams.iv.toString(); + } + if (cipherParams.salt) { + jsonObj.s = cipherParams.salt.toString(); + } + // stringify json object + return JSON.stringify(jsonObj); + }, + parse: function (jsonStr: any) { + // parse json string + var jsonObj = JSON.parse(jsonStr); + // extract ciphertext from json object, and create cipher params object + var cipherParams = (Core).lib.CipherParams.create({ + ciphertext: EncBase64.parse(jsonObj.ct) + }); + // optionally extract iv and salt + if (jsonObj.iv) { + cipherParams.iv = EncHex.parse(jsonObj.iv); + } + if (jsonObj.s) { + cipherParams.salt = EncHex.parse(jsonObj.s); + } return cipherParams; + } +}; +encrypted = AES.encrypt("Message", "Secret Passphrase", { + format: JsonFormatter +}); +alert(encrypted); +// {"ct":"tZ4MsEnfbcDOwqau68aOrQ==","iv":"8a8c8fd8fe33743d3638737ea4a00698","s":"ba06373c8f57179c"} +decrypted = AES.decrypt(encrypted, "Secret Passphrase", { + format: JsonFormatter +}); +alert(decrypted.toString(EncUtf8)); // Message + + +// Progressive Ciphering +var key = EncHex.parse('000102030405060708090a0b0c0d0e0f'); +var iv = EncHex.parse('101112131415161718191a1b1c1d1e1f'); +var aesEncryptor = Core.algo.AES.createEncryptor(key, { iv: iv }); +var ciphertextPart1 = aesEncryptor.process("Message Part 1"); +var ciphertextPart2 = aesEncryptor.process("Message Part 2"); +var ciphertextPart3 = aesEncryptor.process("Message Part 3"); +var ciphertextPart4 = aesEncryptor.finalize(); +var aesDecryptor = Core.algo.AES.createDecryptor(key, { iv: iv }); +var plaintextPart1 = aesDecryptor.process(ciphertextPart1); +var plaintextPart2 = aesDecryptor.process(ciphertextPart2); +var plaintextPart3 = aesDecryptor.process(ciphertextPart3); +var plaintextPart4 = aesDecryptor.process(ciphertextPart4); +var plaintextPart5 = aesDecryptor.finalize(); + + +// Encoders +var words = EncBase64.parse('SGVsbG8sIFdvcmxkIQ=='); +var base64 = EncBase64.stringify(words); +var words = EncLatin1.parse('Hello, World!'); +var latin1 = EncLatin1.stringify(words); +var words = EncHex.parse('48656c6c6f2c20576f726c6421'); +var hex = EncHex.stringify(words); +var words = EncUtf8.parse('𤭢'); +var utf8 = EncUtf8.stringify(words); +var words = EncUtf16.parse('Hello, World!'); +var utf16 = EncUtf16.stringify(words); +var words = Core.enc.Utf16LE.parse('Hello, World!'); +var utf16 = Core.enc.Utf16LE.stringify(words); diff --git a/crypto-js/tsconfig.json b/crypto-js/tsconfig.json index 7fc335c24a..10865613d3 100644 --- a/crypto-js/tsconfig.json +++ b/crypto-js/tsconfig.json @@ -19,6 +19,7 @@ "files": [ "index.d.ts", "crypto-js-tests.ts", + "test/submodule-tests.ts", "core/index.d.ts", "x64-core/index.d.ts", "lib-typedarrays/index.d.ts", From 1221959579dc6d1795b05241f291d640751ad3ab Mon Sep 17 00:00:00 2001 From: James Milner Date: Wed, 25 Jan 2017 11:32:22 +0000 Subject: [PATCH 127/248] Adds clickable to marker options Adds clickable to marker options; this is currently omitted for one reason or another --- leaflet/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index c031df81bc..4112082f54 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1397,6 +1397,7 @@ declare namespace L { export interface MarkerOptions extends InteractiveLayerOptions { icon?: Icon; + clickable?: boolean; draggable?: boolean; keyboard?: boolean; title?: string; From e364a9dd6a0627b52a3aed03a86a45391ee54771 Mon Sep 17 00:00:00 2001 From: Kacper Polak Date: Wed, 25 Jan 2017 13:16:39 +0100 Subject: [PATCH 128/248] Add missing options to isInt method Missing options: `allow_leading_zeroes`: https://github.com/chriso/validator.js/blob/master/src/lib/isInt.js#L13 `lt`: https://github.com/chriso/validator.js/blob/master/src/lib/isInt.js#L20 `gt`: https://github.com/chriso/validator.js/blob/master/src/lib/isInt.js#L21 --- validator/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/validator/index.d.ts b/validator/index.d.ts index 0eae66c3c9..57107ae017 100644 --- a/validator/index.d.ts +++ b/validator/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for validator.js v5.7.0 // Project: https://github.com/chriso/validator.js -// Definitions by: tgfjt , Ilya Mochalov , Ayman Nedjmeddine , Louy Alakkad +// Definitions by: tgfjt , Ilya Mochalov , Ayman Nedjmeddine , Louy Alakkad , Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace ValidatorJS { @@ -276,6 +276,9 @@ declare namespace ValidatorJS { interface IsIntOptions { min?: number; max?: number; + allow_leading_zeroes?: boolean; + lt?: number; + gt?: number; } // options for IsLength From d8e58075a061bc85004701690fa512e98fc071a8 Mon Sep 17 00:00:00 2001 From: Kacper Polak Date: Wed, 25 Jan 2017 13:35:27 +0100 Subject: [PATCH 129/248] Increase version number --- validator/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/index.d.ts b/validator/index.d.ts index 57107ae017..ec1a74c19a 100644 --- a/validator/index.d.ts +++ b/validator/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for validator.js v5.7.0 +// Type definitions for validator.js v6.2.1 // Project: https://github.com/chriso/validator.js // Definitions by: tgfjt , Ilya Mochalov , Ayman Nedjmeddine , Louy Alakkad , Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From b2af2d23e5c0ff1f2e74390f6d93752a6631d594 Mon Sep 17 00:00:00 2001 From: Pablo Moleri Date: Wed, 25 Jan 2017 10:29:43 -0300 Subject: [PATCH 130/248] Move getLocation "Axis" overloads before string ones --- webdriverio/index.d.ts | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index f033ec2bfc..b79b17e98d 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -352,37 +352,22 @@ declare namespace WebdriverIO { ): Client

; getHTML

(includeSelectorTag: boolean): Client

; - getLocation(selector?: string): Location; - getLocation(selector: string, axis: Axis): number; getLocation(axis: Axis): number; - getLocation

(selector?: string): Client

; - getLocation

( - selector: string, - axis: Axis - ): Client

; getLocation

(axis: Axis): Client

; + getLocation(selector?: string): Location; + getLocation

(selector?: string): Client

; + getLocation(selector: string, axis: Axis): number; + getLocation

(selector: string, axis: Axis): Client

; - getLocationInView(selector: string): Location; - getLocationInView(selector: string): Location[]; - getLocationInView(): Location; - getLocationInView(): Location[]; - getLocationInView( - selector: string, - axis: Axis - ): number; - getLocationInView( - selector: string, - axis: Axis - ): number[]; getLocationInView(axis: Axis): number; getLocationInView(axis: Axis): number[]; - getLocationInView

(selector?: string): Client

; - getLocationInView

( - selector: string, - axis: Axis - ): Client

; getLocationInView

(axis: Axis): Client

; - + getLocationInView(selector?: string): Location; + getLocationInView(selector?: string): Location[]; + getLocationInView

(selector?: string): Client

; + getLocationInView(selector: string, axis: Axis): number; + getLocationInView(selector: string, axis: Axis): number[]; + getLocationInView

(selector: string, axis: Axis): Client

; getSource(): Client; getSource

(): Client

; From 9294d370402f80b83a397cca709897623ca1f1f1 Mon Sep 17 00:00:00 2001 From: "LAWO\\heinigu1" Date: Wed, 25 Jan 2017 15:58:19 +0100 Subject: [PATCH 131/248] Add tv4 --- chai-json-schema/chai-json-schema-tests.ts | 20 +++++++++++++++++--- chai-json-schema/index.d.ts | 5 +++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/chai-json-schema/chai-json-schema-tests.ts b/chai-json-schema/chai-json-schema-tests.ts index 8559d3caae..d0c1234e17 100644 --- a/chai-json-schema/chai-json-schema-tests.ts +++ b/chai-json-schema/chai-json-schema-tests.ts @@ -9,19 +9,19 @@ import ChaiJsonSchema = require('chai-json-schema'); chai.use(ChaiJsonSchema); chai.should(); -let goodApple = { +const goodApple = { skin: 'thin', colors: ['red', 'green', 'yellow'], taste: 10 }; -let badApple = { +const badApple = { colors: ['brown'], taste: 0, worms: 2 }; -let fruitSchema = { +const fruitSchema = { title: 'fresh fruit schema v1', type: 'object', required: ['skin', 'colors', 'taste'], @@ -54,3 +54,17 @@ badApple.should.not.be.jsonSchema(fruitSchema); //tdd style assert.jsonSchema(goodApple, fruitSchema); assert.notJsonSchema(badApple, fruitSchema); + +// tv4 +const schema = { + items: { + type: 'boolean' + } +}; + +const data1 = [true, false]; +const data2 = [true, 123]; + +expect(chai.tv4.validate(data1, schema)).to.be.true; +expect(chai.tv4.validate(data2, schema)).to.be.false; + diff --git a/chai-json-schema/index.d.ts b/chai-json-schema/index.d.ts index e66e2c96af..1498510f9f 100644 --- a/chai-json-schema/index.d.ts +++ b/chai-json-schema/index.d.ts @@ -5,6 +5,7 @@ // // +import tv4 = require('tv4'); declare global { namespace Chai { @@ -16,6 +17,10 @@ declare global { export interface LanguageChains { jsonSchema(schema: any, msg?: string): void; } + + export interface ChaiStatic { + tv4: tv4.TV4; + } } } From 201dab6133daa473861a04631e2e6bc1abe914a8 Mon Sep 17 00:00:00 2001 From: york yao Date: Wed, 25 Jan 2017 23:58:49 +0800 Subject: [PATCH 132/248] add types of node-zookeeper-client --- node-zookeeper-client/index.d.ts | 168 ++++++++++++ .../node-zookeeper-client-tests.ts | 253 ++++++++++++++++++ node-zookeeper-client/tsconfig.json | 22 ++ node-zookeeper-client/tslint.json | 1 + 4 files changed, 444 insertions(+) create mode 100644 node-zookeeper-client/index.d.ts create mode 100644 node-zookeeper-client/node-zookeeper-client-tests.ts create mode 100644 node-zookeeper-client/tsconfig.json create mode 100644 node-zookeeper-client/tslint.json diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts new file mode 100644 index 0000000000..f405aeffc7 --- /dev/null +++ b/node-zookeeper-client/index.d.ts @@ -0,0 +1,168 @@ +// Type definitions for Jasmine 2.5 +// Project: https://github.com/alexguan/node-zookeeper-client +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as EventEmitter from "events"; + +export class Id { + scheme: string; + id: string; + constructor(scheme: string, id: string); +} + +export class ACL { + perms: number; + id: Id; + constructor(perms: number, id: Id); +} + +export const Permission: { + READ: number, + WRITE: number, + CREATE: number, + DELETE: number, + ADMIN: number, + ALL: number, +}; + +export interface Stat { + czxid: number; + mzxid: number; + ctime: number; + mtime: number; + version: number; + cversion: number; + aversion: number; + ephemeralOwner: number; + dataLength: number; + numChildren: number; + pzxid: number; +} + +export class State { + static DISCONNECTED: State; + static SYNC_CONNECTED: State; + static AUTH_FAILED: State; + static CONNECTED_READ_ONLY: State; + static SASL_AUTHENTICATED: State; + static EXPIRED: State; + + name: string; + code: number; + constructor(name: string, code: number); + toString(): string; +} + +export class Event { + static NODE_CREATED: number; + static NODE_DELETED: number; + static NODE_DATA_CHANGED: number; + static NODE_CHILDREN_CHANGED: number; + type: string; + name: string; + path: string; + constructor(type: string, name: string, path: string); + toString(): string; + getType(): string; + getName(): string; + getPath(): string; +} + +export class Transaction { + create(path: string, dataOrAclsOrmode1?: Buffer | ACL[] | number, dataOrAclsOrmode2?: Buffer | ACL[] | number, dataOrAclsOrmode3?: Buffer | ACL[] | number): this; + setData(path: string, data: Buffer | null, version?: number): this; + check(path: string, version?: number): this; + remove(path: string, version?: number): this; + commit(callback: (error: Error | Exception, results: any) => void): void; +} + +export class Client extends EventEmitter { + connect(): void; + close(): void; + create(path: string, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + create(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, dataOrAclsOrmode3: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + remove(path: string, callback: (error: Error | Exception) => void): void; + remove(path: string, version: number, callback: (error: Error | Exception) => void): void; + exists(path: string, callback: (error: Error | Exception, stat: Stat) => void): void; + exists(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, stat: Stat) => void): void; + getChildren(path: string, callback: (error: Error | Exception, children: string[], stat: Stat) => void): void; + getChildren(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, children: string[], stat: Stat) => void): void; + getData(path: string, callback: (error: Error | Exception, data: Buffer, stat: Stat) => void): void; + getData(path: string, watcher: (event: Event) => void, callback: (error: Error | Exception, data: Buffer, stat: Stat) => void): void; + setData(path: string, data: Buffer | null, callback: (error: Error | Exception, stat: Stat) => void): void; + setData(path: string, data: Buffer | null, version: number, callback: (error: Error | Exception, stat: Stat) => void): void; + getACL(path: string, callback: (error: Error | Exception, acls: ACL[], stat: Stat) => void): void; + setACL(path: string, acls: ACL[], callback: (error: Error | Exception, stat: Stat) => void): void; + setACL(path: string, acls: ACL[], version: number, callback: (error: Error | Exception, stat: Stat) => void): void; + transaction(): Transaction; + mkdirp(path: string, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + mkdirp(path: string, dataOrAclsOrmode1: Buffer | ACL[] | number, dataOrAclsOrmode2: Buffer | ACL[] | number, dataOrAclsOrmode3: Buffer | ACL[] | number, callback: (error: Error | Exception, path: string) => void): void; + addAuthInfo(scheme: string, auth: Buffer): void; + getState(): State; + getSessionId(): Buffer; + getSessionPassword(): Buffer; + getSessionTimeout(): number; + + on(event: "state", cb: (state: State) => void): this; + on(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; + + once(event: "state", cb: (state: State) => void): this; + once(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; + + addListener(event: "state", cb: (state: State) => void): this; + addListener(event: "connected" | "connectedReadOnly" | "disconnected" | "expired" | "authenticationFailed" | string, cb: () => void): this; +} + +export interface Option { + sessionTimeout: number; + spinDelay: number; + retries: number; +} + +export function createClient(connectionString: string, options?: Partial

wonderful world

'); +str = v('

wonderful world

').escapeHtml().value(); +str = v.chain('

wonderful world

').escapeHtml().value(); + +str = v.escapeRegExp(); +str = v.escapeRegExp('(hours)[minutes]{seconds}'); +str = v('(hours)[minutes]{seconds}').escapeRegExp().value(); +str = v.chain('(hours)[minutes]{seconds}').escapeRegExp().value(); + +str = v.unescapeHtml(); +str = v.unescapeHtml('<p>wonderful world</p>'); +str = v('<p>wonderful world</p>').unescapeHtml().value(); +str = v.chain('<p>wonderful world</p>').unescapeHtml().value(); + +// Format +str = v.sprintf(); +str = v.sprintf('%s, %s!', 'Hello', 'World'); +str = v.sprintf('%s costs $%d', 'coffee', 2); +str = v.sprintf('%1$s %2$s %1$s %2$s, watcha gonna %3$s', 'bad', 'boys', 'do') +str = v.sprintf('% 6s', 'bird'); +str = v.sprintf('%d %i %+d', 15, -2, 25); +str = v.sprintf("%06d", 15); +str = v.sprintf('%.2e %g', 100.5, 0.455); +str = v('%s, %s!').sprintf('Hello', 'World').value(); +str = v.chain('%s, %s!').sprintf('Hello', 'World').value(); + +str = v.vprintf(); +str = v.vprintf('%s', ['Welcome']) +str = v.vprintf('%s has %d apples', ['Alexandra', 3]); +str = v('%s').vprintf(['Welcome']).value(); +str = v.chain('%s').vprintf(['Welcome']).value(); + +// Index +num = v.indexOf(); +num = v.indexOf('morning'); +num = v.indexOf('morning', 'n'); +num = v('morning').indexOf('n'); +num = v.chain('morning').indexOf('n').value(); + +num = v.lastIndexOf(); +num = v.lastIndexOf('morning'); +num = v.lastIndexOf('morning', 'n'); +num = v('morning').lastIndexOf('n'); +num = v.chain('morning').lastIndexOf('n').value(); + +num = v.search('morning', /rn/); +num = v.search('evening', '/\d/'); + +// Manipulate +str = v.insert(); +str = v.insert('ct'); +str = v.insert('ct', 'a'); +str = v.insert('ct', 'a', 1); +str = v('ct').insert('a', 1).value(); +str = v.chain('ct').insert('a', 1).value(); + +str = v.latinise(); +str = v.latinise('cafe\u0301'); + +str = v.pad(); +str = v.pad('dog'); +str = v.pad('dog', 5); +str = v.pad('bird', 6, '-'); + +str = v.padLeft(); +str = v.padLeft('dog'); +str = v.padLeft('dog', 5); +str = v.padLeft('bird', 6, '-'); + +str = v.padRight(); +str = v.padRight('dog'); +str = v.padRight('dog', 5); +str = v.padRight('bird', 6, '-'); + +str = v.repeat(); +str = v.repeat('w'); +str = v.repeat('w', 3); + +str = v.replace(); +str = v.replace('swan', 'wa', 'u'); +str = v.replace('domestic duck', /domestic\s/, ''); +str = v.replace('nice duck', /(nice)(duck)/, (match: string, nice: string, duck: string) => { + return 'the ' + duck + ' is ' + nice; +}); + +str = v.replaceAll(); +str = v.replaceAll('good morning', 'o', '*'); +str = v.replaceAll('evening', /n/, 's'); + +str = v.reverse(); +str = v.reverse('winter'); + +str = v.reverseGrapheme(); +str = v.reverseGrapheme('summer'); + +str = v.slugify(); +str = v.slugify('Italian cappuccino drink'); + +str = v.splice(); +str = v.splice('new year'); +str = v.splice('new year', 0); +str = v.splice('new year', 0, 4); +str = v.splice('new year', 0, 3, 'happy'); + +str = v.trim(); +str = v.trim(' Mother nature '); +str = v.trim('--Earth--', '-'); + +str = v.trimLeft(); +str = v.trimLeft(' Starship Troopers'); +str = v.trimLeft('***Mobile Infantry', '*'); + +str = v.trimRight(); +str = v.trimRight('the fire rises '); +str = v.trimRight('do you feel in charge?!!!', '!'); + +str = v.wordWrap(); +str = v.wordWrap('Hello world'); +str = v.wordWrap('Hello world', { + width: 5 +}); +str = v.wordWrap('Hello world', { + width: 5, + newLine: '
', + indent: '__' +}); +str = v.wordWrap('Wonderful world', { + width: 5, + cut: true +}); + +// Query +bool = v.endsWith(); +bool = v.endsWith('red alert'); +bool = v.endsWith('red alert', 'alert'); +bool = v.endsWith('Murphy', 'ph', 5); +bool = v('Murphy').endsWith('ph', 5); +bool = v.chain('Murphy').endsWith('ph', 5).value(); + +bool = v.includes(); +bool = v.includes('starship'); +bool = v.includes('starship', 'star'); +bool = v.includes('galaxy', 'g', 1); +bool = v('galaxy').includes('g', 1); +bool = v.chain('galaxy').includes('g', 1).value(); + +bool = v.isAlpha(); +bool = v.isAlpha('bart'); + +bool = v.isAlphaDigit(); +bool = v.isAlphaDigit('year2020'); + +bool = v.isBlank(); +bool = v.isBlank(''); + +bool = v.isDigit(); +bool = v.isDigit('35'); + +bool = v.isEmpty(); +bool = v.isEmpty(''); + +bool = v.isLowerCase(); +bool = v.isLowerCase('motorcycle'); + +bool = v.isNumeric(); +bool = v.isNumeric('350'); + +bool = v.isString(); +bool = v.isString('vacation'); +bool = v.isString(560); +bool = v('vacation').isString(); +bool = v(560).isString(); +bool = v.chain('vacation').isString().value(); +bool = v.chain(560).isString().value(); + +bool = v.isUpperCase(); +bool = v.isUpperCase('ACDC'); + +bool = v.matches(); +bool = v.matches('pluto'); +bool = v.matches('pluto', /plu.{2}/); +bool = v.matches('sun', 'S', 'i'); +bool = v.matches('apollo 11', '\\d{3}'); + +bool = v.startsWith(); +bool = v.startsWith('say hello to my little friend'); +bool = v.startsWith('say hello to my little friend', 'say hello'); +bool = v.startsWith('tony', 'on', 1); +bool = v.startsWith('the world is yours', 'world'); + +// Split +strAry = v.chars(); +strAry = v.chars('cloud'); + +numAry = v.codePoints(); +numAry = v.codePoints('rain'); + +strAry = v.graphemes(); +strAry = v.graphemes('\uD835\uDC00\uD835\uDC01'); + +strAry = v.split('rage against the dying of the light', ' '); +strAry = v.split('the dying of the light', /\s/, 3); + +strAry = v.words(); +strAry = v.words('gravity can cross dimensions'); +strAry = v.words('Earth gravity', /[^\s]+/g); + +// Strip +str = v.stripBom(); +str = v.stripBom('\uFEFFsummertime sadness'); + +str = v.stripTags(); +str = v.stripTags('Summer is nice'); +str = v.stripTags('Winter is cold', ['b', 'i']); +str = v.stripTags('Sun
set', '', '-'); + +// Util +var voca: v.VocaStatic = v.noConflict(); +var version: String = v.version; From 3deb18520b97f86a82713ac656597360a0f95109 Mon Sep 17 00:00:00 2001 From: Kacper Polak Date: Wed, 25 Jan 2017 21:11:00 +0100 Subject: [PATCH 145/248] Delete tslint.json --- validator/tslint.json | 1 - 1 file changed, 1 deletion(-) delete mode 100644 validator/tslint.json diff --git a/validator/tslint.json b/validator/tslint.json deleted file mode 100644 index 377cc837d4..0000000000 --- a/validator/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../tslint.json" } From 4c4b7eb90069d7eb7acb32bab636c29a3ceddeeb Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Wed, 25 Jan 2017 21:14:54 +0100 Subject: [PATCH 146/248] add defaultCurrentDate --- react-widgets/lib/DateTimePicker.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/react-widgets/lib/DateTimePicker.d.ts b/react-widgets/lib/DateTimePicker.d.ts index 37e1474416..3c4aadde29 100644 --- a/react-widgets/lib/DateTimePicker.d.ts +++ b/react-widgets/lib/DateTimePicker.d.ts @@ -31,6 +31,10 @@ interface DateTimePickerProps extends React.Props { * @default Date() */ currentDate?: Date; + /* + * Default value for current date. Usefull for suggesting a date when the caldenar opens without keep forcing it once 'value' is set. + */ + defaultCurrentDate?: Date /** * Change event Handler that is called when the currentDate is changed. The handler is * called with the currentDate object. From 1ad011f1f6668cc9ea8fe008ca53b6d38dfbd34f Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Wed, 25 Jan 2017 21:22:54 +0100 Subject: [PATCH 147/248] add defaultOpen --- react-widgets/lib/DropdownList.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/react-widgets/lib/DropdownList.d.ts b/react-widgets/lib/DropdownList.d.ts index f8ac6d6579..aac6ba4765 100644 --- a/react-widgets/lib/DropdownList.d.ts +++ b/react-widgets/lib/DropdownList.d.ts @@ -87,10 +87,14 @@ interface DropdownListProps extends React.Props { onSearch?: (searchTerm: string) => void; /** * Whether or not the DropdownList is open. When unset (undefined) the DropdownList will - * handle the opening and closing internally. The defaultOpen prop can be used to set an - * initialization value for uncontrolled widgets. + * handle the opening and closing internally. */ open?: boolean; + /** + * The defaultOpen prop can be used to set an + * initialization value for uncontrolled widgets. + */ + defaultOpen?: boolean; /** * Called when the DropdownList is about to open or close. onToggle should be used when the * open prop is set otherwise the widget open buttons won't work. From f81b13123cfe681d066c39835685b730a74154be Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 15:38:11 -0500 Subject: [PATCH 148/248] Rewrite definitions and tests, add tslint. --- js-md5/index.d.ts | 61 +++++++++++++++++++----------------------- js-md5/js-md5-tests.ts | 44 +++++++++++++++++------------- js-md5/tsconfig.json | 7 +++-- js-md5/tslint.json | 3 +++ 4 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 js-md5/tslint.json diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index db202ed628..9f6d7abc09 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,40 +1,33 @@ -// Type definitions for js-md5 v0.3.1 +// Type definitions for js-md5 v0.4.2 // Project: https://github.com/emn178/js-md5 -// Definitions by: Roland Greim , Michael McCarthy +// Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ -/// +declare namespace md5 { + type message = string | any[] | Uint8Array | ArrayBuffer; -interface JQuery { - md5(value: string): string; - md5(value: Array): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; + interface Md5 { + array: () => number[]; + arrayBuffer: () => ArrayBuffer; + buffer: () => ArrayBuffer; + digest: () => number[]; + finalize: () => void; + hex: () => string; + toString: () => string; + update: (message: message) => Md5; + } + + interface md5 { + (message: message): string; + hex: (message: message) => string; + array: (message: message) => number[]; + digest: (message: message) => number[]; + arrayBuffer: (message: message) => ArrayBuffer; + buffer: (message: message) => ArrayBuffer; + create: () => Md5; + update: (message: message) => Md5; + } } -interface JQueryStatic { - md5(value: string): string; - md5(value: Array): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; -} - -interface md5 { - (value: string): string; - (value: Array): string; - (value: Uint8Array): string; - (value: ArrayBuffer): string; -} - -interface String { - md5(value: string): string; - md5(value: Array): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; -} - -declare module "js-md5" { - export = md5; -} - -declare var md5: md5; +declare const md5: md5.md5; +export = md5; diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index 77b10c09ce..e77ed82d8e 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -1,23 +1,29 @@ +import * as md5 from "js-md5"; +let str: string = md5.hex('The quick brown fox jumps over the lazy dog'); +str = md5('The quick brown fox jumps over the lazy dog'); +let arr: number[] = md5.digest('The quick brown fox jumps over the lazy dog'); +arr = md5.array('The quick brown fox jumps over the lazy dog'); +let buf: ArrayBuffer = md5.arrayBuffer('The quick brown fox jumps over the lazy dog'); +buf = md5.buffer('The quick brown fox jumps over the lazy dog'); -md5('Message to hash'); -md5(''); -md5('中文'); -md5([]); -md5(new Uint8Array([])); -md5(new ArrayBuffer(0)); +const hash1 = md5.create(); +hash1.update('The quick brown fox jumps over the lazy dog'); +str = hash1.hex(); +str = hash1.toString(); +arr = hash1.digest(); +arr = hash1.array(); +buf = hash1.arrayBuffer(); +buf = hash1.buffer(); -$.md5('message'); -$.md5('Message to hash'); -$.md5(''); -$.md5('中文'); -$.md5([]); -$.md5(new Uint8Array([])); -$.md5(new ArrayBuffer(0)); +const hash2 = md5.update('The quick brown fox jumps over the lazy dog'); +str = hash2.hex(); +str = hash2.toString(); +arr = hash2.digest(); +arr = hash2.array(); +buf = hash2.arrayBuffer(); +buf = hash2.buffer(); -'message'.md5('Message to hash'); -'message'.md5(''); -'message'.md5('中文'); -'message'.md5([]); -'message'.md5(new Uint8Array([])); -'message'.md5(new ArrayBuffer(0)); \ No newline at end of file +str = md5([]); +str = md5(new Uint8Array([])); +str = md5(new ArrayBuffer(0)); diff --git a/js-md5/tsconfig.json b/js-md5/tsconfig.json index eceeb1fb3d..f0ae291e30 100644 --- a/js-md5/tsconfig.json +++ b/js-md5/tsconfig.json @@ -2,12 +2,11 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +19,4 @@ "index.d.ts", "js-md5-tests.ts" ] -} \ No newline at end of file +} diff --git a/js-md5/tslint.json b/js-md5/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/js-md5/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From cf15d34bc47ea7a7b4e553ebb749e76e91bf36b7 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 15:44:52 -0500 Subject: [PATCH 149/248] Replace stray tab with spaces --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 9f6d7abc09..f28a3eef80 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -22,7 +22,7 @@ declare namespace md5 { hex: (message: message) => string; array: (message: message) => number[]; digest: (message: message) => number[]; - arrayBuffer: (message: message) => ArrayBuffer; + arrayBuffer: (message: message) => ArrayBuffer; buffer: (message: message) => ArrayBuffer; create: () => Md5; update: (message: message) => Md5; From 0b4f4a2538fcae6fd25fd4c4e99e3b576cbf8746 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:09:28 -0500 Subject: [PATCH 150/248] Edit import to use require, fix version number --- js-md5/index.d.ts | 2 +- js-md5/js-md5-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index f28a3eef80..4f1a1b351e 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.4.2 +// Type definitions for js-md5 v0.4 // Project: https://github.com/emn178/js-md5 // Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index e77ed82d8e..231b12ebf2 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -1,4 +1,4 @@ -import * as md5 from "js-md5"; +import md5 = require("js-md5"); let str: string = md5.hex('The quick brown fox jumps over the lazy dog'); str = md5('The quick brown fox jumps over the lazy dog'); From cfdd4d3496b96711bc9fa2600213a9dd244875a2 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:13:11 -0500 Subject: [PATCH 151/248] Remove v from version number --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 4f1a1b351e..41f19fba42 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.4 +// Type definitions for js-md5 0.4 // Project: https://github.com/emn178/js-md5 // Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ From fbe1aee12d05e849bb728896a20b1b30e53758f8 Mon Sep 17 00:00:00 2001 From: Jeff Kenney Date: Wed, 25 Jan 2017 11:58:55 -0800 Subject: [PATCH 152/248] knex: use import = require() syntax --- knex/index.d.ts | 4 ++-- knex/knex-tests.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/knex/index.d.ts b/knex/index.d.ts index 910bab9d04..5196f47eb0 100644 --- a/knex/index.d.ts +++ b/knex/index.d.ts @@ -6,8 +6,8 @@ /// /// -import * as events from "events"; -import * as Promise from "bluebird"; +import events = require("events"); +import Promise = require("bluebird"); type Callback = Function; type Client = Function; diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index 8c1878760b..420aafd724 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -1,7 +1,7 @@ "use strict"; -import * as Knex from 'knex'; -import * as Promise from 'bluebird'; -import * as _ from 'lodash'; +import Knex = require('knex'); +import Promise = require('bluebird'); +import _ = require('lodash'); // Initializing the Library var knex = Knex({ From 82634e7bfbc82d4224e20fc3561fc91b91875672 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:27:38 -0500 Subject: [PATCH 153/248] Remove finalize from Md5 interface --- js-md5/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 41f19fba42..690279bbe4 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -11,7 +11,6 @@ declare namespace md5 { arrayBuffer: () => ArrayBuffer; buffer: () => ArrayBuffer; digest: () => number[]; - finalize: () => void; hex: () => string; toString: () => string; update: (message: message) => Md5; From 68f67afc33480c9e218fe5d8c31b26b1e07b0c93 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Wed, 25 Jan 2017 22:34:16 +0100 Subject: [PATCH 154/248] fix semicolon and add DateTimePicker defaultOpen --- react-widgets/lib/DateTimePicker.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/react-widgets/lib/DateTimePicker.d.ts b/react-widgets/lib/DateTimePicker.d.ts index 3c4aadde29..fe090507d3 100644 --- a/react-widgets/lib/DateTimePicker.d.ts +++ b/react-widgets/lib/DateTimePicker.d.ts @@ -34,7 +34,7 @@ interface DateTimePickerProps extends React.Props { /* * Default value for current date. Usefull for suggesting a date when the caldenar opens without keep forcing it once 'value' is set. */ - defaultCurrentDate?: Date + defaultCurrentDate?: Date; /** * Change event Handler that is called when the currentDate is changed. The handler is * called with the currentDate object. @@ -97,11 +97,16 @@ interface DateTimePickerProps extends React.Props { onSelect?: (date?: Date) => void; /** * Whether or not the DateTimePicker is open. When unset (undefined) the DateTimePicker will - * handle the opening and closing internally. The defaultOpen prop can be used to set an - * initialization value for uncontrolled widgets. + * handle the opening and closing internally. * @enum false "calendar" "time" */ open?: boolean | "calendar" | "time"; + /** + * The defaultOpen prop can be used to set an + * initialization value for uncontrolled widgets. + * @enum false "calendar" "time" + */ + defaultOpen?: boolean | "calendar" | "time"; /** * Called when the DateTimePicker is about to open or close. onToggle should be used when * the open prop is set otherwise the widget will never open or close. From 1934bbf00f9981b0250c5a57db046b5318eb7c2c Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Wed, 25 Jan 2017 23:04:21 +0100 Subject: [PATCH 155/248] switch tab -> spaces --- react-widgets/lib/DateTimePicker.d.ts | 2 +- react-widgets/lib/DropdownList.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-widgets/lib/DateTimePicker.d.ts b/react-widgets/lib/DateTimePicker.d.ts index fe090507d3..6428927cf4 100644 --- a/react-widgets/lib/DateTimePicker.d.ts +++ b/react-widgets/lib/DateTimePicker.d.ts @@ -31,7 +31,7 @@ interface DateTimePickerProps extends React.Props { * @default Date() */ currentDate?: Date; - /* + /* * Default value for current date. Usefull for suggesting a date when the caldenar opens without keep forcing it once 'value' is set. */ defaultCurrentDate?: Date; diff --git a/react-widgets/lib/DropdownList.d.ts b/react-widgets/lib/DropdownList.d.ts index aac6ba4765..52a8e83a99 100644 --- a/react-widgets/lib/DropdownList.d.ts +++ b/react-widgets/lib/DropdownList.d.ts @@ -90,11 +90,11 @@ interface DropdownListProps extends React.Props { * handle the opening and closing internally. */ open?: boolean; - /** + /** * The defaultOpen prop can be used to set an * initialization value for uncontrolled widgets. */ - defaultOpen?: boolean; + defaultOpen?: boolean; /** * Called when the DropdownList is about to open or close. onToggle should be used when the * open prop is set otherwise the widget open buttons won't work. From df1efcebfb309e85d4d22cccec8cd42b6a9236bb Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 25 Jan 2017 14:08:40 -0800 Subject: [PATCH 156/248] Issue template: Clarify that authors should be found in the header --- ISSUE_TEMPLATE.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index a9ae498738..252df5994f 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,5 +1,4 @@ -- [ ] I tried using the latest `xxxx/xxxx.d.ts` file in this repo and had problems. +- [ ] I tried using the `@types/xxxx` package and had problems. - [ ] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript - [ ] I have a question that is inappropriate for [StackOverflow](https://stackoverflow.com/). (Please ask any appropriate questions there). -- [ ] I want to talk about `xxxx/xxxx.d.ts`. - - The authors of that type definition are cc/ @.... +- The authors (see `Definitions by:` in `index.d.ts`) are cc/ @.... From 59244e309ee9dbf6de35e3c9a8454940e4d70dff Mon Sep 17 00:00:00 2001 From: york yao Date: Thu, 26 Jan 2017 07:26:23 +0800 Subject: [PATCH 157/248] add typescript version --- node-zookeeper-client/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts index f405aeffc7..cb9979e9f4 100644 --- a/node-zookeeper-client/index.d.ts +++ b/node-zookeeper-client/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/alexguan/node-zookeeper-client // Definitions by: York Yao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// From 2157659af755ca9ab5fc959562f5033c5d7a1398 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Wed, 25 Jan 2017 20:11:21 -0500 Subject: [PATCH 158/248] Add type definitions for semantic-ui. --- semantic-ui/index.d.ts | 5434 ++++++++++++++++++++++++++++++ semantic-ui/semantic-ui-tests.ts | 140 + semantic-ui/tsconfig.json | 20 + semantic-ui/tslint.json | 3 + 4 files changed, 5597 insertions(+) create mode 100644 semantic-ui/index.d.ts create mode 100644 semantic-ui/semantic-ui-tests.ts create mode 100644 semantic-ui/tsconfig.json create mode 100644 semantic-ui/tslint.json diff --git a/semantic-ui/index.d.ts b/semantic-ui/index.d.ts new file mode 100644 index 0000000000..0c8ddda9be --- /dev/null +++ b/semantic-ui/index.d.ts @@ -0,0 +1,5434 @@ +// Type definitions for Semantic UI 2.2 +// Project: http://semantic-ui.com/ +// Definitions by: Leonard Thieu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +// tslint:disable:unified-signatures + +interface JQuery { + // TODO: Do all modules have a 'setting' behavior? + + // region Modules + + // region Accordion + + /** + * Refreshes all cached selectors and data + */ + accordion(behavior: 'refresh'): JQuery; + /** + * Opens accordion content at index + */ + accordion(behavior: 'open', index: number): JQuery; + /** + * Closes accordion content that are not active + */ + accordion(behavior: 'close others'): JQuery; + /** + * Closes accordion content at index + */ + accordion(behavior: 'close', index: number): JQuery; + /** + * Toggles accordion content at index + */ + accordion(behavior: 'toggle', index: number): JQuery; + accordion(settings: SemanticUI.AccordionSettings): JQuery; + accordion(): JQuery; + + // endregion + + // region Checkbox + + /** + * Switches a checkbox from current state + */ + checkbox(behavior: 'toggle'): JQuery; + /** + * Set a checkbox state to checked + */ + checkbox(behavior: 'check'): JQuery; + /** + * Set a checkbox state to unchecked + */ + checkbox(behavior: 'uncheck'): JQuery; + /** + * Set as indeterminate checkbox + */ + checkbox(behavior: 'indeterminate'): JQuery; + /** + * Set as determinate checkbox + */ + checkbox(behavior: 'determinate'): JQuery; + /** + * Enable interaction with a checkbox + */ + checkbox(behavior: 'enable'): JQuery; + /** + * Set a checkbox state to checked without callbacks + */ + checkbox(behavior: 'set checked'): JQuery; + /** + * Set a checkbox state to unchecked without callbacks + */ + checkbox(behavior: 'set unchecked'): JQuery; + /** + * Set as indeterminate checkbox without callbacks + */ + checkbox(behavior: 'set indeterminate'): JQuery; + /** + * Set as determinate checkbox without callbacks + */ + checkbox(behavior: 'set determinate'): JQuery; + /** + * Enable interaction with a checkbox without callbacks + */ + checkbox(behavior: 'set enabled'): JQuery; + /** + * Disable interaction with a checkbox without callbacks + */ + checkbox(behavior: 'set disabled'): JQuery; + /** + * Attach checkbox events to another element + */ + checkbox(behavior: 'attach events', selector: string, event: string): JQuery; + /** + * Returns whether element is radio selection + */ + checkbox(behavior: 'is radio'): boolean; + /** + * Returns whether element is currently checked + */ + checkbox(behavior: 'is checked'): boolean; + /** + * Returns whether element is not checked + */ + checkbox(behavior: 'is unchecked'): boolean; + /** + * Returns whether element is able to be changed + */ + checkbox(behavior: 'can change'): boolean; + /** + * Returns whether element can be checked (checking if already checked or `beforeChecked` would cancel) + */ + checkbox(behavior: 'should allow check'): boolean; + /** + * Returns whether element can be unchecked (checking if already unchecked or `beforeUnchecked` would cancel) + */ + checkbox(behavior: 'should allow uncheck'): boolean; + /** + * Returns whether element can be determinate (checking if already determinate or `beforeDeterminate` would cancel) + */ + checkbox(behavior: 'should allow determinate'): boolean; + /** + * Returns whether element can be indeterminate (checking if already indeterminate or `beforeIndeterminate` would cancel) + */ + checkbox(behavior: 'should allow indeterminate'): boolean; + /** + * Returns whether element is able to be unchecked + */ + checkbox(behavior: 'can uncheck'): boolean; + checkbox(settings: SemanticUI.CheckboxSettings): JQuery; + checkbox(): JQuery; + + // endregion + + // region Dimmer + + /** + * Detaches a given element from DOM and reattaches element inside dimmer + */ + dimmer(behavior: 'add content', element: SemanticUI.Selector): JQuery; + /** + * Shows dimmer + */ + dimmer(behavior: 'show'): JQuery; + /** + * Hides dimmer + */ + dimmer(behavior: 'hide'): JQuery; + /** + * Toggles current dimmer visibility + */ + dimmer(behavior: 'toggle'): JQuery; + /** + * Changes dimmer opacity + */ + dimmer(behavior: 'set opacity', opacity: number): JQuery; + /** + * Creates a new dimmer in dimmable context + */ + dimmer(behavior: 'create'): JQuery; + /** + * Returns current duration for show or hide event depending on current visibility + */ + dimmer(behavior: 'get duration'): number; + /** + * Returns DOM element for dimmer + */ + dimmer(behavior: 'get dimmer'): JQuery; + /** + * Returns whether current dimmable has a dimmer + */ + dimmer(behavior: 'has dimmer'): boolean; + /** + * Whether section's dimmer is active + */ + dimmer(behavior: 'is active'): boolean; + /** + * Whether dimmer is animating + */ + dimmer(behavior: 'is animating'): boolean; + /** + * Whether current element is a dimmer + */ + dimmer(behavior: 'is dimmer'): boolean; + /** + * Whether current element is a dimmable section + */ + dimmer(behavior: 'is dimmable'): boolean; + /** + * Whether dimmer is disabled + */ + dimmer(behavior: 'is disabled'): boolean; + /** + * Whether dimmer is not disabled + */ + dimmer(behavior: 'is enabled'): boolean; + /** + * Whether dimmable section is body + */ + dimmer(behavior: 'is page'): boolean; + /** + * Whether dimmer is a page dimmer + */ + dimmer(behavior: 'is page dimmer'): boolean; + /** + * Sets page dimmer to active + */ + dimmer(behavior: 'set active'): JQuery; + /** + * Sets an element as a dimmable section + */ + dimmer(behavior: 'set dimmable'): JQuery; + /** + * Sets a dimmable section as dimmed + */ + dimmer(behavior: 'set dimmed'): JQuery; + /** + * Sets current dimmer as a page dimmer + */ + dimmer(behavior: 'set page dimmer'): JQuery; + /** + * Sets a dimmer as disabled + */ + dimmer(behavior: 'set disabled'): JQuery; + dimmer(settings: SemanticUI.DimmerSettings): JQuery; + dimmer(): JQuery; + + // endregion + + // region Dropdown + + // TODO: Should 'value'/'values' parameters be of type 'string' instead of 'any'? + + /** + * Recreates dropdown menu from select option values. + */ + dropdown(behavior: 'setup menu'): JQuery; + /** + * Refreshes all cached selectors and data + */ + dropdown(behavior: 'refresh'): JQuery; + /** + * Toggles current visibility of dropdown + */ + dropdown(behavior: 'toggle'): JQuery; + /** + * Shows dropdown + */ + dropdown(behavior: 'show'): JQuery; + /** + * Hides dropdown + */ + dropdown(behavior: 'hide'): JQuery; + /** + * Clears dropdown of selection + */ + dropdown(behavior: 'clear'): JQuery; + /** + * Hides all other dropdowns that is not current dropdown + */ + dropdown(behavior: 'hide others'): JQuery; + /** + * Restores dropdown text and value to its value on page load + */ + dropdown(behavior: 'restore defaults'): JQuery; + /** + * Restores dropdown text to its value on page load + */ + dropdown(behavior: 'restore default text'): JQuery; + /** + * Restores dropdown text to its prompt, placeholder text + */ + dropdown(behavior: 'restore placeholder text'): JQuery; + /** + * Restores dropdown value to its value on page load + */ + dropdown(behavior: 'restore default value'): JQuery; + /** + * Saves current text and value as new defaults (for use with restore) + */ + dropdown(behavior: 'save defaults'): JQuery; + /** + * Sets value as selected + */ + dropdown(behavior: 'set selected', value: any): JQuery; + /** + * Remove value from selected + */ + dropdown(behavior: 'remove selected', value: any): JQuery; + /** + * Adds a group of values as selected + */ + dropdown(behavior: 'set selected', values: any[]): JQuery; + /** + * Sets selected values to exactly specified values, removing current selection + */ + dropdown(behavior: 'set exactly', values: any[]): JQuery; + /** + * Sets dropdown text to a value + */ + dropdown(behavior: 'set text', text: string): JQuery; + /** + * Sets dropdown input to value (does not update display state) + */ + dropdown(behavior: 'set value', value: any): JQuery; + /** + * Returns current dropdown text + */ + dropdown(behavior: 'get text'): string; + /** + * Returns current dropdown input value + */ + dropdown(behavior: 'get value'): any; + /** + * Returns DOM element that matches a given input value + */ + dropdown(behavior: 'get item', value: any): JQuery; + /** + * Adds touch events to element + */ + dropdown(behavior: 'bind touch events'): JQuery; + /** + * Adds mouse events to element + */ + dropdown(behavior: 'bind mouse events'): JQuery; + /** + * Binds a click to document to determine if you click away from a dropdown + */ + dropdown(behavior: 'bind intent'): JQuery; + /** + * Unbinds document intent click + */ + dropdown(behavior: 'unbind intent'): JQuery; + /** + * Returns whether event occurred inside dropdown + */ + dropdown(behavior: 'determine intent'): boolean; + /** + * Triggers preset item selection action based on settings passing text/value + */ + dropdown(behavior: 'determine select action', text: string, value: any): JQuery; + /** + * Sets dropdown to active state + */ + dropdown(behavior: 'set active'): JQuery; + /** + * Sets dropdown to visible state + */ + dropdown(behavior: 'set visible'): JQuery; + /** + * Removes dropdown active state + */ + dropdown(behavior: 'remove active'): JQuery; + /** + * Removes dropdown visible state + */ + dropdown(behavior: 'remove visible'): JQuery; + /** + * Returns whether dropdown is a selection dropdown + */ + dropdown(behavior: 'is selection'): boolean; + /** + * Returns whether dropdown is animated + */ + dropdown(behavior: 'is animated'): boolean; + /** + * Returns whether dropdown is visible + */ + dropdown(behavior: 'is visible'): boolean; + /** + * Returns whether dropdown is hidden + */ + dropdown(behavior: 'is hidden'): boolean; + /** + * Returns dropdown value as set on page load + */ + dropdown(behavior: 'get default text'): string; + /** + * Returns placeholder text + */ + dropdown(behavior: 'get placeholder text'): string; + dropdown(settings: SemanticUI.DropdownSettings): JQuery; + dropdown(): JQuery; + + // endregion + + // region Embed + + /** + * Changes iframe to a new content source + */ + embed(behavior: 'change', source: string, id: string, url: string): JQuery; + /** + * Removes embed and shows placeholder content if available + */ + embed(behavior: 'reset'): JQuery; + /** + * Shows embed content + */ + embed(behavior: 'show'): JQuery; + /** + * Hides embed content and shows placeholder content + */ + embed(behavior: 'hide'): JQuery; + /** + * Returns current content id + */ + embed(behavior: 'get id'): string; + /** + * Returns placeholder image url + */ + embed(behavior: 'get placeholder'): string; + /** + * Returns source name + */ + embed(behavior: 'get sources'): string; + /** + * Returns source type + */ + embed(behavior: 'get type'): string; + /** + * Returns URL with all parameters added + */ + embed(behavior: 'get url'): string; + /** + * Returns whether embed content has placeholder + */ + embed(behavior: 'has placeholder'): boolean; + /** + * Destroys instance and removes all events + */ + embed(behavior: 'destroy'): JQuery; + embed(settings: SemanticUI.EmbedSettings): JQuery; + embed(): JQuery; + + // endregion + + // region Modal + + /** + * Shows the modal + */ + modal(behavior: 'show'): JQuery; + /** + * Hides the modal + */ + modal(behavior: 'hide'): JQuery; + /** + * Toggles the modal + */ + modal(behavior: 'toggle'): JQuery; + /** + * Refreshes centering of modal on page + */ + modal(behavior: 'refresh'): JQuery; + /** + * Shows associated page dimmer + */ + modal(behavior: 'show dimmer'): JQuery; + /** + * Hides associated page dimmer + */ + modal(behavior: 'hide dimmer'): JQuery; + /** + * Hides all modals not selected modal in a dimmer + */ + modal(behavior: 'hide others'): JQuery; + /** + * Hides all visible modals in the same dimmer + */ + modal(behavior: 'hide all'): JQuery; + /** + * Caches current modal size + */ + modal(behavior: 'cache sizes'): JQuery; + /** + * Returns whether the modal can fit on the page + */ + modal(behavior: 'can fit'): boolean; + /** + * Returns whether the modal is active + */ + modal(behavior: 'is active'): boolean; + /** + * Sets modal to active + */ + modal(behavior: 'set active'): JQuery; + modal(behavior: 'attach events', selector: SemanticUI.Selector, event?: string): JQuery; + modal(behavior: 'setting', name: string, value: any): JQuery; + modal(settings: SemanticUI.ModalSettings): JQuery; + modal(): JQuery; + + // endregion + + // region Nag + + // TODO: Documentation is lacking. Is it possible to infer intended behaviors? + + nag(behavior: 'show'): JQuery; + /** + * Clears cookie so nag shows again + */ + nag(behavior: 'clear'): JQuery; + nag(settings: SemanticUI.NagSettings): JQuery; + + // endregion + + // region Popup + + /** + * Shows popup + */ + popup(behavior: 'show'): JQuery; + /** + * Hides popup + */ + popup(behavior: 'hide'): JQuery; + /** + * Hides all visible pop ups on the page + */ + popup(behavior: 'hide all'): JQuery; + /** + * Returns current popup dom element + */ + popup(behavior: 'get popup'): JQuery; + /** + * Changes current popup content + */ + popup(behavior: 'change content', html: string): JQuery; + /** + * Toggles visibility of popup + */ + popup(behavior: 'toggle'): JQuery; + /** + * Returns whether popup is visible + */ + popup(behavior: 'is visible'): boolean; + /** + * Returns whether popup is hidden + */ + popup(behavior: 'is hidden'): boolean; + /** + * Returns whether popup is created and inserted into the page + */ + popup(behavior: 'exists'): boolean; + /** + * Adjusts popup when content size changes (only necessary for centered popups) + */ + popup(behavior: 'reposition'): JQuery; + /** + * Repositions a popup + */ + popup(behavior: 'set position', position: string): JQuery; + /** + * Removes popup from the page and removes all events + */ + popup(behavior: 'destroy'): JQuery; + /** + * Removes popup from the page + */ + popup(behavior: 'remove popup'): JQuery; + popup(settings: SemanticUI.PopupSettings): JQuery; + popup(): JQuery; + + // endregion + + // region Progress + + /** + * Sets current percent of progress to value. If using a total will convert from percent to estimated value. + */ + progress(behavior: 'set percent', percent: number): JQuery; + /** + * Sets progress to specified value. Will automatically calculate percent from total. + */ + progress(behavior: 'set progress', value: number): JQuery; + /** + * Increments progress by increment value, if not passed a value will use random amount specified in settings + */ + progress(behavior: 'increment', incrementValue: number): JQuery; + /** + * Decrements progress by decrement value, if not passed a value will use random amount specified in settings + */ + progress(behavior: 'decrement', decrementValue: number): JQuery; + /** + * Immediately updates progress to value, ignoring progress animation interval delays + */ + progress(behavior: 'update progress', value: number): JQuery; + /** + * Finishes progress and sets loaded to 100% + */ + progress(behavior: 'complete'): JQuery; + /** + * Resets progress to zero + */ + progress(behavior: 'reset'): JQuery; + /** + * Set total to a new value + */ + progress(behavior: 'set total', total: number): JQuery; + /** + * Replaces templated string with value, total, percent left and percent. + */ + progress(behavior: 'get text', text: string): string; + /** + * Returns normalized value inside acceptable range specified by total. + */ + progress(behavior: 'get normalized value', value: number): number; + /** + * Returns percent as last specified + */ + progress(behavior: 'get percent'): number; + /** + * Returns current progress value + */ + progress(behavior: 'get value'): number; + /** + * Returns total + */ + progress(behavior: 'get total'): number; + /** + * Returns whether progress is completed + */ + progress(behavior: 'is complete'): boolean; + /** + * Returns whether progress was a success + */ + progress(behavior: 'is success'): boolean; + /** + * Returns whether progress is in warning state + */ + progress(behavior: 'is warning'): boolean; + /** + * Returns whether progress is in error state + */ + progress(behavior: 'is error'): boolean; + /** + * Returns whether progress is in active state + */ + progress(behavior: 'is active'): boolean; + /** + * Sets progress to active state + */ + progress(behavior: 'set active'): JQuery; + /** + * Sets progress to warning state + */ + progress(behavior: 'set warning'): JQuery; + /** + * Sets progress to success state + */ + progress(behavior: 'set success'): JQuery; + /** + * Sets progress to error state + */ + progress(behavior: 'set error'): JQuery; + /** + * Changes progress animation speed + */ + progress(behavior: 'set duration', value: number): JQuery; + /** + * Sets progress exterior label to text + */ + progress(behavior: 'set label', text: string): JQuery; + /** + * Sets progress bar label to text + */ + progress(behavior: 'set bar label', text: string): JQuery; + /** + * Removes progress to active state + */ + progress(behavior: 'remove active'): JQuery; + /** + * Removes progress to warning state + */ + progress(behavior: 'remove warning'): JQuery; + /** + * Removes progress to success state + */ + progress(behavior: 'remove success'): JQuery; + /** + * Removes progress to error state + */ + progress(behavior: 'remove error'): JQuery; + progress(settings: SemanticUI.ProgressSettings): JQuery; + progress(): JQuery; + + // endregion + + // region Rating + + /** + * Sets rating programmatically + */ + rating(behavior: 'set rating', rating: number): JQuery; + /** + * Gets current rating + */ + rating(behavior: 'get rating'): number; + /** + * Disables interactive rating mode + */ + rating(behavior: 'disable'): JQuery; + /** + * Enables interactive rating mode + */ + rating(behavior: 'enable'): JQuery; + /** + * Clears current rating + */ + rating(behavior: 'clear rating'): JQuery; + rating(settings: SemanticUI.RatingSettings): JQuery; + rating(): JQuery; + + // endregion + + // region Search + + /** + * Search for value currently set in search input + */ + search(behavior: 'query'): JQuery; + /** + * Displays message in search results with text, using template matching type + */ + search(behavior: 'display message', text: string, type: string): JQuery; + /** + * Cancels current remote search query + */ + search(behavior: 'cancel query'): JQuery; + /** + * Search local object for specified query and display results + */ + search(behavior: 'search local', query: string): JQuery; + /** + * Whether has minimum characters + */ + search(behavior: 'has minimum characters'): boolean; + /** + * Search remote endpoint for specified query and display results + */ + search(behavior: 'search remote', query: string): JQuery; + /** + * Search object for specified query and return results + */ + search(behavior: 'search object', query: string, object: any, searchFields: string[]): any; + /** + * Cancels current remote search request + */ + search(behavior: 'cancel query'): JQuery; + /** + * Whether search is currently focused + */ + search(behavior: 'is focused'): boolean; + /** + * Whether search results are visible + */ + search(behavior: 'is visible'): boolean; + /** + * Whether search results are empty + */ + search(behavior: 'is empty'): boolean; + /** + * Returns current search value + */ + search(behavior: 'get value'): any; + /** + * Returns JSON object matching searched title or id (see above) + */ + search(behavior: 'get result', value: any): any; + /** + * Sets search input to value + */ + search(behavior: 'set value', value: any): JQuery; + /** + * Reads cached results for query + */ + search(behavior: 'read cache', query: string): JQuery; + /** + * Clears value from cache, if no parameter passed clears all cache + */ + search(behavior: 'clear cache', query?: string): JQuery; + /** + * Writes cached results for query + */ + search(behavior: 'write cache', query: string): JQuery; + /** + * Adds HTML to results and displays + */ + search(behavior: 'add results', html: string): JQuery; + /** + * Shows results container + */ + search(behavior: 'show results'): JQuery; + /** + * Hides results container + */ + search(behavior: 'hide results'): JQuery; + /** + * Generates results using parser specified by settings.template + */ + search(behavior: 'generate results', response: any): JQuery; + /** + * Removes all events + */ + search(behavior: 'destroy'): JQuery; + search(settings: SemanticUI.SearchSettings): JQuery; + search(): JQuery; + + // endregion + + // region Shape + + /** + * Flips the shape upward + */ + shape(behavior: 'flip up'): JQuery; + /** + * Flips the shape downward + */ + shape(behavior: 'flip down'): JQuery; + /** + * Flips the shape right + */ + shape(behavior: 'flip right'): JQuery; + /** + * Flips the shape left + */ + shape(behavior: 'flip left'): JQuery; + /** + * Flips the shape over clock-wise + */ + shape(behavior: 'flip over'): JQuery; + /** + * Flips the shape over counter-clockwise + */ + shape(behavior: 'flip back'): JQuery; + /** + * Set the next side to a specific selector + */ + shape(behavior: 'set next side', selector: SemanticUI.Selector): JQuery; + /** + * Returns whether shape is currently animating + */ + shape(behavior: 'is animating'): boolean; + /** + * Removes all inline styles + */ + shape(behavior: 'reset'): JQuery; + /** + * Queues an animation until after current animation + */ + shape(behavior: 'queue', animation: string): JQuery; + /** + * Forces a reflow on element + */ + shape(behavior: 'repaint'): JQuery; + /** + * Set the next side to next sibling to active element + */ + shape(behavior: 'set default side'): JQuery; + /** + * Sets shape to the content size of the next side + */ + shape(behavior: 'set stage size'): JQuery; + /** + * Refreshes the selector cache for element sides + */ + shape(behavior: 'refresh'): JQuery; + /** + * Returns translation for next side staged below + */ + shape(behavior: 'get transform down'): SemanticUI.Translation; + /** + * Returns translation for next side staged left + */ + shape(behavior: 'get transform left'): SemanticUI.Translation; + /** + * Returns translation for next side staged right + */ + shape(behavior: 'get transform right'): SemanticUI.Translation; + /** + * Returns translation for next side staged up + */ + shape(behavior: 'get transform up'): SemanticUI.Translation; + /** + * Returns translation for next side staged down + */ + shape(behavior: 'get transform down'): SemanticUI.Translation; + shape(settings: SemanticUI.ShapeSettings): JQuery; + shape(): JQuery; + + // endregion + + // region Sidebar + + /** + * Attaches sidebar action to given selector. Default event if none specified is toggle + */ + sidebar(behavior: 'attach events', selector: string, event?: string): JQuery; + /** + * Shows sidebar + */ + sidebar(behavior: 'show'): JQuery; + /** + * Hides sidebar + */ + sidebar(behavior: 'hide'): JQuery; + /** + * Toggles visibility of sidebar + */ + sidebar(behavior: 'toggle'): JQuery; + /** + * Returns whether sidebar is visible + */ + sidebar(behavior: 'is visible'): boolean; + /** + * Returns whether sidebar is hidden + */ + sidebar(behavior: 'is hidden'): boolean; + /** + * Pushes page content to be visible alongside sidebar + */ + sidebar(behavior: 'push page'): JQuery; + /** + * Returns direction of current sidebar + */ + sidebar(behavior: 'get direction'): string; + /** + * Returns page content to original position + */ + sidebar(behavior: 'pull page'): JQuery; + /** + * Adds stylesheet to page head to trigger sidebar animations + */ + sidebar(behavior: 'add body CSS'): JQuery; + /** + * Removes any inline stylesheets for sidebar animation + */ + sidebar(behavior: 'remove body CSS'): JQuery; + /** + * Returns vendor prefixed transition end event + */ + sidebar(behavior: 'get transition event'): string; + sidebar(settings: SemanticUI.SidebarSettings): JQuery; + sidebar(): JQuery; + + // endregion + + // region Sticky + + /** + * recalculates offsets + */ + sticky(behavior: 'refresh'): JQuery; + sticky(settings: SemanticUI.StickySettings): JQuery; + sticky(): JQuery; + + // endregion + + // region Tab + + /** + * Attaches tab action to given selector. Default event if none specified is toggle + */ + tab(behavior: 'attach events', selector: string, event?: string): JQuery; + /** + * Changes tab to path + */ + tab(behavior: 'change tab', path: string): JQuery; + /** + * Sets current path to state + */ + tab(behavior: 'set state', path: string): JQuery; + /** + * Returns current path + */ + tab(behavior: 'get path'): string; + /** + * Returns whether tab exists + */ + tab(behavior: 'is tab'): boolean; + /** + * Returns cached HTML for path + */ + tab(behavior: 'cache read', path: string): string | false; + /** + * Sets cached HTML for path + */ + tab(behavior: 'cache add', path: string, html: string): JQuery; + /** + * Removes cached HTML for path + */ + tab(behavior: 'cache remove', path: string): JQuery; + tab(settings: SemanticUI.TabSettings): JQuery; + tab(): JQuery; + + // endregion + + // region Transition + + /** + * Stop current animation and preserve queue + */ + transition(behavior: 'stop'): JQuery; + /** + * Stop current animation and queued animations + */ + transition(behavior: 'stop all'): JQuery; + /** + * Clears all queued animations + */ + transition(behavior: 'clear queue'): JQuery; + /** + * Stop current animation and show element + */ + transition(behavior: 'show'): JQuery; + /** + * Stop current animation and hide element + */ + transition(behavior: 'hide'): JQuery; + /** + * Toggles between hide and show + */ + transition(behavior: 'toggle'): JQuery; + /** + * Forces reflow using a more expensive but stable method + */ + transition(behavior: 'force repaint'): JQuery; + /** + * Triggers reflow on element + */ + transition(behavior: 'repaint'): JQuery; + /** + * Resets all conditions changes during transition + */ + transition(behavior: 'reset'): JQuery; + /** + * Enables animation looping + */ + transition(behavior: 'looping'): JQuery; + /** + * Removes looping state from element + */ + transition(behavior: 'remove looping'): JQuery; + /** + * Adds disabled state (stops ability to animate) + */ + transition(behavior: 'disable'): JQuery; + /** + * Removes disabled state + */ + transition(behavior: 'enable'): JQuery; + /** + * Modifies element animation duration + */ + transition(behavior: 'set duration', duration: number): JQuery; + /** + * Saves all class names and styles to cache to be retrieved after animation + */ + transition(behavior: 'save conditions'): JQuery; + /** + * Adds back cached names and styles to element + */ + transition(behavior: 'restore conditions'): JQuery; + /** + * Returns vendor prefixed animation property for animationname + */ + transition(behavior: 'get animation name'): string; + /** + * Returns vendor prefixed animation property for animationend + */ + transition(behavior: 'get animation event'): string; + /** + * Returns whether element is currently visible + */ + transition(behavior: 'is visible'): boolean; + /** + * Returns whether transition is currently occurring + */ + transition(behavior: 'is animating'): boolean; + /** + * Returns whether animation looping is set + */ + transition(behavior: 'is looping'): boolean; + /** + * Returns whether animations are supported + */ + transition(behavior: 'is supported'): boolean; + transition(transition: string): JQuery; + transition(settings: SemanticUI.TransitionSettings): JQuery; + transition(): JQuery; + + // endregion + + // endregion + + // region Behaviors + + // region API + + /** + * Execute query using existing API settings + */ + api(behavior: 'query'): JQuery; + /** + * Adds data to existing templated url and returns full url string + */ + api(behavior: 'add url data', url: string, data: any): string; + /** + * Gets promise for current API request + */ + api(behavior: 'get request'): JQueryDeferred | false; + /** + * Aborts current API request + */ + api(behavior: 'abort'): JQuery; + /** + * Removes loading and error state from element + */ + api(behavior: 'reset'): JQuery; + /** + * Returns whether last request was cancelled + */ + api(behavior: 'was cancelled'): boolean; + /** + * Returns whether last request was failure + */ + api(behavior: 'was failure'): boolean; + /** + * Returns whether last request was successful + */ + api(behavior: 'was successful'): boolean; + /** + * Returns whether last request was completed + */ + api(behavior: 'was complete'): boolean; + /** + * Returns whether element is disabled + */ + api(behavior: 'is disabled'): boolean; + /** + * Returns whether element response is mocked + */ + api(behavior: 'is mocked'): boolean; + /** + * Returns whether element is loading + */ + api(behavior: 'is loading'): boolean; + /** + * Sets loading state to element + */ + api(behavior: 'set loading'): JQuery; + /** + * Sets error state to element + */ + api(behavior: 'set error'): JQuery; + /** + * Removes loading state to element + */ + api(behavior: 'remove loading'): JQuery; + /** + * Removes error state to element + */ + api(behavior: 'remove error'): JQuery; + /** + * Gets event that API request will occur on + */ + api(behavior: 'get event'): string; + /** + * Returns encodeURIComponent value only if value passed is not already encoded + */ + api(behavior: 'get url encoded value', value: any): string; + /** + * Reads a locally cached response for a URL + */ + api(behavior: 'read cached response', url: string): any; + /** + * Writes a cached response for a URL + */ + api(behavior: 'write cached response', url: string, response: any): JQuery; + /** + * Creates new cache, removing all locally cached URLs + */ + api(behavior: 'create cache'): JQuery; + /** + * Removes API settings from the page and all events + */ + api(behavior: 'destroy'): JQuery; + api(settings: SemanticUI.ApiSettings): JQuery; + api(): JQuery; + + // endregion + + // region Form Validation + + /** + * Submits selected form + */ + form(behavior: 'submit'): JQuery; + /** + * Returns true/false whether a form passes its validation rules + */ + form(behavior: 'is valid'): boolean; + /** + * Validates form and calls onSuccess or onFailure + */ + form(behavior: 'validate form'): JQuery; + /** + * gets browser property change event + */ + form(behavior: 'get change event'): string; + /** + * Returns element with matching name, id, or data-validate metadata to ID + */ + form(behavior: 'get field', id: string): JQuery; + /** + * Returns value of element with id + */ + form(behavior: 'get value', id: string): any; + /** + * Returns object of element values that match array of ids. If no IDS are passed will return all fields + */ + form(behavior: 'get values', ids?: string[]): any; + /** + * Sets value of element with id + */ + form(behavior: 'set value', id: string): JQuery; + /** + * Sets key/value pairs from passed values object to matching ids + */ + form(behavior: 'set values', values: any): JQuery; + /** + * Returns validation rules for a given jQuery-referenced input field + */ + form(behavior: 'get validation', element: JQuery): any; + /** + * Returns whether a field exists + */ + form(behavior: 'has field', identifier: string): boolean; + /** + * Adds errors to form, given an array errors + */ + form(behavior: 'add errors', errors: string[]): JQuery; + form(settings: SemanticUI.FormSettings): JQuery; + form(): JQuery; + + // endregion + + // region Visibility + + /** + * Disable callbacks temporarily. This is useful if you need to adjust scroll position and do not want to trigger callbacks during the position change. + */ + visibility(behavior: 'disable callbacks'): JQuery; + /** + * Re-enable callbacks + */ + visibility(behavior: 'enable callbacks'): JQuery; + /** + * Returns whether element is on screen + */ + visibility(behavior: 'is on screen'): boolean; + /** + * Returns whether element is off screen + */ + visibility(behavior: 'is off screen'): boolean; + /** + * Returns number of pixels passed in current element from top of element + */ + visibility(behavior: 'get pixels passed'): number; + /** + * Returns element calculations as object + */ + visibility(behavior: 'get element calculations'): SemanticUI.ElementCalculations; + /** + * Returns screen calculations as object + */ + visibility(behavior: 'get screen calculations'): SemanticUI.ScreenCalculations; + /** + * Returns screen size as object + */ + visibility(behavior: 'get screen size'): SemanticUI.ScreenSize; + visibility(settings: SemanticUI.VisibilitySettings): JQuery; + visibility(): JQuery; + + // endregion + + // endregion +} + +declare namespace SemanticUI { + type Selector = string | JQuery; + + /** + * These settings are native to all modules, and define how the component ties content to DOM attributes, and debugging settings for the module. + */ + interface ComponentSettings { + // region DOM Settings + + /** + * Event namespace. Makes sure module teardown does not effect other events attached to an element. + */ + namespace?: string; + + // endregion + + // region Debug Settings + + /** + * Name used in log statements + */ + name?: string; + /** + * Silences all console output including error messages, regardless of other debug settings. + */ + silent?: boolean; + /** + * Debug output to console + */ + debug?: boolean; + /** + * Show console.table output with performance metrics + */ + performance?: boolean; + /** + * Debug output includes all internal behaviors + */ + verbose?: boolean; + + // endregion + } + + // region Modules + + // region Accordion + + /** + * @see {@link http://semantic-ui.com/modules/accordion.html#/settings} + */ + interface AccordionSettings extends ComponentSettings { + // region Behavior + + /** + * Only allow one section open at a time + * + * @default true + */ + exclusive?: boolean; + /** + * Event on title that will cause accordion to open + * + * @default 'click' + */ + on?: string; + /** + * Whether child content opacity should be animated (may cause performance issues with many child elements) + * + * @default true + */ + animateChildren?: boolean; + /** + * Close open nested accordion content when an element closes + * + * @default true + */ + closeNested?: boolean; + /** + * Allow active sections to collapse + * + * @default true + */ + collapsible?: boolean; + /** + * Duration in ms of opening animation + * + * @default 500 + */ + duration?: number; + /** + * Easing of opening animation. EaseInOutQuint is included with accordion, for additional options you must include easing equations. + * + * @default 'easeInOutQuint' + * @see {@link http://gsgd.co.uk/sandbox/jquery/easing/} + */ + easing?: string; + // TODO: Undocumented but probably intended to be public? + // observeChanges?: boolean; + + // endregion + + // region Callbacks + + /** + * Callback before element opens + */ + onOpening?: (this: JQuery) => void; + /** + * Callback after element is open + */ + onOpen?: (this: JQuery) => void; + /** + * Callback before element closes + */ + onClosing?: (this: JQuery) => void; + /** + * Callback after element is closed + */ + onClose?: (this: JQuery) => void; + /** + * Callback on element open or close + */ + onChange?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + /** + * Selectors used to find parts of a module + */ + selector?: { + /** + * @default '.accordion' + */ + accordion?: string; + /** + * @default '.title' + */ + title?: string; + /** + * @default '.title' + */ + trigger?: string; + /** + * @default '.content' + */ + content?: string; + }; + /** + * Class names used to determine element state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'animating' + */ + animating?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Checkbox + + /** + * @see {@link http://semantic-ui.com/modules/checkbox.html#/settings} + */ + interface CheckboxSettings extends ComponentSettings { + // region Behavior + + /** + * Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes + * + * @default 'auto' + */ + uncheckable?: 'auto' | boolean; + /** + * Whether callbacks for checked status should be fired on init as well as change + * + * @default false + */ + fireOnInit?: boolean; + + // endregion + + // region Callbacks + + /** + * Callback after a checkbox is either checked or unchecked. + */ + onChange?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is checked. + */ + onChecked?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is set to undeterminate. + */ + onIndeterminate?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is set to determinate. + */ + onDeterminate?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is unchecked. + */ + onUnchecked?: (this: HTMLElement) => void; + /** + * Callback before a checkbox is checked. Can cancel change by returning false + */ + beforeChecked?: (this: HTMLElement) => boolean; + /** + * Callback before a checkbox is set to undeterminate. Can cancel change by returning false + */ + beforeIndeterminate?: (this: HTMLElement) => boolean; + /** + * Callback before a checkbox is set to determinate. Can cancel change by returning false + */ + beforeDeterminate?: (this: HTMLElement) => boolean; + /** + * Callback before a checkbox is unchecked. Can cancel change by returning false + */ + beforeUnchecked?: (this: HTMLElement) => boolean; + /** + * Callback after a checkbox is enabled. + */ + onEnable?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is disabled. + */ + onDisable?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is enabled. + * + * @deprecated + */ + onEnabled?: (this: HTMLElement) => void; + /** + * Callback after a checkbox is disabled. + * + * @deprecated + */ + onDisabled?: (this: HTMLElement) => void; + + // endregion + + // region DOM Settings + + /** + * Selectors used to find parts of a module + */ + selector?: { + /** + * @default 'input[type=checkbox], input[type=radio]' + */ + input?: string; + /** + * @default 'label' + */ + label?: string; + }; + /** + * Class names used to determine element state + */ + className?: { + /** + * @default 'checked' + */ + checked?: string; + /** + * @default 'disabled' + */ + disabled?: string; + /** + * @default 'radio' + */ + radio?: string; + /** + * @default 'read-only' + */ + readOnly?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Dimmer + + /** + * @see {@link http://semantic-ui.com/modules/dimmer.html#/settings} + */ + interface DimmerSettings extends ComponentSettings { + // region Behavior + + /** + * Dimmers opacity from 0-1. Defaults to auto which uses the CSS specified opacity. + * + * @default 'auto' + */ + opacity?: 'auto' | number; + /** + * Specify a variation to add when generating dimmer, like inverted + * + * @default false + */ + variation?: false | string; + /** + * If initializing a dimmer on a dimmable context, you can use dimmerName to distinguish between multiple dimmers in that context. + * + * @default false + */ + dimmerName?: false | string; + /** + * Whether clicking on the dimmer should hide the dimmer (Defaults to auto, closable only when settings.on is not hover + * + * @default 'auto' + */ + closable?: 'auto' | boolean; + /** + * Can be set to hover or click to show/hide dimmer on dimmable event + * + * @default false + */ + on?: false | 'hover' | 'click'; + /** + * Whether to dim dimmers using CSS transitions. + * + * @default true + */ + useCSS?: boolean; + /** + * Animation duration of dimming. If an integer is used, that value will apply to both show and hide animations. + */ + duration?: number | { + /** + * @default 500 + */ + show?: number; + /** + * @default 500 + */ + hide?: number; + }; + /** + * Named transition to use when animating menu in and out. Fade and slide down are available without including ui transitions + * + * @default 'fade' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: string; + + // endregion + + // region Callbacks + + /** + * Callback on element show + */ + onShow?: (this: JQuery) => void; + /** + * Callback on element hide + */ + onHide?: (this: JQuery) => void; + /** + * Callback on element show or hide + */ + onchange?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + /** + * Object containing selectors used by module. + */ + selector?: { + /** + * @default '.dimmable' + */ + dimmable?: string; + /** + * @default '.ui.dimmer' + */ + dimmer?: string; + /** + * @default '.ui.dimmer > .content, .ui.dimmer > .content > .center' + */ + content?: string; + }; + /** + * Templates used to generate dimmer content + */ + template?: { + dimmer?: () => JQuery; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'dimmable' + */ + dimmable?: string; + /** + * @default 'dimmed' + */ + dimmed?: string; + /** + * @default 'disabled' + */ + disabled?: string; + /** + * @default 'page' + */ + pageDimmer?: string; + /** + * @default 'hide' + */ + hide?: string; + /** + * @default 'show' + */ + show?: string; + /** + * @default 'transition' + */ + transition?: string; + }; + + // endregion + + // region Debug Settings + + /** + * Error messages displayed to console + */ + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Dropdown + + /** + * @see {@link http://semantic-ui.com/modules/dropdown.html#/settings} + */ + interface DropdownSettings extends ComponentSettings { + // TODO: Should 'value'/'values' parameters be of type 'string' instead of 'any'? + + // region Frequently Used Settings + + /** + * Event used to trigger dropdown (Hover, Click, Custom Event) + * + * @default 'click' + */ + on?: string; + /** + * When set to true will fire onChange even when the value a user select matches the currently selected value. + * + * @default false + */ + allowReselection?: boolean; + /** + * Whether search selection should allow users to add their own selections, works for single or multi-select. + * + * @default false + */ + allowAdditions?: boolean; + /** + * When disabled user additions will appear in the results menu using a specially formatted selection item formatted by templates.addition. + * + * @default true + */ + hideAdditions?: boolean; + /** + * Sets a default action to occur. (See usage guide) + * + * @default 'activate' + * @see {@link http://semantic-ui.com/modules/dropdown.html#/usage} + */ + action?: 'activate' | 'select' | 'combo' | 'nothing' | 'hide' | ((this: JQuery, text: string, value: string | false, element: JQuery) => void); + /** + * The minimum characters for a search to begin showing results + * + * @default 1 + */ + minCharacters?: number; + /** + * When using search selection specifies how to match values. + * + * @default 'both' + */ + match?: 'both' | 'value' | 'text'; + /** + * Whether dropdown should select new option when using keyboard shortcuts. Setting to false will require enter or left click to confirm a choice. + * + * @default true + */ + selectOnKeydown?: boolean; + /** + * Whether search selection will force currently selected choice when element is blurred. + * + * @default true + */ + forceSelection?: boolean; + /** + * Whether menu items with sub-menus (categories) should be selectable + * + * @default false + */ + allowCategorySelection?: boolean; + /** + * @default 'auto' + */ + placeholder?: 'auto' | 'value' | false; + + // endregion + + // region Remote Settings + + /** + * Can be set to an object to specify API settings for retrieving remote selection menu content from an API endpoint + * + * @default false + * @see {@link http://semantic-ui.com/behaviors/api.html} + */ + apiSettings?: false | ApiSettings; + /** + * List mapping dropdown content to JSON Property when using API + */ + fields?: { + /** + * grouping for api results + * + * @default 'results' + */ + remoteValues?: string; + /** + * grouping for all dropdown values + * + * @default 'values' + */ + values?: string; + /** + * displayed dropdown text + * + * @default 'name' + */ + name?: string; + /** + * actual dropdown value + * + * @default 'value' + */ + value?: string; + }; + /** + * When enabled will automatically store selected name/value pairs in sessionStorage to preserve user selection on page refresh. Disabling will clear remote dropdown values on refresh. + * + * @default true + */ + saveRemoteData?: boolean; + + // endregion + + // region Multiple Select Settings + + /** + * Whether multiselect should use labels. Must be set to true when allowAdditions is true + * + * @default true + */ + useLabels?: boolean; + /** + * When set to a number, sets the maximum number of selections + * + * @default false + */ + maxSelections?: boolean; + /** + * Maximum glyph width, used to calculate search size. This is usually size of a "W" in your font in em + * + * @default 1.0714 + */ + glyphWidth?: number; + /** + * Allows customization of multi-select labels + */ + label?: { + /** + * @default 'horizontal flip' + */ + transition?: string; + /** + * @default 200 + */ + duration?: number; + /** + * @default false + */ + variation?: false | string; + }; + + // endregion + + // region Additional Settings + + /** + * When set to auto determines direction based on whether dropdown can fit on screen. Set to upward or downward to always force a direction. + * + * @default 'auto' + */ + direction?: 'auto' | 'upward' | 'downward'; + /** + * Whether dropdown should try to keep itself on screen by checking whether menus display position in its context (Default context is page). + * + * @default true + */ + keepOnScreen?: boolean; + /** + * Element context to use when checking whether can show when keepOnScreen: true + * + * @default 'window' + */ + context?: Selector; + /** + * Specifying to "true" will use a fuzzy full text search, setting to "exact" will force the exact search to be matched somewhere in the string + * + * @default false + */ + fullTextSearch?: boolean | 'exact'; + /** + * Whether HTML included in dropdown values should be preserved. (Allows icons to show up in selected value) + * + * @default true + */ + preserveHTML?: boolean; + /** + * Whether to sort values when creating a dropdown automatically from a select element. + * + * @default false + */ + sortSelect?: boolean; + /** + * Whether to show dropdown menu automatically on element focus. + * + * @default true + */ + showOnFocus?: boolean; + /** + * Whether to allow the element to be navigable by keyboard, by automatically creating a tabindex + * + * @default true + */ + allowTab?: boolean; + /** + * Named transition to use when animating menu in and out. Defaults to slide down or slide up depending on dropdown direction. Fade and slide down are available without including ui transitions + * + * @default 'auto' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: 'auto' | string; + /** + * Duration of animation events + * + * @default 200 + */ + duration?: number; + /** + * The keycode used to represent keyboard shortcuts. To avoid issues with some foreign languages, you can pass false for comma delimiter's value + */ + keys?: { + /** + * @default 8 + */ + backspace?: number; + /** + * @default 188 + */ + delimiter?: number | false; + /** + * @default 46 + */ + deleteKey?: number; + /** + * @default 13 + */ + enter?: number; + /** + * @default 27 + */ + escape?: number; + /** + * @default 33 + */ + pageUp?: number; + /** + * @default 34 + */ + pageDown?: number; + /** + * @default 37 + */ + leftArrow?: number; + /** + * @default 38 + */ + upArrow?: number; + /** + * @default 39 + */ + rightArrow?: number; + /** + * @default 40 + */ + downArrow?: number; + }; + /** + * Time in milliseconds to debounce show or hide behavior when on: hover is used, or when touch is used. + */ + delay?: { + /** + * @default 300 + */ + hide?: number; + /** + * @default 200 + */ + show?: number; + /** + * @default 50 + */ + search?: number; + /** + * @default 50 + */ + touch?: number; + }; + + // endregion + + // region Callbacks + + /** + * Is called after a dropdown value changes. Receives the name and value of selection and the active menu element + */ + onChange?: (this: JQuery, value: any, text: string, $choice: JQuery) => void; + /** + * Is called after a dropdown selection is added using a multiple select dropdown, only receives the added value + */ + onAdd?: (this: JQuery, addedValue: any, addedText: string, $addedChoice: JQuery) => void; + /** + * Is called after a dropdown selection is removed using a multiple select dropdown, only receives the removed value + */ + onRemove?: (this: JQuery, removedValue: any, removedText: string, $removedChoice: JQuery) => void; + /** + * Allows you to modify a label before it is added. Expects the jQ DOM element for a label to be returned. + */ + onLabelCreate?: (this: JQuery, value: any, text: string) => JQuery; + /** + * Called when a label is remove, return false; will prevent the label from being removed. + */ + onLabelRemove?: (this: JQuery, value: any) => false | void; + /** + * Is called after a label is selected by a user + */ + onLabelSelect?: (this: JQuery, $selectedLabels: JQuery) => void; + /** + * Is called after a dropdown is searched with no matching values + */ + onNoResults?: (this: JQuery, searchValue: any) => void; + /** + * Is called before a dropdown is shown. If false is returned, dropdown will not be shown. + */ + onShow?: (this: JQuery) => false | void; + /** + * Is called before a dropdown is hidden. If false is returned, dropdown will not be hidden. + */ + onHide?: (this: JQuery) => false | void; + + // endregion + + // region DOM Settings + + /** + * You can specify site wide messages by modifying $.fn.dropdown.settings.message that will apply on any dropdown if it appears in the page. + */ + message?: { + /** + * @default 'Add {term}' + */ + addResult?: string; + /** + * @default '{count} selected' + */ + count?: string; + /** + * @default 'Max {maxCount} selections' + */ + maxSelections?: string; + /** + * 'No results found.' + */ + noResults?: string; + }; + selector?: { + /** + * @default '.addition' + */ + addition?: string; + /** + * @default '.ui.dropdown' + */ + dropdown?: string; + /** + * @default '> .dropdown.icon' + */ + icon?: string; + /** + * @default '> input[type="hidden"], > select' + */ + input?: string; + /** + * @default '.item' + */ + item?: string; + /** + * @default '> .label' + */ + label?: string; + /** + * @default '> .label > .delete.icon' + */ + remove?: string; + /** + * @default '.label' + */ + siblingLabel?: string; + /** + * @default '.menu' + */ + menu?: string; + /** + * @default '.message' + */ + message?: string; + /** + * @default '.dropdown.icon' + */ + menuIcon?: string; + /** + * @default 'input.search, .menu > .search > input' + */ + search?: string; + /** + * @default '> .text:not(.icon)' + */ + text?: string; + }; + regExp?: { + /** + * @default /[-[\]{}()*+?.,\\^$|#\s]/g + */ + escape?: RegExp; + }; + metadata?: { + /** + * @default 'defaultText' + */ + defaultText?: string; + /** + * @default 'defaultValue' + */ + defaultValue?: string; + /** + * @default 'placeholderText' + */ + placeholderText?: string; + /** + * @default 'text' + */ + text?: string; + /** + * @default 'value' + */ + value?: string; + }; + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'addition' + */ + addition?: string; + /** + * @default 'animating' + */ + animating?: string; + /** + * @default 'disabled' + */ + disabled?: string; + /** + * @default 'ui dropdown' + */ + dropdown?: string; + /** + * @default 'filtered' + */ + filtered?: string; + /** + * @default 'hidden transition' + */ + hidden?: string; + /** + * @default 'item' + */ + item?: string; + /** + * @default 'ui label' + */ + label?: string; + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'menu' + */ + menu?: string; + /** + * @default 'message' + */ + message?: string; + /** + * @default 'multiple' + */ + multiple?: string; + /** + * @default 'default' + */ + placeholder?: string; + /** + * @default 'search' + */ + search?: string; + /** + * @default 'selected' + */ + selected?: string; + /** + * @default 'selection' + */ + selection?: string; + /** + * @default 'upward' + */ + upward?: string; + /** + * @default 'visible' + */ + visible?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'You called a dropdown action that was not defined' + */ + action?: string; + /** + * @default 'Once a select has been initialized behaviors must be called on the created ui dropdown' + */ + alreadySetup?: string; + /** + * @default 'Allowing user additions currently requires the use of labels.' + */ + labels?: string; + /** + * @default 'The method you called is not defined.' + */ + method?: string; + /** + * @default 'This module requires ui transitions ' + */ + noTransition?: string; + }; + + // endregion + } + + // endregion + + // region Embed + + /** + * @see {@link http://semantic-ui.com/modules/embed.html#/settings} + */ + interface EmbedSettings extends ComponentSettings { + /** + * Specifies a url to use for embed + * + * @default false + */ + url?: false | string; + + // region Embed Settings + + /** + * Specifies an icon to use with placeholder content + * + * @default false + */ + icon?: false | string; + /** + * Specifies a source to use, if no source is provided it will be determined from the domain of a specified url. + * + * @default false + */ + source?: false | string; + /** + * Specifies an id value to replace with the {id} value found in templated urls + * + * @default false + */ + id?: false | string; + /** + * Specify an object containing key/value pairs to add to the iframes GET parameters + * + * @default false + */ + parameters?: false | any; + + // endregion + + // region Video Settings + + /** + * Default setting auto will only autoplay content when a placeholder is specified. Setting to true or false will force autoplay. + * + * @default 'auto' + */ + autoplay?: 'auto' | boolean; + /** + * Specifies a default chrome color with Vimeo or YouTube. + * + * @default '#444444' + */ + color?: string; + /** + * Whether to prefer HD content + * + * @default true + */ + hd?: boolean; + /** + * Whether to show networks branded UI like title cards, or after video calls to action. + * + * @default false + */ + brandedUI?: boolean; + + // endregion + + // region Callbacks + + /** + * Callback when iframe is generated + */ + onCreate?: (this: JQuery, url: string) => void; + /** + * Whenever an iframe contents is shown + */ + onDisplay?: (this: JQuery) => void; + /** + * Callback immediately before Embed is removed from DOM + */ + onPlaceholderDisplay?: (this: JQuery) => void; + /** + * Callback when module parameters are determined. Allows you to adjust parameters at run time by returning a new parameters object. + */ + onEmbed?: (this: JQuery, parameters: any) => any; + + // endregion + + // region DOM Settings + + /** + * DOM Selectors used internally + */ + selector?: { + /** + * @default '.embed' + */ + embed?: string; + /** + * @default '.placeholder' + */ + placeholder?: string; + /** + * @default '.play' + */ + play?: string; + }; + /** + * HTML Data attributes used to store data + */ + metadata?: { + /** + * @default 'id' + */ + id?: string; + /** + * @default 'icon' + */ + icon?: string; + /** + * @default 'placeholder' + */ + placeholder?: string; + /** + * @default 'source' + */ + source?: string; + /** + * @default 'url' + */ + url?: string; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'embed' + */ + embed?: string; + }; + templates?: { + /** + * returns html for iframe + */ + iframe?: (url: string, parameters: string) => string; + /** + * returns html for placeholder element + */ + placeholder?: (image: string, icon: string) => string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'No URL specified' + */ + noURL?: string; + /** + * @default 'The method you called is not defined' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Modal + + /** + * @see {@link http://semantic-ui.com/modules/modal.html#/settings} + */ + interface ModalSettings extends ComponentSettings { + // region Modal Settings + + /** + * If set to false will prevent the modal from being moved to inside the dimmer + * + * @default true + */ + detachable?: boolean; + /** + * When true, the first form input inside the modal will receive focus when shown. Set this to false to prevent this behavior. + * + * @default true + */ + autofocus?: boolean; + /** + * Whether any change in modal DOM should automatically refresh cached positions + * + * @default false + */ + observeChanges?: boolean; + /** + * If set to true will not close other visible modals when opening a new one + * + * @default false + */ + allowMultiple?: boolean; + /** + * Whether to automatically bind keyboard shortcuts + * + * @default true + */ + keyboardShortcuts?: boolean; + /** + * A vertical offset to allow for content outside of modal, for example a close button, to be centered. + * + * @default 0 + */ + offset?: number; + /** + * Selector or jquery object specifying the area to dim + * + * @default 'body' + */ + context?: Selector; + /** + * Setting to false will not allow you to close the modal by clicking on the dimmer + * + * @default true + */ + closable?: boolean; + /** + * You can specify custom settings to extend UI dimmer + * + * @see {@link http://semantic-ui.com/modules/dimmer.html} + */ + dimmerSettings?: DimmerSettings; + /** + * Named transition to use when animating menu in and out, full list can be found in ui transitions docs. + * + * @default 'scale' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: string; + /** + * Duration of animation + * + * @default 400 + */ + duration?: number; + /** + * Whether additional animations should queue + * + * @default false + */ + queue?: boolean; + + // endregion + + // region Callbacks + + /** + * Is called when a modal starts to show. + */ + onShow?: (this: JQuery) => void; + /** + * Is called after a modal has finished showing animating. + */ + onVisible?: (this: JQuery) => void; + /** + * Is called after a modal starts to hide. If the function returns false, the modal will not hide. + */ + onHide?: (this: JQuery, $element: JQuery) => false | void; + /** + * Is called after a modal has finished hiding animation. + */ + onHidden?: (this: JQuery) => void; + /** + * Is called after a positive, approve or ok button is pressed. If the function returns false, the modal will not hide. + */ + onApprove?: (this: JQuery, $element: JQuery) => false | void; + /** + * Is called after a negative, deny or cancel button is pressed. If the function returns false the modal will not hide. + */ + onDeny?: (this: JQuery, $element: JQuery) => false | void; + + // endregion + + // region DOM Settings + + selector?: { + /** + * @default '.close, .actions .button' + */ + close?: string; + /** + * @default '.actions .positive, .actions .approve, .actions .ok' + */ + approve?: string; + /** + * @default '.actions .negative, .actions .deny, .actions .cancel' + */ + deny?: string; + }; + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'scrolling' + */ + scrolling?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Nag + + /** + * @see {@link http://semantic-ui.com/modules/nag.html} + */ + interface NagSettings extends ComponentSettings { + // region Behavior + + /** + * allows cookie to be overridden + * + * @default false + */ + persist?: boolean; + /** + * set to zero to require manually dismissal, otherwise hides on its own + * + * @default 0 + */ + displayTime?: number; + animation?: { + /** + * @default 'slide' + */ + show?: string; + /** + * @default 'slide' + */ + hide?: string; + }; + /** + * @default false + */ + context?: false | Selector; + /** + * @default false + */ + detachable?: boolean; + + /** + * @default 30 + */ + expires?: number; + /** + * @default false + */ + domain?: false | string; + /** + * @default '/' + */ + path?: string; + + /** + * type of storage to use + * + * @default 'cookie' + */ + storageMethod?: 'cookie' | 'localstorage' | 'sessionstorage'; + + /** + * @default 'nag' + */ + key?: any; + /** + * @default 'dismiss' + */ + value?: any; + + /** + * @default 500 + */ + speed?: number; + /** + * @default 'easeOutQuad' + */ + easing?: string; + + // endregion + + // region Callbacks + + onHide?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + className?: { + /** + * @default 'bottom' + */ + bottom?: string; + /** + * @default 'fixed' + */ + fixed?: string; + }; + selector?: { + /** + * @default '.close.icon' + */ + close?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default '$.cookie is not included. A storage solution is required.' + */ + noCookieStorage?: string; + /** + * @default 'Neither $.cookie or store is defined. A storage solution is required for storing state' + */ + noStorage?: string; + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Popup + + /** + * @see {@link http://semantic-ui.com/modules/popup.html#/settings} + */ + interface PopupSettings extends ComponentSettings { + // region Popup Settings + + /** + * Can specify a DOM element that should be used as the popup. This is useful for including a pre-formatted popup. + * + * @default false + */ + popup?: false | Selector; + /** + * Whether all other popups should be hidden when this popup is opened + * + * @default false + */ + exclusive?: boolean; + /** + * Whether to move popup to same offset container as target element when popup already exists on the page. + * Using a popup inside of an element without overflow:visible, like a sidebar, may require you to set this to false + * + * @default true + */ + movePopup?: boolean; + /** + * Whether popup should attach mutationObservers to automatically run destroy when the element is removed from the page's DOM. + * + * @default true + */ + observeChanges?: boolean; + /** + * When the popup surpasses the boundary of this element, it will attempt to find another display position. + */ + boundary?: Selector; + /** + * Selector or jquery object specifying where the popup should be created. + * + * @default 'body' + */ + context?: Selector; + /** + * Will automatically hide a popup on scroll event in this context + */ + scrollContext?: Selector; + /** + * Number of pixels that a popup is allowed to appear outside the boundaries of its context. + * This allows for permissible rounding errors when an element is against the edge of its context. + * + * @default 2 + */ + jitter?: number; + /** + * Position that the popup should appear + * + * @default 'top left' + */ + position?: string; + /** + * If a popup is inline it will be created next to current element, allowing for local css rules to apply. + * It will not be removed from the DOM after being hidden. + * Otherwise popups will appended to body and removed after being hidden. + * + * @default false + */ + inline?: boolean; + /** + * Whether popup contents should be preserved in the page after being hidden, allowing it to re-appear slightly faster on subsequent loads. + * + * @default false + */ + preserve?: boolean; + /** + * Can be set to adjacent or opposite to prefer adjacent or opposite position if popup cannot fit on screen + * + * @default 'adjacent' + */ + prefer?: 'adjacent' | 'opposite'; + /** + * When set to false, a popup will not appear and produce an error message if it cannot entirely fit on page. + * Setting this to a position like, right center forces the popup to use this position as a last resort even if it is partially offstage. + * Setting this to true will use the last attempted position. + * + * @default false + */ + lastResort?: boolean | string; + /** + * Event used to trigger popup. Can be either focus, click, hover, or manual. Manual popups must be triggered with $('.element').popup('show'); + * + * @default 'hover' + */ + on?: 'focus' | 'click' | 'hover' | 'manual'; + /** + * Delay in milliseconds before showing or hiding a popup on hover or focus + */ + delay?: { + show?: number; + hide?: number; + }; + /** + * Named transition to use when animating menu in and out. Fade and slide down are available without including ui transitions + * + * @default 'slide down' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: string; + /** + * Duration of animation events + * + * @default 200 + */ + duration?: number; + /** + * Whether popup should set fluid popup variation width on load to avoid width: 100% including padding + * + * @default true + */ + setFluidWidth?: boolean; + /** + * Whether popup should not close on hover (useful for popup navigation menus) + * + * @default false + */ + hoverable?: boolean; + /** + * When using on: 'click' specifies whether clicking the page should close the popup + * + * @default true + */ + closable?: boolean; + /** + * When using on: 'hover' whether touchstart events should be added to allow the popup to be triggered + */ + addTouchEvents?: boolean; + /** + * Whether popup should hide on scroll or touchmove, auto only hides for popups without on: 'click'. + * Set this to false to prevent mobile browsers from closing popups when you tap inside input fields. + * + * @default 'auto' + */ + hideOnScroll?: 'auto' | false; + /** + * If a selector or jQuery object is specified this allows the popup to be positioned relative to that element. + * + * @default false + */ + target?: false | Selector; + /** + * Offset for distance of popup from element + * + * @default 0 + */ + distanceAway?: number; + /** + * Offset in pixels from calculated position + * + * @default 0 + */ + offset?: number; + /** + * Number of iterations before giving up search for popup position when a popup cannot fit on screen + * + * @default 10 + */ + maxSearchDepth?: number; + + // endregion + + // region Callbacks + + /** + * Callback on popup element creation, with created popup + */ + onCreate?: (this: JQuery, $module: JQuery) => void; + /** + * Callback immediately before Popup is removed from DOM + */ + onRemove?: (this: JQuery, $module: JQuery) => void; + /** + * Callback before popup is shown. Returning false from this callback will cancel the popup from showing. + */ + onShow?: (this: JQuery, $module: JQuery) => false | void; + /** + * Callback after popup is shown + */ + onVisible?: (this: JQuery, $module: JQuery) => void; + /** + * Callback before popup is hidden. Returning false from this callback will cancel the popup from hiding. + */ + onHide?: (this: JQuery, $module: JQuery) => false | void; + /** + * Callback after popup is hidden + */ + onHidden?: (this: JQuery, $module: JQuery) => void; + /** + * Callback after popup cannot be plaed on screen + */ + onUnplaceable?: (this: JQuery, $module: JQuery) => void; + + // endregion + + // region Content Settings + + /** + * Popup variation to use, can use multiple variations with a space delimiter + */ + variation?: string; + /** + * Content to display + */ + content?: string; + /** + * Title to display alongside content + */ + title?: string; + /** + * HTML content to display instead of preformatted title and content + */ + html?: string; + + // endregion + + // region DOM Settings + + /** + * DOM Selectors used internally + */ + selector?: { + /** + * @default '.ui.popup' + */ + popup?: string; + }; + /** + * HTML Data attributes used to store data + */ + metadata?: { + /** + * @default 'content' + */ + content?: string; + /** + * @default 'html' + */ + html?: string; + /** + * @default 'offset' + */ + offset?: string; + /** + * @default 'position' + */ + position?: string; + /** + * @default 'title' + */ + title?: string; + /** + * @default 'variation' + */ + variation?: string; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'ui popup' + */ + popup?: string; + /** + * @default 'top left center bottom right' + */ + position?: string; + /** + * @default 'visible' + */ + visible?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The position you specified is not a valid position' + */ + invalidPosition?: string; + /** + * @default 'Popup does not fit within the boundaries of the viewport' + */ + cannotPlace?: string; + /** + * @default 'The method you called is not defined.' + */ + method?: string; + /** + * @default 'This module requires ui transitions ' + */ + noTransition?: string; + /** + * @default 'The target or popup you specified does not exist on the page' + */ + notFound?: string; + }; + + // endregion + } + + // endregion + + // region Progress + + /** + * @see {@link http://semantic-ui.com/modules/progress.html#/settings} + */ + interface ProgressSettings extends ComponentSettings { + // region Progress Settings + + /** + * Whether success state should automatically trigger when progress completes + * + * @default true + */ + autoSuccess?: boolean; + /** + * Whether progress should automatically show activity when incremented + * + * @default true + */ + showActivity?: boolean; + /** + * When set to true, values that calculate to above 100% or below 0% will be adjusted. + * When set to false, inappropriate values will produce an error. + * + * @default true + */ + limitValues?: boolean; + /** + * Can be set to either to display progress as percent or ratio. Matches up to corresponding text template with the same name. + * + * @default 'percent' + */ + label?: 'percent' | 'ratio'; + /** + * When incrementing without value, sets range for random increment value + */ + random?: { + /** + * @default 2 + */ + min?: number; + /** + * @default 5 + */ + max?: number; + }; + /** + * Decimal point precision for calculated progress + * + * @default 1 + */ + precision?: number; + /** + * Setting a total value will make each call to increment get closer to this total (i.e. 1/20, 2/20 etc) + * + * @default false + */ + total?: false | number; + /** + * Sets current value, when total is specified, this is used to calculate a ratio of the total, with percent this should be the overall percent + * + * @default false + */ + value?: false | number; + + // endregion + + // region Callbacks + + /** + * Callback on percentage change + */ + onChange?: (this: JQuery, percent: number, value: number, total: number) => void; + /** + * Callback on success state + */ + onSuccess?: (this: JQuery, total: number) => void; + /** + * Callback on active state + */ + onActive?: (this: JQuery, value: number, total: number) => void; + /** + * Callback on error state + */ + onError?: (this: JQuery, value: number, total: number) => void; + /** + * Callback on warning state + */ + onWarning?: (this: JQuery, value: number, total: number) => void; + + // endregion + + // region DOM Settings + + /** + * Text content for each state, uses simple templating with {percent}, {value}, {total} + */ + text?: { + /** + * @default false + */ + active?: false | string; + /** + * @default false + */ + error?: false | string; + /** + * @default false + */ + success?: false | string; + /** + * @default false + */ + warning?: false | string; + /** + * @default '{percent}%' + */ + percent?: false | string; + /** + * @default '{value} of {total}' + */ + ratio?: false | string; + }; + /** + * Regular expressions used by module + */ + regExp?: { + /** + * @default /\{\$*[A-z0-9]+\}/g + */ + variable?: RegExp; + }; + /** + * Selectors used by module + */ + selector?: { + /** + * @default '> .bar + */ + bar?: string; + /** + * @default '> .label' + */ + label?: string; + /** + * @default '.bar > .progress' + */ + progress?: string; + }; + /** + * DOM metadata used by module + */ + metadata?: { + /** + * @default 'percent' + */ + percent?: string; + /** + * @default 'total' + */ + total?: string; + /** + * @default 'value' + */ + value?: string; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'error' + */ + error?: string; + /** + * @default 'success' + */ + success?: string; + /** + * @default 'warning' + */ + warning?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + /** + * @default 'Progress value is non numeric' + */ + nonNumeric?: string; + }; + + // endregion + } + + // endregion + + // region Rating + + /** + * @see {@link http://semantic-ui.com/modules/rating.html#/settings} + */ + interface RatingSettings extends ComponentSettings { + // region Rating Settings + + /** + * A number representing the default rating to apply + * + * @default 0 + */ + initialRating?: number; + /** + * Whether callbacks like onRate should fire immediately after initializing with the current value. + * + * @default false + */ + fireOnInit?: boolean; + /** + * By default a rating will be only clearable if there is 1 icon. Setting to true/false will allow or disallow a user to clear their rating + * + * @default 'auto' + */ + clearable?: 'auto' | boolean; + /** + * Whether to enable user's ability to rate + * + * @default true + */ + interactive?: boolean; + + // endregion + + // region Callbacks + + /** + * Is called after user selects a new rating + */ + onRate?: (this: JQuery, value: number) => void; + + // endregion + + // region DOM Settings + + selector?: { + /** + * @default '.icon' + */ + icon?: string; + }; + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'hover' + */ + hover?: string; + /** + * @default 'loading' + */ + loading?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'You called a rating action that was not defined' + */ + action?: string; + }; + + // endregion + } + + // endregion + + // region Search + + /** + * @see {@link http://semantic-ui.com/modules/search.html#/settings} + */ + interface SearchSettings extends ComponentSettings { + // region Behavior + + /** + * Settings for API call. + * + * @see {@link http://semantic-ui.com/behaviors/api.html#/usage} + */ + apiSettings?: ApiSettings; + /** + * Minimum characters to query for results + * + * @default 1 + */ + minCharacters?: number; + /** + * Named transition to use when animating menu in and out. Fade and slide down are available without including ui transitions + * + * @default 'fade' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: string; + /** + * Duration of animation events + * + * @default 300 + */ + duration?: number; + /** + * Maximum results to display when using local and simple search, maximum category count for category search + * + * @default 7 + */ + maxResults?: number; + /** + * Caches results locally to avoid requerying server + * + * @default true + */ + cache?: boolean; + /** + * Specify a Javascript object which will be searched locally + * + * @default false + */ + source?: false | any; + /** + * Whether the search should automatically select the first search result after searching + * + * @default false + */ + selectFirstResult?: boolean; + /** + * Whether a "no results" message should be shown if no results are found. (These messages can be modified using the template object specified below) + * + * @default false + */ + showNoResults?: boolean; + /** + * Return local results that match anywhere inside your content + * + * @default true + */ + searchFullText?: boolean; + /** + * List mapping display content to JSON property, either with API or source. + */ + fields?: { + /** + * array of categories (category view) + * + * @default 'results' + */ + categories?: string; + /** + * name of category (category view) + * + * @default 'name' + */ + categoryName?: string; + /** + * array of results (category view) + * + * @default 'results' + */ + categoryResults?: string; + /** + * result description + * + * @default 'description' + */ + description?: string; + /** + * result image + * + * @default 'image' + */ + image?: string; + /** + * result price + * + * @default 'price' + */ + price?: string; + /** + * array of results (standard) + * + * @default 'results' + */ + results?: string; + /** + * result title + * + * @default 'title' + */ + title?: string; + /** + * "view more" object name + * + * @default 'action' + */ + action?: string; + /** + * "view more" text + * + * @default 'text' + */ + actionText?: string; + /** + * "view more" url + * + * @default 'url' + */ + actionURL?: string; + }; + /** + * Specify object properties inside local source object which will be searched + */ + searchFields?: string[]; + /** + * Delay before hiding results after search blur + * + * @default 0 + */ + hideDelay?: number; + /** + * Delay before querying results on inputchange + * + * @default 100 + */ + searchDelay?: number; + /** + * Easing equation when using fallback Javascript animation + * + * @default 'easeOutExpo' + */ + easing?: string; + + // endregion + + // region Callbacks + + /** + * Callback on element selection by user. + * The first parameter includes the filtered response results for that element. + * The function should return false to prevent default action (closing search results and selecting value). + */ + onSelect?: (this: JQuery, result: any, response: any) => false | void; + /** + * Callback after processing element template to add HTML to results. Function should return false to prevent default actions. + */ + onResultsAdd?: (this: JQuery, html: string) => false | void; + /** + * Callback on search query + */ + onSearchQuery?: (this: JQuery, query: string) => void; + /** + * Callback on server response + */ + onResults?: (this: JQuery, response: any) => void; + /** + * Callback when results are opened + */ + onResultsOpen?: (this: JQuery) => void; + /** + * Callback when results are closed + */ + onResultsClose?: (this: JQuery) => void; + + // endregion + + // region Templates + + templates?: { + escape?: (string: string) => string; + message?: (message: string, type: string) => string; + category?: (response: any) => string; + standard?: (response: any) => string; + }; + + // endregion + + // region DOM Settings + + /** + * Regular expressions used for matching + */ + regExp?: { + /** + * @default /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g + */ + escape?: RegExp; + /** + * @default '(?:\s|^)' + */ + beginsWith?: string; + }; + /** + * Selectors used to find parts of a module + */ + selector?: { + /** + * @default '.prompt' + */ + prompt?: string; + /** + * @default '.search.button' + */ + searchButton?: string; + /** + * @default '.results' + */ + results?: string; + /** + * @default '.category' + */ + category?: string; + /** + * @default '.result' + */ + result?: string; + }; + /** + * HTML5 metadata attributes used internally + */ + metadata?: { + /** + * @default 'cache' + */ + cache?: string; + /** + * @default 'results' + */ + results?: string; + }; + /** + * Class names used to determine element state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'empty' + */ + empty?: string; + /** + * @default 'focus' + */ + focus?: string; + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'down' + */ + pressed?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'Cannot search. No source used, and Semantic API module was not included' + */ + source?: string; + /** + * @default 'Your search returned no results' + */ + noResults?: string; + /** + * @default 'Error in debug logging, exiting.' + */ + logging?: string; + /** + * @default 'A valid template name was not specified.' + */ + noTemplate?: string; + /** + * @default 'There was an issue with querying the server.' + */ + serverError?: string; + /** + * @default 'Results must be an array to use maxResults setting' + */ + maxResults?: string; + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Shape + + /** + * @see {@link http://semantic-ui.com/modules/shape.html#/settings} + */ + interface ShapeSettings extends ComponentSettings { + // region Shape Settings + + /** + * Duration of side change animation + * + * @default 700 + */ + duration?: number; + /** + * When set to next will use the width of the next side during the shape's animation. + * When set to initial it will use the width of the shape at initialization. + * When set to a specific pixel height, will force the width to that height. + * + * @default 'initial' + * @since 2.2 + */ + width?: 'next' | 'initial' | number; + /** + * When set to next will use the height of the next side during the shape's animation. + * When set to initial it will use the height of the shape at initialization. + * When set to a specific pixel height, will force the height to that height. + * + * @default 'initial' + * @since 2.2 + */ + height?: 'next' | 'initial' | number; + + // endregion + + // region Callbacks + + /** + * Is called before side change + */ + beforeChange?: (this: JQuery) => void; + /** + * Is called after visible side change + */ + onChange?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + selector?: { + /** + * @default '.sides' + */ + sides?: string; + /** + * @default '.side' + */ + side?: string; + }; + className?: { + /** + * @default 'animating' + */ + animating?: string; + /** + * @default 'hidden' + */ + hidden?: string; + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'active' + */ + active?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'You tried to switch to a side that does not exist.' + */ + side?: string; + /** + * @default 'The method you called is not defined' + */ + method?: string; + }; + + // endregion + } + + interface Translation { + transform: string; + } + + // endregion + + // region Sidebar + + /** + * @see {@link http://semantic-ui.com/modules/sidebar.html#/settings} + */ + interface SidebarSettings extends ComponentSettings { + // region Behavior + + /** + * Context which sidebar will appear inside + * + * @default 'body' + */ + context?: Selector; + /** + * Whether multiple sidebars can be open at once + * + * @default false + */ + exclusive?: boolean; + /** + * Whether sidebar can be closed by clicking on page + * + * @default true + */ + closable?: boolean; + /** + * Whether to dim page contents when sidebar is visible + * + * @default true + */ + dimPage?: boolean; + /** + * Whether to lock page scroll when sidebar is visible + * + * @default false + */ + scrollLock?: boolean; + /** + * Whether to return to original scroll position when sidebar is hidden, automatically occurs with transition: scale + * + * @default false + */ + returnScroll?: boolean; + /** + * When sidebar is initialized without the proper HTML, using this option will defer creation of DOM to use requestAnimationFrame. + * + * @default false + */ + delaySetup?: boolean; + + // endregion + + // region Animation + + /** + * Named transition to use when animating sidebar. Defaults to 'auto' which selects transition from defaultTransition based on direction. + * + * @default 'auto' + */ + transition?: string; + /** + * Named transition to use when animating when detecting mobile device. Defaults to 'auto' which selects transition from defaultTransition based on direction. + * + * @default 'auto' + */ + mobileTransition?: string; + /** + * Default transitions for each direction and screen size, used with transition: auto + */ + defaultTransition?: { + computer?: { + /** + * @default 'uncover' + */ + left?: string; + /** + * @default 'uncover' + */ + right?: string; + /** + * @default 'overlay' + */ + top?: string; + /** + * @default 'overlay' + */ + bottom?: string; + }; + mobile?: { + /** + * @default 'uncover' + */ + left?: string; + /** + * @default 'uncover' + */ + right?: string; + /** + * @default 'overlay' + */ + top?: string; + /** + * @default 'overlay' + */ + bottom?: string; + }; + }; + /** + * Whether Javascript animations should be used. Defaults to false. Setting to auto will use legacy animations only for browsers that do not support CSS transforms + * + * @default false + */ + useLegacy?: 'auto' | boolean; + /** + * Duration of sidebar animation when using legacy Javascript animation + * + * @default 500 + */ + duration?: number; + /** + * Easing to use when using legacy Javascript animation + * + * @default 'easeInOutQuint' + */ + easing?: string; + + // endregion + + // region Callbacks + + /** + * Is called when a sidebar begins animating in. + */ + onVisible?: (this: JQuery) => void; + /** + * Is called when a sidebar has finished animating in. + */ + onShow?: (this: JQuery) => void; + /** + * Is called when a sidebar begins to hide or show + */ + onChange?: (this: JQuery) => void; + /** + * Is called before a sidebar begins to animate out. + */ + onHide?: (this: JQuery) => void; + /** + * Is called after a sidebar has finished animating out. + */ + onHidden?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'animating' + */ + animating?: string; + /** + * @default 'dimmed' + */ + dimmed?: string; + /** + * @default 'ios' + */ + ios?: string; + /** + * @default 'pushable' + */ + pushable?: string; + /** + * @default 'pushed' + */ + pushed?: string; + /** + * @default 'right' + */ + right?: string; + /** + * @default 'top' + */ + top?: string; + /** + * @default 'left' + */ + left?: string; + /** + * @default 'bottom' + */ + bottom?: string; + /** + * @default 'visible' + */ + visible?: string; + }; + regExp?: { + /** + * @default /(iPad|iPhone|iPod)/g + */ + ios?: RegExp; + /** + * @default /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g + */ + mobile?: RegExp; + }; + selector?: { + /** + * @default '.fixed' + */ + fixed?: string; + /** + * @default 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed' + */ + omitted?: string; + /** + * @default '.pusher' + */ + pusher?: string; + /** + * @default '.ui.sidebar' + */ + sidebar?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + /** + * @default 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element' + */ + pusher?: string; + /** + * @default 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag' + */ + movedSidebar?: string; + /** + * @default 'The overlay setting is no longer supported, use animation: overlay' + */ + overlay?: string; + /** + * @default 'There were no elements that matched the specified selector' + */ + notFound?: string; + }; + + // endregion + } + + // endregion + + // region Sticky + + /** + * @see {@link http://semantic-ui.com/modules/sticky.html#/settings} + */ + interface StickySettings extends ComponentSettings { + // region Sticky Settings + + /** + * Whether element should be "pushed" by the viewport, attaching to the bottom of the screen when scrolling up + * + * @default false + */ + pushing?: boolean; + /** + * Sticky container height will only be set if the difference between heights of container and context is larger than this jitter value. + * + * @default 5 + */ + jitter?: number; + /** + * Whether any change in context DOM should automatically refresh cached sticky positions + * + * @default false + */ + observeChanges?: boolean; + /** + * Context which sticky element should stick to + * + * @default false + */ + context?: false | Selector; + /** + * Context which sticky should attach onscroll events. + * + * @default 'window' + */ + scrollContext?: Selector; + /** + * Offset in pixels from the top of the screen when fixing element to viewport + * + * @default 0 + */ + offset?: number; + /** + * Offset in pixels from the bottom of the screen when fixing element to viewport + * + * @default 0 + */ + bottomOffset?: number; + + // endregion + + // region Callbacks + + /** + * Callback when element is repositioned from layout change + */ + onReposition?: (this: JQuery) => void; + /** + * Callback when requestAnimationFrame fires from scroll handler. + */ + onScroll?: (this: JQuery) => void; + /** + * Callback when element is fixed to page + */ + onStick?: (this: JQuery) => void; + /** + * Callback when element is unfixed from page + */ + onUnstick?: (this: JQuery) => void; + /** + * Callback when element is bound to top of parent container + */ + onTop?: (this: JQuery) => void; + /** + * Callback when element is bound to bottom of parent container + */ + onBottom?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'bound' + */ + bound?: string; + /** + * @default 'fixed' + */ + fixed?: string; + /** + * @default 'native' + */ + supported?: string; + /** + * @default 'top' + */ + top?: string; + /** + * @default 'bottom' + */ + bottom?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'Sticky element must be inside a relative container' + */ + container?: string; + /** + * @default 'Element is hidden, you must call refresh after element becomes visible' + */ + visible?: string; + /** + * @default 'The method you called is not defined.' + */ + method?: string; + /** + * @default 'Context specified does not exist' + */ + invalidContext?: string; + /** + * @default 'Sticky element is larger than its container, cannot create sticky.' + */ + elementSize?: string; + }; + + // endregion + } + + // endregion + + // region Tab + + /** + * @see {@link http://semantic-ui.com/modules/tab.html#/settings} + */ + interface TabSettings extends ComponentSettings { + // region Tab Settings + + /** + * Whether tab should load remote content as same url as history + * + * @default false + */ + auto?: boolean; + /** + * When set to siblings will only deactivate elements that are DOM siblings with the activated element. + * When set to all the component will deactivate all other elements initialized at the same time. + * + * @default 'siblings' + * @since 2.2 + */ + deactivate?: 'siblings' | 'all'; + /** + * Whether to record history events for tab changes + * + * @default false + */ + history?: boolean; + /** + * Do not load content remotely on first tab load. Useful when open tab is rendered on server. + * + * @default false + */ + ignoreFirstLoad?: boolean; + /** + * Whether inline scripts in tab HTML should be parsed on tab load. + * Defaults to once, parsing only on first load. + * Can also be set to true or false to always parse or never parse inline scripts. + * + * @default 'once' + */ + evaluateScripts?: 'once' | boolean; + /** + * Tab should reload content every time it is opened + */ + alwaysRefresh?: boolean; + /** + * Can be set to either response, DOM or html. + * Using DOM will cache the a clone of the DOM tree, preserving all events as they existed on render. + * response will cache the original response on load, this way callbacks always receive the same content. + * Using html will cache the resulting html after all callbacks, making sure any changes to content are preserved. + * + * @default 'response' + */ + cacheType?: 'response' | 'DOM' | 'html'; + /** + * Tab should cache content after loading locally to avoid server trip on second load + * + * @default true + */ + cache?: boolean; + /** + * Settings object for $.api call + * + * @default false + * @see {@link http://semantic-ui.com/behaviors/api.html} + */ + apiSettings?: ApiSettings; + /** + * Can be set to hash or state. + * Hash will use an in-page link to create history events. + * State will use DOM History and load pages from server on refresh. + * + * @default 'hash' + * @see {@link https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history} + */ + historyType?: 'hash' | 'state'; + /** + * When using historyType state you must specify the base URL for all internal links. + * + * @default false + */ + path?: false | string; + /** + * Tabs are limited to those found inside this context + * + * @default false + */ + context?: false | Selector; + /** + * If enabled limits tabs to children of passed context + * + * @default false + */ + childrenOnly?: boolean; + /** + * Maximum amount of nested tabs allowed (avoids recursion) + * + * @default 25 + */ + maxDepth?: number; + + // endregion + + // region Callbacks + + /** + * Callback only the first time a tab is loaded + */ + onFirstLoad?: (this: JQuery, tabPath: string, parameterArray: any[], historyEvent: any) => void; + /** + * Callback every time a tab is loaded + */ + onLoad?: (this: JQuery, tabPath: string, parameterArray: any[], historyEvent: any) => void; + /** + * Called when a tab begins loading remote content + */ + onRequest?: (this: JQuery, tabPath: string) => void; + /** + * Called after a tab becomes visible + */ + onVisible?: (this: JQuery, tabPath: string) => void; + + // endregion + + // region DOM Settings + + /** + * Functions used to return content + */ + templates?: { + /** + * returns page title + */ + determineTitle?: (tabArray: any[]) => string; + }; + /** + * Selectors used by module + */ + selector?: { + /** + * @default '.ui.tab' + */ + tabs?: string; + /** + * @default '.ui:not(.menu)' + */ + parent?: string; + }; + /** + * DOM metadata used by module + */ + metadata?: { + /** + * @default 'tab' + */ + tab?: string; + /** + * @default 'loaded' + */ + loaded?: string; + /** + * @default 'promise' + */ + promise?: string; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'active' + */ + active?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'You attempted to load content without API module' + */ + api?: string; + /** + * @default 'The method you called is not defined' + */ + method?: string; + /** + * @default 'Activated tab cannot be found for this context.' + */ + missingTab?: string; + /** + * @default 'The tab you specified is missing a content url.' + */ + noContent?: string; + /** + * @default 'History enabled, but no path was specified' + */ + path?: string; + /** + * @default 'Max recursive depth reached' + */ + recursion?: string; + /** + * @default 'The state library has not been initialized' + */ + state?: string; + }; + + // endregion + } + + // endregion + + // region Transition + + /** + * @see {@link http://semantic-ui.com/modules/transition.html#/settings} + */ + interface TransitionSettings extends ComponentSettings { + // region Transition Settings + + /** + * Named animation event to used. Must be defined in CSS. + * + * @default 'fade' + */ + animation?: string; + /** + * Interval in MS between each elements transition + * + * @default 0 + */ + interval?: number; + /** + * When an interval is specified, sets order of animations. auto reverses only animations that are hiding. + * + * @default 'auto' + */ + reverse?: 'auto' | boolean; + /** + * Specify the final display type (block, inline-block etc) so that it doesn't have to be calculated. + * + * @default false + */ + displayType?: false | string; + /** + * Duration of the CSS transition animation + * + * @default 500 + */ + duration?: number; + /** + * If enabled a timeout will be added to ensure animationend callback occurs even if element is hidden + */ + useFailSafe?: boolean; + /** + * If enabled will allow same animation to be queued while it is already occurring + */ + allowRepeats?: boolean; + /** + * Whether to automatically queue animation if another is occurring + */ + queue?: boolean; + + // endregion + + // region Callbacks + + /** + * Callback on each transition that changes visibility to shown + */ + onShow?: (this: JQuery) => void; + /** + * Callback on each transition that changes visibility to hidden + */ + onHide?: (this: JQuery) => void; + /** + * Callback on animation start, useful for queued animations + */ + onStart?: (this: JQuery) => void; + /** + * Callback on each transition complete + */ + onComplete?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'animating' + */ + animating?: string; + /** + * @default 'disabled' + */ + disabled?: string; + /** + * @default 'hidden' + */ + hidden?: string; + /** + * @default 'in' + */ + inward?: string; + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'looping' + */ + looping?: string; + /** + * @default 'out' + */ + outward?: string; + /** + * @default 'transition' + */ + transition?: string; + /** + * @default 'visible' + */ + visible?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'There is no CSS animation matching the one you specified.' + */ + noAnimation?: string; + /** + * @default 'The method you called is not defined' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // endregion + + // region Behaviors + + // region API + + /** + * @see {@link http://semantic-ui.com/behaviors/api.html#/settings} + */ + interface ApiSettings extends ComponentSettings { + // region Behavior + + /** + * When API event should occur + * + * @default 'auto' + */ + on?: string; + /** + * Can be set to 'local' to cache successful returned AJAX responses when using a JSON API. + * This helps avoid server round trips when API endpoints will return the same results when accessed repeatedly. + * Setting to false, will add cache busting parameters to the URL. + * + * @default true + */ + cache?: 'local' | boolean; + /** + * UI state will be applied to this element, defaults to triggering element. + */ + stateContext?: Selector; + /** + * Whether to encode parameters with encodeURIComponent before adding into url string + * + * @default true + */ + encodeParameters?: boolean; + /** + * Whether to automatically include default data like {value} and {text} + * + * @default true + */ + defaultData?: boolean; + /** + * Whether to serialize closest form and include in request + * + * @default false + */ + serializeForm?: boolean; + /** + * How long to wait when a request is made before triggering request, useful for rate limiting oninput + * + * @default 0 + */ + throttle?: number; + /** + * When set to false will not delay the first request made, when no others are queued + * + * @default true + */ + throttleFirstRequest?: boolean; + /** + * Whether an API request can occur while another request is still pending + * + * @default false + */ + interruptRequests?: boolean; + /** + * Minimum duration to show loading indication + * + * @default 0 + */ + loadingDuration?: number; + /** + * The default auto will automatically remove error state after error duration, unless the element is a form + * + * @default 'auto' + */ + hideError?: 'auto' | boolean; + /** + * Setting to true, will not remove error. + * Setting to a duration in milliseconds to show error state after request error. + * + * @default 2000 + */ + errorDuration?: true | number; + + // endregion + + // region Request Settings + + /** + * Named API action for query, originally specified in $.fn.settings.api + */ + action?: string | false; + /** + * Templated URL for query, will override specified action + */ + url?: string | false; + /** + * Variables to use for replacement + */ + urlData?: any | false; + /** + * Can be set to a Javascript object which will be returned automatically instead of requesting JSON from server + */ + response?: any | false; + /** + * When specified, this function can be used to retrieve content from a server and return it asynchronously instead of a standard AJAX call. + * The callback function should return the server response. + * + * @default false + */ + responseAsync?: ((settings: ApiSettings, callback: (response: any) => void) => void) | false; + /** + * @see response + */ + mockResponse?: any | false; + /** + * @see responseAsync + */ + mockResponseAsync?: ((settings: ApiSettings, callback: (response: any) => void) => void) | false; + /** + * Method for transmitting request to server + */ + method?: 'post' | 'get'; + /** + * Expected data type of response + */ + dataType?: 'xml' | 'json' | 'jsonp' | 'script' | 'html' | 'text'; + /** + * POST/GET Data to Send with Request + */ + data?: any; + + // endregion + + // region Callbacks + + /** + * Allows modifying settings before request, or cancelling request + */ + beforeSend?: (settings: ApiSettings) => any; + /** + * Allows modifying XHR object for request + */ + beforeXHR?: (xhrObject: JQueryXHR) => any; + /** + * Callback that occurs when request is made. Receives both the API success promise and the XHR request promise. + */ + onRequest?: (promise: JQueryDeferred, xhr: JQueryXHR) => void; + /** + * Allows modifying the server's response before parsed by other callbacks to determine API event success + */ + onResponse?: (response: any) => void; + /** + * Determines whether completed JSON response should be treated as successful + * + * @see {@link http://semantic-ui.com/behaviors/api.html#determining-json-success} + */ + successTest?: (response: any) => boolean; + /** + * Callback after successful response, JSON response must pass successTest + */ + onSuccess?: (response: any, element: JQuery, xhr: JQueryXHR) => void; + /** + * Callback on request complete regardless of conditions + */ + onComplete?: (response: any, element: JQuery, xhr: JQueryXHR) => void; + /** + * Callback on failed response, or JSON response that fails successTest + */ + onFailure?: (response: any, element: JQuery) => void; + /** + * Callback on server error from returned status code, or XHR failure. + */ + onError?: (errorMessage: string, element: JQuery, xhr: JQueryXHR) => void; + /** + * Callback on abort caused by user clicking a link or manually cancelling request. + */ + onAbort?: (errorMessage: string, element: JQuery, xhr: JQueryXHR) => void; + + // endregion + + // region DOM Settings + + /** + * Regular expressions used for template matching + */ + regExp?: { + /** + * @default /\{\$*[A-z0-9]+\}/g + */ + required?: RegExp; + /** + * @default /\{\/\$*[A-z0-9]+\}/g + */ + optional?: RegExp; + }; + /** + * Selectors used to find parts of a module + */ + selector?: { + /** + * @default '.disabled' + */ + disabled?: string; + /** + * @default 'form' + */ + form?: string; + }; + /** + * Class names used to determine element state + */ + className?: { + /** + * @default 'loading' + */ + loading?: string; + /** + * @default 'error' + */ + error?: string; + }; + /** + * Metadata used to store XHR and response promise + */ + metadata?: { + /** + * @default 'action' + */ + action?: string; + /** + * @default 'url' + */ + url?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The before send function has aborted the request' + */ + beforeSend?: string; + /** + * @default 'There was an error with your request' + */ + error?: string; + /** + * @default 'API Request Aborted. Exit conditions met' + */ + exitConditions?: string; + /** + * @default 'JSON could not be parsed during error handling' + */ + JSONParse?: string; + /** + * @default 'You are using legacy API success callback names' + */ + legacyParameters?: string; + /** + * @default 'API action used but no url was defined' + */ + missingAction?: string; + /** + * @default 'Required dependency jquery-serialize-object missing, using basic serialize' + */ + missingSerialize?: string; + /** + * @default 'No URL specified for API event' + */ + missingURL?: string; + /** + * @default 'The beforeSend callback must return a settings object, beforeSend ignored.' + */ + noReturnedValue?: string; + /** + * @default 'There was an error parsing your request' + */ + parseError?: string; + /** + * @default 'Missing a required URL parameter: ' + */ + requiredParameter?: string; + /** + * @default 'Server gave an error: ' + */ + statusMessage?: string; + /** + * @default 'Your request timed out' + */ + timeout?: string; + }; + + // endregion + } + + // endregion + + // region Form Validation + + /** + * @see {@link http://semantic-ui.com/behaviors/form.html#/settings} + */ + interface FormSettings extends ComponentSettings { + // region Form Settings + + /** + * Adds keyboard shortcuts for enter and escape keys to submit form and blur fields respectively + * + * @default true + */ + keyboardShortcuts?: boolean; + /** + * Event used to trigger validation. Can be either submit, blur or change. + * + * @default 'submit' + */ + on?: 'submit' | 'blur' | 'change'; + /** + * If set to true will revalidate fields with errors on input change + * + * @default true + */ + revalidate?: boolean; + /** + * Delay from last typed letter to validate a field when using on: change or when revalidating a field. + * + * @default true + */ + delay?: boolean; + /** + * Adds inline error on field validation error + * + * @default false + */ + inline?: boolean; + /** + * Named transition to use when animating validation errors. Fade and slide down are available without including ui transitions + * + * @default 'scale' + * @see {@link http://semantic-ui.com/modules/transition.html} + */ + transition?: string; + /** + * Animation speed for inline prompt + * + * @default 150 + */ + duration?: number; + + // endregion + + // region Form Prompts + + text?: { + /** + * @default 'Please enter a valid value' + */ + unspecifiedRule?: string; + /** + * @default 'This field' + */ + unspecifiedField?: string; + }; + prompt?: { + /** + * @default '{name} must have a value' + */ + empty?: string; + /** + * @default '{name} must be checked' + */ + checked?: string; + /** + * @default '{name} must be a valid e-mail' + */ + email?: string; + /** + * @default '{name} must be a valid url' + */ + url?: string; + /** + * @default '{name} is not formatted correctly' + */ + regExp?: string; + /** + * @default '{name} must be an integer' + */ + integer?: string; + /** + * @default '{name} must be a decimal number' + */ + decimal?: string; + /** + * @default '{name} must be set to a number' + */ + number?: string; + /** + * @default '{name} must be \'{ruleValue}\'' + */ + is?: string; + /** + * @default '{name} must be exactly \'{ruleValue}\'' + */ + isExactly?: string; + /** + * @default '{name} cannot be set to \'{ruleValue}\'' + */ + not?: string; + /** + * @default '{name} cannot be set to exactly \'{ruleValue}\'' + */ + notExactly?: string; + /** + * @default '{name} cannot contain \'{ruleValue}\'' + */ + contain?: string; + /** + * @default '{name} cannot contain exactly \'{ruleValue}\'' + */ + containExactly?: string; + /** + * @default '{name} must contain \'{ruleValue}\'' + */ + doesntContain?: string; + /** + * @default '{name} must contain exactly \'{ruleValue}\'' + */ + doesntContainExactly?: string; + /** + * @default '{name} must be at least {ruleValue} characters' + */ + minLength?: string; + /** + * @default '{name} must be at least {ruleValue} characters' + */ + length?: string; + /** + * @default '{name} must be exactly {ruleValue} characters' + */ + exactLength?: string; + /** + * @default '{name} cannot be longer than {ruleValue} characters' + */ + maxLength?: string; + /** + * @default '{name} must match {ruleValue} field' + */ + match?: string; + /** + * @default '{name} must have a different value than {ruleValue} field' + */ + different?: string; + /** + * @default '{name} must be a valid credit card number' + */ + creditCard?: string; + /** + * @default '{name} must have at least {ruleValue} choices' + */ + minCount?: string; + /** + * @default '{name} must have exactly {ruleValue} choices' + */ + exactCount?: string; + /** + * @default '{name} must have {ruleValue} or less choices' + */ + maxCount?: string; + }; + + // endregion + + // region Callbacks + + /** + * Callback on each valid field + */ + onValid?: (this: JQuery) => void; + /** + * Callback on each invalid field + */ + onInvalid?: (this: JQuery) => void; + /** + * Callback if a form is all valid + */ + onSuccess?: (this: JQuery, event: JQueryEventObject, fields: any) => void; + /** + * Callback if any form field is invalid + */ + onFailure?: (this: JQuery, formErrors: string[], fields: any) => void; + + // endregion + + // region DOM Settings + + /** + * Selectors used to match functionality to DOM + */ + selector?: { + /** + * @default '.error.message' + */ + message?: string; + /** + * @default 'input, textarea, select' + */ + field?: string; + /** + * @default '.field' + */ + group?: string; + /** + * @default 'input' + */ + input?: string; + /** + * @default '.prompt' + */ + prompt?: string; + /** + * @default '.submit' + */ + submit?: string; + }; + /** + * HTML5 metadata attributes + */ + metadata?: { + /** + * @default 'validate' + */ + validate?: string; + }; + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'active' + */ + active?: string; + /** + * @default 'default' + */ + placeholder?: string; + /** + * @default 'disabled' + */ + disabled?: string; + /** + * @default 'visible' + */ + visible?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + // endregion + + // region Visibility + + /** + * @see {@link http://semantic-ui.com/behaviors/visibility.html#/settings} + */ + interface VisibilitySettings extends ComponentSettings { + // region Functionality + + /** + * When set to false a callback will occur each time an element passes the threshold for a condition. + * + * @default true + */ + once?: boolean; + /** + * When set to true a callback will occur anytime an element passes a condition not just immediately after the threshold is met. + * + * @default false + */ + continuous?: boolean; + /** + * Set to image to load images when on screen. Set to fixed to add class name fixed when passed. + * + * @default false + */ + type?: false | 'image' | 'fixed'; + /** + * Whether visibility conditions should be checked immediately on init + * + * @default true + */ + initialCheck?: boolean; + /** + * The scroll context visibility should use. + * + * @default 'window' + */ + context?: Selector; + /** + * Whether visibility conditions should be checked on window load. This ensures that after images load content positions will be updated correctly. + * + * @default true + */ + refreshOnLoad?: boolean; + /** + * Whether visibility conditions should be checked on window resize. Useful when content resizes causes continuous changes in position + * + * @default true + */ + refreshOnResize?: boolean; + /** + * Whether visibility conditions should be checked on calls to refresh. + * These calls can be triggered from either resize, load or manually calling $('.foo').visibility('refresh') + * + * @default true + */ + checkOnRefresh?: boolean; + /** + * Specify a z-index when using type: 'fixed'. + * + * @default 1 + * @since 2.2 + */ + zIndex?: number; + /** + * Value that context scrollTop should be adjusted in pixels. Useful for making content appear below content fixed to the page. + * + * @default 0 + */ + offset?: number; + /** + * Whether element calculations should include its margin + * + * @default false + */ + includeMargin?: boolean; + /** + * When set to an integer, scroll position will be debounced using this ms value. false will debounce with requestAnimationFrame. + * + * @default false + */ + throttle?: false | number; + /** + * Whether to automatically refresh content when changes are made to the element's DOM subtree + * + * @default true + */ + observeChanges?: boolean; + /** + * When using type: image allows you to specify transition when showing a loaded image + * + * @default false + */ + transition?: false | string; + /** + * When using type: image allows you to specify transition duration + * + * @default 1000 + */ + duration?: number; + + // endregion + + // region Visibility Callbacks + + /** + * Element's top edge has passed bottom of screen + */ + onTopVisible?: (this: JQuery) => void; + /** + * Element's top edge has passed top of the screen + */ + onTopPassed?: (this: JQuery) => void; + /** + * Element's bottom edge has passed bottom of screen + */ + onBottomVisible?: (this: JQuery) => void; + /** + * Any part of an element is visible on screen + */ + onPassing?: (this: JQuery) => void; + /** + * Element's bottom edge has passed top of screen + */ + onBottomPassed?: (this: JQuery) => void; + /** + * Element's top edge has not passed bottom of screen + */ + onTopVisibleReverse?: (this: JQuery) => void; + /** + * Element's top edge has not passed top of the screen + */ + onTopPassedReverse?: (this: JQuery) => void; + /** + * Element's bottom edge has not passed bottom of screen + */ + onBottomVisibleReverse?: (this: JQuery) => void; + /** + * Element's top has not passed top of screen but bottom has + */ + onPassingReverse?: (this: JQuery) => void; + /** + * Element's bottom edge has not passed top of screen + */ + onBottomPassedReverse?: (this: JQuery) => void; + + // endregion + + // region Image Callbacks + + /** + * Occurs after an image has completed loading + * + * @since 2.2 + */ + onLoad?: (this: JQuery) => void; + /** + * Occurs after all img initialized at the same time have loaded. + * + * @since 2.2 + */ + onAllLoaded?: (this: JQuery) => void; + + // endregion + + // region Fixed Callbacks + + /** + * Occurs after element has been assigned position fixed + * + * @since 2.2 + */ + onFixed?: (this: JQuery) => void; + /** + * Occurs after element has been removed from fixed position + * + * @since 2.2 + */ + onUnfixed?: (this: JQuery) => void; + + // endregion + + // region Utility Callbacks + + /** + * Occurs each time an elements calculations are updated + */ + onUpdate?: (this: JQuery, calculations: ElementCalculations) => void; + /** + * Occurs whenever element's visibility is refreshed + */ + onRefresh?: (this: JQuery) => void; + + // endregion + + // region DOM Settings + + /** + * Class names used to attach style to state + */ + className?: { + /** + * @default 'fixed' + */ + fixed?: string; + }; + + // endregion + + // region Debug Settings + + error?: { + /** + * @default 'The method you called is not defined.' + */ + method?: string; + }; + + // endregion + } + + interface ElementPosition { + fits: boolean; + offset: JQueryCoordinates; + width: number; + height: number; + } + + interface ElementCalculations extends ElementPosition { + margin?: { + top: number; + bottom: number; + }; + top: number; + bottom: number; + + topVisible: boolean; + topPassed: boolean; + bottomVisible: boolean; + bottomPassed: boolean; + pixelsPassed: number; + percentagePassed: number; + + onScreen: boolean; + passing: boolean; + offScreen: boolean; + } + + interface ScreenCalculations { + top: number; + bottom: number; + } + + interface ScreenSize { + height: number; + } + + // endregion + + // endregion +} diff --git a/semantic-ui/semantic-ui-tests.ts b/semantic-ui/semantic-ui-tests.ts new file mode 100644 index 0000000000..f116507459 --- /dev/null +++ b/semantic-ui/semantic-ui-tests.ts @@ -0,0 +1,140 @@ +function test_Accordion() { + const selector = '.ui.accordion'; + $(selector).accordion('refresh'); + $(selector).accordion('open', 0); + $(selector).accordion('close others'); + $(selector).accordion('close', 0); + $(selector).accordion('toggle', 0); + $(selector).accordion({ + selector: { + trigger: '.title .icon' + } + }); + $(selector).accordion(); +} +test_Accordion(); + +function test_Checkbox() { + const selector = '.ui.checkbox'; + $(selector).checkbox({}); + $(selector).checkbox(); +} +test_Checkbox(); + +function test_Dimmer() { + const selector = '.ui.dimmer'; + $(selector).dimmer({}); + $(selector).dimmer(); +} +test_Dimmer(); + +function test_Dropdown() { + const selector = '.ui.dropdown'; + $(selector).dropdown({}); + $(selector).dropdown(); +} +test_Dropdown(); + +function test_Embed() { + const selector = '.ui.embed'; + $(selector).embed({}); + $(selector).embed(); +} +test_Embed(); + +function test_Modal() { + const selector = '.ui.modal'; + $(selector).modal({}); + $(selector).modal(); +} +test_Modal(); + +function test_Nag() { + const selector = '.ui.nag'; + $(selector).nag({}); +} +test_Nag(); + +function test_Popup() { + const selector = '.ui.popup'; + $(selector).popup({}); + $(selector).popup(); +} +test_Popup(); + +function test_Progress() { + const selector = '.ui.progress'; + $(selector).progress({}); + $(selector).progress(); +} +test_Progress(); + +function test_Rating() { + const selector = '.ui.rating'; + $(selector).rating({}); + $(selector).rating(); +} +test_Rating(); + +function test_Search() { + const selector = '.ui.search'; + $(selector).search({}); + $(selector).search(); +} +test_Search(); + +function test_Shape() { + const selector = '.ui.shape'; + $(selector).shape({}); + $(selector).shape(); +} +test_Shape(); + +function test_Sidebar() { + const selector = '.ui.sidebar'; + $(selector).sidebar({}); + $(selector).sidebar(); +} +test_Sidebar(); + +function test_Sticky() { + const selector = '.ui.sticky'; + $(selector).sticky({}); + $(selector).sticky(); +} +test_Sticky(); + +function test_Tab() { + const selector = '.ui.tab'; + $(selector).tab({}); + $(selector).tab(); +} +test_Tab(); + +function test_Transition() { + const selector = '.ui.transition'; + $(selector).transition({}); + $(selector).transition(); +} +test_Transition(); + +function test_Api() { + const selector = '.ui.api'; + $(selector).api({}); + $(selector).api(); +} +test_Api(); + +function test_Form() { + const selector = '.ui.form'; + $(selector).form({}); + $(selector).form(); +} +test_Form(); + +function test_Visibility() { + const selector = '.ui.visibility'; + $(selector).visibility({}); + $(selector).visibility(); +} +test_Visibility(); diff --git a/semantic-ui/tsconfig.json b/semantic-ui/tsconfig.json new file mode 100644 index 0000000000..f57f321023 --- /dev/null +++ b/semantic-ui/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "semantic-ui-tests.ts" + ] +} diff --git a/semantic-ui/tslint.json b/semantic-ui/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/semantic-ui/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 227e85833925be724fa847d1acc9ad1a75b2eac2 Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Fri, 20 Jan 2017 09:44:32 +0900 Subject: [PATCH 159/248] Fix typings that depend on old version --- react-i18next/tsconfig.json | 2 +- react-router/tsconfig.json | 4 +-- react-router/v2/tsconfig.json | 3 ++- redux-bootstrap/index.d.ts | 46 +++++++++++++++++------------------ redux-bootstrap/tsconfig.json | 3 --- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/react-i18next/tsconfig.json b/react-i18next/tsconfig.json index 5936e04b91..c64579c2e8 100644 --- a/react-i18next/tsconfig.json +++ b/react-i18next/tsconfig.json @@ -12,7 +12,7 @@ "paths": { "history": ["history/v2"], "history/*": ["history/v2/*"], - "react-router": ["react-router/v2"], + "react-router": ["react-router/v2"] }, "typeRoots": [ "../" diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index c013e2c959..e2a4e054ad 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -10,9 +10,7 @@ "strictNullChecks": false, "jsx": "react", "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/react-router/v2/tsconfig.json b/react-router/v2/tsconfig.json index c92402947c..d9c384bdcf 100644 --- a/react-router/v2/tsconfig.json +++ b/react-router/v2/tsconfig.json @@ -14,7 +14,8 @@ ], "paths": { "history": ["history/v2"], - "react-router": ["react-router/v2"] + "react-router": ["react-router/v2"], + "react-router/*": ["react-router/v2/*"] }, "types": [], "noEmit": true, diff --git a/redux-bootstrap/index.d.ts b/redux-bootstrap/index.d.ts index 6a539853b7..a4dc46fcfc 100644 --- a/redux-bootstrap/index.d.ts +++ b/redux-bootstrap/index.d.ts @@ -1,29 +1,29 @@ -// Type definitions for react-bootstrap v1.0.0 +// Type definitions for react-bootstrap 1.0 // Project: https://github.com/remojansen/redux-bootstrap // Definitions by: Remo H. Jansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "redux-bootstrap" { - import * as Redux from "redux"; - import ReactRouterRedux = require("react-router-redux"); +import * as React from "react"; +import { Middleware, Reducer, Store } from "redux"; +import { History } from "history"; - interface BootstrapOptions { - routes: JSX.Element; - reducers: ReducersOption; - middlewares?: Redux.Middleware[]; - initialState?: any; - container?: string; - } - - interface BootstrapResult { - store: Redux.Store; - history: ReactRouterRedux.ReactRouterReduxHistory; - root: JSX.Element; - } - - interface ReducersOption { - [index: string]: Redux.Reducer; - } - - export default function bootstrap(options: BootstrapOptions): BootstrapResult; +export interface BootstrapOptions { + routes: JSX.Element; + reducers: ReducersOption; + middlewares?: Middleware[]; + initialState?: any; + container?: string; } + +export interface BootstrapResult { + store: Store; + history: History; + root: JSX.Element; +} + +export interface ReducersOption { + [index: string]: Reducer; +} + +export default function bootstrap(options: BootstrapOptions): BootstrapResult; + diff --git a/redux-bootstrap/tsconfig.json b/redux-bootstrap/tsconfig.json index a5c0900ca4..cca0524f9c 100644 --- a/redux-bootstrap/tsconfig.json +++ b/redux-bootstrap/tsconfig.json @@ -9,9 +9,6 @@ "noImplicitThis": true, "strictNullChecks": false, "baseUrl": "../", - "paths": { - "history": ["history/v2"] - }, "typeRoots": [ "../" ], From 57db8d571f777dfef1277a01f30107665e362eeb Mon Sep 17 00:00:00 2001 From: Brett Epps Date: Thu, 26 Jan 2017 00:22:29 -0600 Subject: [PATCH 160/248] Add types for keycloak-authz.js in keycloak-js package --- keycloak-js/index.d.ts | 2 +- keycloak-js/keycloak-authz.d.ts | 39 ++++++++++++++++++++++++++++++++ keycloak-js/keycloak-js-tests.ts | 4 ++++ keycloak-js/tsconfig.json | 3 ++- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 keycloak-js/keycloak-authz.d.ts diff --git a/keycloak-js/index.d.ts b/keycloak-js/index.d.ts index 2cd417da6b..540084d6fd 100644 --- a/keycloak-js/index.d.ts +++ b/keycloak-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for keycloak-js 2.4 +// Type definitions for keycloak-js 2.5 // Project: https://github.com/keycloak/keycloak // Definitions by: Brett Epps // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/keycloak-js/keycloak-authz.d.ts b/keycloak-js/keycloak-authz.d.ts new file mode 100644 index 0000000000..4db057ad97 --- /dev/null +++ b/keycloak-js/keycloak-authz.d.ts @@ -0,0 +1,39 @@ +import * as Keycloak from 'keycloak-js'; + +export as namespace KeycloakAuthorization; + +export = KeycloakAuthorization; + +/** + * Creates a new Keycloak client instance. + * @param config Path to a JSON config file or a plain config object. + */ +declare function KeycloakAuthorization(keycloak: Keycloak.KeycloakInstance): KeycloakAuthorization.KeycloakAuthorizationInstance; + +declare namespace KeycloakAuthorization { + export interface KeycloakAuthorizationPromise { + then(onGrant: (rpt: string) => void, onDeny: () => void, onError: () => void): void; + } + + export interface KeycloakAuthorizationInstance { + rpt: any; + config: { rpt_endpoint: string }; + + init(): void; + + /** + * This method enables client applications to better integrate with resource servers protected by a Keycloak + * policy enforcer. + * + * In this case, the resource server will respond with a 401 status code and a WWW-Authenticate header holding the + * necessary information to ask a Keycloak server for authorization data using both UMA and Entitlement protocol, + * depending on how the policy enforcer at the resource server was configured. + */ + authorize(wwwAuthenticateHeader: string): KeycloakAuthorizationPromise; + + /** + * Obtains all entitlements from a Keycloak server based on a given resourceServerId. + */ + entitlement(resourceServerId: string, entitlementRequest: {}): KeycloakAuthorizationPromise; + } +} diff --git a/keycloak-js/keycloak-js-tests.ts b/keycloak-js/keycloak-js-tests.ts index f0957d2114..dc97d8da18 100644 --- a/keycloak-js/keycloak-js-tests.ts +++ b/keycloak-js/keycloak-js-tests.ts @@ -11,4 +11,8 @@ import { KeycloakResponseType } from 'keycloak-js'; +import * as KeycloakAuthorization from 'keycloak-js/keycloak-authz'; +import { KeycloakAuthorizationPromise } from 'keycloak-js/keycloak-authz'; + let keycloak = Keycloak(); +let keycloakAuthz = KeycloakAuthorization(keycloak); diff --git a/keycloak-js/tsconfig.json b/keycloak-js/tsconfig.json index 02d8f5053a..7ac994a5dc 100644 --- a/keycloak-js/tsconfig.json +++ b/keycloak-js/tsconfig.json @@ -17,6 +17,7 @@ }, "files": [ "index.d.ts", + "keycloak-authz.d.ts", "keycloak-js-tests.ts" ] -} \ No newline at end of file +} From b3d69dbd466bc3876d7e411fa39e325433d4818d Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Thu, 26 Jan 2017 07:47:00 +0100 Subject: [PATCH 161/248] fix Useful --- react-widgets/lib/DateTimePicker.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-widgets/lib/DateTimePicker.d.ts b/react-widgets/lib/DateTimePicker.d.ts index 6428927cf4..0760648984 100644 --- a/react-widgets/lib/DateTimePicker.d.ts +++ b/react-widgets/lib/DateTimePicker.d.ts @@ -32,7 +32,7 @@ interface DateTimePickerProps extends React.Props { */ currentDate?: Date; /* - * Default value for current date. Usefull for suggesting a date when the caldenar opens without keep forcing it once 'value' is set. + * Default value for current date. Useful for suggesting a date when the caldenar opens without keep forcing it once 'value' is set. */ defaultCurrentDate?: Date; /** From 748431211f8bc7306c1384f44f4b9bbe05222cee Mon Sep 17 00:00:00 2001 From: Shun Date: Wed, 25 Jan 2017 23:37:18 -0800 Subject: [PATCH 162/248] Add typing files for forever-monitor 1.7 --- forever-monitor/forever-monitor-tests.ts | 15 +++++++++++++++ forever-monitor/index.d.ts | 18 +++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/forever-monitor/forever-monitor-tests.ts b/forever-monitor/forever-monitor-tests.ts index e69de29bb2..f679c4704a 100644 --- a/forever-monitor/forever-monitor-tests.ts +++ b/forever-monitor/forever-monitor-tests.ts @@ -0,0 +1,15 @@ +// Test from https://github.com/foreverjs/forever-monitor + +import * as forever from "forever-monitor"; + +const child = new (forever.Monitor)('your-filename.js', { + max: 3, + silent: true, + args: [] +}); + +child.on('exit', function() { + console.log('your-filename.js has exited after 3 restarts'); +}); + +child.start(); diff --git a/forever-monitor/index.d.ts b/forever-monitor/index.d.ts index b22905cae2..58c32ec5e6 100644 --- a/forever-monitor/index.d.ts +++ b/forever-monitor/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for forever-monitor 1.7 // Project: https://github.com/nodejitsu/forever-monitor#readme -// Definitions by: My Self +// Definitions by: Shun Takahashi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -53,44 +53,44 @@ export declare class Monitor extends NodeJS.EventEmitter { * @description Start the process that this instance is configured for * @param [restart] - Value indicating whether this is a restart. */ - public start(restart?: boolean): this; + start(restart?: boolean): this; /** * @description Tries to spawn the target Forever child process. */ - public trySpawn(): boolean; + trySpawn(): boolean; /** * @description Restarts the target script associated with this instance. */ - public restart(): this; + restart(): this; /** * @description Stops the target script associated with this instance. Prevents it from auto-respawning */ - public stop(): this; + stop(): this; /** * @description Kills the ChildProcess object associated with this instance * @param [forceStop] - Value indicating whether short circuit forever auto-restart */ - public kill(forceStop?: boolean): this; + kill(forceStop?: boolean): this; /** * @description Sends a message to a forked ChildProcess object associated with this instance */ - public send(msg?: any): this; + send(msg?: any): this; /** * respond with JSON for this instance */ - public toString(): string; + toString(): string; /** * @param command - Command string to parse * @param args - Additional default arguments */ - public parseCommand(command: string, args?: string[]): (false | { command: string, args?: string[]}); + parseCommand(command: string, args?: string[]): (false | { command: string, args?: string[]}); } interface forever { From d34e301e35d6bac5d7b6b8c44ba3580cbd3d0d5b Mon Sep 17 00:00:00 2001 From: Kacper Polak Date: Thu, 26 Jan 2017 09:17:44 +0100 Subject: [PATCH 163/248] Downgrade version --- validator/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/index.d.ts b/validator/index.d.ts index ec1a74c19a..36b7d23088 100644 --- a/validator/index.d.ts +++ b/validator/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for validator.js v6.2.1 +// Type definitions for validator.js v6.2.0 // Project: https://github.com/chriso/validator.js // Definitions by: tgfjt , Ilya Mochalov , Ayman Nedjmeddine , Louy Alakkad , Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From e297d2677fb7bb82e6c06ef4a34532c8d65bcb0b Mon Sep 17 00:00:00 2001 From: york yao Date: Thu, 26 Jan 2017 19:20:44 +0800 Subject: [PATCH 164/248] fix name, class to interface, var to const, enable strictNullChecks --- node-zookeeper-client/index.d.ts | 6 +++--- .../node-zookeeper-client-tests.ts | 14 +++++++------- node-zookeeper-client/tsconfig.json | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts index cb9979e9f4..a85d14b7cc 100644 --- a/node-zookeeper-client/index.d.ts +++ b/node-zookeeper-client/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jasmine 2.5 +// Type definitions for node-zookeeper-client 0.2 // Project: https://github.com/alexguan/node-zookeeper-client // Definitions by: York Yao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -72,7 +72,7 @@ export class Event { getPath(): string; } -export class Transaction { +interface Transaction { create(path: string, dataOrAclsOrmode1?: Buffer | ACL[] | number, dataOrAclsOrmode2?: Buffer | ACL[] | number, dataOrAclsOrmode3?: Buffer | ACL[] | number): this; setData(path: string, data: Buffer | null, version?: number): this; check(path: string, version?: number): this; @@ -80,7 +80,7 @@ export class Transaction { commit(callback: (error: Error | Exception, results: any) => void): void; } -export class Client extends EventEmitter { +interface Client extends EventEmitter { connect(): void; close(): void; create(path: string, callback: (error: Error | Exception, path: string) => void): void; diff --git a/node-zookeeper-client/node-zookeeper-client-tests.ts b/node-zookeeper-client/node-zookeeper-client-tests.ts index 19cca8628b..91c434bafa 100644 --- a/node-zookeeper-client/node-zookeeper-client-tests.ts +++ b/node-zookeeper-client/node-zookeeper-client-tests.ts @@ -1,8 +1,8 @@ import * as zookeeper from "node-zookeeper-client"; { - var client = zookeeper.createClient('localhost:2181'); - var path = process.argv[2]; + const client = zookeeper.createClient('localhost:2181'); + const path = process.argv[2]; client.once('connected', function () { console.log('Connected to the server.'); @@ -44,8 +44,8 @@ function listChildren(client: zookeeper.Client, path: string) { } { - var client = zookeeper.createClient('localhost:2181'); - var path = process.argv[2]; + const client = zookeeper.createClient('localhost:2181'); + const path = process.argv[2]; client.once('connected', function () { console.log('Connected to ZooKeeper.'); @@ -55,7 +55,7 @@ function listChildren(client: zookeeper.Client, path: string) { client.connect(); } -var client = zookeeper.createClient( +const client = zookeeper.createClient( 'localhost:2181/test', { sessionTimeout: 10000 } ); @@ -188,12 +188,12 @@ var client = zookeeper.createClient( } { - var state = client.getState(); + const state = client.getState(); console.log('Current state is: %s', state); } { - var id = client.getSessionId(); + const id = client.getSessionId(); console.log('Session id is: %s', id.toString('hex')); } diff --git a/node-zookeeper-client/tsconfig.json b/node-zookeeper-client/tsconfig.json index d93291d45b..1f5ffdedf8 100644 --- a/node-zookeeper-client/tsconfig.json +++ b/node-zookeeper-client/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From c4cee4d79eb3b6d8eb5e99424913ea5af103ec10 Mon Sep 17 00:00:00 2001 From: york yao Date: Thu, 26 Jan 2017 20:01:15 +0800 Subject: [PATCH 165/248] fix wrong CreateMode value --- node-zookeeper-client/index.d.ts | 2 +- node-zookeeper-client/node-zookeeper-client-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node-zookeeper-client/index.d.ts b/node-zookeeper-client/index.d.ts index a85d14b7cc..227ebd45ad 100644 --- a/node-zookeeper-client/index.d.ts +++ b/node-zookeeper-client/index.d.ts @@ -132,7 +132,7 @@ export function createClient(connectionString: string, options?: Partial