diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 4d9a7aab6f..1fc8897d23 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -3,8 +3,8 @@ Please fill in this template. - [ ] Make your PR against the `master` branch. - [ ] Use a meaningful title for the pull request. Include the name of the package modified. - [ ] Test the change in your own code. (Compile and run.) -- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request). -- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes). +- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request). +- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes). - [ ] Run `tsc` without errors. - [ ] Run `npm run lint package-name` if a `tslint.json` is present. diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts index 0d8d9bd47f..fb09beda8a 100644 --- a/aws-lambda/aws-lambda-tests.ts +++ b/aws-lambda/aws-lambda-tests.ts @@ -6,11 +6,48 @@ var anyObj: any = { abc: 123 }; var num: number = 5; var error: Error = new Error(); var b: boolean = true; +var apiGwEvt: AWSLambda.APIGatewayEvent; var clientCtx: AWSLambda.ClientContext; var clientContextEnv: AWSLambda.ClientContextEnv; var clientContextClient: AWSLambda.ClientContextClient; var context: AWSLambda.Context; var identity: AWSLambda.CognitoIdentity; +var proxyResult: AWSLambda.ProxyResult; + +/* API Gateway Event */ +str = apiGwEvt.body; +str = apiGwEvt.headers["example"]; +str = apiGwEvt.httpMethod; +b = apiGwEvt.isBase64Encoded; +str = apiGwEvt.path; +str = apiGwEvt.pathParameters["example"]; +str = apiGwEvt.queryStringParameters["example"]; +str = apiGwEvt.stageVariables["example"]; +str = apiGwEvt.requestContext.accountId; +str = apiGwEvt.requestContext.apiId; +str = apiGwEvt.requestContext.httpMethod; +str = apiGwEvt.requestContext.identity.accessKey; +str = apiGwEvt.requestContext.identity.accountId; +str = apiGwEvt.requestContext.identity.apiKey; +str = apiGwEvt.requestContext.identity.caller; +str = apiGwEvt.requestContext.identity.cognitoAuthenticationProvider; +str = apiGwEvt.requestContext.identity.cognitoAuthenticationType; +str = apiGwEvt.requestContext.identity.cognitoIdentityId; +str = apiGwEvt.requestContext.identity.cognitoIdentityPoolId; +str = apiGwEvt.requestContext.identity.sourceIp; +str = apiGwEvt.requestContext.identity.user; +str = apiGwEvt.requestContext.identity.userAgent; +str = apiGwEvt.requestContext.identity.userArn; +str = apiGwEvt.requestContext.stage; +str = apiGwEvt.requestContext.requestId; +str = apiGwEvt.requestContext.resourceId; +str = apiGwEvt.requestContext.resourcePath; +str = apiGwEvt.resource; + +/* Lambda Proxy Result */ +num = proxyResult.statusCode; +str = proxyResult.headers["example"]; +str = proxyResult.body /* Context */ b = context.callbackWaitsForEmptyEventLoop; @@ -54,6 +91,15 @@ function callback(cb: AWSLambda.Callback) { cb(error); cb(null, anyObj); } + +/* Proxy Callback */ +function proxyCallback(cb: AWSLambda.ProxyCallback) { + cb(); + cb(null); + cb(error); + cb(null, proxyResult); +} + /* Compatibility functions */ context.done(); context.done(error); @@ -66,3 +112,4 @@ context.fail(str); /* Handler */ let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => {}; +let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => {}; diff --git a/aws-lambda/index.d.ts b/aws-lambda/index.d.ts index 1aa41b9e62..e8b70db7bd 100644 --- a/aws-lambda/index.d.ts +++ b/aws-lambda/index.d.ts @@ -1,8 +1,44 @@ // Type definitions for AWS Lambda // Project: http://docs.aws.amazon.com/lambda -// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede +// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede , Rich Buggy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// API Gateway "event" +interface APIGatewayEvent { + body: string | null; + headers: { [name: string]: string }; + httpMethod: string; + isBase64Encoded: boolean; + path: string; + pathParameters: { [name: string]: string } | null; + queryStringParameters: { [name: string]: string } | null; + stageVariables: { [name: string]: string } | null; + requestContext: { + accountId: string; + apiId: string; + httpMethod: string; + identity: { + accessKey: string | null; + accountId: string | null; + apiKey: string | null; + caller: string | null; + cognitoAuthenticationProvider: string | null; + cognitoAuthenticationType: string | null; + cognitoIdentityId: string | null; + cognitoIdentityPoolId: string | null; + sourceIp: string; + user: string | null; + userAgent: string | null; + userArn: string | null; + }, + stage: string; + requestId: string; + resourceId: string; + resourcePath: string; + }; + resource: string; +} + // Context // http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html interface Context { @@ -58,6 +94,14 @@ interface ClientContextEnv { locale: string; } +interface ProxyResult { + statusCode: number; + headers?: { + [header: string]: string; + }, + body: string; +} + /** * AWS Lambda handler function. * http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html @@ -67,6 +111,7 @@ interface ClientContextEnv { * @param callback – optional callback to return information to the caller, otherwise return value is null. */ export type Handler = (event: any, context: Context, callback?: Callback) => void; +export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void; /** * Optional callback parameter. @@ -76,5 +121,6 @@ export type Handler = (event: any, context: Context, callback?: Callback) => vo * @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible. */ export type Callback = (error?: Error, result?: any) => void; +export type ProxyCallback = (error?: Error, result?: ProxyResult) => void; export as namespace AWSLambda; diff --git a/axios/axios-tests.ts b/axios/axios-tests.ts deleted file mode 100644 index 2587222b36..0000000000 --- a/axios/axios-tests.ts +++ /dev/null @@ -1,125 +0,0 @@ - - -enum HttpMethod { GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH } -enum ResponseType { arraybuffer, blob, document, json, text } - -interface Repository { - id: number; - name: string; -} - -interface Issue { - id: number; - 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; -}); - - -const requestId: number = axios.interceptors.request.use( - (config) => { - console.log("Method:" + config.method + " Url:" +config.url); - return config; - }, - (error: any) => error); - - -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); - return config; - }, - (error: any) => error); - -axios.interceptors.response.eject(responseId); - -axios.get("https://api.github.com/repos/mzabriskie/axios") - .then(r => console.log(r.config.method)); - -var getRepoDetails = axios({ - url: "https://api.github.com/repos/mzabriskie/axios", - method: HttpMethod[HttpMethod.GET], - headers: {}, -}).then(r => { - console.log("ID:" + r.data.id + " Name: " + r.data.name); - return r; -}); - -axios.post("http://example.com/", {}, { - transformRequest: (data: any) => data -}); - -axios.post("http://example.com/", { - headers: {'X-Custom-Header': 'foobar'} -}, { - transformRequest: [ - (data: any) => data - ] -}); - -var config: Axios.AxiosXHRConfigBase = {headers: {}}; -config.headers['X-Custom-Header'] = 'baz'; -axios.post("http://example.com/", config); - -var getRepoIssue = axios.get("https://api.github.com/repos/mzabriskie/axios/issues/1"); - -var axiosInstance = axios.create({ - baseURL: "https://api.github.com/repos/mzabriskie/axios/", - timeout: 1000 -}); - -axiosInstance.request({url: "issues/1"}).then(res => { - if (res.headers['content-type'].startsWith('application/json')) { - throw new Error('Unexpected content-type'); - } -}); - -axios.all([getRepoDetails, getRepoDetails]).then(([repo1, repo2]) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}); - -var repoSum = (repo1: Axios.AxiosXHR, repo2: Axios.AxiosXHR) => { - var sumIds = repo1.data.id + repo2.data.id; - console.log("Sum ID:" + sumIds); - return sumIds; -}; - -axios.all([getRepoDetails, getRepoDetails]).then(axios.spread(repoSum)); - -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"; diff --git a/axios/index.d.ts b/axios/index.d.ts deleted file mode 100644 index b32a78ebe0..0000000000 --- a/axios/index.d.ts +++ /dev/null @@ -1,328 +0,0 @@ -// Type definitions for axios 0.9.1 -// Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Axios { - - interface IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; - } - - interface IPromise extends IThenable { - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; - then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; - catch(onRejected?: (error: any) => U | IThenable): IPromise; - } - - /** - * HTTP Basic auth details - */ - interface AxiosHttpBasicAuth { - username: string; - password: string; - } - - /** - * Common axios XHR config interface - * - request body data type - */ - interface AxiosXHRConfigBase { - /** - * will be prepended to `url` unless `url` is absolute. - * It can be convenient to set `baseURL` for an instance - * of axios to pass relative URLs to methods of that instance. - */ - baseURL?: string; - - /** - * custom headers to be sent - */ - headers?: {[key: string]: any}; - - /** - * URL parameters to be sent with the request - */ - params?: Object; - - /** - * optional function in charge of serializing `params` - * (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/) - */ - paramsSerializer?: (params: Object) => string; - - /** - * specifies the number of milliseconds before the request times out. - * If the request takes longer than `timeout`, the request will be aborted. - */ - timeout?: number; - - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; - - /** - * indicates that HTTP Basic auth should be used, and supplies - * credentials. This will set an `Authorization` header, - * overwriting any existing `Authorization` custom headers you have - * set using `headers`. - */ - auth?: AxiosHttpBasicAuth; - - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer - */ - transformRequest?: ((data: T) => U) | [(data: T) => U]; - - /** - * 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; - * otherwise, the promise will be rejected - */ - validateStatus?: (status: number) => boolean | undefined; - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - interface AxiosXHRConfigDefaults extends AxiosXHRConfigBase { - /** - * custom headers to be sent - */ - headers: { - common: {[index: string]: string}; - patch: {[index: string]: string}; - post: {[index: string]: string}; - put: {[index: string]: string}; - }; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: {[index: string]: any}; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - interface Interceptor { - /** - * intercept request before it is sent - */ - request: RequestInterceptor; - - /** - * intercept response of request when it is received. - */ - response: ResponseInterceptor - } - - type InterceptorId = number; - - interface RequestInterceptor { - /** - * - request body data type - */ - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig): InterceptorId; - - use(fulfilledFn: (config: AxiosXHRConfig) => AxiosXHRConfig, - 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; - } - - interface ResponseInterceptor { - /** - * - expected response type - */ - - 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; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosInstance { - - /** - * Send request as configured - */ - (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - new (config: AxiosXHRConfig): IPromise>; - - /** - * Send request as configured - */ - request(config: AxiosXHRConfig): IPromise>; - - /** - * intercept requests or responses before they are handled by then or catch - */ - interceptors: Interceptor; - - /** - * Config defaults - */ - defaults: AxiosXHRConfigDefaults; - - /** - * equivalent to `Promise.all` - */ - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>, T10 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>, T9 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>, T8 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>, T7 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>, T6 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>, T5 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>, T4 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>, T3 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR, AxiosXHR]>; - all(values: [T1 | IPromise>, T2 | IPromise>]): IPromise<[AxiosXHR, AxiosXHR]>; - - /** - * spread array parameter to `fn`. - * note: alternative to `spread`, destructuring assignment. - */ - spread(fn: (t1: T1, t2: T2) => U): (arr: ([T1, T2])) => U; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): IPromise>; - - - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): IPromise>; - } - - /** - * - expected response type, - */ - interface AxiosStatic extends AxiosInstance { - /** - * create a new instance of axios with a custom config - */ - create(config: AxiosXHRConfigBase): AxiosInstance; - } -} - -declare var axios: Axios.AxiosStatic; - -declare module "axios" { - export = axios; -} diff --git a/bintrees/index.d.ts b/bintrees/index.d.ts index 9853be67dc..7a7b2c233e 100644 --- a/bintrees/index.d.ts +++ b/bintrees/index.d.ts @@ -5,7 +5,7 @@ declare module 'bintrees' { - type Callback = (err: Error, item: T) => void; + type Callback = (item: T) => void; type Comparator = (a: T, b: T) => number; class Iterator { diff --git a/chai-http/index.d.ts b/chai-http/index.d.ts index 567f13e4e7..2e619b6166 100644 --- a/chai-http/index.d.ts +++ b/chai-http/index.d.ts @@ -55,6 +55,7 @@ declare namespace ChaiHttp { send(data: Object): Request; auth(user: string, name: string): Request; field(name: string, val: string): Request; + buffer(): Request; end(callback?: (err: any, res: Response) => void): FinishedRequest; } diff --git a/chrome/index.d.ts b/chrome/index.d.ts index 2822dd421e..cd6922f5fb 100644 --- a/chrome/index.d.ts +++ b/chrome/index.d.ts @@ -7267,6 +7267,7 @@ declare namespace chrome.webRequest { interface WebResponseHeadersDetails extends WebResponseDetails { /** Optional. The HTTP response headers that have been received with this response. */ responseHeaders?: HttpHeader[]; + method: string; /** standard HTTP method i.e. GET, POST, PUT, etc. */ } interface WebResponseCacheDetails extends WebResponseHeadersDetails { diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 5502b0eb85..eb77ce21eb 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -329,7 +329,7 @@ interface CommonWrapper { * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first * argument, and will be run with a context of the original instance. */ - forEach(fn: (wrapper: this) => any): this; + forEach(fn: (wrapper: this, index: number) => any): this; /** * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map @@ -339,7 +339,7 @@ interface CommonWrapper { * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run * with a context of the original instance. */ - map(fn: (wrapper: this) => V): V[]; + map(fn: (wrapper: this, index: number) => V): V[]; /** * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node diff --git a/fusioncharts/fusioncharts-tests.ts b/fusioncharts/fusioncharts-tests.ts index 9bbf640225..77b912ba18 100644 --- a/fusioncharts/fusioncharts-tests.ts +++ b/fusioncharts/fusioncharts-tests.ts @@ -1,3 +1,5 @@ +import * as FusionCharts from "fusioncharts"; + FusionCharts.addEventListener('ready',(eventObject)=>{ eventObject.stopPropagation(); }); diff --git a/fusioncharts/fusioncharts.charts.d.ts b/fusioncharts/fusioncharts.charts.d.ts new file mode 100644 index 0000000000..f06060a054 --- /dev/null +++ b/fusioncharts/fusioncharts.charts.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var charts: (H: FusionChartStatic) => FusionChartStatic; +export = charts; +export as namespace charts; + diff --git a/fusioncharts/fusioncharts.gantt.d.ts b/fusioncharts/fusioncharts.gantt.d.ts new file mode 100644 index 0000000000..d29fa26f78 --- /dev/null +++ b/fusioncharts/fusioncharts.gantt.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var gantt: (H: FusionChartStatic) => FusionChartStatic; +export = gantt; +export as namespace gantt; + diff --git a/fusioncharts/fusioncharts.maps.d.ts b/fusioncharts/fusioncharts.maps.d.ts new file mode 100644 index 0000000000..1894383758 --- /dev/null +++ b/fusioncharts/fusioncharts.maps.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var maps: (H: FusionChartStatic) => FusionChartStatic; +export = maps; +export as namespace maps; + diff --git a/fusioncharts/fusioncharts.powercharts.d.ts b/fusioncharts/fusioncharts.powercharts.d.ts new file mode 100644 index 0000000000..46178c8b8f --- /dev/null +++ b/fusioncharts/fusioncharts.powercharts.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var powercharts: (H: FusionChartStatic) => FusionChartStatic; +export = powercharts; +export as namespace powercharts; + diff --git a/fusioncharts/fusioncharts.ssgrid.d.ts b/fusioncharts/fusioncharts.ssgrid.d.ts new file mode 100644 index 0000000000..b44f5336c1 --- /dev/null +++ b/fusioncharts/fusioncharts.ssgrid.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var ssgrid: (H: FusionChartStatic) => FusionChartStatic; +export = ssgrid; +export as namespace ssgrid; + diff --git a/fusioncharts/fusioncharts.treemap.d.ts b/fusioncharts/fusioncharts.treemap.d.ts new file mode 100644 index 0000000000..c555a627bc --- /dev/null +++ b/fusioncharts/fusioncharts.treemap.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var treemap: (H: FusionChartStatic) => FusionChartStatic; +export = treemap; +export as namespace treemap; + diff --git a/fusioncharts/fusioncharts.widgets.d.ts b/fusioncharts/fusioncharts.widgets.d.ts new file mode 100644 index 0000000000..a4547b99b7 --- /dev/null +++ b/fusioncharts/fusioncharts.widgets.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var widgets: (H: FusionChartStatic) => FusionChartStatic; +export = widgets; +export as namespace widgets; + diff --git a/fusioncharts/fusioncharts.zoomscatter.d.ts b/fusioncharts/fusioncharts.zoomscatter.d.ts new file mode 100644 index 0000000000..106908b6df --- /dev/null +++ b/fusioncharts/fusioncharts.zoomscatter.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var zoomscatter: (H: FusionChartStatic) => FusionChartStatic; +export = zoomscatter; +export as namespace zoomscatter; + diff --git a/fusioncharts/index.d.ts b/fusioncharts/index.d.ts index dc053859b9..9c46955075 100644 --- a/fusioncharts/index.d.ts +++ b/fusioncharts/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for FusionCharts 3.11.2 +// Type definitions for fusioncharts 3.11 // Project: http://www.fusioncharts.com -// Definitions by: Shivaraj KV +// Definitions by: Rohit Kumar , Shivaraj KV // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -136,9 +136,9 @@ declare namespace FusionCharts { outputTo(callback: (message: any) => any): void; - enable(state:any,outputTo?:(message: any) =>any,outputFormat?:any):void + enable(state: any, outputTo?: (message: any) => any, outputFormat?: any): void; - enableFirebugLite():any; + enableFirebugLite(): any; } interface FusionCharts { @@ -154,7 +154,7 @@ declare namespace FusionCharts { configureLink(param: {} | any[], level?: number): void; - setChartAttribute(attributes: ChartObject | String, value?: string): void; + setChartAttribute(attributes: ChartObject | string, value?: string): void; getChartAttribute(attribute?: string | string[]): ChartObject; @@ -273,7 +273,7 @@ declare namespace FusionCharts { formatNumber(num: number, type?: string, config?: {}): Element; - setCurrentRenderer(name: string): void + setCurrentRenderer(name: string): void; getCurrentRenderer(): string; @@ -285,7 +285,7 @@ declare namespace FusionCharts { options: {}; - debugger:Debugger; + debugger: Debugger; } diff --git a/fusioncharts/maps/fusioncharts.usa.d.ts b/fusioncharts/maps/fusioncharts.usa.d.ts new file mode 100644 index 0000000000..16ed0d6c91 --- /dev/null +++ b/fusioncharts/maps/fusioncharts.usa.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var usa: (H: FusionChartStatic) => FusionChartStatic; +export = usa; +export as namespace usa; + diff --git a/fusioncharts/maps/fusioncharts.world.d.ts b/fusioncharts/maps/fusioncharts.world.d.ts new file mode 100644 index 0000000000..3e545e2556 --- /dev/null +++ b/fusioncharts/maps/fusioncharts.world.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var world: (H: FusionChartStatic) => FusionChartStatic; +export = world; +export as namespace world; + diff --git a/fusioncharts/themes/fusioncharts.theme.carbon.d.ts b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts new file mode 100644 index 0000000000..79ba171231 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.carbon.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var carbon: (H: FusionChartStatic) => FusionChartStatic; +export = carbon; +export as namespace carbon; + diff --git a/fusioncharts/themes/fusioncharts.theme.fint.d.ts b/fusioncharts/themes/fusioncharts.theme.fint.d.ts new file mode 100644 index 0000000000..cee08aa6b2 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.fint.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var fint: (H: FusionChartStatic) => FusionChartStatic; +export = fint; +export as namespace fint; + diff --git a/fusioncharts/themes/fusioncharts.theme.ocean.d.ts b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts new file mode 100644 index 0000000000..8b7e3828c0 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.ocean.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var ocean: (H: FusionChartStatic) => FusionChartStatic; +export = ocean; +export as namespace ocean; + diff --git a/fusioncharts/themes/fusioncharts.theme.zune.d.ts b/fusioncharts/themes/fusioncharts.theme.zune.d.ts new file mode 100644 index 0000000000..06ab4c1787 --- /dev/null +++ b/fusioncharts/themes/fusioncharts.theme.zune.d.ts @@ -0,0 +1,7 @@ + +import { FusionChartStatic } from "fusioncharts"; + +declare var zune: (H: FusionChartStatic) => FusionChartStatic; +export = zune; +export as namespace zune; + diff --git a/fusioncharts/tsconfig.json b/fusioncharts/tsconfig.json index dc4436d64c..970238d9a8 100644 --- a/fusioncharts/tsconfig.json +++ b/fusioncharts/tsconfig.json @@ -18,6 +18,20 @@ }, "files": [ "index.d.ts", + "fusioncharts.charts.d.ts", + "fusioncharts.powercharts.d.ts", + "fusioncharts.widgets.d.ts", + "fusioncharts.maps.d.ts", + "fusioncharts.zoomscatter.d.ts", + "fusioncharts.ssgrid.d.ts", + "fusioncharts.gantt.d.ts", + "fusioncharts.treemap.d.ts", + "maps/fusioncharts.usa.d.ts", + "maps/fusioncharts.world.d.ts", + "themes/fusioncharts.theme.carbon.d.ts", + "themes/fusioncharts.theme.fint.d.ts", + "themes/fusioncharts.theme.ocean.d.ts", + "themes/fusioncharts.theme.zune.d.ts", "fusioncharts-tests.ts" ] } \ No newline at end of file diff --git a/fusioncharts/tslint.json b/fusioncharts/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fusioncharts/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts index 0bf559061b..6f79d6e79a 100644 --- a/highcharts-ng/highcharts-ng-tests.ts +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -33,7 +33,8 @@ class AppController { title: { text: 'My Awesome Chart' }, - loading: true + loading: true, + noData: 'No data here' }; constructor($timeout: ng.ITimeoutService) { var vm = this; diff --git a/highcharts-ng/index.d.ts b/highcharts-ng/index.d.ts index 123799e76c..639d21d88e 100644 --- a/highcharts-ng/index.d.ts +++ b/highcharts-ng/index.d.ts @@ -35,6 +35,8 @@ declare global { }; //function (optional) - setup some logic for the chart func?: (chart: ChartObject) => void; + //no data text (optional) to show if all series are empty + noData?: string; } //Instantiated Chart diff --git a/mapbox-gl/index.d.ts b/mapbox-gl/index.d.ts index 360eb1ce33..2e75704dde 100644 --- a/mapbox-gl/index.d.ts +++ b/mapbox-gl/index.d.ts @@ -986,3 +986,7 @@ declare namespace mapboxgl { declare module 'mapbox-gl' { export = mapboxgl; } + +declare module 'mapbox-gl/dist/mapbox-gl' { + export = mapboxgl; +} diff --git a/msgpack-lite/index.d.ts b/msgpack-lite/index.d.ts index 400d22b2e7..e451267dbc 100644 --- a/msgpack-lite/index.d.ts +++ b/msgpack-lite/index.d.ts @@ -1,71 +1,153 @@ -// Type definitions for msgpack-lite 0.1.20 +// Type definitions for msgpack-lite 0.1 // Project: https://github.com/kawanet/msgpack-lite -// Definitions by: Endel Dreyer +// Definitions by: Endel Dreyer , Edmund Fokschaner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare module "msgpack-lite" { - import { Transform } from "stream"; +import * as stream from 'stream'; - namespace MsgpackLite { - interface BufferOptions { codec: any; } +/** + * encode from JS Object to MessagePack + */ +export function encode(input: any, options?: EncoderOptions): Buffer; - interface Encoder { - bufferish: any; - maxBufferSize: number; - minBufferSize: number; - offset: number; - start: number; - write: (chunk: any) => void; - fetch: () => void; - flush: () => void; - push: (chunk: any) => void; - pull: () => number; - read: () => number; - reserve: (length: number) => number; - send: (buffer: Buffer) => void; - encode: (chunk: any) => void; - end: (chunk: any) => void; - } +/** + * decode from MessagePack to JS Object + */ +export function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any; - interface Decoder { - bufferish: any; - offset: number; - fetch: () => void; - flush: () => void; - pull: () => number; - read: () => number; - write: (chunk: any) => void; - reserve: (length: number) => number; - decode: (chunk: any) => void; - push: (chunk: any) => void; - end: (chunk: any) => void; - } +/** + * create a stream that encodes from JS Object to MessagePack + */ +export function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream; - interface EncodeStream extends Transform { - encoder: Encoder; - } - interface DecodeStream extends Transform { - decoder: Decoder; - } +/** + * create a stream that decodes from MessagePack (Buffer) to JS Object + */ +export function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream; - interface Codec { - new (options?: any): Codec; - options: any; - init (): void; - addExtPacker (etype: number, Class: any, packer: (value: any) => any): void; - getExtPacker (value: any): (value: any) => any; - addExtUnpacker (etype: number, unpacker: (value: any) => any): void; - getExtUnpacker (etype: number): (value: any) => any; - } +/** + * Codecs allow for Custom Extension Types + * Register a custom extension type number to serialize/deserialize your own class instances. + * https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs + * If you wish to modify the default built-in codec, you can access it at msgpack.codec.preset + */ +export function createCodec(options?: CodecOptions): Codec; - export function encode(input: any, options?: BufferOptions): any; - export function decode(input: Buffer | Uint8Array | Array, options?: BufferOptions): any; - export function createEncodeStream (): EncodeStream; - export function createDecodeStream (): DecodeStream; - export function createCodec (options?: any): Codec; - export function codec (): { preset: Codec }; - } +/** + * The default built-in codec + */ +export var codec: { + /** + * The default built-in codec + */ + preset: Codec; +}; - export = MsgpackLite; +export interface Codec { + /** + * Register a custom extension to serialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param Class the constructor of the type you wish to serialize + * @param packer a function that converts an instance of T to bytes + */ + addExtPacker( + etype: number, + Class: new(...args: any[]) => T, + packer: (t: T) => Buffer | Uint8Array): void; + + /** + * Register a custom extension to deserialize your own class instances + * + * @param etype an integer within the range of 0 and 127 (0x0 and 0x7F) + * @param unpacker a function that converts bytes to an instance of T + */ + addExtUnpacker(etype: number, unpacker: (data: Buffer | Uint8Array) => T): void; } + +export interface Encoder { + bufferish: any; + maxBufferSize: number; + minBufferSize: number; + offset: number; + start: number; + write: (chunk: any) => void; + fetch: () => void; + flush: () => void; + push: (chunk: any) => void; + pull: () => number; + read: () => number; + reserve: (length: number) => number; + send: (buffer: Buffer) => void; + encode: (chunk: any) => void; + end: (chunk: any) => void; +} + +export interface Decoder { + bufferish: any; + offset: number; + fetch: () => void; + flush: () => void; + pull: () => number; + read: () => number; + write: (chunk: any) => void; + reserve: (length: number) => number; + decode: (chunk: any) => void; + push: (chunk: any) => void; + end: (chunk: any) => void; +} + +export interface EncodeStream extends stream.Transform { + encoder: Encoder; +} + +export interface DecodeStream extends stream.Transform { + decoder: Decoder; +} + +export interface CodecOptions { + /** + * It includes the preset extensions for JavaScript native objects. + * @see https://github.com/kawanet/msgpack-lite#extension-types + * @default false + */ + preset?: boolean; + /** + * It runs a validation of the value before writing it into buffer. + * This is the default behavior for some old browsers which do not support ArrayBuffer object. + * @default varies + */ + safe?: boolean; + /** + * It uses raw formats instead of bin and str. + * Set true for compatibility with msgpack's old spec. + * @see https://github.com/kawanet/msgpack-lite#compatibility-mode + * @default false + */ + raw?: boolean; + /** + * It decodes msgpack's int64/uint64 formats with int64-buffer object. + * int64-buffer is a cutom integer type with 64 bits of precision instead + * of the built-in IEEE-754 53 bits. See https://github.com/kawanet/int64-buffer + * @default false + */ + int64?: boolean; + /** + * It ties msgpack's bin format with ArrayBuffer object, instead of Buffer object. + * @default false + */ + binarraybuffer?: boolean; + /** + * It returns Uint8Array object when encoding, instead of Buffer object. + */ + uint8array?: boolean; +} + +export interface EncoderOptions { + codec?: Codec; +} + +export interface DecoderOptions { + codec?: Codec; +} \ No newline at end of file diff --git a/msgpack-lite/msgpack-lite-tests.ts b/msgpack-lite/msgpack-lite-tests.ts index f6d8725754..033fde060c 100644 --- a/msgpack-lite/msgpack-lite-tests.ts +++ b/msgpack-lite/msgpack-lite-tests.ts @@ -1,5 +1,74 @@ +import * as msgpack from 'msgpack-lite'; -import * as msgpack from "msgpack-lite"; +// https://github.com/kawanet/msgpack-lite#encoding-and-decoding-messagepack +function encodingAndDecoding() { + // encode from JS Object to MessagePack (Buffer) + var buffer = msgpack.encode({"foo": "bar"}); -var encoded = msgpack.encode(""); -msgpack.decode(encoded); + // decode from MessagePack (Buffer) to JS Object + var data = msgpack.decode(buffer); // => {"foo": "bar"} +} + +// https://github.com/kawanet/msgpack-lite#writing-to-messagepack-stream +function writingToStream() { + var fs = require("fs"); + + var writeStream = fs.createWriteStream("test.msp"); + var encodeStream = msgpack.createEncodeStream(); + encodeStream.pipe(writeStream); + + // send multiple objects to stream + encodeStream.write({foo: "bar"}); + encodeStream.write({baz: "qux"}); + + // call this once you're done writing to the stream. + encodeStream.end(); +} + +// https://github.com/kawanet/msgpack-lite#reading-from-messagepack-stream +function readingFromStream() { + var fs = require("fs"); + + var readStream = fs.createReadStream("test.msp"); + var decodeStream = msgpack.createDecodeStream(); + + // show multiple objects decoded from stream + readStream.pipe(decodeStream).on("data", console.warn); +} + +// https://github.com/kawanet/msgpack-lite#decoding-messagepack-bytes-array +function decodingBytesArray() { + // decode() accepts Buffer instance per default + msgpack.decode(new Buffer([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72])); + + // decode() also accepts Array instance + msgpack.decode([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72]); + + // decode() accepts raw Uint8Array instance as well + msgpack.decode(new Uint8Array([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72])); +} + +// https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs +function customExtensionTypes() { + var codec = msgpack.createCodec(); + codec.addExtPacker(0x3F, MyVector, myVectorPacker); + codec.addExtUnpacker(0x3F, myVectorUnpacker); + + var data = new MyVector(1, 2); + var encoded = msgpack.encode(data, {codec: codec}); + var decoded = msgpack.decode(encoded, {codec: codec}); + + class MyVector { + constructor(public x: number, public y: number) {} + } + + function myVectorPacker(vector: MyVector) { + var array = [vector.x, vector.y]; + return msgpack.encode(array); // return Buffer serialized + } + + function myVectorUnpacker(buffer: Buffer | Uint8Array): MyVector { + var array = msgpack.decode(buffer); + return new MyVector(array[0], array[1]); // return Object deserialized + } +} diff --git a/msgpack-lite/tsconfig.json b/msgpack-lite/tsconfig.json index 9a06c485e9..2547929f61 100644 --- a/msgpack-lite/tsconfig.json +++ b/msgpack-lite/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/msgpack-lite/tslint.json b/msgpack-lite/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/msgpack-lite/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file diff --git a/ngstorage/index.d.ts b/ngstorage/index.d.ts index b8fcf023c8..15fb3c0481 100644 --- a/ngstorage/index.d.ts +++ b/ngstorage/index.d.ts @@ -1,29 +1,25 @@ -// Type definitions for ngstorage 0.3.10 +// Type definitions for ngstorage 0.3.11 // Project: https://github.com/gsklee/ngStorage // Definitions by: Jakub Pistek // Definitions: https://github.com/kubiq/DefinitelyTyped -import * as angular from 'angular'; +declare module 'ngstorage' { -declare module 'angular' { - export namespace storage { + interface IStorageService { + $default(items: {}): IStorageService; + $reset(items?: {}): IStorageService; + $apply(): void; + $sync(): void; + get(key: string): T; + } - export interface IStorageService { - $default(items: {}): IStorageService; - $reset(items?: {}): IStorageService; - $apply(): void; - $sync(): void; - get(key: string): T; - } + interface IStorageProvider extends angular.IServiceProvider { - export interface IStorageProvider extends angular.IServiceProvider { + get(key: string): T; + set(key: string, value: T): T; - get(key: string): T; - set(key: string, value: T): T; - - setKeyPrefix(prefix: string): void; - setSerializer(serializer: (value: any) => string): void; - setDeserializer(deserializer: (value: string) => any): void; - } + setKeyPrefix(prefix: string): void; + setSerializer(serializer: (value: any) => string): void; + setDeserializer(deserializer: (value: string) => any): void; } } diff --git a/ngstorage/ngstorage-tests.ts b/ngstorage/ngstorage-tests.ts index 924d017a66..abddf19bb7 100644 --- a/ngstorage/ngstorage-tests.ts +++ b/ngstorage/ngstorage-tests.ts @@ -1,9 +1,9 @@ -/// +/// +import {IStorageService, IStorageProvider} from "ngstorage"; var app: any; - -app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageService) { +app.controller('LocalCtrl', function ($localStorage: IStorageService) { $localStorage.$default({ counter: 1 @@ -12,15 +12,15 @@ app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageSer $localStorage.$reset({ counter: 1 }); - + $localStorage.$reset(); $localStorage.$apply(); - + $localStorage.$sync(); }); -app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorageService) { +app.controller('SessionCtrl', function ($sessionStorage: IStorageService) { $sessionStorage.$default({ counter: 1 @@ -29,50 +29,50 @@ app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorag $sessionStorage.$reset({ counter: 1 }); - + $sessionStorage.$reset(); $sessionStorage.$apply(); - + $sessionStorage.$sync(); }); -app.config(['$localStorageProvider', function ($localStorageProvider: angular.storage.IStorageProvider) { +app.config(['$localStorageProvider', function ($localStorageProvider: IStorageProvider) { - $localStorageProvider.setKeyPrefix('NewPrefix'); + $localStorageProvider.setKeyPrefix('NewPrefix'); - $localStorageProvider.get('MyKey'); + $localStorageProvider.get('MyKey'); - $localStorageProvider.set('MyKey', { counter: 'value' }); + $localStorageProvider.set('MyKey', {counter: 'value'}); - var mySerializer = function (value:any):string { - return value.toString(); - }; + var mySerializer = function (value: any): string { + return value.toString(); + }; - var myDeserializer = function (value:string):any { - return value; - }; + var myDeserializer = function (value: string): any { + return value; + }; - $localStorageProvider.setSerializer(mySerializer); - $localStorageProvider.setDeserializer(myDeserializer); - } -]).config(['$sessionStorageProvider', function ($sessionStorageProvider: angular.storage.IStorageProvider) { + $localStorageProvider.setSerializer(mySerializer); + $localStorageProvider.setDeserializer(myDeserializer); +} +]).config(['$sessionStorageProvider', function ($sessionStorageProvider: IStorageProvider) { - $sessionStorageProvider.setKeyPrefix('NewPrefix'); + $sessionStorageProvider.setKeyPrefix('NewPrefix'); - $sessionStorageProvider.get('MyKey'); + $sessionStorageProvider.get('MyKey'); - $sessionStorageProvider.set('MyKey', { counter: 'value' }); + $sessionStorageProvider.set('MyKey', {counter: 'value'}); - var mySerializer = function (value:any):string { - return value.toString(); - }; + var mySerializer = function (value: any): string { + return value.toString(); + }; - var myDeserializer = function (value:string):any { - return value; - }; + var myDeserializer = function (value: string): any { + return value; + }; - $sessionStorageProvider.setSerializer(mySerializer); - $sessionStorageProvider.setDeserializer(myDeserializer); - } + $sessionStorageProvider.setSerializer(mySerializer); + $sessionStorageProvider.setDeserializer(myDeserializer); +} ]); diff --git a/ngstorage/tsconfig.json b/ngstorage/tsconfig.json index 691875db20..a3cdb4a204 100644 --- a/ngstorage/tsconfig.json +++ b/ngstorage/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "ngstorage-tests.ts" ] -} \ No newline at end of file +} diff --git a/notNeededPackages.json b/notNeededPackages.json index e671ef4523..46509a1642 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -293,6 +293,12 @@ "typingsPackageName": "redux-saga", "sourceRepoURL": "https://github.com/redux-saga/redux-saga", "asOfVersion": "0.10.5" + }, + { + "libraryName": "axios", + "typingsPackageName": "axios", + "sourceRepoURL": "https://github.com/mzabriskie/axios", + "asOfVersion": "0.14.0" } ] } diff --git a/pg/index.d.ts b/pg/index.d.ts index ca555b1f83..a2178d4823 100644 --- a/pg/index.d.ts +++ b/pg/index.d.ts @@ -88,10 +88,7 @@ export declare class Client extends events.EventEmitter { end(callback?: (err: Error) => void): void; release(): void; - query(queryText: string, values?: any[]): Promise; - - query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query; - query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; + query(queryTextOrConfig: string | QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query; copyFrom(queryText: string): stream.Writable; diff --git a/react-bootstrap-daterangepicker/index.d.ts b/react-bootstrap-daterangepicker/index.d.ts index e2ac7d49c6..baec72795b 100644 --- a/react-bootstrap-daterangepicker/index.d.ts +++ b/react-bootstrap-daterangepicker/index.d.ts @@ -5,12 +5,13 @@ // TypeScript Version: 2.1 /// -/// +/// declare namespace ReactBootstrapDaterangepicker { + export interface EventHandler { (event?: any, picker?: any): any; } - export interface Props extends DatepickerOptions { + export interface Props extends daterangepicker.Settings{ onShow?: EventHandler; onHide?: EventHandler; onShowCalendar?: EventHandler; diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index f2993d95c5..01c5492922 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -75,7 +75,7 @@ declare namespace ReactDayPicker { toMonth?: Date; localeUtils?: LocaleUtils; locale?: string; - captionElement?: React.ReactElement | null; + captionElement?: React.ReactElement; onDayClick?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayTouchTap?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; onDayMouseEnter?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; diff --git a/react-dom/index.d.ts b/react-dom/index.d.ts index bf0a246211..00520fc6ed 100644 --- a/react-dom/index.d.ts +++ b/react-dom/index.d.ts @@ -28,7 +28,7 @@ declare namespace ReactDOM { container: Element | null, callback?: (component: T) => any): T; function render

