diff --git a/angular-clipboard/angular-clipboard-tests.ts b/angular-clipboard/angular-clipboard-tests.ts new file mode 100644 index 0000000000..ccb1c7ce9a --- /dev/null +++ b/angular-clipboard/angular-clipboard-tests.ts @@ -0,0 +1,14 @@ +/// +/// + +import * as angular from "angular"; +import {ClipboardService} from "angular-clipboard"; + +const app = angular.module('testModule', ['angular-clipboard']); +app.controller('TestController', ($scope: ng.IScope, clipboard: ClipboardService) => { + $scope['testCopy'] = () => { + if (clipboard.supported) { + clipboard.copyText('hiiiiiii'); + } + }; +}); diff --git a/angular-clipboard/index.d.ts b/angular-clipboard/index.d.ts new file mode 100644 index 0000000000..bb2d93ce49 --- /dev/null +++ b/angular-clipboard/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for angular-clipboard v1.5 +// Project: https://github.com/omichelsen/angular-clipboard +// Definitions by: Bradford Wagner +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Definition of the Clipboard Service + */ +export interface ClipboardService { + /** + * tells us whether or not angular-clipboard is supported + */ + supported: boolean; + + /** + * copies text to a clipboard + * @param text the text to be copied to the clipboard + */ + copyText(text: string): void; +} diff --git a/angular-clipboard/tsconfig.json b/angular-clipboard/tsconfig.json new file mode 100644 index 0000000000..1f69b1e8fa --- /dev/null +++ b/angular-clipboard/tsconfig.json @@ -0,0 +1,19 @@ +{ + "files": [ + "index.d.ts", + "angular-clipboard-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/angular-permission/angular-permission-tests.ts b/angular-permission/angular-permission-tests.ts index 4f3a35f5df..051ace69b8 100644 --- a/angular-permission/angular-permission-tests.ts +++ b/angular-permission/angular-permission-tests.ts @@ -66,7 +66,7 @@ angular PermissionStore.removePermissionDefinition('user'); - let permissions: Array = PermissionStore.getStore(); + let permissions = PermissionStore.getStore(); }); @@ -90,5 +90,5 @@ angular RoleStore.removeRoleDefinition('user'); - let roles: Array = RoleStore.getStore(); + let roles = RoleStore.getStore(); }); diff --git a/angular-permission/index.d.ts b/angular-permission/index.d.ts index 0b8d06f32a..28781cb5df 100644 --- a/angular-permission/index.d.ts +++ b/angular-permission/index.d.ts @@ -30,8 +30,8 @@ declare module 'angular' { * @param validationFunction {Function} Function used to validate if permission is valid */ definePermission( - name: string, - validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise + permissionName: string, + validationFunction: PermissionValidationFunction ): void; /** @@ -43,10 +43,14 @@ declare module 'angular' { * @param validationFunction {Function} Function used to validate if permission is valid */ defineManyPermissions( - permissions: string[], - validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise + permissionNames: string[], + validationFunction: PermissionValidationFunction ): void; + /** + * Removes all permissions + * @method + */ clearStore(): void; /** @@ -55,7 +59,7 @@ declare module 'angular' { * * @param permissionName {String} Name of defined permission */ - removePermissionDefinition(permission: string): void; + removePermissionDefinition(permissionName: string): void; /** * Checks if permission exists @@ -66,13 +70,21 @@ declare module 'angular' { */ hasPermissionDefinition(permissionName: string): boolean; + /** + * Returns permission by it's name + * @method + * + * @returns {permission.Permission} Permissions definition object + */ + getPermissionDefinition(permissionName: string): Permission; + /** * Returns all permissions * @method * * @returns {Object} Permissions collection */ - getStore(): Permission[]; + getStore(): { [permissionName: string]: Permission }; } export interface RoleStore { @@ -85,8 +97,8 @@ declare module 'angular' { * @param [validationFunction] {Function} Function used to validate if permissions in role are valid */ defineRole( - role: string, - permissions: Array, + roleName: string, + permissions: string[], validationFunction: RoleValidationFunction ): void; @@ -97,7 +109,10 @@ declare module 'angular' { * @param roleName {String} Name of defined role * @param permissions {Array} Set of permission names */ - defineRole(role: string, permissions: Array): void; + defineRole( + roleName: string, + permissions: string[] + ): void; /** * Checks if role is defined in store @@ -106,7 +121,7 @@ declare module 'angular' { * @param roleName {String} Name of role * @returns {Boolean} */ - hasRoleDefinition(role: string): boolean; + hasRoleDefinition(roleName: string): boolean; /** * Returns role definition object by it's name @@ -136,27 +151,31 @@ declare module 'angular' { * * @returns {Object} Defined roles collection */ - getStore(): Role[]; + getStore(): { [roleName: string]: Role }; } export interface Role { roleName: string; permissionNames: string[]; validationFunction?: RoleValidationFunction; + validateRole: () => angular.IPromise; } export interface Permission { permissionName: string; validationFunction?: PermissionValidationFunction; + validatePermission: () => angular.IPromise; } - interface RoleValidationFunction { - (permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise; - } + export type RoleValidationFunction = ( + roleName?: string, + transitionProperties?: TransitionProperties + ) => boolean | angular.IPromise; - interface PermissionValidationFunction { - (permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise; - } + export type PermissionValidationFunction = ( + permissionName?: string, + transitionProperties?: TransitionProperties + ) => boolean | angular.IPromise; export interface IPermissionState extends angular.ui.IState { data?: any | DataWithPermissions; @@ -164,8 +183,8 @@ declare module 'angular' { export interface DataWithPermissions { permissions?: { - only?: (() => void) | Array | angular.IPromise; - except?: (() => void) | Array | angular.IPromise; + only?: (() => void) | string | string[] | angular.IPromise; + except?: (() => void) | string | string[] | angular.IPromise; redirectTo: string | (() => string) | (() => PermissionRedirectConfigation) | { [index: string]: PermissionRedirectConfigation } }; } diff --git a/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts b/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts index 3f14b2a40f..2ca6e18806 100644 --- a/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts +++ b/angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts @@ -1,5 +1,3 @@ -/// - angular.module("test", [ "ui.bootstrap", "ui.router", diff --git a/angular-ui-router-uib-modal/angular-ui-router-uib-modal.d.ts b/angular-ui-router-uib-modal/index.d.ts similarity index 64% rename from angular-ui-router-uib-modal/angular-ui-router-uib-modal.d.ts rename to angular-ui-router-uib-modal/index.d.ts index 598fe964fe..29e963fc6e 100644 --- a/angular-ui-router-uib-modal/angular-ui-router-uib-modal.d.ts +++ b/angular-ui-router-uib-modal/index.d.ts @@ -3,10 +3,12 @@ // Definitions by: Stepan Riha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as auir from "angular-ui-router"; -declare namespace angular.ui { - interface IState { - modal?: boolean | string[]; +declare module "angular" { + namespace ui { + interface IState { + modal?: boolean | string[]; + } } } diff --git a/angular-ui-router-uib-modal/tsconfig.json b/angular-ui-router-uib-modal/tsconfig.json new file mode 100644 index 0000000000..08dbd4d4cf --- /dev/null +++ b/angular-ui-router-uib-modal/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "angular-ui-router-uib-modal-tests.ts" + ] +} \ No newline at end of file diff --git a/arbiter/Arbiter-tests.ts b/arbiter/arbiter-tests.ts similarity index 100% rename from arbiter/Arbiter-tests.ts rename to arbiter/arbiter-tests.ts diff --git a/aws-sdk/aws-sdk-tests.ts b/aws-sdk/aws-sdk-tests.ts index 7d3b7a5c2c..5188a3e725 100644 --- a/aws-sdk/aws-sdk-tests.ts +++ b/aws-sdk/aws-sdk-tests.ts @@ -381,3 +381,42 @@ dynamoDBDocClient.query( else console.log(data); // successful response } ); + +var kinesis = new AWS.Kinesis(); + +var putRecordParam = { + Data: new Buffer('...') || 'STRING_VALUE', /* required */ + PartitionKey: 'STRING_VALUE', /* required */ + StreamName: 'STRING_VALUE', /* required */ + ExplicitHashKey: 'STRING_VALUE', + SequenceNumberForOrdering: 'STRING_VALUE' +}; +kinesis.putRecord(putRecordParam, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response +}); + +var putRecordParams = { + Records: [ /* required */ + { + Data: new Buffer('...') || 'STRING_VALUE', /* required */ + PartitionKey: 'STRING_VALUE', /* required */ + ExplicitHashKey: 'STRING_VALUE' + }, + /* more items */ + ], + StreamName: 'STRING_VALUE' /* required */ +}; +kinesis.putRecords(putRecordParams, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response +}); + +var increaseStreamRetentionPeriodParams = { + RetentionPeriodHours: 0, /* required */ + StreamName: 'STRING_VALUE' /* required */ +}; +kinesis.increaseStreamRetentionPeriod(increaseStreamRetentionPeriodParams, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response +}); \ No newline at end of file diff --git a/aws-sdk/index.d.ts b/aws-sdk/index.d.ts index 884cbbcdc7..fbee8f926c 100644 --- a/aws-sdk/index.d.ts +++ b/aws-sdk/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for aws-sdk // Project: https://github.com/aws/aws-sdk-js -// Definitions by: midknight41 +// Definitions by: midknight41 , Casper Skydt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/aws-sdk.d.ts @@ -335,6 +335,56 @@ export declare class SNS { publish(request: Sns.PublishRequest, callback: (err: any, data: any) => void): void; } +export class Kinesis { + constructor(options?: any); + endpoint: Endpoint; + + putRecord(params: KINESIS.PutRecordParams, callback: (error: Error, data: KINESIS.PutRecordResult) => void): void; + putRecords(params: KINESIS.PutRecordsParams, callback: (error: Error, data: KINESIS.PutRecordsResult) => void): void; + increaseStreamRetentionPeriod(params: KINESIS.IncreaseStreamRetentionPeriodParams, callback: (error: Error, data: any) => void): void; + } + + export module KINESIS { + export interface Record { + Data: Buffer | string | Blob; + PartitionKey: string; + ExplicitHashKey?: string; + } + + export interface RecordResult { + SequenceNumber: string; + ShardId: string; + ErrorCode: string; + ErrorMessage: string; + } + + export interface PutRecordParams extends Record { + StreamName: string; + SequenceNumberForOrdering?: string; + } + + export interface PutRecordResult { + ShardId: string; + SequenceNumber: string; + } + + export interface PutRecordsParams { + StreamName: string; + Records: Record[]; + } + + export interface PutRecordsResult { + FailedRecordCount: number; + Records: RecordResult[] + } + + export interface IncreaseStreamRetentionPeriodParams { + RetentionPeriodHours: number; + StreamName: string; + } + } + + export declare class SWF { constructor(options?: any); endpoint: Endpoint; diff --git a/bind-ponyfill/bind-ponyfill-tests.ts b/bind-ponyfill/bind-ponyfill-tests.ts new file mode 100644 index 0000000000..8c5ba7ec05 --- /dev/null +++ b/bind-ponyfill/bind-ponyfill-tests.ts @@ -0,0 +1,8 @@ +import ponyBind = require('bind-ponyfill'); + +let boundFn: Function; + +boundFn = ponyBind(() => { console.log(this); }, 'Hello world!'); +boundFn = ponyBind((...args: Array) => { console.log(this, ...args); }, 'Hello world!', 'arg1'); +boundFn = ponyBind((...args: Array) => { console.log(this, ...args); }, 'Hello world!', 'arg1', 'arg2'); +boundFn = ponyBind((arg1: string, arg2: number) => { console.log(this, arg1, arg2); }, 'Hello world!', 'arg1', 2); \ No newline at end of file diff --git a/bind-ponyfill/index.d.ts b/bind-ponyfill/index.d.ts new file mode 100644 index 0000000000..8fb2227627 --- /dev/null +++ b/bind-ponyfill/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for bind-ponyfill 0.1.0 +// Project: https://www.npmjs.com/package/bind-ponyfill +// Definitions by: Steve Jenkins +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function ponyBind(fn: Function, that: any, ...args: Array): Function; +export = ponyBind; \ No newline at end of file diff --git a/bind-ponyfill/tsconfig.json b/bind-ponyfill/tsconfig.json new file mode 100644 index 0000000000..44c1eca54a --- /dev/null +++ b/bind-ponyfill/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bind-ponyfill-tests.ts" + ] +} diff --git a/browser-resolve/tsconfig.json b/browser-resolve/tsconfig.json index 937a2406b8..d708711572 100644 --- a/browser-resolve/tsconfig.json +++ b/browser-resolve/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/cassandra-driver/tsconfig.json b/cassandra-driver/tsconfig.json index 0dec57214f..10b7ab8253 100644 --- a/cassandra-driver/tsconfig.json +++ b/cassandra-driver/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "cassandra-driver.tests.ts" + "cassandra-driver-tests.ts" ] } \ No newline at end of file diff --git a/chai-spies/chai-spies-tests.ts b/chai-spies/chai-spies-tests.ts new file mode 100644 index 0000000000..7ac0610e4d --- /dev/null +++ b/chai-spies/chai-spies-tests.ts @@ -0,0 +1,135 @@ +/// +/// + +import * as chai from 'chai'; +import * as spies from 'chai-spies'; +import * as Mocha from 'mocha'; + +function original(): void { + // do something cool +} + +let ee = { + on(name: string, fn: () => void) { + } +}; + +let spiedFn = chai.spy(original); + +// then use in place of original +ee.on('some event', spiedFn); + +// or use without original +let spy_again = chai.spy(); +ee.on('some other event', spy_again); + +// or you can track an object's method +let array = [ 1, 2, 3 ]; +chai.spy.on(array, 'push'); + +// or you can track multiple object's methods +chai.spy.on(array, 'push', 'pop'); + +array.push(5); + +// and you can reset the object calls +// array.push.reset(); + +// or you can create spy object +let object = chai.spy.object([ 'push', 'pop' ]); +object.push(5); + +// or you create spy which returns static value +spiedFn = chai.spy.returns(true); + +spiedFn(); // true + + +let should = chai.should() + , expect = chai.expect; + +const spy = chai.spy(); + +// .spy + +expect(spy).to.be.spy; +spy.should.be.spy; + +// .called + +expect(spy).to.have.been.called(); +spy.should.have.been.called(); + +// .with +const spyStringArg = chai.spy((arg: string) => arg); +spyStringArg('foo'); +expect(spyStringArg).to.have.been.called.with('foo'); +spyStringArg.should.have.been.called.with('foo'); + +const spyTwoStringArgsAndOneNumber = chai.spy((arg1: string, arg2: string, arg3: number) => arg3); +spyTwoStringArgsAndOneNumber('foo', 'bar', 1); +expect(spyTwoStringArgsAndOneNumber).to.have.been.called.with('bar', 'foo'); +spyTwoStringArgsAndOneNumber.should.have.been.called.with('bar', 'foo'); + +// .with.exactly +const spyTwoStringArgs = chai.spy((arg1: string, arg2: string) => arg1); +spyTwoStringArgs('', ''); +spyTwoStringArgs('foo', 'bar'); +expect(spyTwoStringArgs).to.have.been.called.with.exactly('foo', 'bar'); +spyTwoStringArgs.should.have.been.called.with.exactly('foo', 'bar'); + +// .always.with +const spyThreeAnyArgs = chai.spy((arg1: any, arg2: any, arg3: any) => arg1); +spyThreeAnyArgs('foo', null, null); +spyThreeAnyArgs('foo', 'bar', null); +spyThreeAnyArgs(1, 2, 'foo'); +expect(spy).to.have.been.called.always.with('foo'); +spy.should.have.been.called.always.with('foo'); + +// .always.with.exactly +spyStringArg('foo'); +spyStringArg('foo'); +expect(spyStringArg).to.have.been.called.always.with.exactly('foo'); +spyStringArg.should.have.been.called.always.with.exactly('foo'); + +// .once +expect(spy).to.have.been.called.once; +expect(spy).to.not.have.been.called.once; +spy.should.have.been.called.once; +spy.should.not.have.been.called.once; + +// .twice +expect(spy).to.have.been.called.twice; +expect(spy).to.not.have.been.called.twice; +spy.should.have.been.called.twice; +spy.should.not.have.been.called.twice; + +// .exactly(n) +expect(spy).to.have.been.called.exactly(3); +expect(spy).to.not.have.been.called.exactly(3); +spy.should.have.been.called.exactly(3); +spy.should.not.have.been.called.exactly(3); + +// .min(n) / .at.least(n) +expect(spy).to.have.been.called.min(3); +expect(spy).to.not.have.been.called.at.least(3); +spy.should.have.been.called.at.least(3); +spy.should.not.have.been.called.min(3); + +// .max(n) / .at.most(n) +expect(spy).to.have.been.called.max(3); +expect(spy).to.not.have.been.called.at.most(3); +spy.should.have.been.called.at.most(3); +spy.should.not.have.been.called.max(3); + +// .above(n) / .gt(n) +expect(spy).to.have.been.called.above(3); +expect(spy).to.not.have.been.called.gt(3); +spy.should.have.been.called.gt(3); +spy.should.not.have.been.called.above(3); + +// .below(n) / .lt(n) +expect(spy).to.have.been.called.below(3); +expect(spy).to.not.have.been.called.lt(3); +spy.should.have.been.called.lt(3); +spy.should.not.have.been.called.below(3); \ No newline at end of file diff --git a/chai-spies/index.d.ts b/chai-spies/index.d.ts new file mode 100644 index 0000000000..ffed6e594b --- /dev/null +++ b/chai-spies/index.d.ts @@ -0,0 +1,411 @@ +// Type definitions for chai-spies +// Project: https://github.com/chaijs/chai-spies +// Definitions by: Ilya Kuznetsov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Chai { + interface ChaiStatic { + spy: ChaiSpies.Spy; + } + + interface Assertion { + /** + * ####.spy + * Asserts that object is a spy. + * ```ts + * expect(spy).to.be.spy; + * spy.should.be.spy; + * ``` + */ + spy: Assertion; + + /** + * ####.called + * Assert that a spy has been called. Negation passes through. + * ```ts + * expect(spy).to.have.been.called(); + * spy.should.have.been.called(); + * ``` + * Note that ```called``` can be used as a chainable method. + */ + called: ChaiSpies.Called; + } +} + +declare namespace ChaiSpies { + + interface Spy { + /** + * #### chai.spy (function) + * + * Wraps a function in a proxy function. All calls will pass through to the original function. + * ```ts + * function original() {} + * var spy = chai.spy(original) + * , e_spy = chai.spy(); + * ``` + * @param fn function to spy on. @default ```function () {}``` + * @returns function to actually call + */ + (): SpyFunc0Proxy; + (fn: SpyFunc0): SpyFunc0Proxy; + (fn: SpyFunc1): SpyFunc1Proxy; + (fn: SpyFunc2): SpyFunc2Proxy; + (fn: SpyFunc3): SpyFunc3Proxy; + (fn: SpyFunc4): SpyFunc4Proxy; + (fn: SpyFunc5): SpyFunc5Proxy; + (fn: SpyFunc6): SpyFunc6Proxy; + (fn: SpyFunc7): SpyFunc7Proxy; + (fn: SpyFunc8): SpyFunc8Proxy; + (fn: SpyFunc9): SpyFunc9Proxy; + (fn: SpyFunc10): SpyFunc10Proxy; + (name: string, fn: SpyFunc0): SpyFunc0Proxy; + (name: string, fn: SpyFunc1): SpyFunc1Proxy; + (name: string, fn: SpyFunc2): SpyFunc2Proxy; + (name: string, fn: SpyFunc3): SpyFunc3Proxy; + (name: string, fn: SpyFunc4): SpyFunc4Proxy; + (name: string, fn: SpyFunc5): SpyFunc5Proxy; + (name: string, fn: SpyFunc6): SpyFunc6Proxy; + (name: string, fn: SpyFunc7): SpyFunc7Proxy; + (name: string, fn: SpyFunc8): SpyFunc8Proxy; + (name: string, fn: SpyFunc9): SpyFunc9Proxy; + (name: string, fn: SpyFunc10): SpyFunc10Proxy; + + /** + * #### chai.spy.on (function) + * + * Wraps an object method into spy. All calls will pass through to the original function. + * ```ts + * var spy = chai.spy.on(Array, 'isArray'); + * ``` + * @param {Object} object + * @param {String} method name to spy on + * @returns function to actually call + */ + on(object: Object, ...methodNames: string[]): any; + + /** + * #### chai.spy.object (function) + * + * Creates an object with spied methods. + * ```ts + * var object = chai.spy.object('Array', [ 'push', 'pop' ]); + * ``` + * @param {String} [name] object name + * @param {String[]|Object} method names or method definitions + * @returns object with spied methods + */ + object(name: string, methods: string[]): any; + object(methods: string[]): any; + object(name: string, methods: T): T; + object(methods: T): T; + + /** + * #### chai.spy.returns (function) + * + * Creates a spy which returns static value. + *```ts + * var method = chai.spy.returns(true); + *``` + * @param {*} value static value which is returned by spy + * @returns new spy function which returns static value + * @api public + */ + + returns(value: T): SpyFunc0Proxy; + } + + interface Called { + (): Chai.Assertion; + with: With; + always: Always; + + /** + * ####.once + * Assert that a spy has been called exactly once. + * ```ts + * expect(spy).to.have.been.called.once; + * expect(spy).to.not.have.been.called.once; + * spy.should.have.been.called.once; + * spy.should.not.have.been.called.once; + * ``` + */ + once: Chai.Assertion; + + /** + * ####.twice + * Assert that a spy has been called exactly twice. + * ```ts + * expect(spy).to.have.been.called.twice; + * expect(spy).to.not.have.been.called.twice; + * spy.should.have.been.called.twice; + * spy.should.not.have.been.called.twice; + * ``` + */ + twice: Chai.Assertion; + + /** + * ####.exactly(n) + * Assert that a spy has been called exactly ```n``` times. + * ```ts + * expect(spy).to.have.been.called.exactly(3); + * expect(spy).to.not.have.been.called.exactly(3); + * spy.should.have.been.called.exactly(3); + * spy.should.not.have.been.called.exactly(3); + * ``` + */ + exactly(n: number): Chai.Assertion; + + /** + * ####.min(n) / .at.least(n) + * Assert that a spy has been called minimum of ```n``` times. + * ```ts + * expect(spy).to.have.been.called.min(3); + * expect(spy).to.not.have.been.called.at.least(3); + * spy.should.have.been.called.at.least(3); + * spy.should.not.have.been.called.min(3); + * ``` + */ + min(n: number): Chai.Assertion; + + /** + * ####.max(n) / .at.most(n) + * Assert that a spy has been called maximum of ```n``` times. + * ```ts + * expect(spy).to.have.been.called.max(3); + * expect(spy).to.not.have.been.called.at.most(3); + * spy.should.have.been.called.at.most(3); + * spy.should.not.have.been.called.max(3); + * ``` + */ + max(n: number): Chai.Assertion; + + at: At; + /** + * ####.above(n) / .gt(n) + * Assert that a spy has been called more than ```n``` times. + * ```ts + * expect(spy).to.have.been.called.above(3); + * spy.should.not.have.been.called.above(3); + * ``` + */ + above(n: number): Chai.Assertion; + + /** + * ####.above(n) / .gt(n) + * Assert that a spy has been called more than ```n``` times. + * ```ts + * expect(spy).to.have.been.called.gt(3); + * spy.should.not.have.been.called.gt(3); + * ``` + */ + gt(n: number): Chai.Assertion; + + /** + * ####.below(n) / .lt(n) + * Assert that a spy has been called fewer than ```n``` times. + * ```ts + * expect(spy).to.have.been.called.below(3); + * spy.should.not.have.been.called.below(3); + * ``` + */ + below(n: number): Chai.Assertion; + + /** + * ####.below(n) / .lt(n) + * Assert that a spy has been called fewer than ```n``` times. + * ```ts + * expect(spy).to.have.been.called.lt(3); + * spy.should.not.have.been.called.lt(3); + * ``` + */ + lt(n: number): Chai.Assertion; + } + + interface With { + /** + * ####.with + * Assert that a spy has been called with a given argument at least once, even if more arguments were provided. + * ```ts + * spy('foo'); + * expect(spy).to.have.been.called.with('foo'); + * spy.should.have.been.called.with('foo'); + * ``` + * Will also pass for ```spy('foo', 'bar')``` and ```spy(); spy('foo')```. + * If used with multiple arguments, assert that a spy has been called with all the given arguments at least once. + * ```ts + * spy('foo', 'bar', 1); + * expect(spy).to.have.been.called.with('bar', 'foo'); + * spy.should.have.been.called.with('bar', 'foo'); + * ``` + */ + (a: any, b?: any, c?: any, d?: any, e?: any, f?: any, g?: any, h?: any, i?: any, j?: any): Chai.Assertion; + + /** + * ####.with.exactly + * Similar to .with, but will pass only if the list of arguments is exactly the same as the one provided. + * ```ts + * spy(); + * spy('foo', 'bar'); + * expect(spy).to.have.been.called.with.exactly('foo', 'bar'); + * spy.should.have.been.called.with.exactly('foo', 'bar'); + * ``` + * Will not pass for ```spy('foo')```, ```spy('bar')```, ```spy('bar'); spy('foo')```, ```spy('foo'); spy('bar')```, ```spy('bar', 'foo')``` or ```spy('foo', 'bar', 1)```. + * Can be used for calls with a single argument too. + */ + + exactly(a?: any, b?: any, c?: any, d?: any, e?: any, f?: any, g?: any, h?: any, i?: any, j?: any): Chai.Assertion; + } + + interface Always { + with: AlwaysWith; + } + + interface AlwaysWith { + /** + * ####.always.with + * Assert that every time the spy has been called the argument list contained the given arguments. + * ```ts + * spy('foo'); + * spy('foo', 'bar'); + * spy(1, 2, 'foo'); + * expect(spy).to.have.been.called.always.with('foo'); + * spy.should.have.been.called.always.with('foo'); + * ``` + */ + (a: any, b?: any, c?: any, d?: any, e?: any, f?: any, g?: any, h?: any, i?: any, j?: any): Chai.Assertion; + + /** + * ####.always.with.exactly + * Assert that the spy has never been called with a different list of arguments than the one provided. + * ```ts + * spy('foo'); + * spy('foo'); + * expect(spy).to.have.been.called.always.with.exactly('foo'); + * spy.should.have.been.called.always.with.exactly('foo'); + * ``` + */ + exactly(a?: any, b?: any, c?: any, d?: any, e?: any, f?: any, g?: any, h?: any, i?: any, j?: any): Chai.Assertion; + } + + interface At { + /** + * ####.min(n) / .at.least(n) + * Assert that a spy has been called minimum of ```n``` times. + * ```ts + * expect(spy).to.have.been.called.min(3); + * expect(spy).to.not.have.been.called.at.least(3); + * spy.should.have.been.called.at.least(3); + * spy.should.not.have.been.called.min(3); + * ``` + */ + least(n: number): Chai.Assertion; + + /** + * ####.max(n) / .at.most(n) + * Assert that a spy has been called maximum of ```n``` times. + * ```ts + * expect(spy).to.have.been.called.max(3); + * expect(spy).to.not.have.been.called.at.most(3); + * spy.should.have.been.called.at.most(3); + * spy.should.not.have.been.called.max(3); + * ``` + */ + most(n: number): Chai.Assertion; + } + + interface Resetable { + /** + * #### proxy.reset (function) + * + * Resets __spy object parameters for instantiation and reuse + * @returns proxy spy object + */ + reset(): this; + } + + interface SpyFunc0 { + (): R; + } + + interface SpyFunc1 { + (a: A1): R; + } + + interface SpyFunc2 { + (a: A1, b: A2): R; + } + + interface SpyFunc3 { + (a: A1, b: A2, c: A3): R; + } + + interface SpyFunc4 { + (a: A1, b: A2, c: A3, d: A4): R; + } + + interface SpyFunc5 { + (a: A1, b: A2, c: A3, d: A4, e: A5): R; + } + + interface SpyFunc6 { + (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6): R; + } + + interface SpyFunc7 { + (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7): R; + } + + interface SpyFunc8 { + (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8): R; + } + + interface SpyFunc9 { + (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9): R; + } + + interface SpyFunc10 { + (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, g: A7, h: A8, i: A9, j: A10): R; + } + + interface SpyFunc0Proxy extends SpyFunc0, Resetable { + } + + interface SpyFunc1Proxy extends SpyFunc1, Resetable { + } + + interface SpyFunc2Proxy extends SpyFunc2, Resetable { + } + + interface SpyFunc3Proxy extends SpyFunc3, Resetable { + } + + interface SpyFunc4Proxy extends SpyFunc4, Resetable { + } + + interface SpyFunc5Proxy extends SpyFunc5, Resetable { + } + + interface SpyFunc6Proxy extends SpyFunc6, Resetable { + } + + interface SpyFunc7Proxy extends SpyFunc7, Resetable { + } + + interface SpyFunc8Proxy extends SpyFunc8, Resetable { + } + + interface SpyFunc9Proxy extends SpyFunc9, Resetable { + } + + interface SpyFunc10Proxy extends SpyFunc10, Resetable { + } +} + +declare var spies: ChaiSpies.Spy; + +declare module "chai-spies" { + export = spies; +} diff --git a/chai-spies/tsconfig.json b/chai-spies/tsconfig.json new file mode 100644 index 0000000000..91c115a7a5 --- /dev/null +++ b/chai-spies/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "chai-spies-tests.ts" + ] +} \ No newline at end of file diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 9bf41eeaae..e9186035c7 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -392,7 +392,7 @@ interface RadialLinearScale { } declare class Chart { - constructor (context: CanvasRenderingContext2D, options: ChartConfiguration); + constructor (context: CanvasRenderingContext2D | HTMLCanvasElement, options: ChartConfiguration); config: ChartConfiguration; destroy: () => {}; update: (duration?: any, lazy?: any) => {}; diff --git a/clipboard/clipboard-tests.ts b/clipboard/clipboard-tests.ts index c6c7b756cb..7521c651dd 100644 --- a/clipboard/clipboard-tests.ts +++ b/clipboard/clipboard-tests.ts @@ -1,4 +1,4 @@ - +import * as Clipboard from 'clipboard'; var cb1 = new Clipboard('.btn'); var cb2 = new Clipboard(document.getElementById('id'), { diff --git a/clipboard/index.d.ts b/clipboard/index.d.ts index d4b014e2f3..0757eb1208 100644 --- a/clipboard/index.d.ts +++ b/clipboard/index.d.ts @@ -3,54 +3,56 @@ // Definitions by: Andrei Kurosh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare class Clipboard { - constructor(selector: (string | Element | NodeListOf), options?: ClipboardOptions); - - /** - * Subscribes to events that indicate the result of a copy/cut operation. - * @param type {String} Event type ('success' or 'error'). - * @param handler Callback function. - */ - on(type: "success", handler: (e: ClipboardEvent) => void): this; - on(type: "error", handler: (e: ClipboardEvent) => void): this; - on(type: string, handler: (e: ClipboardEvent) => void): this; - - /** - * Clears all event bindings. - */ - destroy(): void; -} - -interface ClipboardOptions { - /** - * Overwrites default command ('cut' or 'copy'). - * @param {Element} elem Current element - * @returns {String} Only 'cut' or 'copy'. - */ - action?: (elem: Element) => string; - - /** - * Overwrites default target input element. - * @param {Element} elem Current element - * @returns {Element} element to use. - */ - target?: (elem: Element) => Element; - - /** - * Returns the explicit text to copy. - * @param {Element} elem Current element - * @returns {String} Text to be copied. - */ - text?: (elem: Element) => string; -} - -interface ClipboardEvent { - action: string; - text: string; - trigger: Element; - clearSelection(): void; -} - declare module 'clipboard' { + class Clipboard { + constructor(selector: (string | Element | NodeListOf), options?: Clipboard.Options); + + /** + * Subscribes to events that indicate the result of a copy/cut operation. + * @param type {String} Event type ('success' or 'error'). + * @param handler Callback function. + */ + on(type: "success", handler: (e: Clipboard.Event) => void): this; + on(type: "error", handler: (e: Clipboard.Event) => void): this; + on(type: string, handler: (e: Clipboard.Event) => void): this; + + /** + * Clears all event bindings. + */ + destroy(): void; + } + + namespace Clipboard { + interface Options { + /** + * Overwrites default command ('cut' or 'copy'). + * @param {Element} elem Current element + * @returns {String} Only 'cut' or 'copy'. + */ + action?: (elem: Element) => string; + + /** + * Overwrites default target input element. + * @param {Element} elem Current element + * @returns {Element} element to use. + */ + target?: (elem: Element) => Element; + + /** + * Returns the explicit text to copy. + * @param {Element} elem Current element + * @returns {String} Text to be copied. + */ + text?: (elem: Element) => string; + } + + interface Event { + action: string; + text: string; + trigger: Element; + clearSelection(): void; + } + } + export = Clipboard; } diff --git a/codemirror/index.d.ts b/codemirror/index.d.ts index 708b32812e..83c45e93ab 100644 --- a/codemirror/index.d.ts +++ b/codemirror/index.d.ts @@ -393,8 +393,8 @@ declare namespace CodeMirror { /** Fired whenever a line is (re-)rendered to the DOM. Fired right after the DOM element is built, before it is added to the document. The handler may mess with the style of the resulting element, or add event handlers, but should not try to change the state of the editor. */ - on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void; - off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void; + on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; + off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => void ): void; /** Expose the state object, so that the Editor.state.completionActive property is reachable*/ state: any; @@ -1240,4 +1240,3 @@ declare namespace CodeMirror { } } } - diff --git a/cookiejs/tsconfig.json b/cookiejs/tsconfig.json index 49aa749ae4..76d537c57c 100644 --- a/cookiejs/tsconfig.json +++ b/cookiejs/tsconfig.json @@ -5,11 +5,11 @@ "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", - "typesSearchPaths": [ + "typeRoots": [ "../" ], + "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true }, "files": [ diff --git a/cordova-plugin-battery-status/tsconfig.json b/cordova-plugin-battery-status/tsconfig.json index b781800488..0ba34b4eaf 100644 --- a/cordova-plugin-battery-status/tsconfig.json +++ b/cordova-plugin-battery-status/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-camera/tsconfig.json b/cordova-plugin-camera/tsconfig.json index fd82d2283c..4bcb17e701 100644 --- a/cordova-plugin-camera/tsconfig.json +++ b/cordova-plugin-camera/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-contacts/tsconfig.json b/cordova-plugin-contacts/tsconfig.json index 150cbbc01b..e7622317a1 100644 --- a/cordova-plugin-contacts/tsconfig.json +++ b/cordova-plugin-contacts/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-device-motion/tsconfig.json b/cordova-plugin-device-motion/tsconfig.json index 38d054da74..8fdea1bb00 100644 --- a/cordova-plugin-device-motion/tsconfig.json +++ b/cordova-plugin-device-motion/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-device/tsconfig.json b/cordova-plugin-device/tsconfig.json index 2382a3c48b..a7004ed713 100644 --- a/cordova-plugin-device/tsconfig.json +++ b/cordova-plugin-device/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-dialogs/tsconfig.json b/cordova-plugin-dialogs/tsconfig.json index 8a06fc75a3..66e676d30c 100644 --- a/cordova-plugin-dialogs/tsconfig.json +++ b/cordova-plugin-dialogs/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-file/tsconfig.json b/cordova-plugin-file/tsconfig.json index 62e93d809e..52446e1912 100644 --- a/cordova-plugin-file/tsconfig.json +++ b/cordova-plugin-file/tsconfig.json @@ -9,7 +9,8 @@ "../" ], "types": [], - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-globalization/tsconfig.json b/cordova-plugin-globalization/tsconfig.json index c743a2a3ee..1f61009199 100644 --- a/cordova-plugin-globalization/tsconfig.json +++ b/cordova-plugin-globalization/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-inappbrowser/tsconfig.json b/cordova-plugin-inappbrowser/tsconfig.json index 171d99407e..d26ba0222f 100644 --- a/cordova-plugin-inappbrowser/tsconfig.json +++ b/cordova-plugin-inappbrowser/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-keyboard/tsconfig.json b/cordova-plugin-keyboard/tsconfig.json index 00a8c3f7c5..d2f26294bc 100644 --- a/cordova-plugin-keyboard/tsconfig.json +++ b/cordova-plugin-keyboard/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-media/tsconfig.json b/cordova-plugin-media/tsconfig.json index 7875dd04a0..d9fc3553b5 100644 --- a/cordova-plugin-media/tsconfig.json +++ b/cordova-plugin-media/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-splashscreen/tsconfig.json b/cordova-plugin-splashscreen/tsconfig.json index 032aed70bc..43e60dcd63 100644 --- a/cordova-plugin-splashscreen/tsconfig.json +++ b/cordova-plugin-splashscreen/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-statusbar/tsconfig.json b/cordova-plugin-statusbar/tsconfig.json index c464e89096..99f1b831a0 100644 --- a/cordova-plugin-statusbar/tsconfig.json +++ b/cordova-plugin-statusbar/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-vibration/tsconfig.json b/cordova-plugin-vibration/tsconfig.json index 8835563a00..65aa81393a 100644 --- a/cordova-plugin-vibration/tsconfig.json +++ b/cordova-plugin-vibration/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova-plugin-websql/tsconfig.json b/cordova-plugin-websql/tsconfig.json index 36e7e41481..7bace33807 100644 --- a/cordova-plugin-websql/tsconfig.json +++ b/cordova-plugin-websql/tsconfig.json @@ -4,7 +4,8 @@ "target": "es6", "noImplicitAny": false, "strictNullChecks": false, - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/cordova/tsconfig.json b/cordova/tsconfig.json index 417dadb8b6..afe8d4ba45 100644 --- a/cordova/tsconfig.json +++ b/cordova/tsconfig.json @@ -9,7 +9,8 @@ "../" ], "types": [], - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/dat-gui/index.d.ts b/dat-gui/index.d.ts index 5a902b228b..7d1e2147d7 100644 --- a/dat-gui/index.d.ts +++ b/dat-gui/index.d.ts @@ -1,7 +1,7 @@ -// Type definitions for dat.GUI v0.5 +// Type definitions for dat.GUI v0.6.1 // Project: https://github.com/dataarts/dat.gui -// Definitions by: Satoru Kimura -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Definitions by: Satoru Kimura , ZongJing Lu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace dat { export class GUI { @@ -23,11 +23,40 @@ declare namespace dat { addColor(target: Object, propName:string, rgba: number[]): GUIController; // rgb or rgba addColor(target: Object, propName:string, hsv:{h:number; s:number; v:number}): GUIController; + remove(controller: GUIController): void; + destroy(): void; + addFolder(propName:string): GUI; - close(): void; open(): void; - remember(target: Object): void; + close(): void; + + remember(target: Object, ...additionalTargets: Object[]): void; + getRoot(): GUI; + + getSaveObject(): Object; + save(): void; + saveAs(presetName:string): void; + revert(gui:GUI): void; + + listen(controller: GUIController): void; + updateDisplay(): void; + + // gui properties in dat/gui/GUI.js + parent(): GUI; + scrollable(): boolean; + autoPlace(): boolean; + preset(): string; + preset(s: string): void; + width(): number; + width(n: number): void; + name(): string; + name(s: string): void; + closed(): boolean; + closed(b: boolean): void; + load(): Object; + useLocalStorage(): boolean; + useLocalStorage(b: boolean): void; } export interface GUIParams{ @@ -41,17 +70,28 @@ declare namespace dat { export class GUIController { destroy(): void; - fire(): GUIController; - getValue(): any; - isModified(): boolean; - listen(): GUIController; - min(n: number): GUIController; - remove(target: GUIController): void; - setValue(value: any): GUIController; - step(n: number): GUIController; - updateDisplay(): void; + // Controller onChange: (value?: any) => void; onFinishChange: (value?: any) => void; + + setValue(value: any): GUIController; + getValue(): any; + updateDisplay(): void; + isModified(): boolean; + + // NumberController + min(n: number): GUIController; + max(n: number): GUIController; + step(n: number): GUIController; + + // FunctionController + fire(): GUIController; + + // augmentController in dat/gui/GUI.js + options(option:any):GUIController; + name(s: string): GUIController; + listen(): GUIController; + remove(): GUIController; } } diff --git a/deku/deku-tests.ts b/deku/deku-tests.ts new file mode 100644 index 0000000000..d123c7b8f7 --- /dev/null +++ b/deku/deku-tests.ts @@ -0,0 +1,208 @@ +// Example from deku/examples/basic +(function (){ + const {h, createApp} = deku + + function view(state = { count: 0 }, dispatch: Function){ + return ( + h('div', {}, [ + h('div', {}, 'Counter: ' + state.count), + h('button', {onClick: increment(dispatch)}, 'Increment'), + h('button', {onClick: decrement(dispatch)}, 'Decrement') + ]) + ) + } + + function increment(dispatch: Function){ + return () => dispatch({ + type: 'INCREMENT' + }) + } + + function decrement(dispatch: Function){ + return () => dispatch({ + type: 'DECREMENT' + }) + } + + let render = createApp(document.body) + + function main(state: any){ + let vnode = view(state, (action: any) => main({ count: 0 })) + + render(vnode) + } + + main({ count: 0 }) +})(); + +// Example from deku/docs/api/create-app +(function (){ + const {createApp, element} = deku + + const App = ({ props = { size: 'medium' } }) => { + return element('div', { class: `size-${ props.size }` }) + } + + const render = createApp(document.body) + + render(element(App, { size: 'small' })) + + render(element(App, { size: 'large' })) +})(); + +// Example from deku/docs/api/string +(function (){ + const { h } = deku + + const html = deku.string.render(h('div', {}, [ + h('header'), + h('sidebar'), + h('app'), + ])) +})(); + +// Example from deku/docs/api/element +(function (){ + const { element } = deku + + // Native elements + element('div', { class: 'greeting' }, [ + element('span', {}, ['Hello']) + ]) + + // Components + let App = { + render: ({ props = { name: '' } }) => element('div', {}, `Hello ${ props.name }!`) + } + + element(App, { name: 'Tom' }) +})(); + +// deku.createApp +(function (){ + const { createApp, element } = deku + + let render: Function = createApp(document.body) + + render(element('div')) + + render = createApp(document.body, (action: any) => { + render(element('div')) + }) + + render(element('div')) +})(); + +// deku.dom +(function (){ + const { dom, element } = deku + + let el: HTMLElement = dom.create(element('div'), '0.0', ()=>{}, {}) + + const update: (DOMElement: HTMLElement, action: any) => HTMLElement = dom.update(()=>{}, {}) + + el = update(el, {}) +})(); + +// deku.string +(function (){ + const { element } = deku + + let html: string = deku.string.render(element('div')) + + html = deku.string.render(element('div'), {}) +})(); + +// deku.element +(function (){ + const { element } = deku + + let v: deku.VirtualElement = element('div') + + v = element('div', {}) + + v = element('div', {}, []) + + v = element('div', {}, ['foo', 0, 'bar']) + + v = element('div', {}, 'foo') + + v = element('div', {}, 0) + + v = element('div', {}, 'foo', 'bar') + + let Component = { + render({}){ + return element('div') + } + } + + v = element(Component) + + v = element(Component, {}) + + v = element(Component, {}, []) +})(); + +// deku.diff +(function (){ + const { diff, element } = deku + + const { Actions } = diff + + let diffs: any[] = diff.diffNode(element('div'), element('span')) + + let actions: deku.diff.Actions[] = [ + Actions.setAttribute('class', 'foo', 'bar'), + Actions.removeAttribute('foo', {}), + Actions.insertChild({}, 0, '0.0'), + Actions.removeChild(0), + Actions.updateChild(0, []), + Actions.updateChildren([]), + Actions.insertBefore(0), + Actions.replaceNode({}, {}, '0.0'), + Actions.removeNode({}), + Actions.sameNode(), + Actions.updateThunk({}, {}, '0.0') + ] + + actions.forEach(action => { + Actions.case({ + setAttribute: (name: string, value: any, previousValue: any) => { + }, + _: () => { + } + }, action) + }) +})(); + +// deku.vnode +(function (){ + const { vnode, element } = deku + + let v: deku.VirtualElement = vnode.create('div') + + v = vnode.createTextElement('foo') + + const Component = { + render({}){ + return element('div') + } + } + + v = vnode.createThunkElement(Component.render, '', Component, [], {}) + + v = vnode.createEmptyElement() + + let b: boolean = vnode.isThunk(v) + + b = vnode.isText(v) + + b = vnode.isEmpty(v) + + b = vnode.isSameThunk(v, v) + + let path: string = vnode.createPath('0', '1', '2', '3') + + path = vnode.createPath(0, 1, 2, 3) +})(); diff --git a/deku/index.d.ts b/deku/index.d.ts new file mode 100644 index 0000000000..ff5a68f8bb --- /dev/null +++ b/deku/index.d.ts @@ -0,0 +1,136 @@ +// Type definitions for deku v2.0 +// Project: https://github.com/anthonyshort/deku +// Definitions by: Sho Fuji +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = deku; +export as namespace deku; + +declare namespace deku { + + interface VirtualElement { + type: string; + } + + /** + * Create a DOM renderer using a container element. + * Everything will be rendered inside of that container. + * Returns a function that accepts new state that can replace what is currently rendered. + */ + function createApp(el: HTMLElement, dispatch?: Dispatch): Render; + + namespace dom { + /** + * Create a real DOM element from a virtual element, recursively looping down. + * When it finds custom elements it will render them, cache them, and keep going, + * so they are treated like any other native element. + */ + function create(vnode: VirtualElement, path: string, dispatch: Dispatch, context: C): HTMLElement; + + /** + * Modify a DOM element given an array of actions. + */ + function update(dispatch: Dispatch, context: C): (DOMElement: HTMLElement, action: A) => HTMLElement; + } + + namespace string { + /** + * Render a virtual element to a string. You can pass in an option state context object that will be given to all components. + */ + function render(vnode: VirtualElement): string; + function render(vnode: VirtualElement, context: C): string; + } + + /** + * This function lets us create virtual nodes using a simple syntax. + * It is compatible with JSX transforms so you can use JSX to write nodes that will compile to this function. + */ + function element(type: string): VirtualElement; + function element(type: string, attributes: A, ...children: any[]): VirtualElement; + + function element(type: Thunk): VirtualElement; + function element(type: Thunk, attributes: A, ...children: any[]): VirtualElement; + + var h: typeof element; + + namespace diff { + /** + * Compare two virtual nodes and return an array of changes to turn the left into the right. + */ + function diffNode(prevNode: VirtualElement, nextNode: VirtualElement): any[]; + + class Actions { + private _keys: string[]; + private _name: string; + + static setAttribute(a: string, b: any, c: any): Actions; + static removeAttribute(a: string, b: any): Actions; + static insertChild(a: any, b: number, c: string): Actions; + static removeChild(a: number): Actions; + static updateChild(a: number, b: any[]): Actions; + static updateChildren(a: any[]): Actions; + static insertBefore(a: number): Actions; + static replaceNode(a: any, b: any, c: string): Actions; + static removeNode(a: any): Actions; + static sameNode(): Actions; + static updateThunk(a: any, b: any, c: string): Actions; + + static case(pat: any, action: Actions): any; + } + } + + namespace vnode { + var create: typeof element; + + /** + * Text nodes are stored as objects to keep things simple + */ + function createTextElement(text: string): VirtualElement; + + /** + * Lazily-rendered virtual nodes + */ + function createThunkElement(fn: (model: Model) => VirtualElement, key: string, props: P, children: T[], options: O): VirtualElement; + + function createEmptyElement(): VirtualElement; + + function isThunk(vnode: VirtualElement): boolean; + + function isText(vnode: VirtualElement): boolean; + + function isEmpty(vnode: VirtualElement): boolean; + + function isSameThunk(prevNode: VirtualElement, nextNode: VirtualElement): boolean; + + // function isValidAttribute(value: A): boolean; + + /** + * Create a node path, eg. (23,5,2,4) => '23.5.2.4' + */ + function createPath(...paths: (number|string)[]): string; + } +} + +interface Model { + props?: any, + children?: any[], + path?: string, + dispatch?: Dispatch, + context?: any +} + +interface Component { + render: (model: Model) => deku.VirtualElement; + onCreate?: (model: Model) => any; + onUpdate?: (model: Model) => any; + onRemove?: (model: Model) => any; +} + +/** + * Thunk object passed to `element` + */ +type Thunk = Component | ((model: Model) => deku.VirtualElement); + +type Render = (vnode: deku.VirtualElement, context?: any) => void; + +type Dispatch = (action: any) => any; diff --git a/deku/tsconfig.json b/deku/tsconfig.json new file mode 100644 index 0000000000..3a18954e88 --- /dev/null +++ b/deku/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "deku-tests.ts" + ] +} diff --git a/easeljs/index.d.ts b/easeljs/index.d.ts index a0dc7b566f..a5916a56f2 100644 --- a/easeljs/index.d.ts +++ b/easeljs/index.d.ts @@ -623,6 +623,7 @@ declare namespace createjs { primary: boolean; rawX: number; rawY: number; + relatedTarget: DisplayObject; stageX: number; stageY: number; mouseMoveOutside: boolean; diff --git a/electron/index.d.ts b/electron/index.d.ts index d39710189b..c0797775a2 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2850,7 +2850,7 @@ declare namespace Electron { interface StringProtocolCallback extends ProtocolCallback { (str: string): void; (obj: { - data: Buffer, + data: string, mimeType: string, charset?: string }): void; diff --git a/extjs/ExtJS-tests.ts b/extjs/extjs-tests.ts similarity index 100% rename from extjs/ExtJS-tests.ts rename to extjs/extjs-tests.ts diff --git a/google-libphonenumber/index.d.ts b/google-libphonenumber/index.d.ts index 937a0d9623..4a0f865373 100644 --- a/google-libphonenumber/index.d.ts +++ b/google-libphonenumber/index.d.ts @@ -20,10 +20,11 @@ declare namespace libphonenumber { parse(number: string, region: string): PhoneNumber; isValidNumber(phoneNumber: PhoneNumber): boolean; isPossibleNumber(phoneNumber: PhoneNumber): boolean; - isValidNumberForRegion(phoneNumber: PhoneNumber): boolean; + isValidNumberForRegion(phoneNumber: PhoneNumber, region: string): boolean; getRegionCodeForNumber(phoneNumber: PhoneNumber): string; isNANPACountry(regionCode: string): boolean; format(phoneNumber: PhoneNumber, format: PhoneNumberFormat): string; + parseAndKeepRawInput(number: string, regionCode: string): PhoneNumber; } export class AsYouTypeFormatter { diff --git a/google.visualization/google.visualization-tests.ts b/google.visualization/google.visualization-tests.ts index 2cbd8220f2..a51657a592 100644 --- a/google.visualization/google.visualization-tests.ts +++ b/google.visualization/google.visualization-tests.ts @@ -156,10 +156,17 @@ function test_areaChart() { ['2016', 1030, 540] ]); - var options = { + var options:google.visualization.AreaChartOptions = { title: 'Company Performance', hAxis: {title: 'Year', titleTextStyle: {color: '#333'}}, - vAxis: {minValue: 0} + vAxis: {minValue: 0}, + annotations: { + textStyle: { + bold: true, + italic: true, + color: "black" + } + } }; var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); @@ -510,3 +517,107 @@ function test_ChartsLoad() { google.charts.setOnLoadCallback(drawChart); } + + +function test_ChartAnnotations() { + var annotations:google.visualization.ChartAnnotations = { + boxStyle: { + // Color of the box outline. + stroke: '#888', + // Thickness of the box outline. + strokeWidth: 1, + // x-radius of the corner curvature. + rx: 10, + // y-radius of the corner curvature. + ry: 10, + // Attributes for linear gradient fill. + gradient: { + // Start color for gradient. + color1: '#fbf6a7', + // Finish color for gradient. + color2: '#33b679', + // Where on the boundary to start and + // end the color1/color2 gradient, + // relative to the upper left corner + // of the boundary. + x1: '0%', y1: '0%', + x2: '100%', y2: '100%', + // If true, the boundary for x1, + // y1, x2, and y2 is the box. If + // false, it's the entire chart. + useObjectBoundingBoxUnits: true + } + }, + datum: { + stem: { + color: 'black', + length: 12 + }, + style: 'point' + }, + domain: { + stem: { + color: 'black', + length: 5 + }, + style: 'point' + }, + highContrast: true, + stem: { + color: 'black', + length: 5 + }, + style: 'line', + textStyle: { + fontName: 'Times-Roman', + fontSize: 18, + bold: true, + italic: true, + // The color of the text. + color: '#871b47', + // The color of the text outline. + auraColor: '#d799ae', + // The transparency of the text. + opacity: 0.8 + } + }; + + var barAnnotations:google.visualization.ChartBarColumnAnnotations = { + alwaysOutside: true, + textStyle: { + fontName: 'Times-Roman', + fontSize: 18, + bold: true + } + }; +} + + +function test_OrgChart() { + var data = new google.visualization.DataTable(); + data.addColumn('string', 'Name'); + data.addColumn('string', 'Manager'); + data.addColumn('string', 'ToolTip'); + + // For each orgchart box, provide the name, manager, and tooltip to show. + data.addRows([ + [{v:'Mike', f:'Mike
President
'}, '', 'The President'], + [{v:'Jim', f:'Jim
Vice President
'}, 'Mike', 'VP'], + ['Alice', 'Mike', ''], + ['Bob', 'Jim', 'Bob Sponge'], + ['Carol', 'Bob', ''] + ]); + + var chart = new google.visualization.OrgChart(document.getElementById('chart_div')); + chart.draw(data, { + allowCollapse: true, + allowHtml: true, + nodeClass: 'node', + selectedNodeClass: 'selected', + size: 'small' + }); + chart.collapse(1, true); + var children = chart.getChildrenIndexes(0); + var collapsed = chart.getCollapsedNodes(); + +} diff --git a/google.visualization/index.d.ts b/google.visualization/index.d.ts index a4dc1b7b1a..83b08296f8 100644 --- a/google.visualization/index.d.ts +++ b/google.visualization/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Visualisation Apis // Project: https://developers.google.com/chart/ -// Definitions by: Dan Ludwig , Gregory Moore +// Definitions by: Dan Ludwig , Gregory Moore , Dan Manastireanu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace google { @@ -331,6 +331,25 @@ declare namespace google { export interface ChartAnnotations { boxStyle?: ChartBoxStyle; textStyle?: ChartTextStyle; + datum?: ChartStemAndStyle; + domain?: ChartStemAndStyle; + highContrast?: boolean; + stem?: ChartStem; + style?: string; // 'line' or 'point' + } + + export interface ChartBarColumnAnnotations extends ChartAnnotations { + alwaysOutside?: boolean; + } + + export interface ChartStemAndStyle { + stem?: ChartStem; + style?: string; + } + + export interface ChartStem { + color?: string; + length?: number; } export interface ChartBoxStyle { @@ -565,7 +584,7 @@ declare namespace google { export interface ColumnChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; - annotations?: ChartAnnotations; + annotations?: ChartBarColumnAnnotations; axisTitlesPosition?: string; // in, out, none backgroundColor?: any; bar?: GroupWidth; @@ -645,7 +664,7 @@ declare namespace google { export interface BarChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; - annotations?: ChartAnnotations; + annotations?: ChartBarColumnAnnotations; axisTitlesPosition?: string; // in, out, none backgroundColor?: any; bar?: GroupWidth; @@ -739,6 +758,7 @@ declare namespace google { export interface AreaChartOptions { aggregationTarget?: string; animation?: TransitionAnimation; + annotations?: ChartAnnotations; areaOpacity?: number; axisTitlesPosition?: string; backgroundColor?: any; @@ -1357,6 +1377,34 @@ declare namespace google { format(dataTable: DataTable, srcColumnIndices: number[], opt_dstColumnIndex?: number): void; } + //#endregion + //#region OrgChart + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/orgchart + export class OrgChart extends CoreChartBase { + draw(data: DataTable, options: OrgChartOptions): void; + draw(data: DataView, options: OrgChartOptions): void; + collapse(row: number, collapsed: boolean): void; + getChildrenIndexes(row: number): number[]; + getCollapsedNodes(): number[]; + } + + // https://google-developers.appspot.com/chart/interactive/docs/gallery/orgchart#Configuration_Options + export interface OrgChartOptions { + allowCollapse?: boolean; + allowHtml?: boolean; + color?: string; + nodeClass?: string; + selectedNodeClass?: string; + selectionColor?: string; + /** + * Chart size + * @type {('small'|'medium'|'large')} + * @default 'medium' + */ + size?: string; + } + //#endregion } } diff --git a/headroom/tsconfig.json b/headroom/tsconfig.json index 6b6f41a4b8..3dd7aec967 100644 --- a/headroom/tsconfig.json +++ b/headroom/tsconfig.json @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "Headroom-tests.ts" + "headroom-tests.ts" ] } \ No newline at end of file diff --git a/ids/tsconfig.json b/ids/tsconfig.json index 822ef6cd32..85fbd7f361 100644 --- a/ids/tsconfig.json +++ b/ids/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/joi/index.d.ts b/joi/index.d.ts index 1a8fb9c018..2f803cdf7d 100644 --- a/joi/index.d.ts +++ b/joi/index.d.ts @@ -125,10 +125,10 @@ export interface IPOptions { } export interface ValidationError extends Error { - message: string; + isJoi: boolean; details: ValidationErrorItem[]; - simple(): string; - annotated(): string; + annotate(): string; + _object: any; } export interface ValidationErrorItem { @@ -136,6 +136,7 @@ export interface ValidationErrorItem { type: string; path: string; options?: ValidationOptions; + context?: any; } export interface ValidationResult { diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts index 71b267e957..d50db6eedd 100644 --- a/joi/joi-tests.ts +++ b/joi/joi-tests.ts @@ -126,7 +126,8 @@ validErrItem = { message: str, type: str, path: str, - options: validOpts + options: validOpts, + context: obj }; // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- diff --git a/jquery.ajaxfile/jquery.ajaxFile-tests.ts b/jquery.ajaxfile/jquery.ajaxfile-tests.ts similarity index 100% rename from jquery.ajaxfile/jquery.ajaxFile-tests.ts rename to jquery.ajaxfile/jquery.ajaxfile-tests.ts diff --git a/jquery.slimscroll/jquery.SlimScroll-tests.ts b/jquery.slimscroll/jquery.slimscroll-tests.ts similarity index 100% rename from jquery.slimscroll/jquery.SlimScroll-tests.ts rename to jquery.slimscroll/jquery.slimscroll-tests.ts diff --git a/jquery.slimscroll/tsconfig.json b/jquery.slimscroll/tsconfig.json index 910f07039e..524b9a8740 100644 --- a/jquery.slimscroll/tsconfig.json +++ b/jquery.slimscroll/tsconfig.json @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "jquery.slimScroll-tests.ts" + "jquery.slimscroll-tests.ts" ] } \ No newline at end of file diff --git a/jstimezonedetect/jstimezonedetect-tests.ts b/jstimezonedetect/jstimezonedetect-tests.ts index c4907aa6b0..9baf0f4aa5 100644 --- a/jstimezonedetect/jstimezonedetect-tests.ts +++ b/jstimezonedetect/jstimezonedetect-tests.ts @@ -1,5 +1,3 @@ -/// - import * as jstz from 'jstimezonedetect'; jstz.determine().name() === 'America/Montreal'; diff --git a/jstimezonedetect/tsconfig.json b/jstimezonedetect/tsconfig.json new file mode 100644 index 0000000000..d036a843d1 --- /dev/null +++ b/jstimezonedetect/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jstimezonedetect-tests.ts" + ] +} \ No newline at end of file diff --git a/leadfoot/tsconfig.json b/leadfoot/tsconfig.json index cdd1c4b81c..b09d84c423 100644 --- a/leadfoot/tsconfig.json +++ b/leadfoot/tsconfig.json @@ -5,7 +5,7 @@ ], "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 9f714717a3..d16be0bc1f 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1222,12 +1222,35 @@ declare namespace L { } export namespace DomEvent { - export function on(el: HTMLElement, types: string, fn: Function, context?: Object): typeof DomEvent; + export function on(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: Object): typeof DomEvent; + export function on(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: Object): typeof DomEvent; - export function off(el: HTMLElement, types: string, fn: Function, context?: Object): typeof DomEvent; + + export function off(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: Object): typeof DomEvent; + export function off(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: Object): typeof DomEvent; + + export function stopPropagation(ev: Event): typeof DomEvent; + export function disableScrollPropagation(el: HTMLElement): typeof DomEvent; + export function disableClickPropagation(el: HTMLElement): typeof DomEvent; + + export function preventDefault(ev: Event): typeof DomEvent; + + export function stop(ev: Event): typeof DomEvent; + + export function getMousePosition(ev: Event, container?: HTMLElement): Point; + + export function getWheelDelta(ev: Event): number; + + export function addListener(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: Object): typeof DomEvent; + + export function addListener(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: Object): typeof DomEvent; + + export function removeListener(el: HTMLElement, types: string, fn: (ev: Event) => any, context?: Object): typeof DomEvent; + + export function removeListener(el: HTMLElement, eventMap: {[eventName: string]: Function}, context?: Object): typeof DomEvent; } interface DefaultMapPanes { diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 04d44f7210..34a5fa245f 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -208,12 +208,24 @@ tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOpti tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''}); let eventHandler = () => {}; -L.DomEvent.on(htmlElement, 'click', eventHandler); -L.DomEvent.off(htmlElement, 'click', eventHandler); -L.DomEvent.on(htmlElement, { 'click': eventHandler }); -L.DomEvent.off(htmlElement, { 'click': eventHandler }, eventHandler); -L.DomEvent.disableScrollPropagation(htmlElement); -L.DomEvent.disableClickPropagation(htmlElement); +let domEvent: Event = {} as Event; +L.DomEvent + .on(htmlElement, 'click', eventHandler) + .addListener(htmlElement, 'click', eventHandler) + .off(htmlElement, 'click', eventHandler) + .removeListener(htmlElement, 'click', eventHandler) + .on(htmlElement, {'click': eventHandler}) + .addListener(htmlElement, {'click': eventHandler}) + .off(htmlElement, {'click': eventHandler}, eventHandler) + .removeListener(htmlElement, {'click': eventHandler}, eventHandler) + .stopPropagation(domEvent) + .disableScrollPropagation(htmlElement) + .disableClickPropagation(htmlElement) + .preventDefault(domEvent) + .stop(domEvent); +point = L.DomEvent.getMousePosition(domEvent); +point = L.DomEvent.getMousePosition(domEvent, htmlElement); +const wheelDelta: number = L.DomEvent.getWheelDelta(domEvent); map = map // addControl diff --git a/leapmotionts/LeapMotionTS-tests.ts b/leapmotionts/leapmotionts-tests.ts similarity index 100% rename from leapmotionts/LeapMotionTS-tests.ts rename to leapmotionts/leapmotionts-tests.ts diff --git a/leapmotionts/tsconfig.json b/leapmotionts/tsconfig.json index d6599c4e70..4e16a4efea 100644 --- a/leapmotionts/tsconfig.json +++ b/leapmotionts/tsconfig.json @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "leapmotionTS-tests.ts" + "leapmotionts-tests.ts" ] } \ No newline at end of file diff --git a/libxmljs/index.d.ts b/libxmljs/index.d.ts index bc33a4eec1..c928f57362 100644 --- a/libxmljs/index.d.ts +++ b/libxmljs/index.d.ts @@ -17,13 +17,13 @@ export declare function parseHtmlString(source: string): HTMLDocument; export declare class XMLDocument { constructor(version: number, encoding: string); - child(idx: number): Element; + child(idx: number): Element | undefined; childNodes(): Element[]; errors(): SyntaxError[]; encoding(): string; encoding(enc: string): void; find(xpath: string): Element[]; - get(xpath: string): Element; + get(xpath: string): Element | undefined; node(name: string, content: string): Element; root(): Element; toString(): string; @@ -48,7 +48,7 @@ export declare class Element { attrs(): Attribute[]; parent(): Element; doc(): XMLDocument; - child(idx: number): Element; + child(idx: number): Element | undefined; childNodes(): Element[]; addChild(child: Element): Element; nextSibling(): Element; @@ -60,9 +60,9 @@ export declare class Element { find(xpath: string): Element[]; find(xpath: string, ns_uri: string): Element[]; find(xpath: string, namespaces: { [key: string]: string; }): Element[]; - get(xpath: string): Element; - get(xpath: string, ns_uri: string): Element; - get(xpath: string, ns_uri: { [key: string]: string; }): Element; + get(xpath: string): Element | undefined; + get(xpath: string, ns_uri: string): Element | undefined; + get(xpath: string, ns_uri: { [key: string]: string; }): Element | undefined; defineNamespace(href: string): Namespace; defineNamespace(prefix: string, href: string): Namespace; namespace(): Namespace; diff --git a/loader-runner/index.d.ts b/loader-runner/index.d.ts index 102348ec71..f0b34ec600 100644 --- a/loader-runner/index.d.ts +++ b/loader-runner/index.d.ts @@ -8,7 +8,7 @@ export interface Loader { path: string; query: string; - request: any; + request: string; options: any; normal: any; pitch: any; @@ -24,12 +24,12 @@ export interface RunLoaderOption { resource: string; loaders: any[]; context: any; - readResource: (filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void) => void; + readResource: (filename: string, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void) => void; } export function runLoaders( options: RunLoaderOption, - callback: (err: NodeJS.ErrnoException, result: any) => any + callback: (err: NodeJS.ErrnoException | null, result: any) => any ): void; diff --git a/loader-runner/loader-runner-tests.ts b/loader-runner/loader-runner-tests.ts index cfdd08f11b..38661b60ec 100644 --- a/loader-runner/loader-runner-tests.ts +++ b/loader-runner/loader-runner-tests.ts @@ -3,7 +3,8 @@ import { runLoaders, getContext, Loader, RunLoaderOption } from 'loader-runner'; const option = {} as RunLoaderOption; runLoaders(option, function (err, result) { - console.log(err, result); + if(err) + console.log(err, result); }); getContext('sdlfkjaldfjiojsdf'); diff --git a/lodash/tsconfig.json b/lodash/tsconfig.json index dd337af9c4..0a0d666d66 100644 --- a/lodash/tsconfig.json +++ b/lodash/tsconfig.json @@ -290,7 +290,7 @@ ], "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/lz-string/index.d.ts b/lz-string/index.d.ts index 499c9cf50c..19c97c419f 100644 --- a/lz-string/index.d.ts +++ b/lz-string/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for lz-string v1.3.3 +// Type definitions for lz-string v1.3.5 // Project: https://github.com/pieroxy/lz-string // Definitions by: Roman Nikitin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -57,5 +57,35 @@ declare namespace LZString { * @param compressed A string obtained from a call to compressToBase64(). */ decompressFromBase64(compressed: string): string; + + /** + * produces ASCII strings representing the original string encoded in Base64 with a few + * tweaks to make these URI safe. Hence, you can send them to the server without thinking + * about URL encoding them. This saves bandwidth and CPU + * + * @param uncompressed A string which should be compressed. + */ + compressToEncodedURIComponent(uncompressed: string): string; + + /** + * Decompresses "valid" input string created by the method compressToEncodedURIComponent(). + * + * @param compressed A string obtained from a call to compressToEncodedURIComponent(). + */ + decompressFromEncodedURIComponent(compressed: string): string; + + /** + * produces an uint8Array + * + * @param uncompressed A string which should be compressed. + */ + compressToUint8Array(uncompressed: string): Uint8Array; + + /** + * Decompresses "valid" array created by the method compressToUint8Array(). + * + * @param compressed A string obtained from a call to compressToUint8Array(). + */ + decompressFromUint8Array(compressed: Uint8Array): string; } } diff --git a/lz-string/lz-string-tests.ts b/lz-string/lz-string-tests.ts index e26160f5f4..131bce2105 100644 --- a/lz-string/lz-string-tests.ts +++ b/lz-string/lz-string-tests.ts @@ -3,10 +3,15 @@ var input = "Someting to compress"; var encoded: string; var decoded: string; +var encodedU8: Uint8Array; encoded = LZString.compress(input); decoded = LZString.decompress(encoded); encoded = LZString.compressToUTF16(input); decoded = LZString.decompressFromUTF16(encoded); encoded = LZString.compressToBase64(input); -decoded = LZString.decompressFromBase64(encoded); \ No newline at end of file +decoded = LZString.decompressFromBase64(encoded); +encoded = LZString.compressToEncodedURIComponent(input); +decoded = LZString.compressToEncodedURIComponent(encoded); +encodedU8 = LZString.compressToUint8Array(input); +decoded = LZString.decompressFromUint8Array(encodedU8); \ No newline at end of file diff --git a/material-ui/index.d.ts b/material-ui/index.d.ts index 941b7aff72..c04d673dc9 100644 --- a/material-ui/index.d.ts +++ b/material-ui/index.d.ts @@ -141,7 +141,7 @@ declare namespace __MaterialUI { fontFamily?: string; palette?: ThemePalette; isRtl?: boolean; - userAgent?: string; + userAgent?: string | boolean; zIndex?: zIndex; baseTheme?: RawTheme; rawTheme?: RawTheme; diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index 12c92571b5..150d94b2df 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -871,7 +871,7 @@ declare module "mongoose" { /** Hash containing current validation errors. */ errors: Object; /** This documents _id. */ - _id: mongodb.ObjectID; + _id: any; /** Boolean flag specifying if the document is new. */ isNew: boolean; /** The documents schema. */ diff --git a/mz/tsconfig.json b/mz/tsconfig.json index 83fafa87ea..7622a546f2 100644 --- a/mz/tsconfig.json +++ b/mz/tsconfig.json @@ -9,7 +9,8 @@ "../" ], "types": [], - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "fs.d.ts", diff --git a/node-schedule/index.d.ts b/node-schedule/index.d.ts index b4cf431e64..d21f46715d 100644 --- a/node-schedule/index.d.ts +++ b/node-schedule/index.d.ts @@ -214,6 +214,67 @@ export class RecurrenceRule { nextInvocationDate(base:Date):Date; } +/** + * Recurrence rule specification. + */ +export interface RecurrenceSpec { + /** + * Day of the month. + * + * @public + * @type {RecurrenceSegment} + */ + date?: RecurrenceSegment; + + /** + * Day of the week. + * + * @public + * @type {RecurrenceSegment} + */ + dayOfWeek?: RecurrenceSegment; + + /** + * Hour. + * + * @public + * @type {RecurrenceSegment} + */ + hour?: RecurrenceSegment; + + /** + * Minute. + * + * @public + * @type {RecurrenceSegment} + */ + minute?: RecurrenceSegment; + + /** + * Month. + * + * @public + * @type {RecurrenceSegment} + */ + month?: RecurrenceSegment; + + /** + * Second. + * + * @public + * @type {RecurrenceSegment} + */ + second?: RecurrenceSegment; + + /** + * Year. + * + * @public + * @type {RecurrenceSegment} + */ + year?: RecurrenceSegment; +} + /** * Invocation. * @@ -266,11 +327,19 @@ export class Invocation { /** * Create a schedule job. * - * @param {string|RecurrenceRule|Date} name either an optional name for the new Job or scheduling information - * @param {RecurrenceRule|Date|string} rule either the scheduling info or the JobCallback - * @param {JobCallback} callback The callback to be executed on each invocation. + * @param {string} name name for the new Job + * @param {RecurrenceRule|RecurrenceSpec|Date|string} rule scheduling info + * @param {JobCallback} callback callback to be executed on each invocation */ - export function scheduleJob(name:string|RecurrenceRule|Date, rule: RecurrenceRule|Date|string|JobCallback, callback?: JobCallback): Job; + export function scheduleJob(name: string, rule: RecurrenceRule | RecurrenceSpec | Date | string, callback: JobCallback): Job; + +/** + * Create a schedule job. + * + * @param {RecurrenceRule|RecurrenceSpec|Date|string} rule scheduling info + * @param {JobCallback} callback callback to be executed on each invocation + */ + export function scheduleJob(rule: RecurrenceRule | RecurrenceSpec | Date | string, callback: JobCallback): Job; /** * Changes the timing of a Job, canceling all pending invocations. @@ -279,7 +348,7 @@ export class Invocation { * @param spec {JobCallback} the new timing for this Job * @return {Job} if the job could be rescheduled, {null} otherwise. */ - export function rescheduleJob(job:Job|string, spec:RecurrenceRule|Date|string):Job; + export function rescheduleJob(job: Job | string, spec: RecurrenceRule | RecurrenceSpec | Date | string): Job; /** * Dictionary of all Jobs, accessible by name. diff --git a/object-refs/tsconfig.json b/object-refs/tsconfig.json index 472dc47723..6b81d1c07d 100644 --- a/object-refs/tsconfig.json +++ b/object-refs/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/ora/index.d.ts b/ora/index.d.ts index a31d2bd5c1..e45a585442 100644 --- a/ora/index.d.ts +++ b/ora/index.d.ts @@ -1,36 +1,34 @@ // Type definitions for ora v0.3.0 // Project: https://github.com/sindresorhus/ora -// Definitions by: Basarat Ali Syed +// Definitions by: Basarat Ali Syed , Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// - type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; -type Text = string; interface Options { - text?: Text; - spinner?: string | Spinner; + text?: string; + spinner?: string | Spinner; color?: Color; - interval?: number; - stream?: NodeJS.WritableStream; - enabled?: boolean; - } - interface Spinner { - interval?: number; - frames: string[]; + interval?: number; + stream?: NodeJS.WritableStream; + enabled?: boolean; +} +interface Spinner { + interval?: number; + frames: string[]; } interface Instance { - start(): Instance; - stop(): Instance; - succeed(): Instance; - fail(): Instance; - stopAndPersist(symbol?: string): Instance; - clear(): Instance; - render(): Instance; - frame(): Instance; - text: string; + start(): Instance; + stop(): Instance; + succeed(): Instance; + fail(): Instance; + stopAndPersist(symbol?: string): Instance; + clear(): Instance; + render(): Instance; + frame(): Instance; + text: string; color: Color; } -declare function ora(options: Options | Text): Instance; +declare function ora(options: Options | string): Instance; export = ora; diff --git a/ora/ora-tests.ts b/ora/ora-tests.ts index 067edd8678..b6e2a671dc 100644 --- a/ora/ora-tests.ts +++ b/ora/ora-tests.ts @@ -1,7 +1,6 @@ import ora = require('ora'); -const spinner = ora('Loading unicorns'); -spinner.start(); +const spinner = ora('Loading unicorns').start(); setTimeout(() => { spinner.color = 'yellow'; diff --git a/passport-local-mongoose/passport-local-mongoose-tests.ts b/passport-local-mongoose/passport-local-mongoose-tests.ts index 21a928a8d7..7b428561fe 100644 --- a/passport-local-mongoose/passport-local-mongoose-tests.ts +++ b/passport-local-mongoose/passport-local-mongoose-tests.ts @@ -23,6 +23,7 @@ import { Strategy as LocalStrategy } from 'passport-local'; //#region Test Models interface User extends PassportLocalDocument { + _id: string; username: string; hash: string; salt: string; diff --git a/react-bootstrap/index.d.ts b/react-bootstrap/index.d.ts index 9780efb443..2ec9eed50d 100644 --- a/react-bootstrap/index.d.ts +++ b/react-bootstrap/index.d.ts @@ -540,6 +540,7 @@ declare namespace ReactBootstrap { brand?: any; // TODO: Add more specific type bsSize?: Sizes; bsStyle?: string; + collapseOnSelect?: boolean; componentClass?: React.ReactType; defaultNavExpanded?: boolean; fixedBottom?: boolean; diff --git a/react-helmet/index.d.ts b/react-helmet/index.d.ts index c44639e0d0..3ddfd1ebb5 100644 --- a/react-helmet/index.d.ts +++ b/react-helmet/index.d.ts @@ -7,14 +7,11 @@ import * as React from "react"; -declare var Helmet: { - (): ReactHelmet.HelmetComponent - rewind(): ReactHelmet.HelmetData - } - -export = Helmet; +declare function ReactHelmet(): ReactHelmet.HelmetComponent; declare namespace ReactHelmet { + function rewind(): ReactHelmet.HelmetData; + interface HelmetProps { base?: any; defaultTitle?: string; @@ -43,3 +40,5 @@ declare namespace ReactHelmet { class HelmetComponent extends React.Component {} } + +export = ReactHelmet; diff --git a/react-helmet/react-helmet-tests.tsx b/react-helmet/react-helmet-tests.tsx index 2db79eb547..3a4a3f09d7 100644 --- a/react-helmet/react-helmet-tests.tsx +++ b/react-helmet/react-helmet-tests.tsx @@ -39,3 +39,9 @@ function HTML() { ); } + +function log(datum: Helmet.HelmetDatum) { + return console.log('logging a helmet datum:', datum.toString()); +} + +log(head.title); diff --git a/react-json-tree/tsconfig.json b/react-json-tree/tsconfig.json index 3076bbca2e..b1145acf81 100644 --- a/react-json-tree/tsconfig.json +++ b/react-json-tree/tsconfig.json @@ -15,6 +15,6 @@ }, "files": [ "index.d.ts", - "react-json-tree-tests.ts" + "react-json-tree-tests.tsx" ] } diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 8dfc205478..1dbb3f8682 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,8 +1,10 @@ // Type definitions for react-router v2.0.0 // Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland +// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + export as namespace ReactRouter; import * as React from 'react'; diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index c375f71513..5a4cfacb15 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -1,4 +1,5 @@ import * as React from 'react'; +import RouterContext from './RouterContext'; import { QueryString, Query, Location, LocationDescriptor, LocationState, @@ -48,16 +49,17 @@ declare namespace Router { components: RouteComponent[]; } - interface RouterProps extends React.Props { - history?: History; - routes?: RouteConfig; // alias for children - createElement?: (component: RouteComponent, props: Object) => any; - onError?: (error: any) => any; - onUpdate?: () => any; - parseQueryString?: ParseQueryString; - stringifyQuery?: StringifyQuery; + interface RouterProps extends React.Props { + history?: History; + routes?: RouteConfig; // alias for children + createElement?: (component: RouteComponent, props: Object) => any; + onError?: (error: any) => any; + onUpdate?: () => any; + parseQueryString?: ParseQueryString; + stringifyQuery?: StringifyQuery; basename?: string; - } + render?: (renderProps: React.Props<{}>) => RouterContext; + } interface PlainRoute { path?: RoutePattern; diff --git a/react-router/lib/applyRouterMiddleware.d.ts b/react-router/lib/applyRouterMiddleware.d.ts index a92384bba6..ed87d815db 100644 --- a/react-router/lib/applyRouterMiddleware.d.ts +++ b/react-router/lib/applyRouterMiddleware.d.ts @@ -1,7 +1,9 @@ import * as React from 'react'; +import Router from './Router'; +import RouterContext from './RouterContext'; export interface Middleware { - renderRouterContext: (previous: React.Props<{}>[], props: React.Props<{}>) => React.Props<{}>[]; - renderRouteComponent: (previous: React.Props<{}>[], props: React.Props<{}>) => React.Props<{}>[]; + renderRouterContext?: (previous: RouterContext, props: React.Props<{}>) => RouterContext; + renderRouteComponent?: (previous: Router.RouteComponent, props: React.Props<{}>) => Router.RouteComponent; } -export default function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: React.Props<{}>) => React.Props<{}>[]; +export default function applyRouterMiddleware(...middlewares: Middleware[]): (renderProps: React.Props<{}>) => RouterContext; diff --git a/react-router/react-router-tests.tsx b/react-router/react-router-tests.tsx index 77262bad50..77a0703462 100644 --- a/react-router/react-router-tests.tsx +++ b/react-router/react-router-tests.tsx @@ -2,7 +2,7 @@ import * as React from "react" import * as ReactDOM from "react-dom" import {renderToString} from "react-dom/server"; -import { browserHistory, hashHistory, match, createMemoryHistory, withRouter, routerShape, Router, Route, IndexRoute, InjectedRouter, Link, RouterOnContext, RouterContext} from "react-router"; +import { applyRouterMiddleware, browserHistory, hashHistory, match, createMemoryHistory, withRouter, routerShape, Router, Route, IndexRoute, InjectedRouter, Link, RouterOnContext, RouterContext} from "react-router"; interface MasterContext { router: RouterOnContext; @@ -105,3 +105,15 @@ const routes = ( match({history, routes, location: "baseurl"}, (error, redirectLocation, renderProps) => { renderToString(); }); + + +ReactDOM.render(( + child + })} + > + +), document.body); diff --git a/react/index.d.ts b/react/index.d.ts index df15fe6eab..49ff853c4c 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -28,7 +28,7 @@ declare namespace React { interface ReactElement

