From 4a8c1ba76037a219de81e44e05ea3c238a0cfef1 Mon Sep 17 00:00:00 2001 From: jKey Lu Date: Tue, 24 Jan 2017 20:54:46 +0800 Subject: [PATCH 001/134] Update koa --- koa/index.d.ts | 762 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 620 insertions(+), 142 deletions(-) diff --git a/koa/index.d.ts b/koa/index.d.ts index 09b2a64426..7f892ad24c 100644 --- a/koa/index.d.ts +++ b/koa/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Koa 2.x // Project: http://koajs.com -// Definitions by: DavidCai1993 +// Definitions by: DavidCai1993 , jKey Lu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* =================== USAGE =================== @@ -14,172 +14,650 @@ =============================================== */ /// -import { EventEmitter } from "events"; -import * as cookies from "cookies"; -import * as http from "http"; -import * as net from "net"; +import { EventEmitter } from 'events'; +import { IncomingMessage, ServerResponse, Server } from 'http'; +import { Socket, ListenOptions } from 'net'; +import * as compose from 'koa-compose'; +import * as Keygrip from 'keygrip'; +import * as httpAssert from 'http-assert'; +import * as Cookies from 'cookies'; +import * as accepts from 'accepts'; + +declare interface ContextDelegatedRequest { + /** + * Return request header. + */ + header: any; + /** + * Return request header, alias as request.header + */ + headers: any; + + /** + * Get/Set request URL. + */ + url: string; + + /** + * Get origin of URL. + */ + origin: string; + + /** + * Get full request URL. + */ + href: string; + + /** + * Get/Set request method. + */ + method: string; + + /** + * Get request pathname. + * Set pathname, retaining the query-string when present. + */ + path: string; + + /** + * Get parsed query-string. + * Set query-string as an object. + */ + query: any; + + /** + * Get/Set query string. + */ + querystring: string; + + /** + * Get the search string. Same as the querystring + * except it includes the leading ?. + * + * Set the search string. Same as + * response.querystring= but included for ubiquity. + */ + search: string; -export = Koa; + /** + * Parse the "Host" header field host + * and support X-Forwarded-Host when a + * proxy is enabled. + */ + host: string; -declare namespace Koa { - export interface Context extends Request, Response { - app: Koa; - req: http.IncomingMessage; - res: http.ServerResponse; - request: Request; - response: Response; + /** + * Parse the "Host" header field hostname + * and support X-Forwarded-Host when a + * proxy is enabled. + */ + hostname: string; - cookies: cookies.ICookies; - originalUrl: string; - state: any; + /** + * Check if the request is fresh, aka + * Last-Modified and/or the ETag + * still match. + */ + fresh: boolean; - name?: string; - respond?: boolean; + /** + * Check if the request is stale, aka + * "Last-Modified" and / or the "ETag" for the + * resource has changed. + */ + stale: boolean; - assert(test: any, ...args: any[]): void; - onerror(err?: any): void; - throw(...args: any[]): void; + /** + * Check if the request is idempotent. + */ + idempotent: boolean; - toJSON(): any; - inspect(): any; + /** + * Return the request socket. + */ + socket: Socket; - [key: string]: any; - } + /** + * Return the protocol string "http" or "https" + * when requested with TLS. When the proxy setting + * is enabled the "X-Forwarded-Proto" header + * field will be trusted. If you're running behind + * a reverse proxy that supplies https for you this + * may be enabled. + */ + protocol: string; - export interface Request { - app: Koa; - req: http.IncomingMessage; - res: http.ServerResponse; - ctx: Context; - response: Response; + /** + * Short-hand for: + * + * this.protocol == 'https' + */ + secure: boolean; - fresh: boolean; - header: any; - headers: any; - host: string; - hostname: string; - href: string; - idempotent: boolean; - ip: string; - ips: string[]; - method: string; - origin: string; - originalUrl: string; - path: string; - protocol: string; - query: any; - querystring: string; - search: string; - secure: boolean; - socket: net.Socket; - stale: boolean; - subdomains: string[]; - type: string; - url: string; + /** + * When `app.proxy` is `true`, parse + * the "X-Forwarded-For" ip address list. + * + * For example if the value were "client, proxy1, proxy2" + * you would receive the array `["client", "proxy1", "proxy2"]` + * where "proxy2" is the furthest down-stream. + */ + ips: string[]; - charset?: string; - length?: number; + /** + * Return subdomains as an array. + * + * Subdomains are the dot-separated parts of the host before the main domain + * of the app. By default, the domain of the app is assumed to be the last two + * parts of the host. This can be changed by setting `app.subdomainOffset`. + * + * For example, if the domain is "tobi.ferrets.example.com": + * If `app.subdomainOffset` is not set, this.subdomains is + * `["ferrets", "tobi"]`. + * If `app.subdomainOffset` is 3, this.subdomains is `["tobi"]`. + */ + subdomains: string[]; - accepts(): string[]; - accepts(arg: string): void | string; - accepts(arg: string[]): void | string; - accepts(...args: string[]): void | string; - acceptsCharsets(): string[]; - acceptsCharsets(arg: string): void | string; - acceptsCharsets(arg: string[]): void | string; - acceptsCharsets(...args: string[]): void | string; - acceptsEncodings(): string[]; - acceptsEncodings(arg: string): void | string; - acceptsEncodings(arg: string[]): void | string; - acceptsEncodings(...args: string[]): void | string; - acceptsLanguages(): string[]; - acceptsLanguages(arg: string): void | string; - acceptsLanguages(arg: string[]): void | string; - acceptsLanguages(...args: string[]): void | string; - get(field: string): string; - is(): string[]; - is(arg: string): void | string; - is(arg: string[]): void | string; - is(...args: string[]): void | string; + /** + * Check if the given `type(s)` is acceptable, returning + * the best match when true, otherwise `undefined`, in which + * case you should respond with 406 "Not Acceptable". + * + * The `type` value may be a single mime type string + * such as "application/json", the extension name + * such as "json" or an array `["json", "html", "text/plain"]`. When a list + * or array is given the _best_ match, if any is returned. + * + * Examples: + * + * // Accept: text/html + * this.accepts('html'); + * // => "html" + * + * // Accept: text/*, application/json + * this.accepts('html'); + * // => "html" + * this.accepts('text/html'); + * // => "text/html" + * this.accepts('json', 'text'); + * // => "json" + * this.accepts('application/json'); + * // => "application/json" + * + * // Accept: text/*, application/json + * this.accepts('image/png'); + * this.accepts('png'); + * // => undefined + * + * // Accept: text/*;q=.5, application/json + * this.accepts(['html', 'json']); + * this.accepts('html', 'json'); + * // => "json" + */ + accepts(): string[] | boolean; + accepts(...types: string[]): string | boolean; + accepts(types: string[]): string | boolean; - toJSON(): any; - inspect(): any; - } + /** + * Return accepted encodings or best fit based on `encodings`. + * + * Given `Accept-Encoding: gzip, deflate` + * an array sorted by quality is returned: + * + * ['gzip', 'deflate'] + */ + acceptsEncodings(): string[] | boolean; + acceptsEncodings(...encodings: string[]): string | boolean; + acceptsEncodings(encodings: string[]): string | boolean; - export interface Response { - app: Koa; - req: http.IncomingMessage; - res: http.ServerResponse; - ctx: Context; - request: Request; + /** + * Return accepted charsets or best fit based on `charsets`. + * + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` + * an array sorted by quality is returned: + * + * ['utf-8', 'utf-7', 'iso-8859-1'] + */ + acceptsCharsets(): string[] | boolean; + acceptsCharsets(...charsets: string[]): string | boolean; + acceptsCharsets(charsets: string[]): string | boolean; - body: any; - etag: string; - header: any; - headers: any; - headerSent: boolean; - lastModified: Date; - message: string; - socket: net.Socket; - status: number; - type: string; - writable: boolean; + /** + * Return accepted languages or best fit based on `langs`. + * + * Given `Accept-Language: en;q=0.8, es, pt` + * an array sorted by quality is returned: + * + * ['es', 'pt', 'en'] + */ + acceptsLanguages(): string[] | boolean; + acceptsLanguages(...langs: string[]): string | boolean; + acceptsLanguages(langs: string[]): string | boolean; - charset?: string; - length?: number; + /** + * Check if the incoming request contains the "Content-Type" + * header field, and it contains any of the give mime `type`s. + * If there is no request body, `null` is returned. + * If there is no content type, `false` is returned. + * Otherwise, it returns the first `type` that matches. + * + * Examples: + * + * // With Content-Type: text/html; charset=utf-8 + * this.is('html'); // => 'html' + * this.is('text/html'); // => 'text/html' + * this.is('text/*', 'application/json'); // => 'text/html' + * + * // When Content-Type is application/json + * this.is('json', 'urlencoded'); // => 'json' + * this.is('application/json'); // => 'application/json' + * this.is('html', 'application/*'); // => 'application/json' + * + * this.is('html'); // => false + */ + // is(): string | boolean; + is(...types: string[]): string | boolean; + is(types: string[]): string | boolean; - append(field: string, val: string | string[]): void; - attachment(filename?: string): void; - get(field: string): string; - is(): string[]; - is(arg: string): void | string; - is(arg: string[]): void | string; - is(...args: string[]): void | string; - redirect(url: string, alt?: string): void; - remove(field: string): void; - set(field: string, val: string | string[]): void; - set(field: any): void; - vary(field: string): void; - - toJSON(): any; - inspect(): any; - } - - export type Middleware = (ctx: Koa.Context, next: () => Promise) => any; + /** + * Return request header. + * + * The `Referrer` header field is special-cased, + * both `Referrer` and `Referer` are interchangeable. + * + * Examples: + * + * this.get('Content-Type'); + * // => "text/plain" + * + * this.get('content-type'); + * // => "text/plain" + * + * this.get('Something'); + * // => undefined + */ + get(field: string): string; } -declare class Koa extends EventEmitter { - subdomainOffset: number; - server: http.Server; - env: string; - context: Koa.Context; - keys: string[]; +declare interface BaseRequest extends ContextDelegatedRequest { + /** + * Get the charset when present or undefined. + */ + charset: string; + + /** + * Return parsed Content-Length when present. + */ + length: number; + + /** + * Return the request mime type void of + * parameters such as "charset". + */ + type: string; + + /** + * Inspect implementation. + */ + inspect(): any; + + /** + * Return JSON representation. + */ + toJSON(): any; +} + +declare interface ContextDelegatedResponse { + /** + * Get/Set response status code. + */ + status: number; + + /** + * Get response status message + */ + message: string; + + /** + * Get/Set response body. + */ + body: any; + + /** + * Return parsed response Content-Length when present. + * Set Content-Length field to `n`. + */ + length: number; + + /** + * Check if a header has been written to the socket. + */ + headerSent: boolean; + + /** + * Vary on `field`. + */ + vary(field: string): void; + + /** + * Perform a 302 redirect to `url`. + * + * The string "back" is special-cased + * to provide Referrer support, when Referrer + * is not present `alt` or "/" is used. + * + * Examples: + * + * this.redirect('back'); + * this.redirect('back', '/index.html'); + * this.redirect('/login'); + * this.redirect('http://google.com'); + */ + redirect(url: string, alt?: string): void; + + /** + * Set Content-Disposition header to "attachment" with optional `filename`. + */ + attachment(filename: string): void; + + /** + * Return the response mime type void of + * parameters such as "charset". + * + * Set Content-Type response header with `type` through `mime.lookup()` + * when it does not contain a charset. + * + * Examples: + * + * this.type = '.html'; + * this.type = 'html'; + * this.type = 'json'; + * this.type = 'application/json'; + * this.type = 'png'; + */ + type: string; + + /** + * Get the Last-Modified date in Date form, if it exists. + * Set the Last-Modified date using a string or a Date. + * + * this.response.lastModified = new Date(); + * this.response.lastModified = '2013-09-13'; + */ + lastModified: Date; + + /** + * Get/Set the ETag of a response. + * This will normalize the quotes if necessary. + * + * this.response.etag = 'md5hashsum'; + * this.response.etag = '"md5hashsum"'; + * this.response.etag = 'W/"123456789"'; + * + * @param {String} etag + * @api public + */ + etag: string; + + /** + * Set header `field` to `val`, or pass + * an object of header fields. + * + * Examples: + * + * this.set('Foo', ['bar', 'baz']); + * this.set('Accept', 'application/json'); + * this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' }); + */ + set(field: { [key: string]: string; }): void; + set(field: string, val: string | string[]): void; + + /** + * Append additional header `field` with value `val`. + * + * Examples: + * + * ``` + * this.append('Link', ['', '']); + * this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); + * this.append('Warning', '199 Miscellaneous warning'); + * ``` + */ + append(field: string, val: string | string[]): void; + + /** + * Remove header `field`. + */ + remove(field: string): void; + + /** + * Checks if the request is writable. + * Tests for the existence of the socket + * as node sometimes does not set it. + */ + writable: boolean; + + /** + * Flush any set headers, and begin the body + */ + flushHeaders(): void; +} + +declare interface BaseResponse extends ContextDelegatedResponse { + /** + * Return the request socket. + * + * @return {Connection} + * @api public + */ + socket: Socket; + + /** + * Return response header. + */ + header: any; + + /** + * Return response header, alias as response.header + */ + headers: any; + + /** + * Check whether the response is one of the listed types. + * Pretty much the same as `this.request.is()`. + * + * @param {String|Array} types... + * @return {String|false} + * @api public + */ + // is(): string; + is(...types: string[]): string; + is(types: string[]): string; + + /** + * Return response header. + * + * Examples: + * + * this.get('Content-Type'); + * // => "text/plain" + * + * this.get('content-type'); + * // => "text/plain" + */ + get(field: string): string; + + /** + * Inspect implementation. + */ + inspect(): any; + + /** + * Return JSON representation. + */ + toJSON(): any; +} + + +declare interface BaseContext extends ContextDelegatedRequest, ContextDelegatedResponse { + /** + * util.inspect() implementation, which + * just returns the JSON output. + */ + inspect(): any; + + /** + * Return JSON representation. + * + * Here we explicitly invoke .toJSON() on each + * object, as iteration will otherwise fail due + * to the getters and cause utilities such as + * clone() to fail. + */ + toJSON(): any; + + /** + * Similar to .throw(), adds assertion. + * + * this.assert(this.user, 401, 'Please login!'); + * + * See: https://github.com/jshttp/http-assert + */ + assert: typeof httpAssert; + + /** + * Throw an error with `msg` and optional `status` + * defaulting to 500. Note that these are user-level + * errors, and the message may be exposed to the client. + * + * this.throw(403) + * this.throw('name required', 400) + * this.throw(400, 'name required') + * this.throw('something exploded') + * this.throw(new Error('invalid'), 400); + * this.throw(400, new Error('invalid')); + * + * See: https://github.com/jshttp/http-errors + */ + throw(message: string, code?: number, properties?: {}): never; + throw(status: number): never; + throw(...properties: Array): never; + + /** + * Default error handling. + */ + onerror(err: Error): void; +} + +declare class Application extends EventEmitter { proxy: boolean; - request: Koa.Request; - response: Koa.Response; + middleware: Application.Middleware[]; + subdomainOffset: number; + env: string; + context: BaseContext; + request: BaseRequest; + response: BaseResponse; silent: boolean; + keys: Keygrip | string[]; constructor(); - // From node.d.ts - listen(): http.Server; - listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): http.Server; - listen(port: number, hostname?: string, listeningListener?: Function): http.Server; - listen(port: number, backlog?: number, listeningListener?: Function): http.Server; - listen(port: number, listeningListener?: Function): http.Server; - listen(path: string, backlog?: number, listeningListener?: Function): http.Server; - listen(path: string, listeningListener?: Function): http.Server; - listen(handle: any, backlog?: number, listeningListener?: Function): http.Server; - listen(handle: any, listeningListener?: Function): http.Server; - listen(options: net.ListenOptions, listeningListener?: Function): http.Server; + /** + * Shorthand for: + * + * http.createServer(app.callback()).listen(...) + */ + listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): Server; + listen(port: number, hostname?: string, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(port: number, backlog?: number, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(port: number, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(path: string, backlog?: number, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(path: string, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(options: ListenOptions, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(handle: any, backlog?: number, listeningListener?: () => void): Server; + // tslint:disable-next-line:unified-signatures + listen(handle: any, listeningListener?: () => void): Server; - callback(): (req: http.IncomingMessage, res: http.ServerResponse) => void; - onerror(err: any): void; - use(middleware: Koa.Middleware): Koa; - - toJSON(): any; + /** + * Return JSON representation. + * We only bother showing settings. + */ inspect(): any; - onerror(err: any): void; + + /** + * Return JSON representation. + * We only bother showing settings. + */ + toJSON(): any; + + /** + * Use the given middleware `fn`. + * + * Old-style middleware will be converted. + */ + use(middleware: Application.Middleware): this; + + /** + * Return a request handler callback + * for node's native http server. + */ + callback(): (req: IncomingMessage, res: ServerResponse) => void; + + /** + * Initialize a new context. + * + * @api private + */ + createContext(req: IncomingMessage, res: ServerResponse): Application.Context; + + /** + * Default error handler. + * + * @api private + */ + onerror(err: Error): void; } +declare namespace Application { + type Middleware = compose.Middleware; + + interface Request extends BaseRequest { + app: Application; + req: IncomingMessage; + res: ServerResponse; + ctx: Context; + response: Response; + originalUrl: string; + ip: string; + accept: accepts.Accepts; + } + + interface Response extends BaseResponse { + app: Application; + req: IncomingMessage; + res: ServerResponse; + ctx: Context; + request: Request; + } + + interface Context extends BaseContext { + app: Application; + request: Request; + response: Response; + req: IncomingMessage; + res: ServerResponse; + originalUrl: string; + cookies: Cookies; + accept: accepts.Accepts; + state: any; + } +} + +export = Application; From 6f94c25abda59471204d75956f7e68f9faed0b46 Mon Sep 17 00:00:00 2001 From: jKey Lu Date: Tue, 24 Jan 2017 21:25:12 +0800 Subject: [PATCH 002/134] fix augmenting koa module scope from other module --- koa-passport/index.d.ts | 2 +- koa-session-minimal/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/koa-passport/index.d.ts b/koa-passport/index.d.ts index 2bdf4bcfac..e3a318004a 100644 --- a/koa-passport/index.d.ts +++ b/koa-passport/index.d.ts @@ -13,7 +13,7 @@ import * as Koa from "koa"; declare module "koa" { - interface Request { + interface Context { authInfo?: any; user?: any; diff --git a/koa-session-minimal/index.d.ts b/koa-session-minimal/index.d.ts index 3fe9da3a52..02d3a68004 100644 --- a/koa-session-minimal/index.d.ts +++ b/koa-session-minimal/index.d.ts @@ -17,7 +17,7 @@ import * as Koa from "koa"; import * as cookies from "cookies"; declare module "koa" { - interface Request { + interface Context { session: any; sessionHandler: { regenerateId: () => void }; } From 2ee15652aedb538d109c5598c2a0f63b845bdb44 Mon Sep 17 00:00:00 2001 From: Jed Mao Date: Wed, 25 Jan 2017 12:15:57 -0600 Subject: [PATCH 003/134] vinyl-fs: add undocumented allowEmpty option flag --- vinyl-fs/.editorconfig | 3 +++ vinyl-fs/index.d.ts | 21 +++++++++--------- vinyl-fs/tsconfig.json | 42 ++++++++++++++++++------------------ vinyl-fs/tslint.json | 3 +++ vinyl-fs/vinyl-fs-tests.ts | 44 +++++++++++++++++--------------------- 5 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 vinyl-fs/.editorconfig create mode 100644 vinyl-fs/tslint.json diff --git a/vinyl-fs/.editorconfig b/vinyl-fs/.editorconfig new file mode 100644 index 0000000000..831139084b --- /dev/null +++ b/vinyl-fs/.editorconfig @@ -0,0 +1,3 @@ +[*.ts] +indent_style = space +indent_size = 3 diff --git a/vinyl-fs/index.d.ts b/vinyl-fs/index.d.ts index 350ee527b5..53de6a6b2c 100644 --- a/vinyl-fs/index.d.ts +++ b/vinyl-fs/index.d.ts @@ -1,25 +1,26 @@ -// Type definitions for vinyl-fs +// Type definitions for vinyl-fs 2.4 // Project: https://github.com/wearefractal/vinyl-fs // Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// -/// declare global { namespace NodeJS { interface WritableStream { - write(buffer: any/* Vinyl.File */, cb?: Function): boolean; + write(buffer: any/* Vinyl.File */, cb?: (err?: Error) => void): boolean; } } } -import _events = require("events"); -import File = require("vinyl"); -import globStream = require("glob-stream"); +import * as _events from 'events'; +import * as File from 'vinyl'; +import * as globStream from 'glob-stream'; + +interface SrcOptions extends globStream.Options { + /** Prevents stream from emitting an error when file not found. */ + allowEmpty?: boolean; -interface ISrcOptions extends globStream.Options { /** Specifies the working directory the folder is relative to */ cwd?: string; @@ -62,7 +63,7 @@ interface ISrcOptions extends globStream.Options { * fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js']) * @param opt Options Vinyl source options, changes the way the files are read, found, or stored in the vinyl stream */ -declare function src(globs: string|string[], opt?: ISrcOptions): NodeJS.ReadWriteStream; +declare function src(globs: string|string[], opt?: SrcOptions): NodeJS.ReadWriteStream; /** * This is just a glob-watcher @@ -80,7 +81,7 @@ declare function watch(globs: string|string[], cb?: (outEvt: { type: any; path: * Globs are executed in order, so negations should follow positive globs * fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js']) */ -declare function watch(globs: string|string[], opt?: { interval?: number; debounceDelay?: number; cwd?: string; maxListeners?: Function; }, cb?: (outEvt: { type: any; path: any; old: any; }) => void): _events.EventEmitter; +declare function watch(globs: string|string[], opt?: { interval?: number; debounceDelay?: number; cwd?: string; maxListeners?: () => number; }, cb?: (outEvt: { type: any; path: any; old: any; }) => void): _events.EventEmitter; /** * On write the stream will save the vinyl File to disk at the folder/cwd specified. diff --git a/vinyl-fs/tsconfig.json b/vinyl-fs/tsconfig.json index 60247086b9..d8cea65d47 100644 --- a/vinyl-fs/tsconfig.json +++ b/vinyl-fs/tsconfig.json @@ -1,22 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "vinyl-fs-tests.ts" - ] -} \ No newline at end of file + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vinyl-fs-tests.ts" + ] +} diff --git a/vinyl-fs/tslint.json b/vinyl-fs/tslint.json new file mode 100644 index 0000000000..89bca6bf0f --- /dev/null +++ b/vinyl-fs/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} diff --git a/vinyl-fs/vinyl-fs-tests.ts b/vinyl-fs/vinyl-fs-tests.ts index 795b38b4aa..41dfa92c4c 100644 --- a/vinyl-fs/vinyl-fs-tests.ts +++ b/vinyl-fs/vinyl-fs-tests.ts @@ -3,10 +3,10 @@ // from src -import vfs = require('vinyl-fs'); +import * as vfs from 'vinyl-fs'; -import path = require('path'); -import fs = require('fs'); // require('graceful-fs'); +import * as path from 'path'; +import * as fs from 'fs'; // require('graceful-fs'); // import bufEqual = require('buffer-equal'); declare var bufEqual: any; @@ -16,8 +16,8 @@ import File = require('vinyl'); // var spies = require('./spy'); declare var spies: any; -import should = require('should'); -require('mocha'); +import * as should from 'should'; +import 'mocha'; declare var gulp: any; declare var bufferStream: any; @@ -210,7 +210,7 @@ import rimraf = require('rimraf'); // var File = require('vinyl'); // var should = require('should'); -require('mocha'); +// require('mocha'); var wipeOut = function (cb: any) { rimraf(path.join(__dirname, "./out-fixtures/"), cb); @@ -374,7 +374,7 @@ describe('dest stream', function () { cwd: __dirname, path: inputPath, contents: expectedContents, - stat: { + stat: { mode: expectedMode } }); @@ -415,7 +415,7 @@ describe('dest stream', function () { cwd: __dirname, path: inputPath, contents: contentStream, - stat: { + stat: { mode: expectedMode } }); @@ -458,10 +458,8 @@ describe('dest stream', function () { cwd: __dirname, path: inputPath, contents: null, - stat: { - isDirectory: function () { - return true; - }, + stat: { + isDirectory: () => true, mode: expectedMode } }); @@ -503,7 +501,7 @@ describe('dest stream', function () { stream1.on('data', function (file: any) { file.path.should.equal(inputPath1); - }) + }); stream1.pipe(rename).pipe(stream2); stream2.on('data', function (file: any) { @@ -519,11 +517,11 @@ describe('dest stream', function () { path: inputPath1, cwd: __dirname, contents: content - }) + }); stream1.write(file); stream1.end(); - }) + }); }); @@ -708,7 +706,7 @@ describe('symlink stream', function () { cwd: __dirname, path: inputPath, contents: expectedContents, - stat: { + stat: { mode: expectedMode } }); @@ -749,7 +747,7 @@ describe('symlink stream', function () { cwd: __dirname, path: inputPath, contents: contentStream, - stat: { + stat: { mode: expectedMode } }); @@ -792,10 +790,8 @@ describe('symlink stream', function () { cwd: __dirname, path: inputPath, contents: null, - stat: { - isDirectory: function () { - return true; - }, + stat: { + isDirectory: () => true, mode: expectedMode } }); @@ -869,7 +865,7 @@ describe('symlink stream', function () { cwd: __dirname, path: inputPath, contents: expectedContents, - stat: { + stat: { mode: expectedMode } }); @@ -878,7 +874,7 @@ describe('symlink stream', function () { fs.chmodSync(expectedBase, 0); var stream = vfs.symlink('./out-fixtures/', { cwd: __dirname }); - stream.on('error', function (err:any) { + stream.on('error', function (err: any) { err.code.should.equal('EACCES'); done(); }); @@ -914,5 +910,5 @@ describe('symlink stream', function () { var file = new File(options); File.isVinyl(file).should.equal(true); File.isVinyl(options).should.equal(false); - }) + }); }); From dc81b9923420a2c2a34d42e68b2671c384950aac Mon Sep 17 00:00:00 2001 From: Karol Janyst Date: Thu, 26 Jan 2017 14:36:05 +0900 Subject: [PATCH 004/134] Add missing onClick property on on props --- react-bootstrap/index.d.ts | 5 +++-- react-bootstrap/react-bootstrap-tests.tsx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/react-bootstrap/index.d.ts b/react-bootstrap/index.d.ts index 3e5c69c034..ee4bfd83e4 100644 --- a/react-bootstrap/index.d.ts +++ b/react-bootstrap/index.d.ts @@ -528,6 +528,7 @@ declare namespace ReactBootstrap { // interface NavbarToggleProps { + onClick?: React.MouseEventHandler<{}>; } type NavbarToggle = React.ClassicComponent; var NavbarToggle: React.ClassicComponentClass; @@ -614,7 +615,7 @@ declare namespace ReactBootstrap { interface TabProps extends React.HTMLProps { animation?: boolean; 'aria-labelledby'?:string; - bsClass?:string; + bsClass?:string; eventKey?: any; // TODO: Add more specific type onEnter?: Function; onEntered?: Function; @@ -765,7 +766,7 @@ declare namespace ReactBootstrap { interface GridProps extends React.HTMLProps { componentClass?: React.ReactType; fluid?: boolean; - bsClass?: string; + bsClass?: string; } type Grid = React.ClassicComponent; var Grid: React.ClassicComponentClass; diff --git a/react-bootstrap/react-bootstrap-tests.tsx b/react-bootstrap/react-bootstrap-tests.tsx index 00bfae517c..f3772d0fef 100644 --- a/react-bootstrap/react-bootstrap-tests.tsx +++ b/react-bootstrap/react-bootstrap-tests.tsx @@ -528,7 +528,7 @@ export class ReactBootstrapTest extends Component { React-Bootstrap - + {} } />