( - element: ReactElement

| null, + element: ReactElement

, container: Element | null, callback?: (component?: Component | Element) => any): Component | Element | void; @@ -57,7 +57,7 @@ declare namespace ReactDOM { callback?: () => any): void; function unstable_renderSubtreeIntoContainer

( parentComponent: Component, - element: ReactElement

| null, + element: ReactElement

, container: Element, callback?: (component?: Component | Element) => any): Component | Element | void; } diff --git a/react-modal/index.d.ts b/react-modal/index.d.ts index e5db7d66f0..4e038b416c 100644 --- a/react-modal/index.d.ts +++ b/react-modal/index.d.ts @@ -1,32 +1,62 @@ -// Type definitions for react-modal v1.6.1 +// Type definitions for react-modal 1.6 // Project: https://github.com/reactjs/react-modal -// Definitions by: Rajab Shakirov +// Definitions by: Rajab Shakirov , Drew Noakes // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -/// +import * as React from "react"; -declare module "react-modal" { - interface ReactModal { - isOpen: boolean; +export as namespace ReactModal; + +export = ReactModal; + +declare namespace ReactModal { + export interface Styles { style?: { content?: { [key: string]: any; - }, + }; overlay?: { [key: string]: any; - } - }, - appElement?: HTMLElement | {}, - onAfterOpen?: Function, - onRequestClose?: Function, - closeTimeoutMS?: number, - ariaHideApp?: boolean, - shouldCloseOnOverlayClick?: boolean, - overlayClassName?: string, - className?: string - contentLabel?: string + }; + }; + } + + export interface Props { + /* Boolean describing if the modal should be shown or not. Defaults to false. */ + isOpen: boolean; + /* Object indicating styles to be used for the modal, divided into overlay and content styles. */ + style?: Styles; + /* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + appElement?: HTMLElement | {}; + /* Function that will be run after the modal has opened. */ + onAfterOpen?: () => void; + /* Function that will be run when the modal is requested to be closed, prior to actually closing. */ + onRequestClose?: () => void; + /* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */ + closeTimeoutMS?: number; + /* Boolean indicating if the appElement should be hidden. Defaults to true. */ + ariaHideApp?: boolean; + /* Boolean indicating if the overlay should close the modal. Defaults to true. */ + shouldCloseOnOverlayClick?: boolean; + /* String className to be applied to the portal. Defaults to "ReactModalPortal". */ + portalClassName?: string; + /* String className to be applied to the overlay. */ + overlayClassName?: string; + /* String className to be applied to the modal content. */ + className?: string; + /* String indicating how the content container should be announced to screenreaders. */ + contentLabel?: string; + /* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */ + role?: string; + /* Function that will be called to get the parent element that the modal will be attached to. */ + parentSelector?: () => HTMLElement; } - let ReactModal: React.ClassicComponentClass; - export = ReactModal; +} + +declare class ReactModal extends React.Component { + /* Override base styles for all instances of this component. */ + static defaultStyles: ReactModal.Styles; + /* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */ + static setAppElement(appElement: HTMLElement): void; } diff --git a/react-modal/tslint.json b/react-modal/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-modal/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-native-datepicker/index.d.ts b/react-native-datepicker/index.d.ts new file mode 100644 index 0000000000..232f2f56d1 --- /dev/null +++ b/react-native-datepicker/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for react-native-datepicker 1.4 +// Project: https://github.com/xgfe/react-native-datepicker +// Definitions by: Jacob Baskin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +import * as React from 'react'; + +interface DatePickerProps { + mode?: 'date' | 'datetime' | 'time'; + date?: string | Date; + format?: string; + minDate?: string | Date; + maxDate?: string | Date; + height?: number; + duration?: number; + confirmBtnText?: string; + cancelBtnText?: string; + showIcon?: boolean; + disabled?: boolean; + onDateChange?: (dateStr: string, date: Date) => void; + placeholder?: string; + modalOnResponderTerminationRequest?: (e: any) => boolean; + is24Hour?: boolean; + style?: any; + customStyles?: any; + minuteInterval?: number; +} + +declare class DatePicker extends React.Component { + constructor(props: DatePickerProps); +} + +export default DatePicker; diff --git a/react-native-datepicker/react-native-datepicker-tests.tsx b/react-native-datepicker/react-native-datepicker-tests.tsx new file mode 100644 index 0000000000..eb423fd554 --- /dev/null +++ b/react-native-datepicker/react-native-datepicker-tests.tsx @@ -0,0 +1,42 @@ +import * as React from 'react'; +import DatePicker from 'react-native-datepicker'; + +interface MyDatePickerState { + date: string; +} + +export default class MyDatePicker extends React.Component<{}, MyDatePickerState> { + constructor(props: {}) { + super(props); + this.state = {date: "2016-05-15"}; + } + + render() { + return ( + {this.setState({date});}} + /> + ); + } +} + diff --git a/axios/tsconfig.json b/react-native-datepicker/tsconfig.json similarity index 70% rename from axios/tsconfig.json rename to react-native-datepicker/tsconfig.json index 4300cfb925..ffbef033e1 100644 --- a/axios/tsconfig.json +++ b/react-native-datepicker/tsconfig.json @@ -7,17 +7,18 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "jsx": "react" }, "files": [ "index.d.ts", - "axios-tests.ts" + "react-native-datepicker-tests.tsx" ] -} \ No newline at end of file +} diff --git a/react-native-datepicker/tslint.json b/react-native-datepicker/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-native-datepicker/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-native-swiper/react-native-swiper-tests.tsx b/react-native-swiper/react-native-swiper-tests.tsx index c8dae8511e..93cdfcfd18 100644 --- a/react-native-swiper/react-native-swiper-tests.tsx +++ b/react-native-swiper/react-native-swiper-tests.tsx @@ -18,7 +18,7 @@ class SwiperTest extends React.Component { super(props); } - public render(): React.ReactElement | null { + public render(): React.ReactElement { return ( diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index dbd2d43fff..95b2e38267 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -86,11 +86,11 @@ export interface InjectedRouter { } export interface RouteComponentProps { - location?: Location; - params?: P & R; - route?: PlainRoute; - router?: InjectedRouter; - routeParams?: R; + location: Location; + params: P & R; + route: PlainRoute; + router: InjectedRouter; + routeParams: R; } export interface RouterProps extends ClassAttributes { diff --git a/react-select/index.d.ts b/react-select/index.d.ts index e59322d0dc..a7c0f2f17a 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -246,6 +246,10 @@ declare namespace ReactSelectClass { * onInputChange handler: function (inputValue) {} */ onInputChange?: (inputValue: string) => void; + /** + * onInputKeyDown handler: function (keyboardEvent) {} + */ + onInputKeyDown?: (event: KeyboardEvent) => void; /** * fires when the menu is scrolled to the bottom; can be used to paginate options */ diff --git a/react-slick/index.d.ts b/react-slick/index.d.ts index 07179c4daa..513fc0d440 100644 --- a/react-slick/index.d.ts +++ b/react-slick/index.d.ts @@ -7,6 +7,10 @@ /// interface __config { + accessibility?: boolean + nextArrow?: HTMLElement | any + prevArrow?: HTMLElement | any + pauseOnHover?: boolean className?: string adaptiveHeight?: boolean arrows?: boolean diff --git a/react-slick/react-slick-tests.tsx b/react-slick/react-slick-tests.tsx index 7b51dbdf3a..2d26b0dcf1 100644 --- a/react-slick/react-slick-tests.tsx +++ b/react-slick/react-slick-tests.tsx @@ -10,7 +10,8 @@ class SliderTest extends React.Component, {}> { slidesToShow: 8, slidesToScroll: 1, draggable: false, - infinite: false + infinite: false, + prevArrow: link }; return ( diff --git a/react/index.d.ts b/react/index.d.ts index f25e5c0afd..001484aa15 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -171,7 +171,7 @@ declare namespace React { setState(f: (prevState: S, props: P) => Pick, callback?: () => any): void; setState(state: Pick, callback?: () => any): void; forceUpdate(callBack?: () => any): void; - render(): JSX.Element; + render(): JSX.Element | null; // React.Props is now deprecated, which means that the `children` // property is not available on `P` by default, even though you can @@ -204,7 +204,7 @@ declare namespace React { type SFC