{ type: string | ComponentClass

| SFC

; props: P; - key?: Key; + key: Key | null; } interface SFCElement

extends ReactElement

{ @@ -74,7 +74,7 @@ declare namespace React { type ClassicFactory

= CFactory>; interface DOMFactory

, T extends Element> { - (props?: P & ClassAttributes, ...children: ReactNode[]): DOMElement; + (props?: P & ClassAttributes | null, ...children: ReactNode[]): DOMElement; } interface HTMLFactory extends DOMFactory, T> { @@ -93,7 +93,7 @@ declare namespace React { // Should be Array but type aliases cannot be recursive type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; + type ReactNode = ReactChild | ReactFragment | boolean | null | undefined; // // Top Level API @@ -201,7 +201,7 @@ declare namespace React { type SFC

= StatelessComponent

; interface StatelessComponent

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

; contextTypes?: ValidationMap; defaultProps?: P; @@ -262,7 +262,7 @@ declare namespace React { } interface ComponentSpec extends Mixin { - render(): ReactElement; + render(): ReactElement | null; [propertyName: string]: any; } @@ -436,98 +436,163 @@ declare namespace React { // Clipboard Events onCopy?: ClipboardEventHandler; + onCopyCapture?: ClipboardEventHandler; onCut?: ClipboardEventHandler; + onCutCapture?: ClipboardEventHandler; onPaste?: ClipboardEventHandler; + onPasteCapture?: ClipboardEventHandler; // Composition Events onCompositionEnd?: CompositionEventHandler; + onCompositionEndCapture?: CompositionEventHandler; onCompositionStart?: CompositionEventHandler; + onCompositionStartCapture?: CompositionEventHandler; onCompositionUpdate?: CompositionEventHandler; + onCompositionUpdateCapture?: CompositionEventHandler; // Focus Events onFocus?: FocusEventHandler; + onFocusCapture?: FocusEventHandler; onBlur?: FocusEventHandler; + onBlurCapture?: FocusEventHandler; // Form Events onChange?: FormEventHandler; + onChangeCapture?: FormEventHandler; onInput?: FormEventHandler; + onInputCapture?: FormEventHandler; onSubmit?: FormEventHandler; + onSubmitCapture?: FormEventHandler; // Image Events onLoad?: ReactEventHandler; + onLoadCapture?: ReactEventHandler; onError?: ReactEventHandler; // also a Media Event + onErrorCapture?: ReactEventHandler; // also a Media Event // Keyboard Events onKeyDown?: KeyboardEventHandler; + onKeyDownCapture?: KeyboardEventHandler; onKeyPress?: KeyboardEventHandler; + onKeyPressCapture?: KeyboardEventHandler; onKeyUp?: KeyboardEventHandler; + onKeyUpCapture?: KeyboardEventHandler; // Media Events onAbort?: ReactEventHandler; + onAbortCapture?: ReactEventHandler; onCanPlay?: ReactEventHandler; + onCanPlayCapture?: ReactEventHandler; onCanPlayThrough?: ReactEventHandler; + onCanPlayThroughCapture?: ReactEventHandler; onDurationChange?: ReactEventHandler; + onDurationChangeCapture?: ReactEventHandler; onEmptied?: ReactEventHandler; + onEmptiedCapture?: ReactEventHandler; onEncrypted?: ReactEventHandler; + onEncryptedCapture?: ReactEventHandler; onEnded?: ReactEventHandler; + onEndedCapture?: ReactEventHandler; onLoadedData?: ReactEventHandler; + onLoadedDataCapture?: ReactEventHandler; onLoadedMetadata?: ReactEventHandler; + onLoadedMetadataCapture?: ReactEventHandler; onLoadStart?: ReactEventHandler; + onLoadStartCapture?: ReactEventHandler; onPause?: ReactEventHandler; + onPauseCapture?: ReactEventHandler; onPlay?: ReactEventHandler; + onPlayCapture?: ReactEventHandler; onPlaying?: ReactEventHandler; + onPlayingCapture?: ReactEventHandler; onProgress?: ReactEventHandler; + onProgressCapture?: ReactEventHandler; onRateChange?: ReactEventHandler; + onRateChangeCapture?: ReactEventHandler; onSeeked?: ReactEventHandler; + onSeekedCapture?: ReactEventHandler; onSeeking?: ReactEventHandler; + onSeekingCapture?: ReactEventHandler; onStalled?: ReactEventHandler; + onStalledCapture?: ReactEventHandler; onSuspend?: ReactEventHandler; + onSuspendCapture?: ReactEventHandler; onTimeUpdate?: ReactEventHandler; + onTimeUpdateCapture?: ReactEventHandler; onVolumeChange?: ReactEventHandler; + onVolumeChangeCapture?: ReactEventHandler; onWaiting?: ReactEventHandler; + onWaitingCapture?: ReactEventHandler; // MouseEvents onClick?: MouseEventHandler; + onClickCapture?: MouseEventHandler; onContextMenu?: MouseEventHandler; + onContextMenuCapture?: MouseEventHandler; onDoubleClick?: MouseEventHandler; + onDoubleClickCapture?: MouseEventHandler; onDrag?: DragEventHandler; + onDragCapture?: DragEventHandler; onDragEnd?: DragEventHandler; + onDragEndCapture?: DragEventHandler; onDragEnter?: DragEventHandler; + onDragEnterCapture?: DragEventHandler; onDragExit?: DragEventHandler; + onDragExitCapture?: DragEventHandler; onDragLeave?: DragEventHandler; + onDragLeaveCapture?: DragEventHandler; onDragOver?: DragEventHandler; + onDragOverCapture?: DragEventHandler; onDragStart?: DragEventHandler; + onDragStartCapture?: DragEventHandler; onDrop?: DragEventHandler; + onDropCapture?: DragEventHandler; onMouseDown?: MouseEventHandler; + onMouseDownCapture?: MouseEventHandler; onMouseEnter?: MouseEventHandler; onMouseLeave?: MouseEventHandler; onMouseMove?: MouseEventHandler; + onMouseMoveCapture?: MouseEventHandler; onMouseOut?: MouseEventHandler; + onMouseOutCapture?: MouseEventHandler; onMouseOver?: MouseEventHandler; + onMouseOverCapture?: MouseEventHandler; onMouseUp?: MouseEventHandler; + onMouseUpCapture?: MouseEventHandler; // Selection Events onSelect?: ReactEventHandler; + onSelectCapture?: ReactEventHandler; // Touch Events onTouchCancel?: TouchEventHandler; + onTouchCancelCapture?: TouchEventHandler; onTouchEnd?: TouchEventHandler; + onTouchEndCapture?: TouchEventHandler; onTouchMove?: TouchEventHandler; + onTouchMoveCapture?: TouchEventHandler; onTouchStart?: TouchEventHandler; + onTouchStartCapture?: TouchEventHandler; // UI Events onScroll?: UIEventHandler; + onScrollCapture?: UIEventHandler; // Wheel Events onWheel?: WheelEventHandler; + onWheelCapture?: WheelEventHandler; // Animation Events onAnimationStart?: AnimationEventHandler; + onAnimationStartCapture?: AnimationEventHandler; onAnimationEnd?: AnimationEventHandler; + onAnimationEndCapture?: AnimationEventHandler; onAnimationIteration?: AnimationEventHandler; + onAnimationIterationCapture?: AnimationEventHandler; // Transition Events onTransitionEnd?: TransitionEventHandler; + onTransitionEndCapture?: TransitionEventHandler; } // This interface is not complete. Only properties accepting @@ -2289,7 +2354,7 @@ declare namespace React { // ---------------------------------------------------------------------- interface Validator { - (object: T, key: string, componentName: string, ...rest: any[]): Error; + (object: T, key: string, componentName: string, ...rest: any[]): Error | null; } interface Requireable extends Validator { diff --git a/react/react-tests.ts b/react/react-tests.ts index b033907a79..ae9538b294 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -41,7 +41,7 @@ var props: Props & React.ClassAttributes<{}> = { foo: 42 }; -var container: Element; +var container: Element = document.createElement("div"); // // Top-Level API @@ -49,11 +49,12 @@ var container: Element; var ClassicComponent: React.ClassicComponentClass = React.createClass({ + displayName: "ClassicComponent", getDefaultProps() { return { - hello: undefined, + hello: "hello", world: "peace", - foo: undefined + foo: 0, }; }, getInitialState() { @@ -151,6 +152,10 @@ StatelessComponent2.defaultProps = { foo: 42 }; +var StatelessComponent3: React.SFC = + // allows usage of props.children + props => React.DOM.div(null, props.foo, props.children); + // React.createFactory var factory: React.CFactory = React.createFactory(ModernComponent); @@ -187,6 +192,10 @@ var domElement: React.ReactHTMLElement = // React.cloneElement var clonedElement: React.CElement = React.cloneElement(element, { foo: 43 }); + +React.cloneElement(element, {}); +React.cloneElement(element, {}, null); + var clonedElement2: React.CElement = // known problem: cloning with key or ref requires cast React.cloneElement(element, >{ @@ -240,18 +249,15 @@ domNode = ReactDOM.findDOMNode(domNode); var type: React.ComponentClass = element.type; var elementProps: Props = element.props; -var key: React.Key = element.key; - -var t: React.ReactType; -var name = typeof t === "string" ? t : t.displayName; +var key = element.key; // // React Components // -------------------------------------------------------------------------- -var displayName: string = ClassicComponent.displayName; -var defaultProps: Props = ClassicComponent.getDefaultProps(); -var propTypes: React.ValidationMap = ClassicComponent.propTypes; +var displayName: string | undefined = ClassicComponent.displayName; +var defaultProps: Props = ClassicComponent.getDefaultProps ? ClassicComponent.getDefaultProps() : {}; +var propTypes: React.ValidationMap | undefined = ClassicComponent.propTypes; // // Component API @@ -282,7 +288,7 @@ class RefComponent extends React.Component { } } -var componentRef: RefComponent; +var componentRef: RefComponent = new RefComponent(); RefComponent.create({ ref: "componentRef" }); // type of c should be inferred RefComponent.create({ ref: c => componentRef = c }); @@ -315,6 +321,10 @@ var htmlAttr: React.HTMLProps = { event.preventDefault(); event.stopPropagation(); }, + onClickCapture: (event: React.MouseEvent<{}>) => { + event.preventDefault(); + event.stopPropagation(); + }, dangerouslySetInnerHTML: { __html: "STRONG" } @@ -373,14 +383,14 @@ var PropTypesSpecification: React.ComponentSpec = { }), requiredFunc: React.PropTypes.func.isRequired, requiredAny: React.PropTypes.any.isRequired, - customProp: function(props: any, propName: string, componentName: string) { + customProp: function(props: any, propName: string, componentName: string): Error | null { if (!/matchme/.test(props[propName])) { return new Error("Validation failed!"); } return null; }, // https://facebook.github.io/react/warnings/dont-call-proptypes.html#fixing-the-false-positive-in-third-party-proptypes - percentage: (object: any, key: string, componentName: string, ...rest: any[]): Error => { + percentage: (object: any, key: string, componentName: string, ...rest: any[]): Error | null => { const error = React.PropTypes.number(object, key, componentName, ...rest); if (error) { return error; @@ -391,7 +401,7 @@ var PropTypesSpecification: React.ComponentSpec = { return null; } }, - render: (): React.ReactElement => { + render: (): React.ReactElement | null => { return null; } }; @@ -425,14 +435,14 @@ var ContextTypesSpecification: React.ComponentSpec = { }), requiredFunc: React.PropTypes.func.isRequired, requiredAny: React.PropTypes.any.isRequired, - customProp: function(props: any, propName: string, componentName: string) { + customProp: function(props: any, propName: string, componentName: string): Error | null { if (!/matchme/.test(props[propName])) { return new Error("Validation failed!"); } return null; } }, - render: (): React.ReactElement => { + render: (): null => { return null; } }; @@ -495,7 +505,7 @@ createFragment({ // -------------------------------------------------------------------------- React.createFactory(CSSTransitionGroup)({ component: React.createClass({ - render: (): React.ReactElement => null + render: (): null => null }), childFactory: (c) => c, transitionName: "transition", @@ -601,16 +611,19 @@ var foundComponents: ModernComponent[] = TestUtils.scryRenderedComponentsWithTyp // ReactTestUtils custom type guards -var emptyElement: React.ReactElement<{}>; -if (TestUtils.isElementOfType(emptyElement, StatelessComponent)) { - emptyElement.props.foo; +var emptyElement1: React.ReactElement<{}> = React.createElement(ModernComponent); +if (TestUtils.isElementOfType(emptyElement1, StatelessComponent)) { + emptyElement1.props.foo; +} +var emptyElement2: React.ReactElement<{}> = React.createElement(StatelessComponent); +if (TestUtils.isElementOfType(emptyElement2, StatelessComponent)) { + emptyElement2.props.foo; } -var anyInstance: Element | React.Component; -if (TestUtils.isDOMComponent(anyInstance)) { - anyInstance.getAttribute("className"); -} else if (TestUtils.isCompositeComponent(anyInstance)) { - anyInstance.props; +if (TestUtils.isDOMComponent(container)) { + container.getAttribute("className"); +} else if (TestUtils.isCompositeComponent(new ModernComponent())) { + new ModernComponent().props; } // @@ -651,4 +664,4 @@ class ConstructorSpreadArgsPureComponent extends React.PureComponent<{}, {}> { constructor(...args: any[]) { super(...args); } -} \ No newline at end of file +} diff --git a/react/react-tsx-tests.tsx b/react/react-tsx-tests.tsx index 3756659a53..f5437f751b 100644 --- a/react/react-tsx-tests.tsx +++ b/react/react-tsx-tests.tsx @@ -13,3 +13,13 @@ StatelessComponent.defaultProps = { }; ; + +var StatelessComponent2: React.SFC = ({ foo, children }) => { + return

{ foo }{ children }
; +}; +StatelessComponent2.displayName = "StatelessComponent4"; +StatelessComponent2.defaultProps = { + foo: 42 +}; + +24; diff --git a/react/tsconfig.json b/react/tsconfig.json index 55fd2537d4..d89fd3bdf7 100644 --- a/react/tsconfig.json +++ b/react/tsconfig.json @@ -8,7 +8,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/redux-actions/index.d.ts b/redux-actions/index.d.ts index 5b5003a3c5..25424e7040 100644 --- a/redux-actions/index.d.ts +++ b/redux-actions/index.d.ts @@ -12,13 +12,13 @@ declare namespace ReduxActions { type: string } - interface Action extends BaseAction { + export interface Action extends BaseAction { payload?: Payload error?: boolean meta?: any } - interface ActionMeta extends Action { + export interface ActionMeta extends Action { meta: Meta } diff --git a/resolve/tsconfig.json b/resolve/tsconfig.json index 3327aff4ab..61c58f56db 100644 --- a/resolve/tsconfig.json +++ b/resolve/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/source-map/index.d.ts b/source-map/index.d.ts index dfddb63e27..8b8f800c85 100644 --- a/source-map/index.d.ts +++ b/source-map/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for source-map v0.1.38 +// Type definitions for source-map v0.5.6 // Project: https://github.com/mozilla/source-map // Definitions by: Morten Houston Ludvigsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -58,7 +58,7 @@ declare namespace SourceMap { public static GENERATED_ORDER: number; public static ORIGINAL_ORDER: number; - constructor(rawSourceMap: RawSourceMap); + constructor(rawSourceMap: RawSourceMap | string); public computeColumnSpans(): void; @@ -115,9 +115,9 @@ declare namespace SourceMap { relativePath?: string ): SourceNode; - public add(chunk: any): SourceNode; + public add(chunk: (string | SourceNode)[] | SourceNode | string): SourceNode; - public prepend(chunk: any): SourceNode; + public prepend(chunk: (string | SourceNode)[] | SourceNode | string): SourceNode; public setSourceContent(sourceFile: string, sourceContent: string): void; diff --git a/source-map/source-map-tests.ts b/source-map/source-map-tests.ts index 23722d8179..4e584d2338 100644 --- a/source-map/source-map-tests.ts +++ b/source-map/source-map-tests.ts @@ -14,6 +14,15 @@ function testSourceMapConsumer() { file: 'sdf' }); + scm = new SourceMap.SourceMapConsumer(JSON.stringify({ + version: 3, + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + sourcesContent: ['foo'], + mappings: 'foo', + file: 'sdf' + })); + // create with partial RawSourceMap scm = new SourceMap.SourceMapConsumer({ version: 3, @@ -129,10 +138,14 @@ function testSourceNode() { function testAdd(node: SourceMap.SourceNode) { node.add('foo'); + node.add(new SourceMap.SourceNode()); + node.add([new SourceMap.SourceNode(), 'bar']); } function testPrepend(node: SourceMap.SourceNode) { node.prepend('foo'); + node.prepend(new SourceMap.SourceNode()); + node.prepend([new SourceMap.SourceNode(), 'bar']); } function testSetSourceContent(node: SourceMap.SourceNode) { diff --git a/ssh2-streams/tsconfig.json b/ssh2-streams/tsconfig.json index 476b06feb6..78441a6fbf 100644 --- a/ssh2-streams/tsconfig.json +++ b/ssh2-streams/tsconfig.json @@ -9,7 +9,8 @@ "../" ], "types": [], - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/ssh2/tsconfig.json b/ssh2/tsconfig.json index 4ab8f30918..a89361b4db 100644 --- a/ssh2/tsconfig.json +++ b/ssh2/tsconfig.json @@ -9,7 +9,8 @@ "../" ], "types": [], - "noEmit": true + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/stompjs/index.d.ts b/stompjs/index.d.ts new file mode 100644 index 0000000000..607be77162 --- /dev/null +++ b/stompjs/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for stompjs 2.3 +// Project: https://github.com/jmesnil/stomp-websocket +// Definitions by: Jimi Charalampidis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export const VERSIONS: { + V1_0: string, + V1_1: string, + V1_2: string, + supportedVersions: () => Array +}; + +export class Client { + + connected: boolean; + counter: number; + heartbeat: { + incoming: number, + outgoing: number + }; + maxWebSocketFrameSize: number; + subscriptions: {}; + ws: WebSocket; + + debug(...args: string[]): any; + + connect(...args: any[]): any; + disconnect(disconnectCallback: () => any, headers?: {}): any; + + send(destination: string, headers?: {}, body?: string): any; + subscribe(destination: string, callback?: (message: Message) => any, headers?: {}): any; + unsubscribe(): any; + + begin(transaction: string): any; + commit(transaction: string): any; + abort(transaction: string): any; + + ack(messageID: string, subscription: string, headers?: {}): any; + nack(messageID: string, subscription: string, headers?: {}): any; +} + +export interface Message { + command: string; + headers: {}; + body: string; + + ack(headers?: {}): any; + nack(headers?: {}): any; +} + +export class Frame { + constructor(command: string, headers?: {}, body?: string); + + toString(): string; + sizeOfUTF8(s: string): number; + unmarshall(datas: any): any; + marshall(command: string, headers?: {}, body?: string): any; +} + +export function client(url: string, protocols?: string | Array): Client; +export function over(ws: WebSocket): Client; +export function overTCP(host: string, port: number): Client; +export function overWS(url: string): Client; +export function setInterval(interval: number, f: (...args: any[]) => void): NodeJS.Timer; +export function clearInterval(id: NodeJS.Timer): void; diff --git a/stompjs/stompjs-tests.ts b/stompjs/stompjs-tests.ts new file mode 100644 index 0000000000..68320259a9 --- /dev/null +++ b/stompjs/stompjs-tests.ts @@ -0,0 +1,87 @@ +import * as Stomp from 'stompjs'; + +let interval = Stomp.setInterval(1000, () => { }); +Stomp.clearInterval(interval); + +let client: Stomp.Client; + +client = Stomp.client('url'); +client = Stomp.client('url', Stomp.VERSIONS.supportedVersions()); +client = Stomp.client('url', Stomp.VERSIONS.V1_0); +client = Stomp.client('url', Stomp.VERSIONS.V1_1); + +client = Stomp.over(new WebSocket('url')); +client = Stomp.over(new WebSocket('url', Stomp.VERSIONS.supportedVersions())); +client = Stomp.over(new WebSocket('url', Stomp.VERSIONS.V1_0)); +client = Stomp.over(new WebSocket('url', Stomp.VERSIONS.V1_1)); + +client = Stomp.overTCP('host', 0); + +client = Stomp.overWS('url'); + +client.connected = false; +client.counter = 0; +client.heartbeat = { incoming: 20000, outgoing: 20000 }; +client.maxWebSocketFrameSize = 16 * 1024; +client.subscriptions = { 'sub-0': {}, 'sub-1': () => { } }; +client.ws = new WebSocket('url'); + +client.debug(); + +client.connect(); +client.connect('', () => { }, {}); + +client.disconnect(() => { }); +client.disconnect(() => { }, {}); + +client.send('destination'); +client.send('destination', {}); +client.send('destination', {}, 'body'); + +client.subscribe('destination', (message) => { }); +client.subscribe('destination', (message) => { }, {}); + +client.unsubscribe(); + +client.begin('transaction'); + +client.commit('transaction'); + +client.abort('transaction'); + +client.ack('messageID', 'subscription'); +client.nack('messageID', 'subscription', {}); + +let message: Stomp.Message = { + command: 'command', + headers: {}, + body: 'body', + + ack({}) { }, + nack({}) { } +} + +message.ack(); +message.ack({}); + +message.nack(); +message.nack({}); + +let frame: Stomp.Frame; + +frame = new Stomp.Frame('command'); +frame = new Stomp.Frame('command', {}); +frame = new Stomp.Frame('command', {}, 'body'); + +frame.toString(); + +frame.sizeOfUTF8('abc'); + +frame.unmarshall(0); +frame.unmarshall('data'); +frame.unmarshall({}); +frame.unmarshall([{}, {}]); + +frame.marshall('command'); +frame.marshall('command', {}); +frame.marshall('command', {}, 'body'); diff --git a/stompjs/tsconfig.json b/stompjs/tsconfig.json new file mode 100644 index 0000000000..2377e6b1b7 --- /dev/null +++ b/stompjs/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "stompjs-tests.ts" + ] +} diff --git a/stripe/index.d.ts b/stripe/index.d.ts index 8a03ee3f33..2f8c895298 100644 --- a/stripe/index.d.ts +++ b/stripe/index.d.ts @@ -1,9 +1,10 @@ // Type definitions for stripe // Project: https://stripe.com/ -// Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon +// Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon , Adam Cmiel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface StripeStatic { + applePay: StripeApplePay; setPublishableKey(key: string): void; validateCardNumber(cardNumber: string): boolean; validateExpiry(month: string, year: string): boolean; @@ -34,11 +35,11 @@ interface StripeTokenResponse { id: string; card: StripeCardData; created: number; - currency: string; livemode: boolean; object: string; + type: string; used: boolean; - error: StripeError; + error?: StripeError; } interface StripeError { @@ -51,10 +52,8 @@ interface StripeError { interface StripeCardData { object: string; last4: string; - type: string; exp_month: number; exp_year: number; - fingerprint: string; country?: string; name?: string; address_line1?: string; @@ -87,7 +86,6 @@ interface StripeBankTokenResponse { id: string; bank_account: { - id: string; country: string; bank_name: string; last4: number; @@ -99,10 +97,72 @@ interface StripeBankTokenResponse type: string; object: string; used: boolean; - error: StripeError; + error?: StripeError; } declare var Stripe: StripeStatic; declare module "Stripe" { export = StripeStatic; } + +interface StripeApplePay +{ + checkAvailability(resopnseHandler: (result: boolean) => void): void; + buildSession(data: StripeApplePayPaymentRequest, + onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void, + onErrorHanlder: (error: { message: string }) => void): any; +} + +type StripeApplePayBillingContactField = 'postalAddress' | 'name'; +type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email'; +type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; + +interface StripeApplePayPaymentRequest +{ + billingContact: StripeApplePayPaymentContact; + countryCode: string; + currencyCode: string; + total: StripeApplePayLineItem; + lineItems?: StripeApplePayLineItem[]; + requiredBillingContactFields?: StripeApplePayBillingContactField[]; + requiredShippingContactFields?: StripeApplePayShippingContactField[]; + shippingContact?: StripeApplePayPaymentContact; + shippingMethods?: StripeApplePayShippingMethod[]; + shippingType?: StripeApplePayShipping[]; +} + +// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types +interface StripeApplePayLineItem +{ + type: 'pending' | 'final'; + label: string; + amount: number; +} + +interface StripeApplePaySessionResult +{ + token: StripeTokenResponse; + shippingContact?: StripeApplePayPaymentContact; + shippingMethod?: StripeApplePayShippingMethod; +} + +interface StripeApplePayShippingMethod +{ + label: string; + detail: string; + amount: number; + identifier: string; +} + +interface StripeApplePayPaymentContact +{ + emailAddress: string; + phoneNumber: string; + givenName: string; + familyName: string; + addressLines: string[]; + locality: string; + administrativeArea: string; + postalCode: string; + countryCode: string; +} diff --git a/tapable/index.d.ts b/tapable/index.d.ts index 4588643c6d..68ea3e4104 100644 --- a/tapable/index.d.ts +++ b/tapable/index.d.ts @@ -4,6 +4,10 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare abstract class Tapable { + private _plugins: { + [index: string]: Tapable.Handler[] + } + /** * Register plugin(s) * This acts as the same as on() of EventEmitter, for registering a handler/listener to do something when the @@ -12,9 +16,9 @@ declare abstract class Tapable { * @param names a string or an array of strings to generate the id(group name) of plugins * @param handler a function which provides the plugin functionality * */ - plugin(names: string, handler: Tapable.Listener): void; + plugin(names: string, handler: Tapable.Handler): void; - plugin(names: string[], handler: Tapable.Listener): void; + plugin(names: string[], handler: Tapable.Handler): void; /** * invoke all plugins with this attached. @@ -185,7 +189,7 @@ declare abstract class Tapable { } declare namespace Tapable { - interface Listener { + interface Handler { (...args: any[]): void; } diff --git a/trim/index.d.ts b/trim/index.d.ts new file mode 100644 index 0000000000..4d9981052e --- /dev/null +++ b/trim/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for trim 0.01 +// Project: https://www.npmjs.com/package/trim +// Definitions by: Steve Jenkins +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function Trim(str: string): string; +declare namespace Trim { + function left(str: string): string; + function right(str: string): string; +} + +export = Trim; \ No newline at end of file diff --git a/trim/trim-tests.ts b/trim/trim-tests.ts new file mode 100644 index 0000000000..906d2a7b03 --- /dev/null +++ b/trim/trim-tests.ts @@ -0,0 +1,9 @@ +import trim = require("trim"); + +var original: string = " padded string "; + +trim(original); + +trim.left(original); + +trim.right(original); diff --git a/trim/tsconfig.json b/trim/tsconfig.json new file mode 100644 index 0000000000..b063e69e5f --- /dev/null +++ b/trim/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "trim-tests.ts" + ] +} \ No newline at end of file diff --git a/tween.js/index.d.ts b/tween.js/index.d.ts index 7091b5a05b..c2c5a22297 100644 --- a/tween.js/index.d.ts +++ b/tween.js/index.d.ts @@ -21,6 +21,7 @@ declare namespace TWEEN { interpolation(interpolation: (v:number[], k:number) => number): Tween; chain(...tweens:Tween[]): Tween; onStart(callback: (object?: any) => void): Tween; + onStop(callback: (object?: any) => void): Tween; onUpdate(callback: (object?: any) => void): Tween; onComplete(callback: (object?: any) => void): Tween; update(time: number): boolean; @@ -101,4 +102,4 @@ interface TweenInterpolation { declare module 'tween.js' { export = TWEEN; -} \ No newline at end of file +} diff --git a/webpack-sources/index.d.ts b/webpack-sources/index.d.ts index c87a29d464..245e251a7f 100644 --- a/webpack-sources/index.d.ts +++ b/webpack-sources/index.d.ts @@ -5,8 +5,10 @@ /// /// +/// -import { SourceNode } from 'source-map' +import { Hash } from 'crypto' +import { SourceNode, RawSourceMap, SourceMapGenerator } from 'source-map' import { SourceListMap } from 'source-list-map' export abstract class Source { @@ -16,10 +18,10 @@ export abstract class Source { sourceAndMap(options?: any): { source: string; - map: string; + map: RawSourceMap; }; - updateHash(hash: any): void; + updateHash(hash: Hash): void; source(options?: any): string; @@ -31,20 +33,22 @@ export abstract class Source { } interface SourceAndMapMixin { - map(options: { columns?: boolean }): string + map(options: { columns?: boolean }): RawSourceMap; sourceAndMap(options: { columns?: boolean }): { - source: string, - map: string - } + source: string; + map: RawSourceMap; + }; } export class CachedSource { _source: Source; _cachedSource: string; _cachedSize: number; - _cachedMaps: any; - node: (options: any) => any; - listMap: (options: any) => any; + _cachedMaps: { + [prop: string]: RawSourceMap + }; + node: (options: any) => SourceNode; + listMap: (options: any) => SourceListMap; constructor(source: Source); @@ -54,12 +58,12 @@ export class CachedSource { sourceAndMap(options: any): { source: string; - map: any; + map: RawSourceMap; }; - map(options: any): any; + map(options: any): RawSourceMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class ConcatSource extends Source implements SourceAndMapMixin { @@ -77,7 +81,7 @@ export class ConcatSource extends Source implements SourceAndMapMixin { listMap(options: any): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class LineToLineMappedSource extends Source implements SourceAndMapMixin { @@ -93,7 +97,7 @@ export class LineToLineMappedSource extends Source implements SourceAndMapMixin listMap(options: any): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class OriginalSource extends Source implements SourceAndMapMixin { @@ -112,7 +116,7 @@ export class OriginalSource extends Source implements SourceAndMapMixin { listMap(options: any): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class PrefixSource extends Source implements SourceAndMapMixin { @@ -125,9 +129,9 @@ export class PrefixSource extends Source implements SourceAndMapMixin { node(options: any): SourceNode; - listMap(options: any): any; + listMap(options: any): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class RawSource extends Source { @@ -137,13 +141,13 @@ export class RawSource extends Source { source(): string; - map(options: any): any; + map(options: any): null; node(options: any): SourceNode; listMap(options: any): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } export class ReplaceSource extends Source implements SourceAndMapMixin { @@ -165,7 +169,7 @@ export class ReplaceSource extends Source implements SourceAndMapMixin { node(options: any): SourceNode; - listMap(options: any): any; + listMap(options: any): SourceListMap; _replacementToSourceNode(oldNode: SourceNode, newString: string): string | SourceNode; @@ -178,11 +182,14 @@ export class ReplaceSource extends Source implements SourceAndMapMixin { export class SourceMapSource extends Source implements SourceAndMapMixin { _value: string; _name: string; - _sourceMap: any; - _originalSource: Source; - _innerSourceMap: any; + _sourceMap: SourceMapGenerator | RawSourceMap; + _originalSource: string; + _innerSourceMap: RawSourceMap; - constructor(value: string, name: string, sourceMap: any, originalSource: Source, innerSourceMap?: any); + constructor( + value: string, name: string, sourceMap: SourceMapGenerator | RawSourceMap, originalSource: string, + innerSourceMap?: RawSourceMap + ); source(): string; @@ -194,5 +201,5 @@ export class SourceMapSource extends Source implements SourceAndMapMixin { } ): SourceListMap; - updateHash(hash: any): void; + updateHash(hash: Hash): void; } diff --git a/webpack-sources/webpack-sources-tests.ts b/webpack-sources/webpack-sources-tests.ts index 4c4dc6afab..622f12cb8e 100644 --- a/webpack-sources/webpack-sources-tests.ts +++ b/webpack-sources/webpack-sources-tests.ts @@ -11,6 +11,7 @@ import { SourceMapSource, } from 'webpack-sources'; +import { RawSourceMap } from 'source-map' const s1 = new OriginalSource('a', 'b'); @@ -20,7 +21,10 @@ const s3 = new ConcatSource('a', 'b', s1); const s4 = new RawSource('hey'); +const a = {} as RawSourceMap +const b = {} as RawSourceMap + const s5 = new LineToLineMappedSource('a', 'v', 'c'); const s6 = new PrefixSource(s4, s5); const s7 = new ReplaceSource(s3, 'ha'); -const s8 = new SourceMapSource('va', 'vb', 'vc', s6, 'good'); +const s8 = new SourceMapSource('va', 'vb', a, 'vc', b); diff --git a/winrt-uwp/tsconfig.json b/winrt-uwp/tsconfig.json index e8f51c4af5..79b9eb6b27 100644 --- a/winrt-uwp/tsconfig.json +++ b/winrt-uwp/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/winrt/tsconfig.json b/winrt/tsconfig.json index e8f51c4af5..79b9eb6b27 100644 --- a/winrt/tsconfig.json +++ b/winrt/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../", diff --git a/winston/index.d.ts b/winston/index.d.ts index 1db5b33c32..6fccfe514c 100644 --- a/winston/index.d.ts +++ b/winston/index.d.ts @@ -11,330 +11,336 @@ /// Winston v2.2.x ///****************** +declare var winston: winston.Winston; +export = winston; -export declare var transports: Transports; -export declare var Transport: TransportStatic; -export declare var Logger: LoggerStatic; -export declare var Container: ContainerStatic; -export declare var loggers: ContainerInstance; -export declare var defaultLogger: LoggerInstance; +declare namespace winston { + export interface Winston { + transports: winston.Transports; + Transport: winston.TransportStatic; + Logger: winston.LoggerStatic; + Container: winston.ContainerStatic; + loggers: winston.ContainerInstance; + default: winston.LoggerInstance; -export declare var exception: Exception; + exception: winston.Exception; -export declare var exitOnError: boolean; -export declare var level: string; + exitOnError: boolean; + level: string; -export declare var log: LogMethod; + log: winston.LogMethod; -export declare var debug: LeveledLogMethod; -export declare var info: LeveledLogMethod; -export declare var warn: LeveledLogMethod; -export declare var error: LeveledLogMethod; + debug: winston.LeveledLogMethod; + info: winston.LeveledLogMethod; + warn: winston.LeveledLogMethod; + error: winston.LeveledLogMethod; -export declare function query(options: QueryOptions, callback?: (err: Error, results: any) => void): any; -export declare function query(callback: (err: Error, results: any) => void): any; -export declare function stream(options?: any): NodeJS.ReadableStream; -export declare function handleExceptions(...transports: TransportInstance[]): void; -export declare function unhandleExceptions(...transports: TransportInstance[]): void; -export declare function add(transport: TransportInstance, options?: TransportOptions, created?: boolean): LoggerInstance; -export declare function clear(): void; -export declare function remove(transport: string): LoggerInstance; -export declare function remove(transport: TransportInstance): LoggerInstance; -export declare function startTimer(): ProfileHandler; -export declare function profile(id: string, msg?: string, meta?: any, callback?: (err: Error, level: string, msg: string, meta: any) => void): LoggerInstance; -export declare function addColors(target: any): any; -export declare function setLevels(target: any): any; -export declare function cli(): LoggerInstance; -export declare function close(): void; - export function configure(options: LoggerOptions): void; + query(options: winston.QueryOptions, callback?: (err: Error, results: any) => void): any; + query(callback: (err: Error, results: any) => void): any; + stream(options?: any): NodeJS.ReadableStream; + handleExceptions(...transports: winston.TransportInstance[]): void; + unhandleExceptions(...transports: winston.TransportInstance[]): void; + add(transport: winston.TransportInstance, options?: winston.TransportOptions, created?: boolean): winston.LoggerInstance; + clear(): void; + remove(transport: string): winston.LoggerInstance; + remove(transport: winston.TransportInstance): winston.LoggerInstance; + startTimer(): winston.ProfileHandler; + profile(id: string, msg?: string, meta?: any, callback?: (err: Error, level: string, msg: string, meta: any) => void): winston.LoggerInstance; + addColors(target: any): any; + setLevels(target: any): any; + cli(): winston.LoggerInstance; + close(): void; + configure(options: winston.LoggerOptions): void; + } -export interface ExceptionProcessInfo { - pid: number; - uid?: number; - gid?: number; - cwd: string; - execPath: string; - version: string; - argv: string; - memoryUsage: NodeJS.MemoryUsage; -} + export interface ExceptionProcessInfo { + pid: number; + uid?: number; + gid?: number; + cwd: string; + execPath: string; + version: string; + argv: string; + memoryUsage: NodeJS.MemoryUsage; + } -export interface ExceptionOsInfo { - loadavg: [number, number, number]; - uptime: number; -} + export interface ExceptionOsInfo { + loadavg: [number, number, number]; + uptime: number; + } -export interface ExceptionTrace { - column: number; - file: string; - "function": string; - line: number; - method: string; - native: boolean; -} + export interface ExceptionTrace { + column: number; + file: string; + "function": string; + line: number; + method: string; + native: boolean; + } -export interface ExceptionAllInfo { - date: Date; - process: ExceptionProcessInfo; - os: ExceptionOsInfo; - trace: Array; - stack: Array; -} + export interface ExceptionAllInfo { + date: Date; + process: ExceptionProcessInfo; + os: ExceptionOsInfo; + trace: Array; + stack: Array; + } -export interface Exception { - getAllInfo(err: Error): ExceptionAllInfo; - getProcessInfo(): ExceptionProcessInfo; - getOsInfo(): ExceptionOsInfo; - getTrace(err: Error): Array; -} + export interface Exception { + getAllInfo(err: Error): ExceptionAllInfo; + getProcessInfo(): ExceptionProcessInfo; + getOsInfo(): ExceptionOsInfo; + getTrace(err: Error): Array; + } -export interface MetadataRewriter { - (level: string, msg: string, meta: any): any; -} + export interface MetadataRewriter { + (level: string, msg: string, meta: any): any; + } -export interface MetadataFilter { - (level: string, msg: string, meta: any): string | { msg: any; meta: any; }; -} + export interface MetadataFilter { + (level: string, msg: string, meta: any): string | { msg: any; meta: any; }; + } -export interface LoggerStatic { - new (options?: LoggerOptions): LoggerInstance; -} + export interface LoggerStatic { + new (options?: LoggerOptions): LoggerInstance; + } -export interface LoggerInstance extends NodeJS.EventEmitter { - rewriters: Array; - filters: Array; - transports: Array; + export interface LoggerInstance extends NodeJS.EventEmitter { + rewriters: Array; + filters: Array; + transports: Array; - extend(target: any): LoggerInstance; + extend(target: any): LoggerInstance; - log: LogMethod; + log: LogMethod; - debug: LeveledLogMethod; - info: LeveledLogMethod; - warn: LeveledLogMethod; - error: LeveledLogMethod; + debug: LeveledLogMethod; + info: LeveledLogMethod; + warn: LeveledLogMethod; + error: LeveledLogMethod; - query(options: QueryOptions, callback?: (err: Error, results: any) => void): any; - query(callback: (err: Error, results: any) => void): any; - stream(options?: any): NodeJS.ReadableStream; - close(): void; - handleExceptions(...transports: TransportInstance[]): void; - unhandleExceptions(...transports: TransportInstance[]): void; - add(transport: TransportInstance, options?: TransportOptions, created?: boolean): LoggerInstance; - clear(): void; - remove(transport: TransportInstance): LoggerInstance; - startTimer(): ProfileHandler; - profile(id: string, msg?: string, meta?: any, callback?: (err: Error, level: string, msg: string, meta: any) => void): LoggerInstance; - configure(options: LoggerOptions): void; - setLevels(target: any): any; - cli(): LoggerInstance; + query(options: QueryOptions, callback?: (err: Error, results: any) => void): any; + query(callback: (err: Error, results: any) => void): any; + stream(options?: any): NodeJS.ReadableStream; + close(): void; + handleExceptions(...transports: TransportInstance[]): void; + unhandleExceptions(...transports: TransportInstance[]): void; + add(transport: TransportInstance, options?: TransportOptions, created?: boolean): LoggerInstance; + clear(): void; + remove(transport: TransportInstance): LoggerInstance; + startTimer(): ProfileHandler; + profile(id: string, msg?: string, meta?: any, callback?: (err: Error, level: string, msg: string, meta: any) => void): LoggerInstance; + configure(options: LoggerOptions): void; + setLevels(target: any): any; + cli(): LoggerInstance; - level: string; -} + level: string; + } -export interface LoggerOptions { - transports?: TransportInstance[]; - rewriters?: TransportInstance[]; - exceptionHandlers?: TransportInstance[]; - handleExceptions?: boolean; + export interface LoggerOptions { + transports?: TransportInstance[]; + rewriters?: TransportInstance[]; + exceptionHandlers?: TransportInstance[]; + handleExceptions?: boolean; - /** - * @type {(boolean|(err: Error) => void)} - */ - exitOnError?: any; + /** + * @type {(boolean|(err: Error) => void)} + */ + exitOnError?: any; - // TODO: Need to make instances specific, - // and need to get options for each instance. - // Unfortunately, the documentation is unhelpful. - [optionName: string]: any; -} + // TODO: Need to make instances specific, + // and need to get options for each instance. + // Unfortunately, the documentation is unhelpful. + [optionName: string]: any; + } -export interface TransportStatic { - new (options?: TransportOptions): TransportInstance; -} + export interface TransportStatic { + new (options?: TransportOptions): TransportInstance; + } -export interface TransportInstance extends TransportStatic, NodeJS.EventEmitter { - formatQuery(query: (string | Object)): (string | Object); - normalizeQuery(options: QueryOptions): QueryOptions; - formatResults(results: (Object | Array), options?: Object): (Object | Array); - logException(msg: string, meta: Object, callback: () => void): void; -} + export interface TransportInstance extends TransportStatic, NodeJS.EventEmitter { + formatQuery(query: (string | Object)): (string | Object); + normalizeQuery(options: QueryOptions): QueryOptions; + formatResults(results: (Object | Array), options?: Object): (Object | Array); + logException(msg: string, meta: Object, callback: () => void): void; + } -export interface ConsoleTransportInstance extends TransportInstance { - new (options?: ConsoleTransportOptions): ConsoleTransportInstance; -} + export interface ConsoleTransportInstance extends TransportInstance { + new (options?: ConsoleTransportOptions): ConsoleTransportInstance; + } -export interface DailyRotateFileTransportInstance extends TransportInstance { - new (options?: DailyRotateFileTransportOptions): DailyRotateFileTransportInstance; -} + export interface DailyRotateFileTransportInstance extends TransportInstance { + new (options?: DailyRotateFileTransportOptions): DailyRotateFileTransportInstance; + } -export interface FileTransportInstance extends TransportInstance { - new (options?: FileTransportOptions): FileTransportInstance; - close(): void; -} + export interface FileTransportInstance extends TransportInstance { + new (options?: FileTransportOptions): FileTransportInstance; + close(): void; + } -export interface HttpTransportInstance extends TransportInstance { - new (options?: HttpTransportOptions): HttpTransportInstance; -} + export interface HttpTransportInstance extends TransportInstance { + new (options?: HttpTransportOptions): HttpTransportInstance; + } -export interface MemoryTransportInstance extends TransportInstance { - new (options?: MemoryTransportOptions): MemoryTransportInstance; -} + export interface MemoryTransportInstance extends TransportInstance { + new (options?: MemoryTransportOptions): MemoryTransportInstance; + } -export interface WebhookTransportInstance extends TransportInstance { - new (options?: WebhookTransportOptions): WebhookTransportInstance; -} + export interface WebhookTransportInstance extends TransportInstance { + new (options?: WebhookTransportOptions): WebhookTransportInstance; + } -export interface WinstonModuleTrasportInstance extends TransportInstance { - new (options?: WinstonModuleTransportOptions): WinstonModuleTrasportInstance; -} + export interface WinstonModuleTrasportInstance extends TransportInstance { + new (options?: WinstonModuleTransportOptions): WinstonModuleTrasportInstance; + } -export interface ContainerStatic { - new (options: LoggerOptions): ContainerInstance; -} + export interface ContainerStatic { + new (options: LoggerOptions): ContainerInstance; + } -export interface ContainerInstance extends ContainerStatic { - get(id: string, options?: LoggerOptions): LoggerInstance; - add(id: string, options: LoggerOptions): LoggerInstance; - has(id: string): boolean; - close(id: string): void; - options: LoggerOptions; - loggers: any; - default: LoggerOptions; -} + export interface ContainerInstance extends ContainerStatic { + get(id: string, options?: LoggerOptions): LoggerInstance; + add(id: string, options: LoggerOptions): LoggerInstance; + has(id: string): boolean; + close(id: string): void; + options: LoggerOptions; + loggers: any; + default: LoggerOptions; + } -export interface Transports { - File: FileTransportInstance; - Console: ConsoleTransportInstance; - Loggly: WinstonModuleTrasportInstance; - DailyRotateFile: DailyRotateFileTransportInstance; - Http: HttpTransportInstance; - Memory: MemoryTransportInstance; - Webhook: WebhookTransportInstance; -} + export interface Transports { + File: FileTransportInstance; + Console: ConsoleTransportInstance; + Loggly: WinstonModuleTrasportInstance; + DailyRotateFile: DailyRotateFileTransportInstance; + Http: HttpTransportInstance; + Memory: MemoryTransportInstance; + Webhook: WebhookTransportInstance; + } -export type TransportOptions = ConsoleTransportOptions | DailyRotateFileTransportOptions | FileTransportOptions | HttpTransportOptions | MemoryTransportOptions | WebhookTransportOptions | WinstonModuleTransportOptions; + export type TransportOptions = ConsoleTransportOptions | DailyRotateFileTransportOptions | FileTransportOptions | HttpTransportOptions | MemoryTransportOptions | WebhookTransportOptions | WinstonModuleTransportOptions; -export interface GenericTransportOptions { - level?: string; - silent?: boolean; - raw?: boolean; - name?: string; - formatter?: Function; - handleExceptions?: boolean; - exceptionsLevel?: string; - humanReadableUnhandledException?: boolean; -} + export interface GenericTransportOptions { + level?: string; + silent?: boolean; + raw?: boolean; + name?: string; + formatter?: Function; + handleExceptions?: boolean; + exceptionsLevel?: string; + humanReadableUnhandledException?: boolean; + } -export interface GenericTextTransportOptions { - json?: boolean; - colorize?: boolean; - colors?: any; - prettyPrint?: boolean; - timestamp?: (Function | boolean); - showLevel?: boolean; - label?: string; - depth?: number; - stringify?: Function; -} + export interface GenericTextTransportOptions { + json?: boolean; + colorize?: boolean; + colors?: any; + prettyPrint?: boolean; + timestamp?: (Function | boolean); + showLevel?: boolean; + label?: string; + depth?: number; + stringify?: Function; + } -export interface GenericNetworkTransportOptions { - host?: string; - port?: number; - auth?: { - username: string; - password: string; - }; - path?: string; -} + export interface GenericNetworkTransportOptions { + host?: string; + port?: number; + auth?: { + username: string; + password: string; + }; + path?: string; + } -export interface ConsoleTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { - logstash?: boolean; - debugStdout?: boolean; -} + export interface ConsoleTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { + logstash?: boolean; + debugStdout?: boolean; + } -export interface DailyRotateFileTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { - logstash?: boolean; - maxsize?: number; - maxFiles?: number; - eol?: string; - maxRetries?: number; - datePattern?: string; - filename?: string; - dirname?: string; - options?: { - flags?: string; - highWaterMark?: number; - }; - stream?: NodeJS.WritableStream; -} + export interface DailyRotateFileTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { + logstash?: boolean; + maxsize?: number; + maxFiles?: number; + eol?: string; + maxRetries?: number; + datePattern?: string; + filename?: string; + dirname?: string; + options?: { + flags?: string; + highWaterMark?: number; + }; + stream?: NodeJS.WritableStream; + } -export interface FileTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { - logstash?: boolean; - maxsize?: number; - rotationFormat?: boolean; - zippedArchive?: boolean; - maxFiles?: number; - eol?: string; - tailable?: boolean; - maxRetries?: number; - filename?: string; - dirname?: string; - options?: { - flags?: string; - highWaterMark?: number; - }; - stream?: NodeJS.WritableStream; -} + export interface FileTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { + logstash?: boolean; + maxsize?: number; + rotationFormat?: boolean; + zippedArchive?: boolean; + maxFiles?: number; + eol?: string; + tailable?: boolean; + maxRetries?: number; + filename?: string; + dirname?: string; + options?: { + flags?: string; + highWaterMark?: number; + }; + stream?: NodeJS.WritableStream; + } -export interface HttpTransportOptions extends GenericTransportOptions, GenericNetworkTransportOptions { - ssl?: boolean; -} + export interface HttpTransportOptions extends GenericTransportOptions, GenericNetworkTransportOptions { + ssl?: boolean; + } -export interface MemoryTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { -} + export interface MemoryTransportOptions extends GenericTransportOptions, GenericTextTransportOptions { + } -export interface WebhookTransportOptions extends GenericTransportOptions, GenericNetworkTransportOptions { - method?: string; - ssl?: { - key?: any; - cert?: any; - ca: any; - }; -} + export interface WebhookTransportOptions extends GenericTransportOptions, GenericNetworkTransportOptions { + method?: string; + ssl?: { + key?: any; + cert?: any; + ca: any; + }; + } -export interface WinstonModuleTransportOptions extends GenericTransportOptions { - [optionName: string]: any; -} + export interface WinstonModuleTransportOptions extends GenericTransportOptions { + [optionName: string]: any; + } -export interface QueryOptions { - rows?: number; - limit?: number; - start?: number; - from?: Date; - until?: Date; - order?: "asc" | "desc"; - fields: any; -} + export interface QueryOptions { + rows?: number; + limit?: number; + start?: number; + from?: Date; + until?: Date; + order?: "asc" | "desc"; + fields: any; + } -export interface ProfileHandler { - logger: LoggerInstance; - start: Date; - done: (msg: string) => LoggerInstance; -} + export interface ProfileHandler { + logger: LoggerInstance; + start: Date; + done: (msg: string) => LoggerInstance; + } -interface LogMethod { - (level: string, msg: string, callback: LogCallback): LoggerInstance; - (level: string, msg: string, meta: any, callback: LogCallback): LoggerInstance; - (level: string, msg: string, ...meta: any[]): LoggerInstance; -} + interface LogMethod { + (level: string, msg: string, callback: LogCallback): LoggerInstance; + (level: string, msg: string, meta: any, callback: LogCallback): LoggerInstance; + (level: string, msg: string, ...meta: any[]): LoggerInstance; + } -interface LeveledLogMethod { - (msg: string, callback: LogCallback): LoggerInstance; - (msg: string, meta: any, callback: LogCallback): LoggerInstance; - (msg: string, ...meta: any[]): LoggerInstance; -} + interface LeveledLogMethod { + (msg: string, callback: LogCallback): LoggerInstance; + (msg: string, meta: any, callback: LogCallback): LoggerInstance; + (msg: string, ...meta: any[]): LoggerInstance; + } -interface LogCallback { - (error?: any, level?: string, msg?: string, meta?: any): void; -} + interface LogCallback { + (error?: any, level?: string, msg?: string, meta?: any): void; + } +} \ No newline at end of file diff --git a/winston/winston-tests.ts b/winston/winston-tests.ts index 0b3c9f916b..dae649d1f9 100644 --- a/winston/winston-tests.ts +++ b/winston/winston-tests.ts @@ -265,3 +265,5 @@ var logger: winston.LoggerInstance = new (winston.Logger)({ /* Reconfigure logger */ logger.configure({ level: 'silly' }); + +winston.default.warn("Don't export reserved words in JavaScript!"); diff --git a/yargs/index.d.ts b/yargs/index.d.ts index 238f5d1edd..fa82e2490e 100644 --- a/yargs/index.d.ts +++ b/yargs/index.d.ts @@ -70,6 +70,8 @@ declare namespace yargs { command(command: string, description: string, builder: { [optionName: string]: Options }): Argv; command(command: string, description: string, builder: { [optionName: string]: Options }, handler: (args: Argv) => void): Argv; command(command: string, description: string, builder: (args: Argv) => Options, handler: (args: Argv) => void): Argv; + command(command: string, description: string, module: CommandModule): Argv; + command(module: CommandModule): Argv; commandDir(dir: string, opts?: RequireDirectoryOptions): Argv; @@ -144,7 +146,7 @@ declare namespace yargs { count(key: string): Argv; count(keys: string[]): Argv; - fail(func: (msg: string, err: Error) => any): Argv; + fail(func: (msg: string, err: Error) => any): Argv; coerce(key: string|string[], func: (arg: T) => U): Argv; coerce(opts: { [key: string]: (arg: T) => U; }): Argv; @@ -170,35 +172,47 @@ declare namespace yargs { recurse?: boolean; extensions?: string[]; visit?: (commandObject: any, pathToFile?: string, filename?: string) => any; - include?: RegExp | ((pathToFile: string)=>boolean); - exclude?: RegExp | ((pathToFile: string)=>boolean); + include?: RegExp | ((pathToFile: string) => boolean); + exclude?: RegExp | ((pathToFile: string) => boolean); } interface Options { - type?: string; - group?: string; - alias?: any; - demand?: any; - required?: any; - require?: any; + alias?: string | string[]; + array?: boolean; + boolean?: boolean; + choices?: string[]; + coerce?: (arg: any) => any; + config?: boolean; + configParser?: (configPath: string) => Object; + count?: boolean; default?: any; defaultDescription?: string; - boolean?: boolean; - string?: boolean; - count?: boolean; - describe?: any; - description?: any; - desc?: any; - requiresArg?: any; - choices?: string[]; + demand?: boolean | string; + desc?: string; + describe?: string; + description?: string; global?: boolean; - array?: boolean; - config?: boolean; - number?: boolean; - normalize?: boolean; + group?: string; nargs?: number; + normalize?: boolean; + number?: boolean; + require?: boolean | string; + required?: boolean | string; + requiresArg?: boolean | string; + skipValidation?: boolean; + string?: boolean; + type?: "array" | "boolean" | "count" | "number" | "string"; } + interface CommandModule { + aliases?: string[] | string; + builder?: CommandBuilder; + command?: string[] | string; + describe?: string | false; + handler: (args: any) => void; + } + + type CommandBuilder = {[key: string]: Options} | ((args: Argv) => Argv); type SyncCompletionFunction = (current: string, argv: any) => string[]; type AsyncCompletionFunction = (current: string, argv: any, done: (completion: string[]) => void) => void; } diff --git a/yargs/yargs-tests.ts b/yargs/yargs-tests.ts index 011d305621..8fb693803a 100644 --- a/yargs/yargs-tests.ts +++ b/yargs/yargs-tests.ts @@ -207,6 +207,23 @@ function command() { 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; } @@ -500,3 +517,34 @@ function Argv$skipValidation() { .skipValidation(['arg2', 'arg3']) .argv } + +function Argv$commandObject() { + var ya = yargs + .command("commandname", "description", { + "arg": { + alias: "string", + array: true, + boolean: true, + choices: ["a", "b", "c"], + coerce: f => JSON.stringify(f), + config: true, + configParser: t => t, + count: true, + default: "myvalue", + defaultDescription: "description", + demand: true, + desc: "desc", + describe: "describe", + description: "description", + global: false, + group: "group", + nargs: 1, + normalize: false, + number: true, + requiresArg: true, + skipValidation: false, + string: true, + type: "string" + } + }) +} diff --git a/yayson/tsconfig.json b/yayson/tsconfig.json index dc04b6dd8c..33d32555f9 100644 --- a/yayson/tsconfig.json +++ b/yayson/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "noImplicitAny": true, "strictNullChecks": false, "baseUrl": "../",