diff --git a/types/baconjs/baconjs-tests.ts b/types/baconjs/baconjs-tests.ts index d39a4fd466..2755bec595 100644 --- a/types/baconjs/baconjs-tests.ts +++ b/types/baconjs/baconjs-tests.ts @@ -188,10 +188,10 @@ function CommonMethodsInEventStreamsAndProperties() { return adds.takeUntil(cancel).map(x => x.val); }; - Bacon.sequentially(2, events) + Bacon.sequentially(2, events) .groupBy(keyF, limitF) .flatMap(groupedStream => groupedStream.fold(0, (acc, x) => acc + x)) - .onValue(sum => { + .onValue((sum: number) => { console.log(sum); // returns [-1, 2, 8] in an order }); } diff --git a/types/cli/cli-tests.ts b/types/cli/cli-tests.ts index 294cb7dd8b..2a88a216db 100644 --- a/types/cli/cli-tests.ts +++ b/types/cli/cli-tests.ts @@ -52,7 +52,8 @@ cli.main(function (args, options) { } return str; } - for (i = 0, l = this.argc; i < l; i++) { + var l: number = this.argc; + for (i = 0; i < l; i++) { args[i] = escape(args[i]); } options.separator = escape(options.separator); diff --git a/types/content-type/index.d.ts b/types/content-type/index.d.ts index 5ff4ae7ff1..c81c78c966 100644 --- a/types/content-type/index.d.ts +++ b/types/content-type/index.d.ts @@ -18,7 +18,7 @@ export interface MediaType { } export interface RequestLike { - headers: {[header: string]: string | string[]}; + headers: {[header: string]: string | string[] | undefined}; } export interface ResponseLike { diff --git a/types/negotiator/index.d.ts b/types/negotiator/index.d.ts index c4d713ac5c..5f665331e3 100644 --- a/types/negotiator/index.d.ts +++ b/types/negotiator/index.d.ts @@ -78,6 +78,6 @@ declare class Negotiator { declare namespace Negotiator { interface Headers { - [key: string]: string | string[]; + [key: string]: string | string[] | undefined; } } diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 188e1315d6..41cc918bac 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -193,8 +193,6 @@ declare var Buffer: { prototype: Buffer; /** * Allocates a new Buffer using an {array} of octets. - * - * @param array */ from(array: any[]): Buffer; /** @@ -204,22 +202,16 @@ declare var Buffer: { * 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; /** @@ -838,7 +830,47 @@ declare module "http" { // incoming headers will never contain number export interface IncomingHttpHeaders { - [header: string]: string | string[]; + 'accept'?: string; + 'access-control-allow-origin'?: string; + 'access-control-allow-credentials'?: string; + 'access-control-expose-headers'?: string; + 'access-control-max-age'?: string; + 'access-control-allow-methods'?: string; + 'access-control-allow-headers'?: string; + 'accept-patch'?: string; + 'accept-ranges'?: string; + 'age'?: string; + 'allow'?: string; + 'alt-svc'?: string; + 'cache-control'?: string; + 'connection'?: string; + 'content-disposition'?: string; + 'content-encoding'?: string; + 'content-language'?: string; + 'content-length'?: string; + 'content-location'?: string; + 'content-range'?: string; + 'content-type'?: string; + 'date'?: string; + 'expires'?: string; + 'host'?: string; + 'last-modified'?: string; + 'location'?: string; + 'pragma'?: string; + 'proxy-authenticate'?: string; + 'public-key-pins'?: string; + 'retry-after'?: string; + 'set-cookie'?: string[]; + 'strict-transport-security'?: string; + 'trailer'?: string; + 'transfer-encoding'?: string; + 'tk'?: string; + 'upgrade'?: string; + 'vary'?: string; + 'via'?: string; + 'warning'?: string; + 'www-authenticate'?: string; + [header: string]: string | string[] | undefined; } // outgoing headers allows numbers (as they are converted internally to strings) @@ -4483,9 +4515,6 @@ declare module "path" { /** * 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; /** @@ -4718,7 +4747,7 @@ declare module "tls" { 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 + * @returns Returns an object representing the cipher name * and the SSL/TLS protocol version of the current connection. */ getCipher(): CipherNameAndProtocol; @@ -4728,21 +4757,21 @@ declare module "tls" { * 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 {PeerCertificate | DetailedPeerCertificate} - An object representing the peer's certificate. + * @param detailed - If true; the full chain with issuer property will be returned. + * @returns An object representing the peer's certificate. */ getPeerCertificate(detailed: true): DetailedPeerCertificate; getPeerCertificate(detailed?: false): PeerCertificate; getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate; /** * 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. + * @returns 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. + * @returns TLS session ticket or undefined if none was negotiated. */ getTLSTicket(): any; /** @@ -4750,9 +4779,9 @@ declare module "tls" { * * 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, + * @param 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 + * @param callback - callback(err) will be executed with null as err, once the renegotiation * is successfully completed. */ renegotiate(options: TlsOptions, callback: (err: Error | null) => void): any; @@ -4763,8 +4792,8 @@ declare module "tls" { * 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. + * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). + * @returns Returns true on success, false otherwise. */ setMaxSendFragment(size: number): boolean; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 315ec48d2f..41639e52c6 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -684,6 +684,7 @@ namespace util_tests { assert(typeof util.inspect.custom === 'symbol'); // util.callbackify + // tslint:disable-next-line no-unnecessary-class class callbackifyTest { static fn(): Promise { assert(arguments.length === 0); @@ -1321,9 +1322,24 @@ namespace http_tests { request.abort(); } - const options: http.RequestOptions = { - timeout: 30000 - }; + // http request options + { + const requestOpts: http.RequestOptions = { + timeout: 30000 + }; + + const clientArgs: http.ClientRequestArgs = { + timeout: 30000 + }; + } + + // http headers + { + const headers: http.IncomingHttpHeaders = { + 'content-type': 'application/json', + 'set-cookie': [ 'type=ninja', 'language=javascript' ] + }; + } } ////////////////////////////////////////////////////// diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index d88db82da1..5496da86cd 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -154,8 +154,6 @@ declare var Buffer: { prototype: Buffer; /** * Allocates a new Buffer using an {array} of octets. - * - * @param array */ from(array: any[]): Buffer; /** @@ -165,22 +163,16 @@ declare var Buffer: { * 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; /** @@ -565,21 +557,74 @@ declare module "http" { import * as net from "net"; import * as stream from "stream"; + // incoming headers will never contain number + export interface IncomingHttpHeaders { + 'accept'?: string; + 'access-control-allow-origin'?: string; + 'access-control-allow-credentials'?: string; + 'access-control-expose-headers'?: string; + 'access-control-max-age'?: string; + 'access-control-allow-methods'?: string; + 'access-control-allow-headers'?: string; + 'accept-patch'?: string; + 'accept-ranges'?: string; + 'age'?: string; + 'allow'?: string; + 'alt-svc'?: string; + 'cache-control'?: string; + 'connection'?: string; + 'content-disposition'?: string; + 'content-encoding'?: string; + 'content-language'?: string; + 'content-length'?: string; + 'content-location'?: string; + 'content-range'?: string; + 'content-type'?: string; + 'date'?: string; + 'expires'?: string; + 'host'?: string; + 'last-modified'?: string; + 'location'?: string; + 'pragma'?: string; + 'proxy-authenticate'?: string; + 'public-key-pins'?: string; + 'retry-after'?: string; + 'set-cookie'?: string[]; + 'strict-transport-security'?: string; + 'trailer'?: string; + 'transfer-encoding'?: string; + 'tk'?: string; + 'upgrade'?: string; + 'vary'?: string; + 'via'?: string; + 'warning'?: string; + 'www-authenticate'?: string; + [header: string]: string | string[] | undefined; + } + + // outgoing headers allows numbers (as they are converted internally to strings) + export interface OutgoingHttpHeaders { + [header: string]: number | string | string[] | undefined; + } + export interface RequestOptions { protocol?: string; host?: string; hostname?: string; family?: number; - port?: number; + port?: number | string; localAddress?: string; socketPath?: string; method?: string; path?: string; - headers?: { [key: string]: any }; + headers?: OutgoingHttpHeaders; auth?: string; - agent?: Agent|boolean; + agent?: Agent | boolean; + timeout?: number; } + export type ClientRequestArgs = RequestOptions + export interface Server extends net.Server { setTimeout(msecs: number, callback: Function): void; maxHeadersCount: number; @@ -600,8 +645,8 @@ declare module "http" { write(str: string, encoding?: string, fd?: string): boolean; writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; statusCode: number; statusMessage: string; headersSent: boolean; @@ -610,7 +655,7 @@ declare module "http" { getHeader(name: string): string; removeHeader(name: string): void; write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; // Extended base methods end(): void; @@ -636,7 +681,7 @@ declare module "http" { setHeader(name: string, value: string | string[]): void; getHeader(name: string): string; removeHeader(name: string): void; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; // Extended base methods end(): void; @@ -647,10 +692,10 @@ declare module "http" { } export interface IncomingMessage extends events.EventEmitter, stream.Readable { httpVersion: string; - headers: any; + headers: IncomingHttpHeaders; rawHeaders: string[]; - trailers: any; - rawTrailers: any; + trailers: OutgoingHttpHeaders; + rawTrailers: string[]; setTimeout(msecs: number, callback: Function): NodeJS.Timer; /** * Only valid for request obtained from http.Server. @@ -1576,15 +1621,11 @@ declare module "fs" { /** * Asynchronous rename. - * @param oldPath - * @param newPath * @param callback No arguments other than a possible exception are given to the completion callback. */ export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rename - * @param oldPath - * @param newPath */ export function renameSync(oldPath: string, newPath: string): void; export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; @@ -1629,79 +1670,62 @@ declare module "fs" { /** * 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. */ export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous unlink - deletes the file specified in {path} - * - * @param path */ export function unlinkSync(path: string): 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. */ export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rmdir - removes the directory specified in {path} - * - * @param path */ export function rmdirSync(path: string): 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. */ export function mkdir(path: string, 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. */ export function mkdir(path: string, 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. */ export function mkdir(path: string, 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, 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, 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; @@ -1736,8 +1760,6 @@ declare module "fs" { /** * 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: null, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; @@ -1746,7 +1768,6 @@ declare module "fs" { /** * 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. */ @@ -1756,7 +1777,6 @@ declare module "fs" { /** * 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. */ @@ -1764,15 +1784,11 @@ declare module "fs" { /** * 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: null): Buffer; export function readFileSync(filename: string, encoding: string): string; @@ -1780,7 +1796,6 @@ declare module "fs" { /** * 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: null; flag?: string; }): Buffer; @@ -1789,7 +1804,6 @@ declare module "fs" { /** * 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; @@ -1910,9 +1924,6 @@ declare module "path" { /** * 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; /** diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 05b20806cd..8f005da455 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -499,6 +499,25 @@ namespace http_tests { request.setNoDelay(true); request.abort(); } + + // http request options + { + const requestOpts: http.RequestOptions = { + timeout: 30000 + }; + + const clientArgs: http.ClientRequestArgs = { + timeout: 30000 + }; + } + + // http headers + { + const headers: http.IncomingHttpHeaders = { + 'content-type': 'application/json', + 'set-cookie': [ 'type=ninja', 'language=javascript' ] + }; + } } ////////////////////////////////////////////////////// diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 8f73bab752..ef2208af0b 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -150,8 +150,6 @@ declare var Buffer: { prototype: Buffer; /** * Allocates a new Buffer using an {array} of octets. - * - * @param array */ from(array: any[]): Buffer; /** @@ -161,22 +159,16 @@ declare var Buffer: { * 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; /** @@ -637,21 +629,74 @@ declare module "http" { import * as net from "net"; import * as stream from "stream"; + // incoming headers will never contain number + export interface IncomingHttpHeaders { + 'accept'?: string; + 'access-control-allow-origin'?: string; + 'access-control-allow-credentials'?: string; + 'access-control-expose-headers'?: string; + 'access-control-max-age'?: string; + 'access-control-allow-methods'?: string; + 'access-control-allow-headers'?: string; + 'accept-patch'?: string; + 'accept-ranges'?: string; + 'age'?: string; + 'allow'?: string; + 'alt-svc'?: string; + 'cache-control'?: string; + 'connection'?: string; + 'content-disposition'?: string; + 'content-encoding'?: string; + 'content-language'?: string; + 'content-length'?: string; + 'content-location'?: string; + 'content-range'?: string; + 'content-type'?: string; + 'date'?: string; + 'expires'?: string; + 'host'?: string; + 'last-modified'?: string; + 'location'?: string; + 'pragma'?: string; + 'proxy-authenticate'?: string; + 'public-key-pins'?: string; + 'retry-after'?: string; + 'set-cookie'?: string[]; + 'strict-transport-security'?: string; + 'trailer'?: string; + 'transfer-encoding'?: string; + 'tk'?: string; + 'upgrade'?: string; + 'vary'?: string; + 'via'?: string; + 'warning'?: string; + 'www-authenticate'?: string; + [header: string]: string | string[] | undefined; + } + + // outgoing headers allows numbers (as they are converted internally to strings) + export interface OutgoingHttpHeaders { + [header: string]: number | string | string[] | undefined; + } + export interface RequestOptions { protocol?: string; host?: string; hostname?: string; family?: number; - port?: number; + port?: number | string; localAddress?: string; socketPath?: string; method?: string; path?: string; - headers?: { [key: string]: any }; + headers?: OutgoingHttpHeaders; auth?: string; agent?: Agent | boolean; + timeout?: number; } + export type ClientRequestArgs = RequestOptions + export interface Server extends net.Server { setTimeout(msecs: number, callback: Function): void; maxHeadersCount: number; @@ -673,8 +718,8 @@ declare module "http" { write(str: string, encoding?: string, fd?: string): boolean; writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; statusCode: number; statusMessage: string; headersSent: boolean; @@ -684,7 +729,7 @@ declare module "http" { getHeader(name: string): string; removeHeader(name: string): void; write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; finished: boolean; // Extended base methods @@ -711,7 +756,7 @@ declare module "http" { setHeader(name: string, value: string | string[]): void; getHeader(name: string): string; removeHeader(name: string): void; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; // Extended base methods end(): void; @@ -725,10 +770,10 @@ declare module "http" { httpVersionMajor: number; httpVersionMinor: number; connection: net.Socket; - headers: any; + headers: IncomingHttpHeaders; rawHeaders: string[]; - trailers: any; - rawTrailers: any; + trailers: OutgoingHttpHeaders; + rawTrailers: string[]; setTimeout(msecs: number, callback: Function): NodeJS.Timer; /** * Only valid for request obtained from http.Server. @@ -2354,15 +2399,11 @@ declare module "fs" { /** * Asynchronous rename. - * @param oldPath - * @param newPath * @param callback No arguments other than a possible exception are given to the completion callback. */ export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rename - * @param oldPath - * @param newPath */ export function renameSync(oldPath: string, newPath: string): void; export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; @@ -2407,79 +2448,62 @@ declare module "fs" { /** * 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. */ export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous unlink - deletes the file specified in {path} - * - * @param path */ 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. */ export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rmdir - removes the directory specified in {path} - * - * @param path */ 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. */ 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. */ 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. */ 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; @@ -2512,8 +2536,6 @@ declare module "fs" { /** * 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: null, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; @@ -2522,7 +2544,6 @@ declare module "fs" { /** * 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. */ @@ -2532,7 +2553,6 @@ declare module "fs" { /** * 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. */ @@ -2540,15 +2560,11 @@ declare module "fs" { /** * 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: null): Buffer; export function readFileSync(filename: string, encoding: string): string; @@ -2556,7 +2572,6 @@ declare module "fs" { /** * 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: null; flag?: string; }): Buffer; @@ -2565,7 +2580,6 @@ declare module "fs" { /** * 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; @@ -2806,9 +2820,6 @@ declare module "path" { /** * 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; /** @@ -3007,7 +3018,7 @@ declare module "tls" { /** * 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' }. + * @returns An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. */ address(): { port: number; family: string; address: string }; /** @@ -3026,8 +3037,8 @@ declare module "tls" { 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. + * @returns Returns an object representing the cipher name and the SSL/TLS protocol version of the current + * connection. */ getCipher(): CipherNameAndProtocol; /** @@ -3036,8 +3047,8 @@ declare module "tls" { * 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. + * @param detailed - If true; the full chain with issuer property will be returned. + * @returns An object representing the peer's certificate. */ getPeerCertificate(detailed?: boolean): { subject: Certificate; @@ -3051,13 +3062,13 @@ declare module "tls" { }; /** * 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. + * @returns 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. + * @returns TLS session ticket or undefined if none was negotiated. */ getTLSTicket(): any; /** @@ -3086,9 +3097,9 @@ declare module "tls" { * * 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, + * @param 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 + * @param callback - callback(err) will be executed with null as err, once the renegotiation * is successfully completed. */ renegotiate(options: TlsOptions, callback: (err: Error) => any): any; @@ -3099,8 +3110,8 @@ declare module "tls" { * 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. + * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). + * @returns Returns true on success, false otherwise. */ setMaxSendFragment(size: number): boolean; diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 15c36ef058..1a6b87db05 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -935,6 +935,25 @@ namespace http_tests { request.setNoDelay(true); request.abort(); } + + // http request options + { + const requestOpts: http.RequestOptions = { + timeout: 30000 + }; + + const clientArgs: http.ClientRequestArgs = { + timeout: 30000 + }; + } + + // http headers + { + const headers: http.IncomingHttpHeaders = { + 'content-type': 'application/json', + 'set-cookie': [ 'type=ninja', 'language=javascript' ] + }; + } } ////////////////////////////////////////////////////// diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index fc6cd33091..9f4208a7cb 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -165,8 +165,6 @@ declare var Buffer: { prototype: Buffer; /** * Allocates a new Buffer using an {array} of octets. - * - * @param array */ from(array: any[]): Buffer; /** @@ -176,22 +174,16 @@ declare var Buffer: { * 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; /** @@ -653,22 +645,74 @@ declare module "http" { import * as net from "net"; import * as stream from "stream"; + // incoming headers will never contain number + export interface IncomingHttpHeaders { + 'accept'?: string; + 'access-control-allow-origin'?: string; + 'access-control-allow-credentials'?: string; + 'access-control-expose-headers'?: string; + 'access-control-max-age'?: string; + 'access-control-allow-methods'?: string; + 'access-control-allow-headers'?: string; + 'accept-patch'?: string; + 'accept-ranges'?: string; + 'age'?: string; + 'allow'?: string; + 'alt-svc'?: string; + 'cache-control'?: string; + 'connection'?: string; + 'content-disposition'?: string; + 'content-encoding'?: string; + 'content-language'?: string; + 'content-length'?: string; + 'content-location'?: string; + 'content-range'?: string; + 'content-type'?: string; + 'date'?: string; + 'expires'?: string; + 'host'?: string; + 'last-modified'?: string; + 'location'?: string; + 'pragma'?: string; + 'proxy-authenticate'?: string; + 'public-key-pins'?: string; + 'retry-after'?: string; + 'set-cookie'?: string[]; + 'strict-transport-security'?: string; + 'trailer'?: string; + 'transfer-encoding'?: string; + 'tk'?: string; + 'upgrade'?: string; + 'vary'?: string; + 'via'?: string; + 'warning'?: string; + 'www-authenticate'?: string; + [header: string]: string | string[] | undefined; + } + + // outgoing headers allows numbers (as they are converted internally to strings) + export interface OutgoingHttpHeaders { + [header: string]: number | string | string[] | undefined; + } + export interface RequestOptions { protocol?: string; host?: string; hostname?: string; family?: number; - port?: number; + port?: number | string; localAddress?: string; socketPath?: string; method?: string; path?: string; - headers?: { [key: string]: any }; + headers?: OutgoingHttpHeaders; auth?: string; agent?: Agent | boolean; timeout?: number; } + export type ClientRequestArgs = RequestOptions + export interface Server extends net.Server { setTimeout(msecs: number, callback: Function): void; maxHeadersCount: number; @@ -690,8 +734,8 @@ declare module "http" { write(str: string, encoding?: string, fd?: string): boolean; writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: OutgoingHttpHeaders): void; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders): void; statusCode: number; statusMessage: string; headersSent: boolean; @@ -701,7 +745,7 @@ declare module "http" { getHeader(name: string): string; removeHeader(name: string): void; write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; finished: boolean; // Extended base methods @@ -728,7 +772,7 @@ declare module "http" { setHeader(name: string, value: string | string[]): void; getHeader(name: string): string; removeHeader(name: string): void; - addTrailers(headers: any): void; + addTrailers(headers: OutgoingHttpHeaders): void; // Extended base methods end(): void; @@ -742,10 +786,10 @@ declare module "http" { httpVersionMajor: number; httpVersionMinor: number; connection: net.Socket; - headers: any; + headers: IncomingHttpHeaders; rawHeaders: string[]; - trailers: any; - rawTrailers: any; + trailers: OutgoingHttpHeaders; + rawTrailers: string[]; setTimeout(msecs: number, callback: Function): NodeJS.Timer; /** * Only valid for request obtained from http.Server. @@ -2487,15 +2531,11 @@ declare module "fs" { /** * Asynchronous rename. - * @param oldPath - * @param newPath * @param callback No arguments other than a possible exception are given to the completion callback. */ export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rename - * @param oldPath - * @param newPath */ export function renameSync(oldPath: string, newPath: string): void; export function truncate(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; @@ -2540,79 +2580,62 @@ declare module "fs" { /** * 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. */ export function unlink(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous unlink - deletes the file specified in {path} - * - * @param path */ 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. */ export function rmdir(path: string | Buffer, callback?: (err?: NodeJS.ErrnoException) => void): void; /** * Synchronous rmdir - removes the directory specified in {path} - * - * @param path */ 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. */ 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. */ 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. */ 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; @@ -2646,8 +2669,6 @@ declare module "fs" { /** * 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: null, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; @@ -2656,7 +2677,6 @@ declare module "fs" { /** * 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. */ @@ -2666,7 +2686,6 @@ declare module "fs" { /** * 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. */ @@ -2674,15 +2693,11 @@ declare module "fs" { /** * 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: null): Buffer; export function readFileSync(filename: string, encoding: string): string; @@ -2690,7 +2705,6 @@ declare module "fs" { /** * 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: null; flag?: string; }): Buffer; @@ -2699,7 +2713,6 @@ declare module "fs" { /** * 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; @@ -2940,9 +2953,6 @@ declare module "path" { /** * 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; /** @@ -3160,7 +3170,7 @@ declare module "tls" { /** * 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' }. + * @returns An object with three properties, e.g. { port: 12346, family: 'IPv4', address: '127.0.0.1' }. */ address(): { port: number; family: string; address: string }; /** @@ -3179,7 +3189,7 @@ declare module "tls" { 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 + * @returns Returns an object representing the cipher name * and the SSL/TLS protocol version of the current connection. */ getCipher(): CipherNameAndProtocol; @@ -3189,15 +3199,15 @@ declare module "tls" { * 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 {PeerCertificate | DetailedPeerCertificate} - An object representing the peer's certificate. + * @param detailed - If true; the full chain with issuer property will be returned. + * @returns An object representing the peer's certificate. */ getPeerCertificate(detailed: true): DetailedPeerCertificate; getPeerCertificate(detailed?: false): PeerCertificate; getPeerCertificate(detailed?: boolean): PeerCertificate | DetailedPeerCertificate; /** * 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. + * @returns ASN.1 encoded TLS session or undefined if none was negotiated. */ getSession(): any; /** @@ -3232,9 +3242,9 @@ declare module "tls" { * * 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, + * @param 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 + * @param callback - callback(err) will be executed with null as err, once the renegotiation * is successfully completed. */ renegotiate(options: TlsOptions, callback: (err: Error) => any): any; @@ -3245,8 +3255,8 @@ declare module "tls" { * 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. + * @param size - TLS fragment size (default and maximum value is: 16384, minimum is: 512). + * @returns Returns true on success, false otherwise. */ setMaxSendFragment(size: number): boolean; diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index f439a83213..9bbf6a9300 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1033,9 +1033,24 @@ namespace http_tests { request.abort(); } - const options: http.RequestOptions = { - timeout: 30000 - }; + // http request options + { + const requestOpts: http.RequestOptions = { + timeout: 30000 + }; + + const clientArgs: http.ClientRequestArgs = { + timeout: 30000 + }; + } + + // http headers + { + const headers: http.IncomingHttpHeaders = { + 'content-type': 'application/json', + 'set-cookie': [ 'type=ninja', 'language=javascript' ] + }; + } } ////////////////////////////////////////////////////// diff --git a/types/request-ip/index.d.ts b/types/request-ip/index.d.ts index 855b9336e9..bba30c4d35 100644 --- a/types/request-ip/index.d.ts +++ b/types/request-ip/index.d.ts @@ -4,16 +4,22 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +/// + +import * as http from 'http'; + +interface RequestHeaders extends http.IncomingHttpHeaders { + 'x-client-ip'?: string; + 'x-forwarded-for'?: string; + 'x-real-ip'?: string; + 'x-cluster-client-ip'?: string; + 'x-forwarded'?: string; + 'forwarded-for'?: string; + 'forwarded'?: string; +} + interface Request { - headers: { - 'x-client-ip'?: string; - 'x-forwarded-for'?: string; - 'x-real-ip'?: string; - 'x-cluster-client-ip'?: string; - 'x-forwarded'?: string; - 'forwarded-for'?: string; - 'forwarded'?: string; - }; + headers: RequestHeaders; connection: { remoteAddress?: string; socket?: { diff --git a/types/viewporter/viewporter-tests.ts b/types/viewporter/viewporter-tests.ts index 9c720bec65..15997f9425 100644 --- a/types/viewporter/viewporter-tests.ts +++ b/types/viewporter/viewporter-tests.ts @@ -45,12 +45,12 @@ function test_swipey() { function rainbow(numOfSteps, step) { var r, g, b, h = step / numOfSteps, i = ~~(h * 6), f = h * 6 - i, q = 1 - f; switch (i % 6) { - case 0: r = 1, g = f, b = 0; break; - case 1: r = q, g = 1, b = 0; break; - case 2: r = 0, g = 1, b = f; break; - case 3: r = 0, g = q, b = 1; break; - case 4: r = f, g = 0, b = 1; break; - case 5: r = 1, g = 0, b = q; break; + case 0: r = 1; g = f; b = 0; break; + case 1: r = q; g = 1; b = 0; break; + case 2: r = 0; g = 1; b = f; break; + case 3: r = 0; g = q; b = 1; break; + case 4: r = f; g = 0; b = 1; break; + case 5: r = 1; g = 0; b = q; break; } return [((~ ~(r * 255))), (~ ~(g * 255)), (~ ~(b * 255))]; } @@ -171,4 +171,4 @@ function test_swipey() { }, 16); }); -} \ No newline at end of file +}