= StatelessComponent

; interface StatelessComponent

{ - (props: P & { children?: ReactNode }, context?: any): ReactElement | null; + (props: P & { children?: ReactNode }, context?: any): ReactElement; propTypes?: ValidationMap

; contextTypes?: ValidationMap; defaultProps?: P; @@ -2628,11 +2628,9 @@ declare namespace React { declare global { namespace JSX { - interface JSXElement extends React.ReactElement { } - type Element = JSXElement | null; - + interface Element extends React.ReactElement { } interface ElementClass extends React.Component { - render(): JSX.Element; + render(): JSX.Element | null; } interface ElementAttributesProperty { props: {}; } diff --git a/react/test/tsx.tsx b/react/test/tsx.tsx index 0b0bc096ae..0531cb52c0 100644 --- a/react/test/tsx.tsx +++ b/react/test/tsx.tsx @@ -32,6 +32,3 @@ StatelessComponent2.defaultProps = { ; - -const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null; -const UseComponent2 = (f: boolean) => ; diff --git a/recompose/index.d.ts b/recompose/index.d.ts index e72302415f..3ff504fab3 100644 --- a/recompose/index.d.ts +++ b/recompose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Recompose v0.20.2 +// Type definitions for Recompose v0.20.3 // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -103,7 +103,7 @@ declare module 'recompose' { export function branch( test: predicate, trueEnhancer: InferableComponentEnhancer, - falseEnhancer: InferableComponentEnhancer + falseEnhancer?: InferableComponentEnhancer ): ComponentEnhancer; // renderComponent: https://github.com/acdlite/recompose/blob/master/docs/API.md#renderComponent diff --git a/recompose/recompose-tests.tsx b/recompose/recompose-tests.tsx index 25b52d70b0..c4c66b3e2c 100644 --- a/recompose/recompose-tests.tsx +++ b/recompose/recompose-tests.tsx @@ -148,13 +148,19 @@ function testBranch() { const innerComponent: React.StatelessComponent = (props: InnerProps) =>

props.update()}>{props.count}
; + const innerComponent2 = () =>
Hello
; const enhancer = branch( (props: OutterProps) => props.toggled, withState("count", "update", 0), withState("count", "update", 100) ); + const enhancer2 = branch( + (props: OutterProps) => props.toggled, + renderComponent(innerComponent), + ) const enhanced: React.ComponentClass = enhancer(innerComponent); + const enhanced2: React.ComponentClass = enhancer2(innerComponent); } function testRenderComponent() { diff --git a/serialport/index.d.ts b/serialport/index.d.ts index 60c240bbda..d94ab9d79f 100644 --- a/serialport/index.d.ts +++ b/serialport/index.d.ts @@ -1,24 +1,24 @@ -// Type definitions for serialport 4.0.1 +// Type definitions for serialport 4.0 // Project: https://github.com/EmergingTechnologyAdvisors/node-serialport // Definitions by: Jeremy Foster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'serialport' { class SerialPort { - constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: string) => void) - isOpen: boolean; + constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: any) => void) + isOpen(): boolean; on(event: string, callback?: (data?: any) => void): void; - open(callback?: () => void): void; - write(buffer: any, callback?: (err: string, bytesWritten: number) => void): void + open(callback?: (err: any) => void): void; + write(buffer: any, callback?: (err: any, bytesWritten: number) => void): void pause(): void; resume(): void; disconnected(err: Error): void; - close(callback?: (err:any) => void): void; - flush(callback?: (err:any) => void): void; - set(options: SerialPort.setOptions, callback: () => void): void; - drain(callback?: (err:any) => void): void; - update(options: SerialPort.updateOptions, callback?: () => void): void; - static list(callback: (err: string, ports: SerialPort.portConfig[]) => void): void; + close(callback?: (err: any) => void): void; + flush(callback?: (err: any) => void): void; + set(options: SerialPort.setOptions, callback: (err: any) => void): void; + drain(callback?: (err: any) => void): void; + update(options: SerialPort.updateOptions, callback?: (err: any) => void): void; + static list(callback: (err: any, ports: SerialPort.portConfig[]) => void): void; static parsers: { readline: (delimiter: string) => void, raw: (emitter: any, buffer: string) => void @@ -49,5 +49,5 @@ declare module 'serialport' { } } - export = SerialPort + export = SerialPort; } diff --git a/three/index.d.ts b/three/index.d.ts index 36263993c7..b4b4995ee8 100644 --- a/three/index.d.ts +++ b/three/index.d.ts @@ -3586,6 +3586,10 @@ declare namespace THREE { export class Spherical { constructor(radius?: number, phi?: number, theta?: number); + radius: number; + phi: number; + theta: number; + set(radius: number, phi: number, theta: number): Spherical; clone(): this; copy(other: this): this; diff --git a/wampy/index.d.ts b/wampy/index.d.ts index 840829f653..f74695503a 100644 --- a/wampy/index.d.ts +++ b/wampy/index.d.ts @@ -3,9 +3,8 @@ // Definitions by: Konstantin Burkalev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -interface WampyOptions { +interface WampyOptions +{ autoReconnect?: boolean; reconnectInterval?: number; maxRetries?: number; @@ -23,82 +22,95 @@ interface WampyOptions { msgpackCoder?: any; } -interface WampyOpStatus { +interface WampyOpStatus +{ code: number; description: string; reqId?: number; } -interface SuccessErrorCallbacksHash { +interface SuccessErrorCallbacksHash +{ onSuccess?: (data: any) => void; - onError?: (err: string) => void; + onError?: (err: string, details: any) => void; } -interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash { - onEvent: (data: any) => void; +interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash +{ + onEvent: (args: any[], kwargs: any) => void; } -interface RegisterCallbacksHash extends SuccessErrorCallbacksHash { +interface RegisterCallbacksHash extends SuccessErrorCallbacksHash +{ rpc: (data: any, options: any) => any[]; } -interface CallSuccessErrorCallbacksHash { - onSuccess: (data: any) => any; - onError?: (err: string) => void; +interface CallSuccessErrorCallbacksHash +{ + onSuccess: (args: any[], kwargs: any) => any; + onError?: (err: string, details: any, args: any[], kwargs: any) => void; } -interface AdvancedOptions { +interface AdvancedOptions +{ exclude?: number | number[]; eligible?: number | number[]; exclude_me?: boolean; disclose_me?: boolean; } -interface PublishAdvancedOptions extends AdvancedOptions { +interface PublishAdvancedOptions extends AdvancedOptions +{ exclude_authid?: string | string[]; exclude_authrole?: string | string[]; eligible_authid?: string | string[]; eligible_authrole?: string | string[]; } -interface CallAdvancedOptions { +interface CallAdvancedOptions +{ disclose_me?: boolean; receive_progress?: boolean; timeout?: number; } -interface CancelAdvancedOptions { +interface CancelAdvancedOptions +{ mode?: "skip" | "kill" | "killnowait"; } -interface Wampy { +interface Wampy +{ + new (url?: string, options?: WampyOptions): Wampy; options(opts?: WampyOptions): WampyOptions | Wampy; getOpStatus(): WampyOpStatus; getSessionId(): number; connect(url?: string): Wampy; disconnect(): Wampy; abort(): Wampy; - subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; - unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy; + subscribe(topicURI: string, callbacks: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; + unsubscribe(topicURI: string, callbacks?: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy; publish(topicURI: string, - payload?: any, - callbacks?: SuccessErrorCallbacksHash, - advancedOptions?: PublishAdvancedOptions): Wampy; + payload?: any, + callbacks?: SuccessErrorCallbacksHash, + advancedOptions?: PublishAdvancedOptions): Wampy; call(topicURI: string, - payload?: any, - callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash), - advancedOptions?: CallAdvancedOptions): Wampy; + payload?: any, + callbacks?: (((args: any[], kwargs: any) => void) | CallSuccessErrorCallbacksHash), + advancedOptions?: CallAdvancedOptions): Wampy; cancel(reqId: number, - callbacks?: ((() => void) | SuccessErrorCallbacksHash), - advancedOptions?: CancelAdvancedOptions): Wampy; + callbacks?: ((() => void) | SuccessErrorCallbacksHash), + advancedOptions?: CancelAdvancedOptions): Wampy; register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy; unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy; } -interface WampyInstance { - new (url?: string, options?: WampyOptions): Wampy; +declare var wampy: Wampy; + +declare module 'wampy' +{ + export = wampy; } -declare var wampy: WampyInstance; -export default wampy; + diff --git a/wampy/wampy-tests.ts b/wampy/wampy-tests.ts index feed5677bc..e3de0cd019 100644 --- a/wampy/wampy-tests.ts +++ b/wampy/wampy-tests.ts @@ -1,47 +1,50 @@ /// -import Wampy from 'wampy'; +import * as Wampy from 'wampy'; -var ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'}); +let ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'}); ws.options(); ws.options({ reconnectInterval: 1000, maxRetries: 999, - onConnect: function () { console.log('Yahoo! We are online!'); }, - onClose: function () { console.log('See you next time!'); }, - onError: function () { console.log('Breakdown happened'); }, - onReconnect: function () { console.log('Reconnecting...'); }, - onReconnectSuccess: function () { console.log('Successfully reconnected!'); } + onConnect: () => console.log('Yahoo! We are online!'), + onClose: () => console.log('See you next time!'), + onError: () => console.log('Breakdown happened'), + onReconnect: () => console.log('Reconnecting...'), + onReconnectSuccess: () => console.log('Successfully reconnected!') }); ws.connect(); ws.connect('/my-socket-path'); ws.connect('wss://socket.server.com:5000/ws'); -var id: number = ws.getSessionId(); + +let id: number = ws.getSessionId(); + ws.disconnect(); ws.abort(); -ws.subscribe('system.monitor.update', function (data) { +ws.subscribe('system.monitor.update', (args: any[], kwargs: any) => { console.log('Received system.monitor.update event!'); }) - .subscribe('client.message', function (data) { + .subscribe('client.message', function (args: any[], kwargs: any) { console.log('Received client.message event!'); }); -var f1 = function () { console.log('Subscribe processing!'); }; +let f1 = () => console.log('Subscribe processing!'); + ws.unsubscribe('subscribed.topic', f1); ws.unsubscribe('chat.message.received'); ws.call('get.server.time', null, { - onSuccess: function (stime) { + onSuccess: (args: any[], kwargs: any) => { console.log('RPC successfully called'); - console.log('Server time is ' + stime); + console.log('Server time is ' + kwargs); }, - onError: function (err) { + onError: (err: string, details: any, args: any[], kwargs: any) => { console.log('RPC call failed with error ' + err); } }); @@ -54,67 +57,48 @@ ws.publish('chat.message.received', 'user message'); ws.publish('chat.message.received', ['user message1', 'user message2']); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, { - onSuccess: function () { console.log('User successfully modified'); } + onSuccess: () => console.log('User successfully modified') }); ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, { - onSuccess: function () { console.log('User successfully modified'); }, - onError: function (err) { console.log('User modification failed', err); } + onSuccess: () => console.log('User successfully modified'), + onError: (err: string, details: any) => console.log('User modification failed', err) }); ws.publish('chat.message.received', ['Private message'], null, { eligible: 123456789 }); -ws.call('server.time', null, function (data) { console.log('Server time is ' + data[0]); }); +ws.call('server.time', null, (args: any[], kwargs: any) => console.log('Server time is ' + args[0])); ws.call('start.migration', null, { - onSuccess: function (data) { - console.log('RPC successfully called'); - }, - onError: function (err) { - console.log('RPC call failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err) }); ws.call('restore.backup', { backupFile: 'backup.zip' }, { - onSuccess: function (data) { - console.log('Backup successfully restored'); - }, - onError: function (err) { - console.log('Restore failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('Backup successfully restored'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('Restore failed!',err) }); ws.call('start.migration', null, { - onSuccess: function (data) { - console.log('RPC successfully called'); - }, - onError: function (err) { - console.log('RPC call failed!',err); - } + onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'), + onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err) }); -var status = ws.getOpStatus(); + +let status = ws.getOpStatus(); ws.cancel(status.reqId); -var sqrt_f = function (x: number, y: any) { return [{}, x*x]; }; +let sqrt_f = (x: number, y: any) => [{}, x*x]; ws.register('sqrt.value', sqrt_f); ws.register('sqrt.value', { rpc: sqrt_f, - onSuccess: function (data) { - console.log('RPC successfully registered'); - }, - onError: function (err) { - console.log('RPC registration failed!',err); - } + onSuccess: (data: any) => console.log('RPC successfully registered'), + onError: (err: string, details: any) => console.log('RPC registration failed!',err) }); ws.unregister('sqrt.value'); ws.unregister('sqrt.value', { - onSuccess: function (data) { - console.log('RPC successfully unregistered'); - }, - onError: function (err) { - console.log('RPC unregistration failed!',err); - } + onSuccess: (data: any) => console.log('RPC successfully unregistered'), + onError: (err: string, details: any) => console.log('RPC unregistration failed!', err) }); diff --git a/yargs/.editorconfig b/yargs/.editorconfig new file mode 100644 index 0000000000..db9b917e06 --- /dev/null +++ b/yargs/.editorconfig @@ -0,0 +1,5 @@ +[*.ts] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 diff --git a/yargs/index.d.ts b/yargs/index.d.ts index da23a91f7f..9c581611db 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for yargs 6.5.0 +// Type definitions for yargs 6.6.0 // Project: https://github.com/chevex/yargs -// Definitions by: Martin Poelstra , Mizunashi Mana , Jeffery Grajkowski +// Definitions by: Martin Poelstra , Mizunashi Mana , Jeffery Grajkowski , Jeff Kenney // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace yargs { @@ -28,6 +28,9 @@ declare namespace yargs { default(key: string, value: any, description?: string): Argv; default(defaults: { [key: string]: any }, description?: string): Argv; + /** + * @deprecated since version 6.6.0 + */ demand(key: string, msg: string): Argv; demand(key: string, required?: boolean): Argv; demand(keys: string[], msg: string): Argv; @@ -36,6 +39,15 @@ declare namespace yargs { demand(positionals: number, msg: string): Argv; demand(positionals: number, max: number, msg?: string): Argv; + demandCommand(min: number, minMsg?: string): Argv; + demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv; + + demandOption(key: string | string[], msg?: string): Argv; + demandOption(key: string | string[], demand?: boolean): Argv; + + /** + * @deprecated since version 6.6.0 + */ require(key: string, msg: string): Argv; require(key: string, required: boolean): Argv; require(keys: number[], msg: string): Argv; @@ -43,6 +55,9 @@ declare namespace yargs { require(positionals: number, required: boolean): Argv; require(positionals: number, msg: string): Argv; + /** + * @deprecated since version 6.6.0 + */ required(key: string, msg: string): Argv; required(key: string, required: boolean): Argv; required(keys: number[], msg: string): Argv; @@ -103,6 +118,9 @@ declare namespace yargs { config(key: string, parseFn: (configPath: string) => Object): Argv; config(keys: string[], parseFn: (configPath: string) => Object): Argv; + conflicts(key: string, value: string): Argv; + conflicts(conflicts: { [key: string]: string }): Argv; + wrap(columns: number): Argv; strict(): Argv; @@ -147,7 +165,7 @@ declare namespace yargs { fail(func: (msg: string, err: Error) => any): Argv; - coerce(key: string|string[], func: (arg: T) => U): Argv; + coerce(key: string | string[], func: (arg: T) => U): Argv; coerce(opts: { [key: string]: (arg: T) => U; }): Argv; getCompletion(args: string[], done: (completions: string[]) => void): Argv; @@ -186,7 +204,9 @@ declare namespace yargs { count?: boolean; default?: any; defaultDescription?: string; + /** @deprecated since version 6.6.0 */ demand?: boolean | string; + demandOption?: boolean | string; desc?: string; describe?: string; description?: string; diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index f44e38b545..f68c1113e9 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -12,539 +12,539 @@ const stringVal = 'string'; // With yargs, the options be just a hash! function xup() { - var argv = yargs.argv; + var argv = yargs.argv; - if (argv.rif - 5 * argv.xup > 7.138) { - console.log('Plunder more riffiwobbles!'); - } - else { - console.log('Drop the xupptumblers!'); - } + if (argv.rif - 5 * argv.xup > 7.138) { + console.log('Plunder more riffiwobbles!'); + } + else { + console.log('Drop the xupptumblers!'); + } } // And non-hyphenated options too! Just use argv._! function nonopt() { - var argv = yargs.argv; - console.log('(%d,%d)', argv.x, argv.y); - console.log(argv._); + var argv = yargs.argv; + console.log('(%d,%d)', argv.x, argv.y); + console.log(argv._); } // Yargs even counts your booleans! function count() { - var argv = yargs - .count('verbose') - .alias('v', 'verbose') - .argv; + var argv = yargs + .count('verbose') + .alias('v', 'verbose') + .argv; - var VERBOSE_LEVEL: number = argv.verbose; + var VERBOSE_LEVEL: number = argv.verbose; - function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } - function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } - function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } + function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); } + function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); } + function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); } } // Tell users how to use yer options and make demands. function divide() { - var argv = yargs - .usage('Usage: $0 -x [num] -y [num]') - .demand(['x', 'y']) - .argv; + var argv = yargs + .usage('Usage: $0 -x [num] -y [num]') + .demand(['x', 'y']) + .argv; - console.log(argv.x / argv.y); + console.log(argv.x / argv.y); } // After yer demands have been met, demand more! Ask for non-hypenated arguments! function demand_count() { - var argv = yargs - .demand(2) - .demand(2, false) - .demand(2, 2) - .demand(2, 2, "message") - .argv; - console.dir(argv); + var argv = yargs + .demand(2) + .demand(2, false) + .demand(2, 2) + .demand(2, 2, "message") + .argv; + console.dir(argv); } // EVEN MORE SHIVER ME TIMBERS! function default_singles() { - var argv = yargs - .default('x', 10) - .default('y', 10) - .argv - ; - console.log(argv.x + argv.y); + var argv = yargs + .default('x', 10) + .default('y', 10) + .argv + ; + console.log(argv.x + argv.y); } function default_hash() { - var argv = yargs - .default({ x: 10, y: 10 }) - .argv - ; - console.log(argv.x + argv.y); + var argv = yargs + .default({ x: 10, y: 10 }) + .argv + ; + console.log(argv.x + argv.y); } // And if you really want to get all descriptive about it... function boolean_single() { - var argv = yargs - .boolean('v') - .argv - ; - console.dir(argv.v); - console.dir(argv._); + var argv = yargs + .boolean('v') + .argv + ; + console.dir(argv.v); + console.dir(argv._); } function boolean_double() { - var argv = yargs - .boolean(['x', 'y', 'z']) - .argv - ; - console.dir([argv.x, argv.y, argv.z]); - console.dir(argv._); + var argv = yargs + .boolean(['x', 'y', 'z']) + .argv + ; + console.dir([argv.x, argv.y, argv.z]); + console.dir(argv._); } // Yargs is here to help you... function line_count() { - var argv = yargs - .usage('Count the lines in a file.\nUsage: $0') - .example('$0 -f', 'count the lines in the given file') - .demand('f') - .alias('f', 'file') - .describe('f', 'Load a file') - .argv - ; + var argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .example('$0 -f', 'count the lines in the given file') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .argv + ; } // Below are tests for individual methods. // Not all methods are covered yet, and neither are all possible invocations of methods. function Argv_parsing() { - var argv1 = yargs.argv; - var argv2 = yargs(['-x', '1', '-y', '2']).argv; - var argv3 = yargs.parse(['-x', '1', '-y', '2']); - console.log(argv1.x, argv2.x, argv3.x); + var argv1 = yargs.argv; + var argv2 = yargs(['-x', '1', '-y', '2']).argv; + var argv3 = yargs.parse(['-x', '1', '-y', '2']); + console.log(argv1.x, argv2.x, argv3.x); } function Argv$options() { - var argv1 = yargs - .options('f', { - alias: 'file', - default: '/etc/passwd', - defaultDescription: 'The /etc/passwd file', - group: 'files', - normalize: true, - global: false, - array: true, - nargs: 3 - }) - .argv - ; + var argv1 = yargs + .options('f', { + alias: 'file', + default: '/etc/passwd', + defaultDescription: 'The /etc/passwd file', + group: 'files', + normalize: true, + global: false, + array: true, + nargs: 3 + }) + .argv + ; - var argv2 = yargs - .alias('f', 'file') - .default('f', '/etc/passwd') - .argv - ; + var argv2 = yargs + .alias('f', 'file') + .default('f', '/etc/passwd') + .argv + ; } function Argv$global() { - var argv = yargs - .global('foo') - .global(['bar', 'baz', 'fizz', 'buzz']) + var argv = yargs + .global('foo') + .global(['bar', 'baz', 'fizz', 'buzz']) } function Argv$group() { - var argv = yargs - .group('foo', 'foogroup') - .group(['bing', 'bang', 'buzz'], 'onomatopoeia') + var argv = yargs + .group('foo', 'foogroup') + .group(['bing', 'bang', 'buzz'], 'onomatopoeia') } function Argv$env() { - var argv = yargs - .env('YARGS_PREFIX_') - .env() - .env(true); + var argv = yargs + .env('YARGS_PREFIX_') + .env() + .env(true); } function Argv$array() { - var argv = yargs - .array('foo') - .array(['bar', 'baz']) + var argv = yargs + .array('foo') + .array(['bar', 'baz']) } function Argv$nargs() { - var argv = yargs - .nargs('foo', 12) - .nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 }) + var argv = yargs + .nargs('foo', 12) + .nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 }) } function Argv$choices() { - // example from documentation - var argv = yargs - .alias('i', 'ingredient') - .describe('i', 'choose your sandwich ingredients') - .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) - .help('help') - .argv + // example from documentation + var argv = yargs + .alias('i', 'ingredient') + .describe('i', 'choose your sandwich ingredients') + .choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles']) + .help('help') + .argv } function command() { - var argv = yargs - .usage('npm ') - .command('install', 'tis a mighty fine package to install') - .command('publish', 'shiver me timbers, should you be sharing all that', yargs => - yargs.option('f', { - alias: 'force', - description: 'yar, it usually be a bad idea' - }) - .help('help') - ) - .command("build", "arghh, build it mate", { - tag: { - default: true, - demand: true, - description: "Tag the build, mate!" - }, - publish: { - default: false, - description:"Should i publish?" - } - }) - .command({ - command: "test", - describe: "test package", - builder: { - mateys: { - demand: false - } - }, - handler: (args: any) => { - /* handle me mateys! */ - } - }) - .command("test", "test mateys", { - handler: (args: any) => { - /* handle me mateys! */ - } - }) - .help('help') - .argv; + var argv = yargs + .usage('npm ') + .command('install', 'tis a mighty fine package to install') + .command('publish', 'shiver me timbers, should you be sharing all that', yargs => + yargs.option('f', { + alias: 'force', + description: 'yar, it usually be a bad idea' + }) + .help('help') + ) + .command("build", "arghh, build it mate", { + tag: { + default: true, + demand: true, + description: "Tag the build, mate!" + }, + publish: { + default: false, + description:"Should i publish?" + } + }) + .command({ + command: "test", + describe: "test package", + builder: { + mateys: { + demand: false + } + }, + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .command("test", "test mateys", { + handler: (args: any) => { + /* handle me mateys! */ + } + }) + .help('help') + .argv; - yargs - .command('get', 'make a get HTTP request', function (yargs) { - return yargs.option('url', { - alias: 'u', - default: 'http://yargs.js.org/' - }) - }) - .help() - .argv + yargs + .command('get', 'make a get HTTP request', function (yargs) { + return yargs.option('url', { + alias: 'u', + default: 'http://yargs.js.org/' + }) + }) + .help() + .argv - yargs - .command( - 'get', - 'make a get HTTP request', - function (yargs) { - return yargs.option('u', { - alias: 'url', - describe: 'the URL to make an HTTP request to' - }) - }, - function (argv: { url: string }) { - console.dir(argv.url) - } - ) - .help() - .argv + yargs + .command( + 'get', + 'make a get HTTP request', + function (yargs) { + return yargs.option('u', { + alias: 'url', + describe: 'the URL to make an HTTP request to' + }) + }, + function (argv: { url: string }) { + console.dir(argv.url) + } + ) + .help() + .argv } function completion_sync() { - var argv = yargs - .completion('completion', (current, argv) => { - // 'current' is the current command being completed. - // 'argv' is the parsed arguments so far. - // simply return an array of completions. - return [ - 'foo', - 'bar' - ]; - }) - .argv; + var argv = yargs + .completion('completion', (current, argv) => { + // 'current' is the current command being completed. + // 'argv' is the parsed arguments so far. + // simply return an array of completions. + return [ + 'foo', + 'bar' + ]; + }) + .argv; } function completion_async() { - var argv = yargs - .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { - setTimeout(function () { - done([ - 'apple', - 'banana' - ]); - }, 500); - }) - .argv; + var argv = yargs + .completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => { + setTimeout(function () { + done([ + 'apple', + 'banana' + ]); + }, 500); + }) + .argv; } function Argv$help() { - var argv = yargs - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") - .help() - .argv; + var argv = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]") + .help() + .argv; } function Argv$showHelpOnFail() { - var argv = yargs - .usage('Count the lines in a file.\nUsage: $0') - .demand('f') - .alias('f', 'file') - .describe('f', 'Load a file') - .showHelpOnFail(false, "Specify --help for available options") - .argv; + var argv = yargs + .usage('Count the lines in a file.\nUsage: $0') + .demand('f') + .alias('f', 'file') + .describe('f', 'Load a file') + .showHelpOnFail(false, "Specify --help for available options") + .argv; } function Argv$showHelp() { - var yargs1 = yargs - .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); - yargs1.showHelp(); + var yargs1 = yargs + .usage("$0 -operand1 number -operand2 number -operation [add|subtract]"); + yargs1.showHelp(); } function Argv$version() { - var argv1 = yargs - .version(); + var argv1 = yargs + .version(); - var argv2 = yargs - .version('1.0.0'); + var argv2 = yargs + .version('1.0.0'); - var argv3 = yargs - .version('1.0.0', '--version'); + var argv3 = yargs + .version('1.0.0', '--version'); - var argv4 = yargs - .version('1.0.0', '--version', 'description'); + var argv4 = yargs + .version('1.0.0', '--version', 'description'); - var argv5 = yargs - .version(function () { return '1.0.0'; }, '--version', 'description'); + var argv5 = yargs + .version(function () { return '1.0.0'; }, '--version', 'description'); } function Argv$wrap() { - var argv1 = yargs - .wrap(null); + var argv1 = yargs + .wrap(null); - var argv2 = yargs - .wrap(yargs.terminalWidth()); + var argv2 = yargs + .wrap(yargs.terminalWidth()); } function Argv$locale() { - var argv = yargs - .usage('./$0 - follow ye instructions true') - .option('option', { - alias: 'o', - describe: "'tis a mighty fine option", - demand: true - }) - .command('run', "Arrr, ya best be knowin' what yer doin'") - .example('$0 run foo', "shiver me timbers, here's an example for ye") - .help('help') - .wrap(70) - .locale('pirate') - .argv + var argv = yargs + .usage('./$0 - follow ye instructions true') + .option('option', { + alias: 'o', + describe: "'tis a mighty fine option", + demand: true + }) + .command('run', "Arrr, ya best be knowin' what yer doin'") + .example('$0 run foo', "shiver me timbers, here's an example for ye") + .help('help') + .wrap(70) + .locale('pirate') + .argv } function Argv$epilogue() { - var argv = yargs - .epilogue('for more information, find our manual at http://example.com'); + var argv = yargs + .epilogue('for more information, find our manual at http://example.com'); } function Argv$reset() { - var ya = yargs - .usage('$0 command') - .command('hello', 'hello command') - .command('world', 'world command') - .demand(1, 'must provide a valid command'), - argv = yargs.argv, - command = argv._[0]; + var ya = yargs + .usage('$0 command') + .command('hello', 'hello command') + .command('world', 'world command') + .demand(1, 'must provide a valid command'), + argv = yargs.argv, + command = argv._[0]; - if (command === 'hello') { - ya.reset() - .usage('$0 hello') - .help('h') - .example('$0 hello', 'print the hello message!') - .argv + if (command === 'hello') { + ya.reset() + .usage('$0 hello') + .help('h') + .example('$0 hello', 'print the hello message!') + .argv - console.log('hello!'); - } else if (command === 'world') { - ya.reset() - .usage('$0 world') - .help('h') - .example('$0 world', 'print the world message!') - .argv + console.log('hello!'); + } else if (command === 'world') { + ya.reset() + .usage('$0 world') + .help('h') + .example('$0 world', 'print the world message!') + .argv - console.log('world!'); - } else { - ya.showHelp(); - } + console.log('world!'); + } else { + ya.showHelp(); + } } // http://yargs.js.org/docs/#methods-commanddirdirectory-opts function Argv$commandDir() { - var ya = yargs - .commandDir('.') - .argv + var ya = yargs + .commandDir('.') + .argv } // http://yargs.js.org/docs/#methods-commanddirdirectory-opts function Argv$commandDirWithOptions() { - var ya = yargs - .commandDir('.', { - recurse: false, - extensions: ['js'], - visit: (commandObject: any, pathToFile: string, filename: string) => { }, - include: /.*\.js$/, - exclude: /.*\.spec.js$/, - }) - .argv + var ya = yargs + .commandDir('.', { + recurse: false, + extensions: ['js'], + visit: (commandObject: any, pathToFile: string, filename: string) => { }, + include: /.*\.js$/, + exclude: /.*\.spec.js$/, + }) + .argv } function Argv$normalize() { - var ya = yargs - .normalize('path') - .normalize(['user', 'group']) - .argv + var ya = yargs + .normalize('path') + .normalize(['user', 'group']) + .argv } // From http://yargs.js.org/docs/#methods-coercekey-fn function Argv$coerce() { - var ya = yargs - .coerce('file', function (arg: string) { - return fs.readFileSync(arg, 'utf8'); - }) - .argv + var ya = yargs + .coerce('file', function (arg: string) { + return fs.readFileSync(arg, 'utf8'); + }) + .argv } function Argv$coerces() { - var ya = yargs - .coerce({ - date: Date.parse, - json: JSON.parse - }) - .argv + var ya = yargs + .coerce({ + date: Date.parse, + json: JSON.parse + }) + .argv } function Argv$coerceWithKeys() { - var ya = yargs - .coerce(['src', 'dest'], path.resolve) - .argv + var ya = yargs + .coerce(['src', 'dest'], path.resolve) + .argv } // From http://yargs.js.org/docs/#methods-failfn function Argv$fail() { - var ya = yargs - .fail(function (msg, err) { - if (err) throw err // preserve stack - console.error('You broke it!') - console.error(msg) - process.exit(1) - }) - .argv + var ya = yargs + .fail(function (msg, err) { + if (err) throw err // preserve stack + console.error('You broke it!') + console.error(msg) + process.exit(1) + }) + .argv } function Argv$implies() { - var ya = yargs - .implies('foo', 'snuh') - .implies({ - x: 'y' - }) - .argv + var ya = yargs + .implies('foo', 'snuh') + .implies({ + x: 'y' + }) + .argv } function Argv$count() { - var ya = yargs - .count('size') - .count(['w', 'h']) - .argv + var ya = yargs + .count('size') + .count(['w', 'h']) + .argv } function Argv$number() { - var ya = yargs - .number('n') - .number(['width', 'height']) - .argv + var ya = yargs + .number('n') + .number(['width', 'height']) + .argv } function Argv$updateStrings() { - var ya = yargs - .command('run', 'the run command') - .help('help') - .updateStrings({ - 'Commands:': 'My Commands -->\n' - }) - .wrap(null) - .argv + var ya = yargs + .command('run', 'the run command') + .help('help') + .updateStrings({ + 'Commands:': 'My Commands -->\n' + }) + .wrap(null) + .argv } function Argv$default() { - var ya = yargs - .default('random', function randomValue() { - return Math.random() * 256; - }) - .argv + var ya = yargs + .default('random', function randomValue() { + return Math.random() * 256; + }) + .argv } function Argv$configObject() { - var ya = yargs - .config({foo: 1, bar: 2}) - .argv + var ya = yargs + .config({foo: 1, bar: 2}) + .argv } function Argv$configParseFunction() { - var ya = yargs - .config('settings', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .config('settings', 'description', function (configPath) { - return JSON.parse(fs.readFileSync(configPath, 'utf-8')) - }) - .argv + var ya = yargs + .config('settings', function (configPath) { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')) + }) + .config('settings', 'description', function (configPath) { + return JSON.parse(fs.readFileSync(configPath, 'utf-8')) + }) + .argv } function Argv$helpDescriptionExplicit() { - var ya = yargs - .help('help', 'description', true) - .argv + var ya = yargs + .help('help', 'description', true) + .argv } function Argv$showHelpConsoleLevel() { - yargs.showHelp("log"); //prints to stdout using console.log() + yargs.showHelp("log"); //prints to stdout using console.log() } function Argv$getCompletion() { - var ya = yargs - .option('foobar', {}) - .option('foobaz', {}) - .completion() - .getCompletion(['./test.js', '--foo'], function (completions) { - console.log(completions) - }) - .argv + var ya = yargs + .option('foobar', {}) + .option('foobaz', {}) + .completion() + .getCompletion(['./test.js', '--foo'], function (completions) { + console.log(completions) + }) + .argv } function Argv$pkgConf() { - var ya = yargs - .pkgConf(['key1', 'key2'], 'configFile.json') - .argv + var ya = yargs + .pkgConf(['key1', 'key2'], 'configFile.json') + .argv } function Argv$recommendCommands() { - var ya = yargs - .recommendCommands() - .argv + var ya = yargs + .recommendCommands() + .argv } function Argv$showCompletionScript() { - var ya = yargs - .showCompletionScript() - .argv + var ya = yargs + .showCompletionScript() + .argv } function Argv$skipValidation() { - var ya = yargs - .skipValidation('arg1') - .skipValidation(['arg2', 'arg3']) - .argv + var ya = yargs + .skipValidation('arg1') + .skipValidation(['arg2', 'arg3']) + .argv } function Argv$commandObject() { @@ -562,6 +562,7 @@ function Argv$commandObject() { default: "myvalue", defaultDescription: "description", demand: true, + demandOption: true, desc: "desc", describe: "describe", description: "description", @@ -577,3 +578,33 @@ function Argv$commandObject() { } }) } + +function Argv$demandCommand() { + var ya = yargs + .demandCommand(1) + .demandCommand(1, 'at least 1 command required') + .demandCommand(1, 2) + .demandCommand(1, 2, 'at least 1 command required') + .demandCommand(1, 2, 'at least 1 command required', 'at most 2 commands required') + .argv; +} + +function Argv$demandOption() { + var ya = yargs + .demandOption('a') + .demandOption('a', 'a is required') + .demandOption('a', true) + .demandOption(['a', 'b']) + .demandOption(['a', 'b'], 'a and b are required') + .demandOption(['a', 'b'], true) + .argv; +} + +function Argv$conflicts() { + var ya = yargs + .conflicts('a', 'b') + .conflicts({ + a: 'b' + }) + .argv; +}