From 5ce0dfb57be2b3ceaec695003bfd4aa5ab0f6981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Luk=C3=A1cs?= Date: Tue, 23 Jun 2015 11:07:10 +0200 Subject: [PATCH 01/86] definitions for angular-gettext v2.1.0 https://angular-gettext.rocketeer.be/ --- angular-gettext/angular-gettext-tests.ts | 55 +++++++++++++++++++ angular-gettext/angular-gettext.d.ts | 68 ++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 angular-gettext/angular-gettext-tests.ts create mode 100644 angular-gettext/angular-gettext.d.ts diff --git a/angular-gettext/angular-gettext-tests.ts b/angular-gettext/angular-gettext-tests.ts new file mode 100644 index 0000000000..5500d914e2 --- /dev/null +++ b/angular-gettext/angular-gettext-tests.ts @@ -0,0 +1,55 @@ +/// + +module angular_gettext_tests { + var gettextCatalog: angular_gettext.gettextCatalog; + + + // Configuring angular-gettext + // https://angular-gettext.rocketeer.be/dev-guide/configure/ + //Setting the language + gettextCatalog.setCurrentLanguage('nl'); + + //Highlighting untranslated strings + gettextCatalog.debug = true; + + + + // Marking strings in JavaScript code as translatable. + // https://angular-gettext.rocketeer.be/dev-guide/annotate-js/ + var gettext = angular_gettext.gettext; + var myString = gettext("Hello"); + + //Translating directly in JavaScript. + angular.module("myApp").controller("helloController", function (gettextCatalog) { + var translated: string = gettextCatalog.getString("Hello"); + }); + + angular.module("myApp").controller("helloController", function (gettextCatalog) { + var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds"); + }); + + var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" }); + + + // Setting strings manually + // https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/ + + angular.module("myApp").run(function (gettextCatalog: angular_gettext.gettextCatalog) { + // Load the strings automatically during initialization. + gettextCatalog.setStrings("nl", { + "Hello": "Hallo", + "One boat": ["Een boot", "{{$count}} boats"] + }); + }); + + + // Lazy-loading languages + // https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ + angular.module("myApp").controller("helloController", function ($scope, gettextCatalog: angular_gettext.gettextCatalog) { + $scope.switchLanguage = function (lang: string) { + gettextCatalog.setCurrentLanguage(lang); + gettextCatalog.loadRemote("/languages/" + lang + ".json"); + }; + }); + +} \ No newline at end of file diff --git a/angular-gettext/angular-gettext.d.ts b/angular-gettext/angular-gettext.d.ts new file mode 100644 index 0000000000..01e4b070ea --- /dev/null +++ b/angular-gettext/angular-gettext.d.ts @@ -0,0 +1,68 @@ +// Type definitions for angular-gettext v2.1.0 +// Project: https://angular-gettext.rocketeer.be/ +// Definitions by: Ákos Lukács https://github.com/AkosLukacs +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular_gettext { + interface gettextCatalog { + + ////////////// + /// Fields /// + ////////////// + + /** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */ + debug: boolean; + /** (default: [MISSING]:): Custom prefix for untranslated strings. */ + debugPrefix: string; + /** (default: false): Whether or not to wrap all processed text with markers.Example output: [Welcome] */ + showTranslatedMarkers: boolean; + /** (default: [): Custom prefix to mark strings that have been run through angular-gettext. */ + translatedMarkerPrefix: string; + /** (default: ]): Custom suffix to mark strings that have been run through angular-gettext. */ + translatedMarkerSuffix: string; + /** An object of loaded translation strings.Shouldn't be used directly. */ + strings: {}; + /** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated */ + baseLanguage: string; + + + /////////////// + /// Methods /// + /////////////// + + /** Sets the current language and makes sure that all translations get updated correctly. */ + setCurrentLanguage(lang: string); + + /** Returns the current language. */ + getCurrentLanguage(): string; + + /** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/ + @param language A language code. + @param strings A dictionary of strings. The format of this dictionary is: + - Keys: Singular English strings (as defined in the source files) + - Values: Either a single string for signular-only strings or an array of plural forms. */ + setStrings(language: string, strings: { [key: string]: string|string[] }); + + /** Get the correct pluralized (but untranslated) string for the value of n. */ + getStringForm(string: string, n: number): string; + + /** Translate a string with the given context. Uses Angular.JS interpolation, so something like this will do what you expect: + * var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" }); + * // var hello will be "Hallo Ruben!" in Dutch. + * The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster. + */ + getString(string: string, context?: any): string; + + /** Translate a plural string with the given context. */ + getPlural(n: number, string: string, stringPlural: string, context?: any): string; + + /** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */ + loadRemote(url: string); + } + + /** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */ + function gettext(dummyString: string): string; +} + From 7a37cdbfbcb3576021f7e19385a93a17a3ed2ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Luk=C3=A1cs?= Date: Tue, 23 Jun 2015 11:23:50 +0200 Subject: [PATCH 02/86] more type arguments + header format fix --- angular-gettext/angular-gettext-tests.ts | 13 +++++++------ angular-gettext/angular-gettext.d.ts | 12 +++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/angular-gettext/angular-gettext-tests.ts b/angular-gettext/angular-gettext-tests.ts index 5500d914e2..706fb67fe0 100644 --- a/angular-gettext/angular-gettext-tests.ts +++ b/angular-gettext/angular-gettext-tests.ts @@ -12,19 +12,18 @@ module angular_gettext_tests { //Highlighting untranslated strings gettextCatalog.debug = true; - - + // Marking strings in JavaScript code as translatable. // https://angular-gettext.rocketeer.be/dev-guide/annotate-js/ var gettext = angular_gettext.gettext; var myString = gettext("Hello"); //Translating directly in JavaScript. - angular.module("myApp").controller("helloController", function (gettextCatalog) { + angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) { var translated: string = gettextCatalog.getString("Hello"); }); - angular.module("myApp").controller("helloController", function (gettextCatalog) { + angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) { var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds"); }); @@ -43,13 +42,15 @@ module angular_gettext_tests { }); + interface helloControllerScope extends ng.IScope { + switchLanguage: (lang: string) => void; + } // Lazy-loading languages // https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ - angular.module("myApp").controller("helloController", function ($scope, gettextCatalog: angular_gettext.gettextCatalog) { + angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular_gettext.gettextCatalog) { $scope.switchLanguage = function (lang: string) { gettextCatalog.setCurrentLanguage(lang); gettextCatalog.loadRemote("/languages/" + lang + ".json"); }; }); - } \ No newline at end of file diff --git a/angular-gettext/angular-gettext.d.ts b/angular-gettext/angular-gettext.d.ts index 01e4b070ea..d226801dc4 100644 --- a/angular-gettext/angular-gettext.d.ts +++ b/angular-gettext/angular-gettext.d.ts @@ -1,6 +1,6 @@ // Type definitions for angular-gettext v2.1.0 // Project: https://angular-gettext.rocketeer.be/ -// Definitions by: Ákos Lukács https://github.com/AkosLukacs +// Definitions by: Ákos Lukács // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -24,7 +24,9 @@ declare module angular_gettext { translatedMarkerSuffix: string; /** An object of loaded translation strings.Shouldn't be used directly. */ strings: {}; - /** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated */ + /** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated + * @deprecreated + */ baseLanguage: string; @@ -33,7 +35,7 @@ declare module angular_gettext { /////////////// /** Sets the current language and makes sure that all translations get updated correctly. */ - setCurrentLanguage(lang: string); + setCurrentLanguage(lang: string): void; /** Returns the current language. */ getCurrentLanguage(): string; @@ -43,7 +45,7 @@ declare module angular_gettext { @param strings A dictionary of strings. The format of this dictionary is: - Keys: Singular English strings (as defined in the source files) - Values: Either a single string for signular-only strings or an array of plural forms. */ - setStrings(language: string, strings: { [key: string]: string|string[] }); + setStrings(language: string, strings: { [key: string]: string|string[] }): void; /** Get the correct pluralized (but untranslated) string for the value of n. */ getStringForm(string: string, n: number): string; @@ -59,7 +61,7 @@ declare module angular_gettext { getPlural(n: number, string: string, stringPlural: string, context?: any): string; /** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */ - loadRemote(url: string); + loadRemote(url: string): ng.IHttpPromise; } /** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */ From 15c8ddaa001be3234a56f246ca0e2e5edcbf772f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Luk=C3=A1cs?= Date: Tue, 23 Jun 2015 16:32:40 +0200 Subject: [PATCH 03/86] rename module from angular_gettext to angular.gettext + some whitespace cleanup --- angular-gettext/angular-gettext-tests.ts | 31 ++++++++++++++---------- angular-gettext/angular-gettext.d.ts | 23 ++++++++++-------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/angular-gettext/angular-gettext-tests.ts b/angular-gettext/angular-gettext-tests.ts index 706fb67fe0..9a10f1062f 100644 --- a/angular-gettext/angular-gettext-tests.ts +++ b/angular-gettext/angular-gettext-tests.ts @@ -1,39 +1,44 @@ /// module angular_gettext_tests { - var gettextCatalog: angular_gettext.gettextCatalog; - + // Configuring angular-gettext // https://angular-gettext.rocketeer.be/dev-guide/configure/ //Setting the language - gettextCatalog.setCurrentLanguage('nl'); + angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) { + gettextCatalog.setCurrentLanguage('nl'); + }); //Highlighting untranslated strings - gettextCatalog.debug = true; + angular.module('myApp').run(function (gettextCatalog: angular.gettext.gettextCatalog) { + gettextCatalog.debug = true; + }); // Marking strings in JavaScript code as translatable. - // https://angular-gettext.rocketeer.be/dev-guide/annotate-js/ - var gettext = angular_gettext.gettext; - var myString = gettext("Hello"); + // https://angular-gettext.rocketeer.be/dev-guide/annotate-js/ + angular.module("myApp").controller("helloController", function (gettext: angular.gettext.gettextFunction) { + var myString = gettext("Hello"); + }); //Translating directly in JavaScript. - angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) { + angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) { var translated: string = gettextCatalog.getString("Hello"); }); - angular.module("myApp").controller("helloController", function (gettextCatalog: angular_gettext.gettextCatalog) { + angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) { var myString2: string = gettextCatalog.getPlural(3, "Bird", "Birds"); }); - var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" }); - + angular.module("myApp").controller("helloController", function (gettextCatalog: angular.gettext.gettextCatalog) { + var translated: string = gettextCatalog.getString("Hello {{name}}", { name: "Ruben" }); + }); // Setting strings manually // https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/ - angular.module("myApp").run(function (gettextCatalog: angular_gettext.gettextCatalog) { + angular.module("myApp").run(function (gettextCatalog: angular.gettext.gettextCatalog) { // Load the strings automatically during initialization. gettextCatalog.setStrings("nl", { "Hello": "Hallo", @@ -47,7 +52,7 @@ module angular_gettext_tests { } // Lazy-loading languages // https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ - angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular_gettext.gettextCatalog) { + angular.module("myApp").controller("helloController", function ($scope: helloControllerScope, gettextCatalog: angular.gettext.gettextCatalog) { $scope.switchLanguage = function (lang: string) { gettextCatalog.setCurrentLanguage(lang); gettextCatalog.loadRemote("/languages/" + lang + ".json"); diff --git a/angular-gettext/angular-gettext.d.ts b/angular-gettext/angular-gettext.d.ts index d226801dc4..1a88ef1641 100644 --- a/angular-gettext/angular-gettext.d.ts +++ b/angular-gettext/angular-gettext.d.ts @@ -5,13 +5,13 @@ /// -declare module angular_gettext { +declare module angular.gettext { interface gettextCatalog { - + ////////////// /// Fields /// ////////////// - + /** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */ debug: boolean; /** (default: [MISSING]:): Custom prefix for untranslated strings. */ @@ -33,7 +33,7 @@ declare module angular_gettext { /////////////// /// Methods /// /////////////// - + /** Sets the current language and makes sure that all translations get updated correctly. */ setCurrentLanguage(lang: string): void; @@ -41,10 +41,11 @@ declare module angular_gettext { getCurrentLanguage(): string; /** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/ - @param language A language code. - @param strings A dictionary of strings. The format of this dictionary is: - - Keys: Singular English strings (as defined in the source files) - - Values: Either a single string for signular-only strings or an array of plural forms. */ + * @param language A language code. + * @param strings A dictionary of strings. The format of this dictionary is: + * - Keys: Singular English strings (as defined in the source files) + * - Values: Either a single string for signular-only strings or an array of plural forms. + */ setStrings(language: string, strings: { [key: string]: string|string[] }): void; /** Get the correct pluralized (but untranslated) string for the value of n. */ @@ -56,7 +57,7 @@ declare module angular_gettext { * The context parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster. */ getString(string: string, context?: any): string; - + /** Translate a plural string with the given context. */ getPlural(n: number, string: string, stringPlural: string, context?: any): string; @@ -65,6 +66,8 @@ declare module angular_gettext { } /** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */ - function gettext(dummyString: string): string; + interface gettextFunction { + (dummyString: string): string; + } } From be05c35168a93633b9b60ff32811545ced7bad49 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 11 Jul 2015 20:51:30 +0500 Subject: [PATCH 04/86] Missing options parameters for .map(), .filter(), .promisifyAll(), and .nodeify() --- bluebird/bluebird-tests.ts | 232 +++++++++++++++++++++++++++++++++++-- bluebird/bluebird.d.ts | 57 +++++---- 2 files changed, 260 insertions(+), 29 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 7770e7c9b8..55ddf76973 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -1,4 +1,4 @@ -/// +/// // Tests by: Bart van der Schoor @@ -365,12 +365,12 @@ fooProm = fooProm.timeout(num, str); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fooProm.nodeify(); -fooProm = fooProm.nodeify((err: any) => { +fooProm = fooProm.nodeify((err: any) => { }); +fooProm = fooProm.nodeify((err: any, foo?: Foo) => { }); -}); -fooProm = fooProm.nodeify((err: any, foo?: Foo) => { - -}); +fooProm.nodeify({ spread: true }); +fooProm = fooProm.nodeify((err: any) => { }, { spread: true }); +fooProm = fooProm.nodeify((err: any, foo?: Foo) => { }, { spread: true }); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -504,6 +504,17 @@ barArrProm = fooProm.map((item: Foo) => { return bar; }); +barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = fooProm.map((item: Foo) => { + return bar; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - barProm = fooProm.reduce((memo: Bar, item: Foo, index: number, arrayLength: number) => { @@ -522,6 +533,17 @@ fooArrProm = fooArrProm.filter((item: Foo) => { return bool; }); +fooArrProm = fooArrProm.filter((item: Foo, index: number, arrayLength: number) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = fooArrProm.filter((item: Foo) => { + return bool; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -613,12 +635,41 @@ voidProm = Promise.delay(num); func = Promise.promisify(f); func = Promise.promisify(f, obj); -; obj = Promise.promisifyAll(obj); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +declare var util: any; + +function defaultFilter(name, func) { + return util.isIdentifier(name) && + name.charAt(0) !== "_" && + !util.isClass(func); +} + +function DOMPromisifier(originalMethod) { + // return a function + return function promisified() { + var args = [].slice.call(arguments); + // Needed so that the original method can be called with the correct receiver + var self = this; + // which returns a promise + return new Promise(function(resolve, reject) { + args.push(resolve, reject); + originalMethod.apply(self, args); + }); + }; +} + +obj = Promise.promisifyAll(obj, { + suffix: "", + filter: defaultFilter, + promisifier: DOMPromisifier +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + //TODO enable generator /* func = Promise.coroutine(f); @@ -704,6 +755,26 @@ barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: return barThen; }); +barArrProm = Promise.map(fooThenArrThen, (item: Foo) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArrThen, (item: Foo) => { + return barThen; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}, { + concurrency: 1 +}); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooArrThen @@ -721,6 +792,27 @@ barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: num return barThen; }); +barArrProm = Promise.map(fooArrThen, (item: Foo) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArrThen, (item: Foo) => { + return barThen; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooThenArr @@ -738,6 +830,27 @@ barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: num return barThen; }); +barArrProm = Promise.map(fooThenArr, (item: Foo) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArr, (item: Foo) => { + return barThen; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooArr @@ -755,6 +868,27 @@ barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) return barThen; }); +barArrProm = Promise.map(fooArr, (item: Foo) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArr, (item: Foo) => { + return barThen; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}, { + concurrency: 1 +}); +barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // reduce() @@ -848,6 +982,27 @@ fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLeng return boolThen; }); +fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => { + return boolThen; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return boolThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooArrThen @@ -865,6 +1020,27 @@ fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: return boolThen; }); +fooArrProm = Promise.filter(fooArrThen, (item: Foo) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArrThen, (item: Foo) => { + return boolThen; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return boolThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooThenArr @@ -882,6 +1058,27 @@ fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: return boolThen; }); +fooArrProm = Promise.filter(fooThenArr, (item: Foo) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArr, (item: Foo) => { + return boolThen; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return boolThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // fooArr @@ -899,4 +1096,25 @@ fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: numb return boolThen; }); +fooArrProm = Promise.filter(fooArr, (item: Foo) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArr, (item: Foo) => { + return boolThen; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => { + return bool; +}, { + concurrency: 1 +}); +fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => { + return boolThen; +}, { + concurrency: 1 +}); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index cd21d77e92..a0ccd30ec5 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -116,7 +116,7 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. * Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything. */ - nodeify(callback: (err: any, value?: R) => void): Promise; + nodeify(callback: (err: any, value?: R) => void, options?: Promise.SpreadOption): Promise; nodeify(...sink: any[]): void; /** @@ -312,8 +312,8 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable): Promise; - map(mapper: (item: Q, index: number, arrayLength: number) => U): Promise; + map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + map(mapper: (item: Q, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. @@ -326,8 +326,8 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ // TODO type inference from array-resolving promise? - filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable): Promise; - filter(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise; + filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + filter(filterer: (item: U, index: number, arrayLength: number) => boolean, options?: Promise.ConcurrencyOption): Promise; /** * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. @@ -416,7 +416,7 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. */ // TODO how to model promisifyAll? - static promisifyAll(target: Object): Object; + static promisifyAll(target: Object, options?: Promise.PromisifyAllOptions): Object; /** * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. @@ -542,20 +542,20 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * *The original array is not modified.* */ // promise of array with promises of value - static map(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static map(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + static map(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + static map(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; // promise of array with values - static map(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static map(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; + static map(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + static map(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; // array with promises of value - static map(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static map(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + static map(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + static map(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; // array with values - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; + static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; + static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; /** * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. @@ -588,20 +588,20 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { * *The original array is not modified. */ // promise of array with promises of value - static filter(values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static filter(values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + static filter(values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; + static filter(values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; // promise of array with values - static filter(values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static filter(values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + static filter(values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; + static filter(values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; // array with promises of value - static filter(values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static filter(values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + static filter(values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; + static filter(values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; // array with values - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; - static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; + static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; + static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; } declare module Promise { @@ -618,6 +618,19 @@ declare module Promise { export interface OperationalError extends Error { } + export interface ConcurrencyOption { + concurrency: number; + } + export interface SpreadOption { + spread: boolean; + } + export interface PromisifyAllOptions { + suffix?: string; + filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean; + // The promisifier gets a reference to the original method and should return a function which returns a promise + promisifier?: (originalMethod: Function) => () => Thenable ; + } + // Ideally, we'd define e.g. "export class RangeError extends Error {}", // but as Error is defined as an interface (not a class), TypeScript doesn't // allow extending Error, only implementing it. From a98c5955e885bbef667c2a3aaf35fcc3e913f5c8 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 11 Jul 2015 20:58:02 +0500 Subject: [PATCH 05/86] explicit typings in tests --- bluebird/bluebird-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 55ddf76973..f338678c79 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -642,13 +642,13 @@ obj = Promise.promisifyAll(obj); declare var util: any; -function defaultFilter(name, func) { +function defaultFilter(name: string, func: Function) { return util.isIdentifier(name) && name.charAt(0) !== "_" && !util.isClass(func); } -function DOMPromisifier(originalMethod) { +function DOMPromisifier(originalMethod: Function) { // return a function return function promisified() { var args = [].slice.call(arguments); From 4d86cc24082d6703ecaee46ecc970bd0ac744236 Mon Sep 17 00:00:00 2001 From: Maciej Kowalski Date: Mon, 20 Jul 2015 15:49:54 +0200 Subject: [PATCH 06/86] bump rx to 2.5.3 --- rx/rx-lite.d.ts | 129 +++++++++++++++++++++++++----------- rx/rx.aggregates.d.ts | 10 +-- rx/rx.async-lite.d.ts | 6 +- rx/rx.async-tests.ts | 2 +- rx/rx.async.d.ts | 2 +- rx/rx.backpressure.d.ts | 2 +- rx/rx.binding-lite.d.ts | 9 +-- rx/rx.binding.d.ts | 2 +- rx/rx.coincidence-lite.d.ts | 18 ++--- rx/rx.coincidence.d.ts | 2 +- rx/rx.d.ts | 4 +- rx/rx.experimental.d.ts | 82 +++++++++++------------ rx/rx.joinpatterns.d.ts | 2 +- rx/rx.lite.d.ts | 2 +- rx/rx.testing.d.ts | 2 +- rx/rx.time-lite.d.ts | 10 +++ rx/rx.time.d.ts | 9 ++- rx/rx.virtualtime.d.ts | 2 +- 18 files changed, 177 insertions(+), 118 deletions(-) diff --git a/rx/rx-lite.d.ts b/rx/rx-lite.d.ts index 3ea8c6ed88..851545fb80 100644 --- a/rx/rx-lite.d.ts +++ b/rx/rx-lite.d.ts @@ -50,7 +50,6 @@ declare module Rx { export module helpers { function noop(): void; function notDefined(value: any): boolean; - function isScheduler(value: any): boolean; function identity(value: T): T; function defaultNow(): number; function defaultComparer(left: any, right: any): boolean; @@ -117,6 +116,7 @@ declare module Rx { export interface IScheduler { now(): number; + isScheduler(value: any): boolean; schedule(action: () => void): IDisposable; scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; @@ -241,6 +241,23 @@ declare module Rx { combineLatest(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; combineLatest(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; combineLatest(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; concat(...sources: Observable[]): Observable; concat(...sources: IPromise[]): Observable; concat(sources: Observable[]): Observable; @@ -291,7 +308,7 @@ declare module Rx { do(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; doAction(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do tap(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do - + doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; doOnError(onError: (exception: any) => void, thisArg?: any): Observable; doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; @@ -305,7 +322,7 @@ declare module Rx { materialize(): Observable>; repeat(repeatCount?: number): Observable; retry(retryCount?: number): Observable; - scan(seed: TAcc, accumulator: (acc: TAcc, value: T) => TAcc): Observable; + scan(accumulator: (acc: TAcc, value: T, seed: TAcc) => TAcc): Observable; scan(accumulator: (acc: T, value: T) => T): Observable; skipLast(count: number): Observable; startWith(...values: T[]): Observable; @@ -322,12 +339,34 @@ declare module Rx { selectMany(selector: (value: T) => IPromise): Observable; selectMany(other: Observable): Observable; selectMany(other: IPromise): Observable; + selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany flatMap(other: Observable): Observable; // alias for selectMany flatMap(other: IPromise): Observable; // alias for selectMany + flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; @@ -336,30 +375,30 @@ declare module Rx { selectConcat(sequence: Observable): Observable; /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. */ selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. */ flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. * @param [thisArg] Object to use as this when executing callback. * @since 2.2.28 - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. */ switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch @@ -383,7 +422,7 @@ declare module Rx { * Converts an existing observable sequence to an ES6 Compatible Promise * @example * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * + * * // With config * Rx.config.Promise = RSVP.Promise; * var promise = Rx.Observable.return(42).toPromise(); @@ -470,36 +509,12 @@ declare module Rx { fromArray(array: T[], scheduler?: IScheduler): Observable; fromArray(array: { length: number;[index: number]: T; }, scheduler?: IScheduler): Observable; - /** - * Converts an iterable into an Observable sequence - * - * @example - * var res = Rx.Observable.fromIterable(new Map()); - * var res = Rx.Observable.fromIterable(function* () { yield 42; }); - * var res = Rx.Observable.fromIterable(new Set(), Rx.Scheduler.timeout); - * @param generator Generator to convert from. - * @param [scheduler] Scheduler to run the enumeration of the input sequence on. - * @returns The observable sequence whose elements are pulled from the given generator sequence. - */ - fromIterable(generator: () => { next(): { done: boolean; value?: T; }; }, scheduler?: IScheduler): Observable; - - /** - * Converts an iterable into an Observable sequence - * - * @example - * var res = Rx.Observable.fromIterable(new Map()); - * var res = Rx.Observable.fromIterable(new Set(), Rx.Scheduler.timeout); - * @param iterable Iterable to convert from. - * @param [scheduler] Scheduler to run the enumeration of the input sequence on. - * @returns The observable sequence whose elements are pulled from the given generator sequence. - */ - fromIterable(iterable: {}, scheduler?: IScheduler): Observable; // todo: can't describe ES6 Iterable via TypeScript type system generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; never(): Observable; /** * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * + * * @example * var res = Rx.Observable.of(1, 2, 3); * @since 2.2.28 @@ -508,7 +523,7 @@ declare module Rx { of(...values: T[]): Observable; /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. * @example * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); * @since 2.2.28 @@ -576,6 +591,38 @@ declare module Rx { combineLatest(souces: Observable[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; combineLatest(souces: IPromise[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: IPromise, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable, second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: Observable[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(souces: IPromise[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + concat(...sources: Observable[]): Observable; concat(...sources: IPromise[]): Observable; concat(sources: Observable[]): Observable; @@ -617,6 +664,8 @@ declare module Rx { * @returns An Observable sequence which wraps the existing promise success and failure. */ fromPromise(promise: IPromise): Observable; + + prototype: any; } export var Observable: ObservableStatic; @@ -625,11 +674,11 @@ declare module Rx { hasObservers(): boolean; } - export interface Subject extends ISubject { - } + export interface Subject extends ISubject { + } - interface SubjectStatic { - new (): Subject; + interface SubjectStatic { + new (): Subject; create(observer?: Observer, observable?: Observable): ISubject; } diff --git a/rx/rx.aggregates.d.ts b/rx/rx.aggregates.d.ts index 001d1b9932..313cb55917 100644 --- a/rx/rx.aggregates.d.ts +++ b/rx/rx.aggregates.d.ts @@ -40,17 +40,9 @@ declare module Rx { sequenceEqual(second: T[]): Observable; elementAt(index: number): Observable; - elementAtOrDefault(index: number, defaultValue?: T): Observable; - single(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - singleOrDefault(predicate?: (value: T, index: number, source: Observable) => boolean, defaultValue?: T, thisArg?: any): Observable; - first(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - firstOrDefault(predicate?: (value: T, index: number, source: Observable) => boolean, defaultValue?: T, thisArg?: any): Observable; - last(predicate?: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - lastOrDefault(predicate?: (value: T, index: number, source: Observable) => boolean, defaultValue?: T, thisArg?: any): Observable; - find(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; findIndex(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; } @@ -58,4 +50,4 @@ declare module Rx { declare module "rx.aggregates" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.async-lite.d.ts b/rx/rx.async-lite.d.ts index 94eb398007..8a725332f5 100644 --- a/rx/rx.async-lite.d.ts +++ b/rx/rx.async-lite.d.ts @@ -65,7 +65,9 @@ declare module Rx { (func: Function, context?: any): (...args: any[]) => Observable; }; - fromEvent(element: any, eventName: string, selector?: (arguments: any[]) => T): Observable; - fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[])=>T): Observable; + fromEvent(element: NodeList, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: Node, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEvent(element: {on: (name: string, cb: (e: any) => any) => void; off: (name: string, cb: (e: any) => any) => void}, eventName: string, selector?: (arguments: any[]) => T): Observable; + fromEventPattern(addHandler: (handler: Function) => void, removeHandler: (handler: Function) => void, selector?: (arguments: any[])=>T): Observable; } } diff --git a/rx/rx.async-tests.ts b/rx/rx.async-tests.ts index 4f8c102c4a..6fe10526c7 100644 --- a/rx/rx.async-tests.ts +++ b/rx/rx.async-tests.ts @@ -81,4 +81,4 @@ module Rx.Tests.Async { function startAsync() { var o: Rx.Observable = Rx.Observable.startAsync(() => >null); } -} \ No newline at end of file +} diff --git a/rx/rx.async.d.ts b/rx/rx.async.d.ts index 783f31d52b..f1af9a6000 100644 --- a/rx/rx.async.d.ts +++ b/rx/rx.async.d.ts @@ -40,4 +40,4 @@ declare module Rx { declare module "rx.async" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.backpressure.d.ts b/rx/rx.backpressure.d.ts index 18ab4ddd95..549cd870a2 100644 --- a/rx/rx.backpressure.d.ts +++ b/rx/rx.backpressure.d.ts @@ -8,4 +8,4 @@ declare module "rx.backpressure" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.binding-lite.d.ts b/rx/rx.binding-lite.d.ts index f896e260db..86db8922cb 100644 --- a/rx/rx.binding-lite.d.ts +++ b/rx/rx.binding-lite.d.ts @@ -7,6 +7,7 @@ declare module Rx { export interface BehaviorSubject extends Subject { + getValue(): T; } interface BehaviorSubjectStatic { @@ -43,10 +44,10 @@ declare module Rx { /** * Returns an observable sequence that shares a single subscription to the underlying sequence. * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * + * * @example * var res = source.share(); - * + * * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. */ share(): Observable; @@ -57,10 +58,10 @@ declare module Rx { /** * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue. * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - * + * * @example * var res = source.shareValue(42); - * + * * @param initialValue Initial value received by observers upon subscription. * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. */ diff --git a/rx/rx.binding.d.ts b/rx/rx.binding.d.ts index b93411a528..2bd4c5b01f 100644 --- a/rx/rx.binding.d.ts +++ b/rx/rx.binding.d.ts @@ -8,4 +8,4 @@ declare module "rx.binding" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.coincidence-lite.d.ts b/rx/rx.coincidence-lite.d.ts index 801e42168c..ca1cc73473 100644 --- a/rx/rx.coincidence-lite.d.ts +++ b/rx/rx.coincidence-lite.d.ts @@ -9,24 +9,24 @@ declare module Rx { interface Observable { /** - * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. - * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. + * Returns a new observable that triggers on the second and subsequent triggerings of the input observable. + * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair. * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs. * @returns An observable that triggers on successive pairs of observations from the input observable as an array. */ pairwise(): Observable; - /** + /** * Returns two observables which partition the observations of the source by the given function. - * The first will trigger observations for those values for which the predicate returns true. - * The second will trigger observations for those values where the predicate returns false. - * The predicate is executed once for each subscribed observer. - * Both also propagate all error observations arising from the source and each completes + * The first will trigger observations for those values for which the predicate returns true. + * The second will trigger observations for those values where the predicate returns false. + * The predicate is executed once for each subscribed observer. + * Both also propagate all error observations arising from the source and each completes * when the source completes. - * @param predicate + * @param predicate * The function to determine which output Observable will trigger a particular observation. * @returns - * An array of observables. The first triggers when the predicate returns true, + * An array of observables. The first triggers when the predicate returns true, * and the second triggers when the predicate returns false. */ partition(predicate: (value: T, index: number, source: Observable) => boolean, thisArg: any): Observable[]; diff --git a/rx/rx.coincidence.d.ts b/rx/rx.coincidence.d.ts index 87fa6a55b5..d06166224a 100644 --- a/rx/rx.coincidence.d.ts +++ b/rx/rx.coincidence.d.ts @@ -33,4 +33,4 @@ declare module Rx { declare module "rx.coincidence" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.d.ts b/rx/rx.d.ts index f1dc527d76..9b806119e4 100644 --- a/rx/rx.d.ts +++ b/rx/rx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS v2.2.28 +// Type definitions for RxJS v2.5.3 // Project: http://rx.codeplex.com/ // Definitions by: gsino , Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -39,7 +39,7 @@ declare module Rx { distinct(skipParameter: boolean, valueSerializer: (value: T) => string): Observable; distinct(keySelector?: (value: T) => TKey, keySerializer?: (key: TKey) => string): Observable; groupBy(keySelector: (value: T) => TKey, skipElementSelector?: boolean, keySerializer?: (key: TKey) => string): Observable>; - groupBy(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable>; + groupBy(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, keySerializer?: (key: TKey) => string): Observable>; groupByUntil(keySelector: (value: T) => TKey, skipElementSelector: boolean, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; groupByUntil(keySelector: (value: T) => TKey, elementSelector: (value: T) => TElement, durationSelector: (group: GroupedObservable) => Observable, keySerializer?: (key: TKey) => string): Observable>; } diff --git a/rx/rx.experimental.d.ts b/rx/rx.experimental.d.ts index 60aec86e1a..e80ca03294 100644 --- a/rx/rx.experimental.d.ts +++ b/rx/rx.experimental.d.ts @@ -29,13 +29,13 @@ declare module Rx { /** * Repeats source as long as condition holds emulating a do while loop. * @param condition The condition which determines if the source will be repeated. - * @returns An observable sequence which is repeated as long as the condition holds. + * @returns An observable sequence which is repeated as long as the condition holds. */ doWhile(condition: () => boolean): Observable; /** * Expands an observable sequence by recursively invoking selector. - * + * * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. * @returns An observable sequence containing all the elements produced by the recursive expansion. @@ -64,7 +64,7 @@ declare module Rx { interface ObservableStatic { /** * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; @@ -132,7 +132,7 @@ declare module Rx { * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => Observable): Observable; @@ -141,7 +141,7 @@ declare module Rx { * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; while(condition: () => boolean, source: IPromise): Observable; @@ -151,7 +151,7 @@ declare module Rx { * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; whileDo(condition: () => boolean, source: IPromise): Observable; @@ -159,14 +159,14 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; @@ -176,16 +176,16 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; case(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; @@ -193,14 +193,14 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; @@ -210,16 +210,16 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; case(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; @@ -227,14 +227,14 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; @@ -244,16 +244,16 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; switchCase(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; @@ -261,14 +261,14 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; @@ -278,23 +278,23 @@ declare module Rx { /** * Uses selector to determine which source in sources to use. * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; switchCase(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; /** * Runs all observable sequences in parallel and collect their last elements. - * + * * @example * res = Rx.Observable.forkJoin([obs1, obs2]); * @param sources Array of source sequences or promises. @@ -305,7 +305,7 @@ declare module Rx { /** * Runs all observable sequences in parallel and collect their last elements. - * + * * @example * res = Rx.Observable.forkJoin(obs1, obs2, ...); * @param args Source sequences or promises. @@ -318,4 +318,4 @@ declare module Rx { declare module "rx.experimental" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.joinpatterns.d.ts b/rx/rx.joinpatterns.d.ts index ce251a2db7..fc20f82547 100644 --- a/rx/rx.joinpatterns.d.ts +++ b/rx/rx.joinpatterns.d.ts @@ -57,4 +57,4 @@ declare module Rx { declare module "rx.joinpatterns" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.lite.d.ts b/rx/rx.lite.d.ts index f6785a1a75..66ec678498 100644 --- a/rx/rx.lite.d.ts +++ b/rx/rx.lite.d.ts @@ -12,4 +12,4 @@ declare module "rx.lite" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.testing.d.ts b/rx/rx.testing.d.ts index 466243784f..58b074f756 100644 --- a/rx/rx.testing.d.ts +++ b/rx/rx.testing.d.ts @@ -61,4 +61,4 @@ declare module Rx { declare module "rx.testing" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.time-lite.d.ts b/rx/rx.time-lite.d.ts index 3642377f82..f7a902685e 100644 --- a/rx/rx.time-lite.d.ts +++ b/rx/rx.time-lite.d.ts @@ -19,11 +19,21 @@ declare module Rx { export interface Observable { delay(dueTime: Date, scheduler?: IScheduler): Observable; delay(dueTime: number, scheduler?: IScheduler): Observable; + + debounce(dueTime: number, scheduler?: IScheduler): Observable; + throttleWithTimeout(dueTime: number, scheduler?: IScheduler): Observable; + /** + * @deprecated use #debounce or #throttleWithTimeout instead. + */ throttle(dueTime: number, scheduler?: IScheduler): Observable; + timeInterval(scheduler?: IScheduler): Observable>; + timestamp(scheduler?: IScheduler): Observable>; + sample(interval: number, scheduler?: IScheduler): Observable; sample(sampler: Observable, scheduler?: IScheduler): Observable; + timeout(dueTime: Date, other?: Observable, scheduler?: IScheduler): Observable; timeout(dueTime: number, other?: Observable, scheduler?: IScheduler): Observable; } diff --git a/rx/rx.time.d.ts b/rx/rx.time.d.ts index 3da66b95c5..2e3ea0a090 100644 --- a/rx/rx.time.d.ts +++ b/rx/rx.time.d.ts @@ -13,7 +13,12 @@ declare module Rx { delayWithSelector(subscriptionDelay: number, delayDurationSelector: (item: T) => number): Observable; timeoutWithSelector(firstTimeout: Observable, timeoutdurationSelector?: (item: T) => Observable, other?: Observable): Observable; - throttleWithSelector(throttleDurationSelector: (item: T) => Observable): Observable; + + debounceWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; + /** + * @deprecated use #debounceWithSelector instead. + */ + throttleWithSelector(debounceDurationSelector: (item: T) => Observable): Observable; skipLastWithTime(duration: number, scheduler?: IScheduler): Observable; takeLastWithTime(duration: number, timerScheduler?: IScheduler, loopScheduler?: IScheduler): Observable; @@ -58,4 +63,4 @@ declare module Rx { declare module "rx.time" { export = Rx; -} \ No newline at end of file +} diff --git a/rx/rx.virtualtime.d.ts b/rx/rx.virtualtime.d.ts index 25e8940746..bac31a0d37 100644 --- a/rx/rx.virtualtime.d.ts +++ b/rx/rx.virtualtime.d.ts @@ -38,4 +38,4 @@ declare module Rx { declare module "rx.virtualtime" { export = Rx; -} \ No newline at end of file +} From 5d0102d544c46020090d8cea9fb6ec82e7997650 Mon Sep 17 00:00:00 2001 From: Almouro Date: Sat, 15 Aug 2015 20:20:49 +0200 Subject: [PATCH 07/86] Add ability to create element without using load --- cheerio/cheerio-tests.ts | 2 ++ cheerio/cheerio.d.ts | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cheerio/cheerio-tests.ts b/cheerio/cheerio-tests.ts index af671cd009..c02b1ed265 100644 --- a/cheerio/cheerio-tests.ts +++ b/cheerio/cheerio-tests.ts @@ -2,6 +2,8 @@ import cheerio = require("cheerio"); +cheerio(''); + var $ = cheerio.load(""); var $el = $('selector'); var $multiEl = $('seletor', 'selector', 'selector'); diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index fc8e5a70ff..bbd47810fd 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -172,11 +172,7 @@ interface CheerioOptionsInterface { normalizeWhitespace?: boolean; } -interface CheerioStatic { - // Document References - // Cheerio https://github.com/cheeriojs/cheerio - // JQuery http://api.jquery.com - +interface CheerioSelector { (selector: string): Cheerio; (selector: string, context: string): Cheerio; (selector: string, context: CheerioElement): Cheerio; @@ -187,7 +183,12 @@ interface CheerioStatic { (selector: string, context: CheerioElement[], root: string): Cheerio; (selector: string, context: Cheerio, root: string): Cheerio; (selector: any): Cheerio; +} +interface CheerioStatic extends CheerioSelector { + // Document References + // Cheerio https://github.com/cheeriojs/cheerio + // JQuery http://api.jquery.com xml(): string; root(): Cheerio; contains(container: CheerioElement, contained: CheerioElement): boolean; @@ -213,6 +214,12 @@ interface CheerioElement { root: CheerioElement; } -declare module "cheerio" { - export function load(html: string, options?: CheerioOptionsInterface): CheerioStatic; +interface CheerioAPI extends CheerioSelector { + load(html: string, options?: CheerioOptionsInterface): CheerioStatic; +} + +declare var cheerio:CheerioAPI; + +declare module "cheerio" { + export = CheerioAPI; } From 2004f8fc47187af24b8d5ba9ae96e6ebf81f6a35 Mon Sep 17 00:00:00 2001 From: Almouro Date: Sat, 15 Aug 2015 20:21:35 +0200 Subject: [PATCH 08/86] Updated definition and tests to reflect Cheerio doc --- cheerio/cheerio-tests.ts | 335 ++++++++++++++++++++++++++++++++------- cheerio/cheerio.d.ts | 46 +++++- 2 files changed, 322 insertions(+), 59 deletions(-) diff --git a/cheerio/cheerio-tests.ts b/cheerio/cheerio-tests.ts index c02b1ed265..6cc9e64856 100644 --- a/cheerio/cheerio-tests.ts +++ b/cheerio/cheerio-tests.ts @@ -1,67 +1,294 @@ /// -import cheerio = require("cheerio"); +import cheerio = require('cheerio'); -cheerio(''); +/* + * LOADING + */ +let html = +`
    +
  • Apple
  • +
  • Orange
  • +
  • Pear
  • + +
`; -var $ = cheerio.load(""); -var $el = $('selector'); -var $multiEl = $('seletor', 'selector', 'selector'); +// Preferred Method +var $ = cheerio.load(html); +// Directly load element +cheerio(html); +cheerio('ul', html); +cheerio('li', 'ul', html); -$el.addClass("class").addClass("test"); -$el.hasClass("test"); -$el.removeClass("class").removeClass("test"); - -$el.attr('class'); -$el.attr('class', 'test'); -$el.removeAttr("class").removeAttr("test"); - -$el.find("ul").find("> li"); - -$el.parent().parent(); -$el.next().next(); -$el.prev().prev(); -$el.siblings().siblings(); - -$el.children().children(); -$el.children("li").children("a"); - -$el.children().each((index, element) => { - return $(element).find('t'); +$ = cheerio.load(html, { + normalizeWhitespace: true, + xmlMode: true }); -$el.children().map((index, element) => { - return $(element).find('t'); +$ = cheerio.load(html, { + normalizeWhitespace: true, + xmlMode: true, + decodeEntities: true, + lowercaseTags: true, + lowerCaseAttributeNames: true, + recognizeCDATA: true, + recognizeSelfClosing: true }); -$el.children().filter((index) => { - return $el.children().eq(index).find('t').length >= 0; -}); +/** + * Selectors + */ +var $el = $('.class'); +var $multiEl = $('selector', 'selector', 'selector'); -$el.filter('span').filter('li'); +/** + * Attributes + */ -$el.first().last().find('t'); - -$('div').eq(0).find('b'); - -$('#id').append("test html", "other html").find('a'); -$('#id').prepend("test html", "other html").find('a'); -$('#id').after("test html", "other html").find('a'); -$('#id').before("test html", "other html").find('a'); - -$el.remove('div').remove('a'); - -$('#id').replaceWith('some html').parent(); -$('#id').empty().parent(); - -$el.html(); -$el.html("").find('div'); - -$el.text(); -$el.text('some text'); - -$el.toArray(); -$el.clone().find('a').parent(); -$.root().find('a'); +// attr +$el.attr('id'); +$el.attr('id', 'favorite').html(); +// data $el.data(); +$el.data('apple-color'); +$el.data('kind', 'mac'); + +// val +$('input[type="text"]').val(); +$('input[type="text"]').val('test').html(); + +// removeAttr +$el.removeAttr('class').html(); + +// hasClass, addClass, removeClass, toggleClass +$el.addClass('class').addClass('test'); +$el.hasClass('test'); +$el.removeClass('class').removeClass('test'); +$el.addClass('red').removeClass().html(); +$el.toggleClass('fruit green red').html(); + +// is +$el.is('#id'); +$el.is($el); +$el.is(() => { + return true; +}); + +/** + * Forms + */ +// serializeArray +$('
').serializeArray(); + +/** + * Traversing + */ + // find +$el.find('li').length; +$el.find($('.apple')).length; + +// .parent([selector]) +$el.parent().attr('id'); +$el.parent('.class').attr('id'); + +// .parents([selector]) +$el.parents().length; +$el.parents('.class').length; + +// .parentsUntil([selector][,filter]) +$el.parentsUntil().length; +$el.parentsUntil('.class').length; + +// .closest(selector) +$el.closest(); +$el.closest('.class'); + +// .next([selector]) +$el.next().hasClass('class'); +$el.next('.class').hasClass('class'); + +// .nextAll([selector]) +$el.nextAll().length; +$el.nextAll('.class').length; + +// .nextUntil([selector], [filter]) +$el.nextUntil(); +$el.nextUntil('.class'); + +// .prev([selector]) +$el.prev().hasClass('class'); +$el.prev('.class').hasClass('class'); + +// .prevAll([selector]) +$el.prevAll().length; +$el.prevAll('.class').length; + +// .prevUntil([selector], [filter]) +$el.prevUntil(); +$el.prevUntil('.class'); + +// .slice( start, [end] ) +$el.slice(1).eq(0).text(); +$el.slice(1, 2).length; + +// .siblings([selector]) +$el.siblings().length; +$el.siblings('.class').length; + +// .children([selector]) +$el.children().length; +$el.children('.class').text(); + +// .contents() +$el.contents().length; + +// .each( function(index, element) ) +$el.each((i, el) => { + $(el).html(); +}); + +// .map( function(index, element) ) +$el.map((i, el) => { + return $(el).text(); +}).get().join(' '); + +// .filter +$ = cheerio.load(html); +$el.filter('.class').attr('class'); +$el.filter($('.class')).attr('class'); +$el.filter($('.class')[0]).attr('class'); + +$el.filter((i, el) => { + return $(el).attr('class') === 'class'; +}).attr('class'); + +// .not +$el.not('.class').length; +$el.not($('.class')).length; +$el.not($('.class')[0]).length; + +$el.not((i, el) => { + return $(el).attr('class') === 'class'; +}).length; + +// .has +$el.has('.class').attr('id'); +$el.has($el[0]).attr('id'); + +// .first() +$el.children().first().text(); + +// .last() +$el.children().last().text(); + +// .eq( i ) +$el.eq(0).text(); +$el.eq(-1).text(); + +// .get( [i] ) +$el.get(0).tagName; +$el.get().length; + +// .index() +// .index( selector ) +// .index( nodeOrSelection ) +$el.index(); +$el.index('li'); +$el.index($('#fruit, li')); + +// .end() +$el.eq(0).end().length; + +// .add +$el.add('.class').length + +// .addBack( [filter] ) +$el.eq(0).addBack().length +$el.eq(0).addBack('.class').length + +/** + * Manipulation + */ + +// .append( content, [content, ...] ) +$el.append('
  • Plum
  • ').html(); +$el.append('
  • Plum
  • ', '
  • Plum
  • ').html(); + +// .prepend( content, [content, ...] ) +$el.prepend('
  • Plum
  • ').html(); +$el.prepend('
  • Plum
  • ', '
  • Plum
  • ').html(); + +// .after( content, [content, ...] ) +$el.after('
  • Plum
  • ').html(); +$el.after('
  • Plum
  • ', '
  • Plum
  • ').html(); + +// .insertAfter( content ) +$('
  • Plum
  • ').insertAfter('.class').html(); + +// .before( content, [content, ...] ) +$el.before('
  • Plum
  • ').html(); +$el.before('
  • Plum
  • ', '
  • Plum
  • ').html(); + +// .insertBefore( content ) +$('
  • Plum
  • ').insertBefore('.class').html(); + +// .remove( [selector] ) +$el.remove().html(); +$el.remove('.class').html(); + +// .replaceWith( content ) +$el.replaceWith($('
  • Plum
  • ')).html(); + +// .empty() +$el.empty().html(); + +// .html( [htmlString] ) +$el.html(); +$el.html('
  • Mango
  • ').html(); + +// .text( [textString] ) +$el.text(); +$el.text('text'); + +// .wrap( content ) +// See https://github.com/cheeriojs/cheerio/issues/731 +// $el.wrap($('
    ')).html(); + +// .css +$el.css('width'); +$el.css(['width', 'height']); +$el.css('width', '50px'); + +/** + * Rendering + */ +$.html(); +$.html('.class'); +$.xml(); + +/** + * Miscellaneous + */ + +// .clone() #### +$el.clone().html(); + +/** + * Utilities + */ + +// $.root +$.root().append('
      ').html(); + +// $.contains( container, contained ) +$.contains($el[0], $el[0]); + +// $.parseHTML( data [, context ] [, keepScripts ] ) +$.parseHTML(html); +$.parseHTML(html, null, true); + +/** + * Not in doc + */ +$el.toArray(); diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index bbd47810fd..840cceef5c 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -17,12 +17,17 @@ interface Cheerio { attr(name: string, value: any): Cheerio; data(): any; + data(name: string): any; + data(name: string, value: any): any; val(): string; val(value: string): Cheerio; removeAttr(name: string): Cheerio; + has(selector: string): Cheerio; + has(element: CheerioElement): Cheerio; + hasClass(className: string): boolean; addClass(classNames: string): Cheerio; @@ -41,6 +46,9 @@ interface Cheerio { is(selection: Cheerio): boolean; is(func: (index: number, element: CheerioElement) => boolean): boolean; + // Form + serializeArray(): {name: string, value: string}[]; + // Traversing find(selector: string): Cheerio; @@ -52,10 +60,12 @@ interface Cheerio { parentsUntil(element: CheerioElement, filter?: string): Cheerio; parentsUntil(element: Cheerio, filter?: string): Cheerio; + closest(): Cheerio; closest(selector: string): Cheerio; next(selector?: string): Cheerio; nextAll(): Cheerio; + nextAll(selector: string): Cheerio; nextUntil(selector?: string, filter?: string): Cheerio; nextUntil(element: CheerioElement, filter?: string): Cheerio; @@ -63,6 +73,7 @@ interface Cheerio { prev(selector?: string): Cheerio; prevAll(): Cheerio; + prevAll(selector: string): Cheerio; prevUntil(selector?: string, filter?: string): Cheerio; prevUntil(element: CheerioElement, filter?: string): Cheerio; @@ -83,15 +94,24 @@ interface Cheerio { filter(selection: Cheerio): Cheerio; filter(element: CheerioElement): Cheerio; filter(elements: CheerioElement[]): Cheerio; - filter(func: (index: number) => boolean): Cheerio; + filter(func: (index: number, element: CheerioElement) => boolean): Cheerio; + + not(selector: string): Cheerio; + not(selection: Cheerio): Cheerio; + not(element: CheerioElement): Cheerio; + not(func: (index: number, element: CheerioElement) => boolean): Cheerio; first(): Cheerio; last(): Cheerio; eq(index: number): Cheerio; - get(): Document[]; - get(index: number): Document; + get(): CheerioElement[]; + get(index: number): CheerioElement; + + index(): number; + index(selector: string): number; + index(selection: Cheerio): number; end(): Cheerio; @@ -101,6 +121,9 @@ interface Cheerio { add(elements: CheerioElement[]): Cheerio; add(selection: Cheerio): Cheerio; + addBack():Cheerio; + addBack(filter: string):Cheerio; + // Manipulation append(content: string, ...contents: any[]): Cheerio; @@ -118,11 +141,19 @@ interface Cheerio { after(content: Document[], ...contents: any[]): Cheerio; after(content: Cheerio, ...contents: any[]): Cheerio; + insertAfter(content: string): Cheerio; + insertAfter(content: Document): Cheerio; + insertAfter(content: Cheerio): Cheerio; + before(content: string, ...contents: any[]): Cheerio; before(content: Document, ...contents: any[]): Cheerio; before(content: Document[], ...contents: any[]): Cheerio; before(content: Cheerio, ...contents: any[]): Cheerio; + insertBefore(content: string): Cheerio; + insertBefore(content: Document): Cheerio; + insertBefore(content: Cheerio): Cheerio; + remove(selector?: string): Cheerio; replaceWith(content: string): Cheerio; @@ -138,6 +169,11 @@ interface Cheerio { text(): string; text(text: string): Cheerio; + // See https://github.com/cheeriojs/cheerio/issues/731 + /*wrap(content: string): Cheerio; + wrap(content: Document): Cheerio; + wrap(content: Cheerio): Cheerio;*/ + css(propertyName: string): string; css(propertyNames: string[]): string[]; css(propertyName: string, value: string): Cheerio; @@ -203,7 +239,7 @@ interface CheerioStatic extends CheerioSelector { interface CheerioElement { // Document References // Node Console - + tagName: string; type: string; name: string; attribs: Object; @@ -221,5 +257,5 @@ interface CheerioAPI extends CheerioSelector { declare var cheerio:CheerioAPI; declare module "cheerio" { - export = CheerioAPI; + export = cheerio; } From 3e6f9cbd89c1e8df81a0ffb16cbc8bab965881ae Mon Sep 17 00:00:00 2001 From: Almouro Date: Sun, 16 Aug 2015 11:51:43 +0200 Subject: [PATCH 09/86] Support ES6 import syntax --- cheerio/cheerio-tests.ts | 2 +- cheerio/cheerio.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cheerio/cheerio-tests.ts b/cheerio/cheerio-tests.ts index 6cc9e64856..c41939a301 100644 --- a/cheerio/cheerio-tests.ts +++ b/cheerio/cheerio-tests.ts @@ -1,6 +1,6 @@ /// -import cheerio = require('cheerio'); +import cheerio from 'cheerio'; /* * LOADING diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index 840cceef5c..8118d33669 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -257,5 +257,5 @@ interface CheerioAPI extends CheerioSelector { declare var cheerio:CheerioAPI; declare module "cheerio" { - export = cheerio; + export default cheerio; } From 81166431feac33c727dc0b02014b7265efa85c32 Mon Sep 17 00:00:00 2001 From: Almouro Date: Sun, 16 Aug 2015 12:12:43 +0200 Subject: [PATCH 10/86] Updated Cheerio Element definition according to doc --- cheerio/cheerio.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index 8118d33669..57d526d1b2 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -244,10 +244,15 @@ interface CheerioElement { name: string; attribs: Object; children: CheerioElement[]; + childNodes: CheerioElement[]; + lastChild: CheerioElement; next: CheerioElement; + nextSibling: CheerioElement; prev: CheerioElement; + previousSibling: CheerioElement; parent: CheerioElement; - root: CheerioElement; + parentNode: CheerioElement; + nodeValue: string; } interface CheerioAPI extends CheerioSelector { From 2daf450b8f86f09f6b0de1b5f86fce3cf185c687 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Aug 2015 14:21:19 +0200 Subject: [PATCH 11/86] updated enabled as per angular changes (after 1.3.14 > 1.4.0) --- angularjs/angular-animate.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 1ecc3d0d76..35fe10ca98 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -30,11 +30,11 @@ declare module angular.animate { /** * Globally enables / disables animations. * - * @param value If provided then set the animation on or off. * @param element If provided then the element will be used to represent the enable/disable operation. + * @param value If provided then set the animation on or off. * @returns current animation state */ - enabled(value?: boolean, element?: JQuery): boolean; + enabled(element?: JQuery, value?: boolean): boolean; /** * Performs an inline animation on the element. From a22c78d619f18548081e69ce68b950dc6265a74a Mon Sep 17 00:00:00 2001 From: Alexander Horn Date: Mon, 24 Aug 2015 21:00:14 +0200 Subject: [PATCH 12/86] mysql: Added .format() overload Added the .format() overload thats accepts an object for the values parameter --- mysql/mysql-tests.ts | 4 ++++ mysql/mysql.d.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/mysql/mysql-tests.ts b/mysql/mysql-tests.ts index f671a63726..97df14dbf4 100644 --- a/mysql/mysql-tests.ts +++ b/mysql/mysql-tests.ts @@ -109,6 +109,10 @@ var sql = "SELECT * FROM ?? WHERE ?? = ?"; var inserts = ['users', 'id', userId]; sql = mysql.format(sql, inserts); +var sql = "INSERT INTO posts SET ?"; +var post = { id: 1, title: 'Hello MySQL' }; +sql = mysql.format(sql, post); + connection.config.queryFormat = function (query, values) { if (!values) return query; return query.replace(/\:(\w+)/g, function (txt: string, key: string) { diff --git a/mysql/mysql.d.ts b/mysql/mysql.d.ts index 9b6ed79988..715c799a2f 100644 --- a/mysql/mysql.d.ts +++ b/mysql/mysql.d.ts @@ -15,6 +15,7 @@ declare module "mysql" { function escape(value: any): string; function format(sql: string): string; function format(sql: string, values: Array): string; + function format(sql: string, values: any): string; interface IMySql { createConnection(connectionUri: string): IConnection; @@ -24,6 +25,7 @@ declare module "mysql" { escape(value: any): string; format(sql: string): string; format(sql: string, values: Array): string; + format(sql: string, values: any): string; } interface IConnectionStatic { @@ -69,6 +71,7 @@ declare module "mysql" { format(sql: string): string; format(sql: string, values: Array): string; + format(sql: string, values: any): string; on(ev: string, callback: (...args: any[]) => void): IConnection; on(ev: 'error', callback: (err: IError) => void): IConnection; From fbdc1b91125a87e62be3803f58aabb176cc2fd50 Mon Sep 17 00:00:00 2001 From: tkQubo Date: Fri, 21 Aug 2015 12:46:12 +0900 Subject: [PATCH 13/86] Move IGulpPlugin into gulp namespace, Gulp extends orchestrator, and gulp#watch method returns NodeJS.EventEmitter --- gulp-protractor/gulp-protractor.d.ts | 2 + gulp-tsd/gulp-tsd-tests.ts | 2 +- gulp-tsd/gulp-tsd.d.ts | 1 + gulp/gulp-tests.ts | 7 +- gulp/gulp.d.ts | 541 ++++++++++++++------------- run-sequence/run-sequence-tests.ts | 2 +- run-sequence/run-sequence.d.ts | 1 + 7 files changed, 291 insertions(+), 265 deletions(-) diff --git a/gulp-protractor/gulp-protractor.d.ts b/gulp-protractor/gulp-protractor.d.ts index d0317e2e2d..4ac814780d 100644 --- a/gulp-protractor/gulp-protractor.d.ts +++ b/gulp-protractor/gulp-protractor.d.ts @@ -7,6 +7,8 @@ /// declare module 'gulp-protractor' { + import gulp = require('gulp'); + interface IOptions { configFile?: string; args?: Array; diff --git a/gulp-tsd/gulp-tsd-tests.ts b/gulp-tsd/gulp-tsd-tests.ts index 9475ace657..a7c20519cd 100644 --- a/gulp-tsd/gulp-tsd-tests.ts +++ b/gulp-tsd/gulp-tsd-tests.ts @@ -9,7 +9,7 @@ gulp.task("tsd", () => { .pipe(tsd()); }); -gulp.task("tsd:options", callback => { +gulp.task("tsd:options", (callback: any) => { tsd({ command: "reinstall", config: "tsd.json" diff --git a/gulp-tsd/gulp-tsd.d.ts b/gulp-tsd/gulp-tsd.d.ts index 68a4c67282..20d279329e 100644 --- a/gulp-tsd/gulp-tsd.d.ts +++ b/gulp-tsd/gulp-tsd.d.ts @@ -7,6 +7,7 @@ /// declare module "gulp-tsd" { + import gulp = require('gulp'); interface IOptions { command?: string; diff --git a/gulp/gulp-tests.ts b/gulp/gulp-tests.ts index 07a92fc919..2a69d40ca5 100644 --- a/gulp/gulp-tests.ts +++ b/gulp/gulp-tests.ts @@ -4,8 +4,8 @@ import gulp = require("gulp"); import browserSync = require("browser-sync"); -var typescript: IGulpPlugin = null; // this would be the TypeScript compiler -var jasmine: IGulpPlugin = null; // this would be the jasmine test runner +var typescript: gulp.IGulpPlugin = null; // this would be the TypeScript compiler +var jasmine: gulp.IGulpPlugin = null; // this would be the jasmine test runner gulp.task('compile', function() { @@ -31,6 +31,7 @@ gulp.task('test', ['compile', 'compile2'], function() gulp.task('default', ['compile', 'test']); + var opts = {}; gulp.watch('*.html', 'compile'); @@ -66,3 +67,5 @@ gulp.task('serve', ['compile'], () => { var browser = browserSync.create(); gulp.watch(['*.html', '*.ts'], ['compile', browser.reload]); }); + +gulp.start('test', 'compile'); diff --git a/gulp/gulp.d.ts b/gulp/gulp.d.ts index 13c12a811f..abb8978d1c 100644 --- a/gulp/gulp.d.ts +++ b/gulp/gulp.d.ts @@ -4,268 +4,287 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// - -declare module gulp { - - /** - * Options to pass to node-glob through glob-stream. - * Specifies two options in addition to those used by node-glob: - * https://github.com/isaacs/node-glob#options - */ - interface ISrcOptions { - /** - * Setting this to false will return file.contents as null - * and not read the file at all. - * Default: true. - */ - read?: boolean; - - /** - * Setting this to false will return file.contents as a stream and not buffer files. - * This is useful when working with large files. - * Note: Plugins might not implement support for streams. - * Default: true. - */ - buffer?: boolean; - - /** - * The base path of a glob. - * - * Default is everything before a glob starts. - */ - base?: string; - - /** - * The current working directory in which to search. - * Defaults to process.cwd(). - */ - cwd?: string; - - /** - * The place where patterns starting with / will be mounted onto. - * Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.) - */ - root?: string; - - /** - * Include .dot files in normal matches and globstar matches. - * Note that an explicit dot in a portion of the pattern will always match dot files. - */ - dot?: boolean; - - /** - * By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid - * filesystem path is returned. Set this flag to disable that behavior. - */ - nomount?: boolean; - - /** - * Add a / character to directory matches. Note that this requires additional stat calls. - */ - mark?: boolean; - - /** - * Don't sort the results. - */ - nosort?: boolean; - - /** - * Set to true to stat all results. This reduces performance somewhat, and is completely unnecessary, unless - * readdir is presumed to be an untrustworthy indicator of file existence. It will cause ELOOP to be triggered one - * level sooner in the case of cyclical symbolic links. - */ - stat?: boolean; - - /** - * When an unusual error is encountered when attempting to read a directory, a warning will be printed to stderr. - * Set the silent option to true to suppress these warnings. - */ - silent?: boolean; - - /** - * When an unusual error is encountered when attempting to read a directory, the process will just continue on in - * search of other matches. Set the strict option to raise an error in these cases. - */ - strict?: boolean; - - /** - * See cache property above. Pass in a previously generated cache object to save some fs calls. - */ - cache?: boolean; - - /** - * A cache of results of filesystem information, to prevent unnecessary stat calls. - * While it should not normally be necessary to set this, you may pass the statCache from one glob() call to the - * options object of another, if you know that the filesystem will not change between calls. - */ - statCache?: boolean; - - /** - * Perform a synchronous glob search. - */ - sync?: boolean; - - /** - * In some cases, brace-expanded patterns can result in the same file showing up multiple times in the result set. - * By default, this implementation prevents duplicates in the result set. Set this flag to disable that behavior. - */ - nounique?: boolean; - - /** - * Set to never return an empty set, instead returning a set containing the pattern itself. - * This is the default in glob(3). - */ - nonull?: boolean; - - /** - * Perform a case-insensitive match. Note that case-insensitive filesystems will sometimes result in glob returning - * results that are case-insensitively matched anyway, since readdir and stat will not raise an error. - */ - nocase?: boolean; - - /** - * Set to enable debug logging in minimatch and glob. - */ - debug?: boolean; - - /** - * Set to enable debug logging in glob, but not minimatch. - */ - globDebug?: boolean; - } - - interface IDestOptions { - /** - * The output folder. Only has an effect if provided output folder is relative. - * Default: process.cwd() - */ - cwd?: string; - - /** - * Octal permission string specifying mode for any folders that need to be created for output folder. - * Default: 0777. - */ - mode?: string; - } - - /** - * Options that are passed to gaze. - * https://github.com/shama/gaze - */ - interface IWatchOptions { - /** Interval to pass to fs.watchFile. */ - interval?: number; - /** Delay for events called in succession for the same file/event. */ - debounceDelay?: number; - /** Force the watch mode. Either 'auto' (default), 'watch' (force native events), or 'poll' (force stat polling). */ - mode?: string; - /** The current working directory to base file patterns from. Default is process.cwd().. */ - cwd?: string; - } - - interface IWatchEvent { - /** The type of change that occurred, either added, changed or deleted. */ - type: string; - /** The path to the file that triggered the event. */ - path: string; - } - - /** - * Callback to be called on each watched file change. - */ - interface IWatchCallback { - (event:IWatchEvent): void; - } - - interface ITaskCallback { - /** - * Defines a task. - * Tasks may be made asynchronous if they are passing a callback or return a promise or a stream. - * @param cb callback used to signal asynchronous completion. Caller includes err in case of error. - */ - (cb?:(err?:any)=>void): any; - } - - interface EventEmitter { - any: any; - } - - interface Gulp { - /** - * Define a task. - * - * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. - * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). - */ - task(name:string, fn:ITaskCallback): any; - - /** - * Define a task. - * - * @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them. - * @param dep an array of tasks to be executed and completed before your task will run. - * @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()). - */ - task(name:string, dep:string[], fn?:ITaskCallback): any; - - - /** - * Takes a glob and represents a file structure. Can be piped to plugins. - * @param glob a glob string, using node-glob syntax - * @param opt an optional option object - */ - src(glob:string, opt?:ISrcOptions): NodeJS.ReadWriteStream; - - /** - * Takes a glob and represents a file structure. Can be piped to plugins. - * @param glob an array of glob strings, using node-glob syntax - * @param opt an optional option object - */ - src(glob:string[], opt?:ISrcOptions): NodeJS.ReadWriteStream; - - - /** - * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders. - * Folders that don't exist will be created. - * - * @param outFolder the path (output folder) to write files to. - * @param opt - */ - dest(outFolder:string, opt?:IDestOptions): NodeJS.ReadWriteStream; - - /** - * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders. - * Folders that don't exist will be created. - * - * @param outFolder a function that converts a vinyl File instance into an output path - * @param opt - */ - dest(outFolder:(file:string)=>string, opt?:IDestOptions): NodeJS.ReadWriteStream; - - - /** - * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. - * - * @param glob a single glob or array of globs that indicate which files to watch for changes. - * @param opt options, that are passed to the gaze library. - * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with gulp.task(). - */ - watch(glob:string, fn:(IWatchCallback|string)): EventEmitter; - watch(glob:string, fn:(IWatchCallback|string)[]): EventEmitter; - watch(glob:string, opt:IWatchOptions, fn:(IWatchCallback|string)): EventEmitter; - watch(glob:string, opt:IWatchOptions, fn:(IWatchCallback|string)[]): EventEmitter; - watch(glob:string[], fn:(IWatchCallback|string)): EventEmitter; - watch(glob:string[], fn:(IWatchCallback|string)[]): EventEmitter; - watch(glob:string[], opt:IWatchOptions, fn:(IWatchCallback|string)): EventEmitter; - watch(glob:string[], opt:IWatchOptions, fn:(IWatchCallback|string)[]): EventEmitter; - } -} +/// declare module "gulp" { - var _tmp:gulp.Gulp; - export = _tmp; -} + import Orchestrator = require("orchestrator"); -interface IGulpPlugin { - (...args: any[]): NodeJS.ReadWriteStream; + namespace gulp { + interface Gulp extends Orchestrator { + /** + * Define a task + * @param name The name of the task. + * @param deps An array of task names to be executed and completed before your task will run. + * @param fn The function that performs the task's operations. For asynchronous tasks, you need to provide a hint when the task is complete: + *
        + *
      • Take in a callback
      • + *
      • Return a stream or a promise
      • + *
      + */ + task: Orchestrator.AddMethod; + /** + * Emits files matching provided glob or an array of globs. Returns a stream of Vinyl files that can be piped to plugins. + * @param glob Glob or array of globs to read. + * @param opt Options to pass to node-glob through glob-stream. + */ + src: SrcMethod; + /** + * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders. + * Folders that don't exist will be created. + * + * @param outFolder The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance. + * @param opt + */ + dest: DestMethod; + /** + * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. + * + * @param glob a single glob or array of globs that indicate which files to watch for changes. + * @param opt options, that are passed to the gaze library. + * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). + */ + watch: WatchMethod; + } + + interface IGulpPlugin { + (...args: any[]): NodeJS.ReadWriteStream; + } + + interface WatchMethod { + /** + * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. + * + * @param glob a single glob or array of globs that indicate which files to watch for changes. + * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). + */ + (glob: string|string[], fn: (IWatchCallback|string)): NodeJS.EventEmitter; + /** + * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. + * + * @param glob a single glob or array of globs that indicate which files to watch for changes. + * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). + */ + (glob: string|string[], fn: (IWatchCallback|string)[]): NodeJS.EventEmitter; + /** + * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. + * + * @param glob a single glob or array of globs that indicate which files to watch for changes. + * @param opt options, that are passed to the gaze library. + * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). + */ + (glob: string|string[], opt: IWatchOptions, fn: (IWatchCallback|string)): NodeJS.EventEmitter; + /** + * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. + * + * @param glob a single glob or array of globs that indicate which files to watch for changes. + * @param opt options, that are passed to the gaze library. + * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). + */ + (glob: string|string[], opt: IWatchOptions, fn: (IWatchCallback|string)[]): NodeJS.EventEmitter; + + } + + interface DestMethod { + /** + * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders. + * Folders that don't exist will be created. + * + * @param outFolder The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance. + * @param opt + */ + (outFolder: string|((file:string)=>string), opt?: IDestOptions): NodeJS.ReadWriteStream; + } + + interface SrcMethod { + /** + * Emits files matching provided glob or an array of globs. Returns a stream of Vinyl files that can be piped to plugins. + * @param glob Glob or array of globs to read. + * @param opt Options to pass to node-glob through glob-stream. + */ + (glob: string|string[], opt?: ISrcOptions): NodeJS.ReadWriteStream; + } + + /** + * Options to pass to node-glob through glob-stream. + * Specifies two options in addition to those used by node-glob: + * https://github.com/isaacs/node-glob#options + */ + interface ISrcOptions { + /** + * Setting this to false will return file.contents as null + * and not read the file at all. + * Default: true. + */ + read?: boolean; + + /** + * Setting this to false will return file.contents as a stream and not buffer files. + * This is useful when working with large files. + * Note: Plugins might not implement support for streams. + * Default: true. + */ + buffer?: boolean; + + /** + * The base path of a glob. + * + * Default is everything before a glob starts. + */ + base?: string; + + /** + * The current working directory in which to search. + * Defaults to process.cwd(). + */ + cwd?: string; + + /** + * The place where patterns starting with / will be mounted onto. + * Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.) + */ + root?: string; + + /** + * Include .dot files in normal matches and globstar matches. + * Note that an explicit dot in a portion of the pattern will always match dot files. + */ + dot?: boolean; + + /** + * By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid + * filesystem path is returned. Set this flag to disable that behavior. + */ + nomount?: boolean; + + /** + * Add a / character to directory matches. Note that this requires additional stat calls. + */ + mark?: boolean; + + /** + * Don't sort the results. + */ + nosort?: boolean; + + /** + * Set to true to stat all results. This reduces performance somewhat, and is completely unnecessary, unless + * readdir is presumed to be an untrustworthy indicator of file existence. It will cause ELOOP to be triggered one + * level sooner in the case of cyclical symbolic links. + */ + stat?: boolean; + + /** + * When an unusual error is encountered when attempting to read a directory, a warning will be printed to stderr. + * Set the silent option to true to suppress these warnings. + */ + silent?: boolean; + + /** + * When an unusual error is encountered when attempting to read a directory, the process will just continue on in + * search of other matches. Set the strict option to raise an error in these cases. + */ + strict?: boolean; + + /** + * See cache property above. Pass in a previously generated cache object to save some fs calls. + */ + cache?: boolean; + + /** + * A cache of results of filesystem information, to prevent unnecessary stat calls. + * While it should not normally be necessary to set this, you may pass the statCache from one glob() call to the + * options object of another, if you know that the filesystem will not change between calls. + */ + statCache?: boolean; + + /** + * Perform a synchronous glob search. + */ + sync?: boolean; + + /** + * In some cases, brace-expanded patterns can result in the same file showing up multiple times in the result set. + * By default, this implementation prevents duplicates in the result set. Set this flag to disable that behavior. + */ + nounique?: boolean; + + /** + * Set to never return an empty set, instead returning a set containing the pattern itself. + * This is the default in glob(3). + */ + nonull?: boolean; + + /** + * Perform a case-insensitive match. Note that case-insensitive filesystems will sometimes result in glob returning + * results that are case-insensitively matched anyway, since readdir and stat will not raise an error. + */ + nocase?: boolean; + + /** + * Set to enable debug logging in minimatch and glob. + */ + debug?: boolean; + + /** + * Set to enable debug logging in glob, but not minimatch. + */ + globDebug?: boolean; + } + + interface IDestOptions { + /** + * The output folder. Only has an effect if provided output folder is relative. + * Default: process.cwd() + */ + cwd?: string; + + /** + * Octal permission string specifying mode for any folders that need to be created for output folder. + * Default: 0777. + */ + mode?: string; + } + + /** + * Options that are passed to gaze. + * https://github.com/shama/gaze + */ + interface IWatchOptions { + /** Interval to pass to fs.watchFile. */ + interval?: number; + /** Delay for events called in succession for the same file/event. */ + debounceDelay?: number; + /** Force the watch mode. Either 'auto' (default), 'watch' (force native events), or 'poll' (force stat polling). */ + mode?: string; + /** The current working directory to base file patterns from. Default is process.cwd().. */ + cwd?: string; + } + + interface IWatchEvent { + /** The type of change that occurred, either added, changed or deleted. */ + type: string; + /** The path to the file that triggered the event. */ + path: string; + } + + /** + * Callback to be called on each watched file change. + */ + interface IWatchCallback { + (event:IWatchEvent): void; + } + + interface ITaskCallback { + /** + * Defines a task. + * Tasks may be made asynchronous if they are passing a callback or return a promise or a stream. + * @param cb callback used to signal asynchronous completion. Caller includes err in case of error. + */ + (cb?:(err?:any)=>void): any; + } + } + + var gulp: gulp.Gulp; + + export = gulp; } diff --git a/run-sequence/run-sequence-tests.ts b/run-sequence/run-sequence-tests.ts index 98e57d9f3a..edc3266e91 100644 --- a/run-sequence/run-sequence-tests.ts +++ b/run-sequence/run-sequence-tests.ts @@ -5,7 +5,7 @@ import gulp = require("gulp"); import tmp = require("run-sequence"); var runSequence = tmp.use(gulp); -gulp.task("run-sequence", callback => { +gulp.task("run-sequence", (callback: any) => { runSequence("task1", ["task2", "task3"], "taks4", diff --git a/run-sequence/run-sequence.d.ts b/run-sequence/run-sequence.d.ts index 3a2cb449c6..221ff270e6 100644 --- a/run-sequence/run-sequence.d.ts +++ b/run-sequence/run-sequence.d.ts @@ -7,6 +7,7 @@ /// declare module "run-sequence" { + import gulp = require('gulp'); interface IRunSequence { (...streams: (string | string[] | gulp.ITaskCallback)[]): NodeJS.ReadWriteStream; From 052725d74978d6b8d7c4ff537b5a3b21ee755a49 Mon Sep 17 00:00:00 2001 From: tkQubo Date: Fri, 21 Aug 2015 13:02:41 +0900 Subject: [PATCH 14/86] Change interface name (remove the first letter 'I') --- gulp-protractor/gulp-protractor.d.ts | 4 ++-- gulp-tsd/gulp-tsd.d.ts | 2 +- gulp/gulp-tests.ts | 4 ++-- gulp/gulp.d.ts | 30 ++++++++++++++-------------- run-sequence/run-sequence.d.ts | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gulp-protractor/gulp-protractor.d.ts b/gulp-protractor/gulp-protractor.d.ts index 4ac814780d..fd98dbd435 100644 --- a/gulp-protractor/gulp-protractor.d.ts +++ b/gulp-protractor/gulp-protractor.d.ts @@ -18,8 +18,8 @@ declare module 'gulp-protractor' { interface IGulpProtractor { getProtractorDir(): string; protractor(options?: IOptions): NodeJS.ReadWriteStream; - webdriver_standalone: gulp.ITaskCallback; - webdriver_update: gulp.ITaskCallback; + webdriver_standalone: gulp.TaskCallback; + webdriver_update: gulp.TaskCallback; } var protractor: IGulpProtractor; diff --git a/gulp-tsd/gulp-tsd.d.ts b/gulp-tsd/gulp-tsd.d.ts index 20d279329e..816d50d25b 100644 --- a/gulp-tsd/gulp-tsd.d.ts +++ b/gulp-tsd/gulp-tsd.d.ts @@ -16,7 +16,7 @@ declare module "gulp-tsd" { opts?: Object; } - function tsd(opts?: IOptions, callback?: gulp.ITaskCallback): NodeJS.ReadWriteStream; + function tsd(opts?: IOptions, callback?: gulp.TaskCallback): NodeJS.ReadWriteStream; export = tsd; } diff --git a/gulp/gulp-tests.ts b/gulp/gulp-tests.ts index 2a69d40ca5..d006908817 100644 --- a/gulp/gulp-tests.ts +++ b/gulp/gulp-tests.ts @@ -4,8 +4,8 @@ import gulp = require("gulp"); import browserSync = require("browser-sync"); -var typescript: gulp.IGulpPlugin = null; // this would be the TypeScript compiler -var jasmine: gulp.IGulpPlugin = null; // this would be the jasmine test runner +var typescript: gulp.GulpPlugin = null; // this would be the TypeScript compiler +var jasmine: gulp.GulpPlugin = null; // this would be the jasmine test runner gulp.task('compile', function() { diff --git a/gulp/gulp.d.ts b/gulp/gulp.d.ts index abb8978d1c..160ee99ce9 100644 --- a/gulp/gulp.d.ts +++ b/gulp/gulp.d.ts @@ -46,7 +46,7 @@ declare module "gulp" { watch: WatchMethod; } - interface IGulpPlugin { + interface GulpPlugin { (...args: any[]): NodeJS.ReadWriteStream; } @@ -57,14 +57,14 @@ declare module "gulp" { * @param glob a single glob or array of globs that indicate which files to watch for changes. * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). */ - (glob: string|string[], fn: (IWatchCallback|string)): NodeJS.EventEmitter; + (glob: string|string[], fn: (WatchCallback|string)): NodeJS.EventEmitter; /** * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. * * @param glob a single glob or array of globs that indicate which files to watch for changes. * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). */ - (glob: string|string[], fn: (IWatchCallback|string)[]): NodeJS.EventEmitter; + (glob: string|string[], fn: (WatchCallback|string)[]): NodeJS.EventEmitter; /** * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. * @@ -72,7 +72,7 @@ declare module "gulp" { * @param opt options, that are passed to the gaze library. * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). */ - (glob: string|string[], opt: IWatchOptions, fn: (IWatchCallback|string)): NodeJS.EventEmitter; + (glob: string|string[], opt: WatchOptions, fn: (WatchCallback|string)): NodeJS.EventEmitter; /** * Watch files and do something when a file changes. This always returns an EventEmitter that emits change events. * @@ -80,7 +80,7 @@ declare module "gulp" { * @param opt options, that are passed to the gaze library. * @param fn a callback or array of callbacks to be called on each change, or names of task(s) to run when a file changes, added with task(). */ - (glob: string|string[], opt: IWatchOptions, fn: (IWatchCallback|string)[]): NodeJS.EventEmitter; + (glob: string|string[], opt: WatchOptions, fn: (WatchCallback|string)[]): NodeJS.EventEmitter; } @@ -92,7 +92,7 @@ declare module "gulp" { * @param outFolder The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance. * @param opt */ - (outFolder: string|((file:string)=>string), opt?: IDestOptions): NodeJS.ReadWriteStream; + (outFolder: string|((file: string) => string), opt?: DestOptions): NodeJS.ReadWriteStream; } interface SrcMethod { @@ -101,7 +101,7 @@ declare module "gulp" { * @param glob Glob or array of globs to read. * @param opt Options to pass to node-glob through glob-stream. */ - (glob: string|string[], opt?: ISrcOptions): NodeJS.ReadWriteStream; + (glob: string|string[], opt?: SrcOptions): NodeJS.ReadWriteStream; } /** @@ -109,7 +109,7 @@ declare module "gulp" { * Specifies two options in addition to those used by node-glob: * https://github.com/isaacs/node-glob#options */ - interface ISrcOptions { + interface SrcOptions { /** * Setting this to false will return file.contents as null * and not read the file at all. @@ -231,7 +231,7 @@ declare module "gulp" { globDebug?: boolean; } - interface IDestOptions { + interface DestOptions { /** * The output folder. Only has an effect if provided output folder is relative. * Default: process.cwd() @@ -249,7 +249,7 @@ declare module "gulp" { * Options that are passed to gaze. * https://github.com/shama/gaze */ - interface IWatchOptions { + interface WatchOptions { /** Interval to pass to fs.watchFile. */ interval?: number; /** Delay for events called in succession for the same file/event. */ @@ -260,7 +260,7 @@ declare module "gulp" { cwd?: string; } - interface IWatchEvent { + interface WatchEvent { /** The type of change that occurred, either added, changed or deleted. */ type: string; /** The path to the file that triggered the event. */ @@ -270,17 +270,17 @@ declare module "gulp" { /** * Callback to be called on each watched file change. */ - interface IWatchCallback { - (event:IWatchEvent): void; + interface WatchCallback { + (event: WatchEvent): void; } - interface ITaskCallback { + interface TaskCallback { /** * Defines a task. * Tasks may be made asynchronous if they are passing a callback or return a promise or a stream. * @param cb callback used to signal asynchronous completion. Caller includes err in case of error. */ - (cb?:(err?:any)=>void): any; + (cb?: (err?: any) => void): any; } } diff --git a/run-sequence/run-sequence.d.ts b/run-sequence/run-sequence.d.ts index 221ff270e6..4507e80c07 100644 --- a/run-sequence/run-sequence.d.ts +++ b/run-sequence/run-sequence.d.ts @@ -10,7 +10,7 @@ declare module "run-sequence" { import gulp = require('gulp'); interface IRunSequence { - (...streams: (string | string[] | gulp.ITaskCallback)[]): NodeJS.ReadWriteStream; + (...streams: (string | string[] | gulp.TaskCallback)[]): NodeJS.ReadWriteStream; use(gulp: gulp.Gulp): IRunSequence; } From 6ee9ce6f2918806e8c005e006809b4be961914f8 Mon Sep 17 00:00:00 2001 From: tkQubo Date: Wed, 26 Aug 2015 01:52:37 +0900 Subject: [PATCH 15/86] Add type annotation for some cbs --- gulp-istanbul/gulp-istanbul-tests.ts | 8 ++++---- gulp-watch/gulp-watch-tests.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gulp-istanbul/gulp-istanbul-tests.ts b/gulp-istanbul/gulp-istanbul-tests.ts index 0d64b53d0e..aada03de1f 100644 --- a/gulp-istanbul/gulp-istanbul-tests.ts +++ b/gulp-istanbul/gulp-istanbul-tests.ts @@ -7,7 +7,7 @@ function testFramework(): NodeJS.ReadWriteStream { return null; } -gulp.task('test', function (cb) { +gulp.task('test', function (cb: Function) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul()) // Covering files .pipe(gulp.dest('test-tmp/')) @@ -19,7 +19,7 @@ gulp.task('test', function (cb) { }); }); -gulp.task('test', function (cb) { +gulp.task('test', function (cb: Function) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) @@ -31,7 +31,7 @@ gulp.task('test', function (cb) { }); }); -gulp.task('test', function (cb) { +gulp.task('test', function (cb: Function) { gulp.src(['lib/**/*.js', 'main.js']) .pipe(istanbul({includeUntested: true})) // Covering files .pipe(istanbul.hookRequire()) @@ -42,4 +42,4 @@ gulp.task('test', function (cb) { .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } })) // .on('end', cb); }); -}); \ No newline at end of file +}); diff --git a/gulp-watch/gulp-watch-tests.ts b/gulp-watch/gulp-watch-tests.ts index 9d9303ac22..dd237dccc2 100644 --- a/gulp-watch/gulp-watch-tests.ts +++ b/gulp-watch/gulp-watch-tests.ts @@ -10,7 +10,7 @@ gulp.task('stream', () => .pipe(gulp.dest('build')) ); -gulp.task('callback', (cb) => +gulp.task('callback', (cb: Function) => watch('css/**/*.css', () => gulp.src('css/**/*.css') .pipe(watch('css/**/*.css')) From fe4d04c34a61d6016429daf449a8a9e6975f2997 Mon Sep 17 00:00:00 2001 From: mputters Date: Sun, 23 Aug 2015 20:24:49 +0200 Subject: [PATCH 16/86] Definitions for ui-router-extras --- ui-router-extras/ui-router-extras-tests.ts | 23 ++++++ ui-router-extras/ui-router-extras.d.ts | 83 ++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 ui-router-extras/ui-router-extras-tests.ts create mode 100644 ui-router-extras/ui-router-extras.d.ts diff --git a/ui-router-extras/ui-router-extras-tests.ts b/ui-router-extras/ui-router-extras-tests.ts new file mode 100644 index 0000000000..22d9e4f733 --- /dev/null +++ b/ui-router-extras/ui-router-extras-tests.ts @@ -0,0 +1,23 @@ +/// + +var myApp = angular.module('testModule') + +myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: angular.ui.IStickyStateProvider) => { + var state: angular.ui.IStickyState = { + name: 'test', + sticky: true, + controller: ($previousState: angular.ui.IPreviousStateService) => { + $previousState.memo('test-memo1'); + $previousState.memo('test-memo2', 'test-state-name2'); + $previousState.memo('test-memo3', 'test-state-name3', {}); + $previousState.forget('test-memo3'); + $previousState.go('test-memo2', { + location: true, + notify: true + }); + } + }; + + $stickyStateProvider.enableDebug(true); + $stateProvider.state(state); +}); diff --git a/ui-router-extras/ui-router-extras.d.ts b/ui-router-extras/ui-router-extras.d.ts new file mode 100644 index 0000000000..8e0c42828e --- /dev/null +++ b/ui-router-extras/ui-router-extras.d.ts @@ -0,0 +1,83 @@ +// Type definitions for UI-Router Extras 0.0.14+ (ct.ui.router.extras module) +// Project: https://github.com/christopherthielen/ui-router-extras +// Definitions by: Michael Putters +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +// Support for AMD require +declare module 'angular-ui-router-extras' { + var _: string; + export = _; +} + +declare module angular.ui { + + /** + * Previous state + */ + interface IPreviousState { + state: IState; + params?: {}; + } + + /** + * Previous state service + */ + interface IPreviousStateService { + + /** + * Get a previous state + * @param memoName Memo name + * @return Previous state + */ + get(memoName?: string): IPreviousState; + + /** + * Go to a state + * @param memoName Memo name + * @param options State options + * @return Promise + */ + go(memoName: string, options?: IStateOptions): angular.IPromise; + + /** + * Memorize a state + * @param memoName Memo name + * @param defaultStateName Default state name + * @param defaultStateParams Default state parameters + */ + memo(memoName: string, defaultStateName?: string, defaultStateParams?: {}): void; + + /** + * Forget a memorized name + * @param memoName Memo name + */ + forget(memoName: string): void; + + } + + /** + * Sticky state + */ + interface IStickyState extends angular.ui.IState { + sticky?: boolean; + } + + /** + * Sticky state service + */ + interface IStickyStateService { + getInactiveStates(): IStickyState[]; + } + + /** + * Sticky state provider + */ + interface IStickyStateProvider extends angular.IServiceProvider { + debugMode(): boolean; + enableDebug(enabled: boolean): boolean; + registerStickyState(state: IStickyState): void; + } + +} From 36324e98d9a42da81a01abc1d2bb918dceac8734 Mon Sep 17 00:00:00 2001 From: tpodolak Date: Tue, 25 Aug 2015 20:45:47 +0200 Subject: [PATCH 17/86] Updated missing Windows.ApplicationModel.Activation.ActivationKind enum values --- winrt/winrt.d.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index f3be7feac2..47aad9302a 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -1541,7 +1541,24 @@ declare module Windows { device, printTaskSettings, cameraSettings, - webAuthenticationBrokerContinuation + restrictedLaunch, + appointmentsProvider, + contact, + lockScreenCall, + voiceCommand, + lockScreen, + pickerReturned, + walletAction, + pickFileContinuation, + pickSaveFileContinuation, + pickFolderContinuation, + webAuthenticationBrokerContinuation, + webAccountProvider, + componentUI, + protocolForResults, + toastNotification, + print3DWorkflow, + dialReceiver } export interface IActivatedEventArgs { kind: Windows.ApplicationModel.Activation.ActivationKind; From cf1f8723e89d19e74e1041a684b63468405f9bda Mon Sep 17 00:00:00 2001 From: Calvin Fernandez Date: Tue, 25 Aug 2015 17:15:33 -0400 Subject: [PATCH 18/86] Add angular-ui-tree --- angular-ui-tree/angular-ui-tree-tests.ts | 13 +++++++++++++ angular-ui-tree/angular-ui-tree.d.ts | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 angular-ui-tree/angular-ui-tree-tests.ts create mode 100644 angular-ui-tree/angular-ui-tree.d.ts diff --git a/angular-ui-tree/angular-ui-tree-tests.ts b/angular-ui-tree/angular-ui-tree-tests.ts new file mode 100644 index 0000000000..e66408814e --- /dev/null +++ b/angular-ui-tree/angular-ui-tree-tests.ts @@ -0,0 +1,13 @@ +/// + +var treeNode: AngularUITree.ITreeNode = { + id: 0, + nodes: [], + title: "test" +}; + +var treeNode2: AngularUITree.ITreeNode = { + id: "0", + nodes: [treeNode], + title: "test2" +}; diff --git a/angular-ui-tree/angular-ui-tree.d.ts b/angular-ui-tree/angular-ui-tree.d.ts new file mode 100644 index 0000000000..1017ac11cd --- /dev/null +++ b/angular-ui-tree/angular-ui-tree.d.ts @@ -0,0 +1,15 @@ +// Type definitions for angular-ui-tree v2.8.0 +// Project: https://github.com/angular-ui-tree/angular-ui-tree +// Definitions by: Calvin Fernandez +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module AngularUITree { + /** + * Node in list + */ + interface ITreeNode { + id: number | string; + nodes: ITreeNode[]; + title: string; + } +} From c340b3634c93a8dbf1c40cf1d7f82f8101fe9200 Mon Sep 17 00:00:00 2001 From: Anthony Guo Date: Mon, 10 Aug 2015 16:40:09 -0700 Subject: [PATCH 19/86] Added typings for the CodeMirror showhint addon --- codemirror/showhint-tests.ts | 33 +++++++++++++++++++ codemirror/showhint.d.ts | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 codemirror/showhint-tests.ts create mode 100644 codemirror/showhint.d.ts diff --git a/codemirror/showhint-tests.ts b/codemirror/showhint-tests.ts new file mode 100644 index 0000000000..b7378e0d68 --- /dev/null +++ b/codemirror/showhint-tests.ts @@ -0,0 +1,33 @@ +/// +/// +var doc = new CodeMirror.Doc('text'); +var pos = new CodeMirror.Pos(2, 3); +CodeMirror.showHint(doc); +CodeMirror.showHint(doc, function (cm) { + return { + from: pos, + list: ["one", "two"], + to: pos + }; +}); +CodeMirror.showHint(doc, function (cm) { + return { + from: pos, + list: [ + { + text: "disp1", + render: function (el, self, data) { + ; + } + }, + { + className: "class2", + displayText: "disp2", + from: pos, + to: pos, + text: "sometext" + } + ], + to: pos + }; +}); diff --git a/codemirror/showhint.d.ts b/codemirror/showhint.d.ts new file mode 100644 index 0000000000..340871db4b --- /dev/null +++ b/codemirror/showhint.d.ts @@ -0,0 +1,62 @@ +// Type definitions for CodeMirror +// Project: https://github.com/marijnh/CodeMirror +// Definitions by: jacqt +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module CodeMirror { + var commands : any; + + /** Provides a framework for showing autocompletion hints. Defines editor.showHint, which takes an optional + options object, and pops up a widget that allows the user to select a completion. Finding hints is done with + a hinting functions (the hint option), which is a function that take an editor instance and options object, + and return a {list, from, to} object, where list is an array of strings or objects (the completions), and + from and to give the start and end of the token that is being completed as {line, ch} objects. An optional + selectedHint property (an integer) can be added to the completion object to control the initially selected hint. */ + function showHint (cm: CodeMirror.Doc, hinter?: (doc : CodeMirror.Doc) => Hints, options?: IShowHintOptions) : void; + + + interface Hints { + from: Position; + to: Position; + list: Hint[] | string[]; + } + + /** Interface used by showHint.js Codemirror add-on + When completions aren't simple strings, they should be objects with the following properties: */ + interface Hint { + text: string; + className?: string; + displayText?: string; + from?: Position; + render?: (element: any, self: any, data: any) => void; + to?: Position; + } + + interface Editor { + /** An extension of the existing CodeMirror typings for the Editor.on("keyup", func) syntax */ + on(eventName: string, handler: (doc: CodeMirror.Doc, event : any ) => void ): void; + off(eventName: string, handler: (doc: CodeMirror.Doc, event : any) => void ): void; + } + + /** Extend CodeMirror.Doc with a state object, so that the Doc.state.completionActive property is reachable*/ + interface Doc { + state: any; + showHint: (options: IShowHintOptions) => void; + } + + interface IShowHintOptions { + completeSingle: boolean; + hint: (doc : CodeMirror.Doc) => Hints; + } + + /** The Handle used to interact with the autocomplete dialog box.*/ + interface Handle { + moveFocus(n: number, avoidWrap: boolean): void; + setFocus(n: number): void; + menuSize(): number; + length: number; + close(): void; + pick(): void; + data: any; + } +} From 1613bfdbda9f1d2704b682fe342c2234760904c5 Mon Sep 17 00:00:00 2001 From: Scott Hatcher Date: Tue, 25 Aug 2015 15:41:27 -0700 Subject: [PATCH 20/86] Initial push for highcharts-ng definitions and tests. --- highcharts-ng/highcharts-ng-tests.ts | 40 ++++++++++++++++++++++++++++ highcharts-ng/highcharts-ng.d.ts | 37 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 highcharts-ng/highcharts-ng-tests.ts create mode 100644 highcharts-ng/highcharts-ng.d.ts diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts new file mode 100644 index 0000000000..2fe0ae906b --- /dev/null +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -0,0 +1,40 @@ +/// +/// + +var app = angular.module('app', ['highcharts-ng']); + +class AppController { + chartConfig: HighChartsNGConfig = { + options: { + chart: { + type: 'bar' + }, + tooltip: { + style: { + padding: 10, + fontWeight: 'bold' + } + }, + credits: { + enabled: false + }, + plotOptions: {} + }, + series: [{ + data: [10, 15, 12, 8, 7] + }], + title: { + text: 'My Awesome Chart' + }, + loading: true + }; + constructor($timeout: ng.ITimeoutService) { + let vm = this; + $timeout(function() { + //Some async action + vm.chartConfig.loading = false; + }); + } +} + +app.controller("AppController", AppController); \ No newline at end of file diff --git a/highcharts-ng/highcharts-ng.d.ts b/highcharts-ng/highcharts-ng.d.ts new file mode 100644 index 0000000000..216d8fbfc9 --- /dev/null +++ b/highcharts-ng/highcharts-ng.d.ts @@ -0,0 +1,37 @@ +// Type definitions for highcharts-ng 0.0.8 +// Project: https://github.com/pablojim/highcharts-ng +// Definitions by: Scott Hatcher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface HighChartsNGConfig { + options: HighchartsChartOptions; + //The below properties are watched separately for changes. + + //Series object (optional) - a list of series using normal highcharts series options. + series?: number[]|[number, number][]| HighchartsDataPoint[]; + //Title configuration (optional) + title?: { + text?: string; + }; + //Boolean to control showng loading status on chart (optional) + //Could be a string if you want to show specific loading text. + loading?: boolean; + //Configuration for the xAxis (optional). Currently only one x axis can be dynamically controlled. + //properties currentMin and currentMax provied 2-way binding to the chart's maximimum and minimum + xAxis?: { + currentMin?: number; + currentMax?: number; + title?: { text?: string } + }, + //Whether to use HighStocks instead of HighCharts (optional). Defaults to false. + useHighStocks?: boolean; + //size (optional) if left out the chart will default to size of the div or something sensible. + size?: { + width?: number; + height?: number; + }; + //function (optional) - setup some logic for the chart + func?: (chart) => void; +} \ No newline at end of file From 29f7e2fe49c25073e26f0a3757a70e2a052d02fa Mon Sep 17 00:00:00 2001 From: Scott Hatcher Date: Tue, 25 Aug 2015 16:02:15 -0700 Subject: [PATCH 21/86] Added instantiated version of chart definition and cleaned up tests. --- highcharts-ng/highcharts-ng-tests.ts | 2 +- highcharts-ng/highcharts-ng.d.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts index 2fe0ae906b..7fb462e9ca 100644 --- a/highcharts-ng/highcharts-ng-tests.ts +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -29,7 +29,7 @@ class AppController { loading: true }; constructor($timeout: ng.ITimeoutService) { - let vm = this; + var vm = this; $timeout(function() { //Some async action vm.chartConfig.loading = false; diff --git a/highcharts-ng/highcharts-ng.d.ts b/highcharts-ng/highcharts-ng.d.ts index 216d8fbfc9..b67ca5da54 100644 --- a/highcharts-ng/highcharts-ng.d.ts +++ b/highcharts-ng/highcharts-ng.d.ts @@ -33,5 +33,11 @@ interface HighChartsNGConfig { height?: number; }; //function (optional) - setup some logic for the chart - func?: (chart) => void; + func?: (chart: HighchartsChartObject) => void; +} + +//Instantiated Chart +interface HighChartsNGChart extends HighChartsNGConfig { + //This is a simple way to access all the Highcharts API that is not currently managed by this directive. + getHighcharts(): HighchartsChartObject; } \ No newline at end of file From a20f2d808f2a85ef6483fe01fbf6169f0aedea94 Mon Sep 17 00:00:00 2001 From: Scott Hatcher Date: Tue, 25 Aug 2015 16:48:13 -0700 Subject: [PATCH 22/86] Moved from tab spacing. --- highcharts-ng/highcharts-ng-tests.ts | 54 +++++++++++++------------- highcharts-ng/highcharts-ng.d.ts | 58 ++++++++++++++-------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts index 7fb462e9ca..5f05b33731 100644 --- a/highcharts-ng/highcharts-ng-tests.ts +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -4,37 +4,37 @@ var app = angular.module('app', ['highcharts-ng']); class AppController { - chartConfig: HighChartsNGConfig = { - options: { - chart: { - type: 'bar' - }, - tooltip: { - style: { - padding: 10, - fontWeight: 'bold' - } - }, - credits: { - enabled: false - }, - plotOptions: {} - }, - series: [{ + chartConfig: HighChartsNGConfig = { + options: { + chart: { + type: 'bar' + }, + tooltip: { + style: { + padding: 10, + fontWeight: 'bold' + } + }, + credits: { + enabled: false + }, + plotOptions: {} + }, + series: [{ data: [10, 15, 12, 8, 7] }], - title: { + title: { text: 'My Awesome Chart' }, - loading: true - }; - constructor($timeout: ng.ITimeoutService) { - var vm = this; - $timeout(function() { - //Some async action - vm.chartConfig.loading = false; - }); - } + loading: true + }; + constructor($timeout: ng.ITimeoutService) { + var vm = this; + $timeout(function() { + //Some async action + vm.chartConfig.loading = false; + }); + } } app.controller("AppController", AppController); \ No newline at end of file diff --git a/highcharts-ng/highcharts-ng.d.ts b/highcharts-ng/highcharts-ng.d.ts index b67ca5da54..d0a3405594 100644 --- a/highcharts-ng/highcharts-ng.d.ts +++ b/highcharts-ng/highcharts-ng.d.ts @@ -6,38 +6,38 @@ /// interface HighChartsNGConfig { - options: HighchartsChartOptions; - //The below properties are watched separately for changes. + options: HighchartsChartOptions; + //The below properties are watched separately for changes. - //Series object (optional) - a list of series using normal highcharts series options. - series?: number[]|[number, number][]| HighchartsDataPoint[]; - //Title configuration (optional) - title?: { - text?: string; - }; - //Boolean to control showng loading status on chart (optional) - //Could be a string if you want to show specific loading text. - loading?: boolean; - //Configuration for the xAxis (optional). Currently only one x axis can be dynamically controlled. - //properties currentMin and currentMax provied 2-way binding to the chart's maximimum and minimum - xAxis?: { - currentMin?: number; - currentMax?: number; - title?: { text?: string } - }, - //Whether to use HighStocks instead of HighCharts (optional). Defaults to false. - useHighStocks?: boolean; - //size (optional) if left out the chart will default to size of the div or something sensible. - size?: { - width?: number; - height?: number; - }; - //function (optional) - setup some logic for the chart - func?: (chart: HighchartsChartObject) => void; + //Series object (optional) - a list of series using normal highcharts series options. + series?: number[]|[number, number][]| HighchartsDataPoint[]; + //Title configuration (optional) + title?: { + text?: string; + }; + //Boolean to control showng loading status on chart (optional) + //Could be a string if you want to show specific loading text. + loading?: boolean; + //Configuration for the xAxis (optional). Currently only one x axis can be dynamically controlled. + //properties currentMin and currentMax provied 2-way binding to the chart's maximimum and minimum + xAxis?: { + currentMin?: number; + currentMax?: number; + title?: { text?: string } + }, + //Whether to use HighStocks instead of HighCharts (optional). Defaults to false. + useHighStocks?: boolean; + //size (optional) if left out the chart will default to size of the div or something sensible. + size?: { + width?: number; + height?: number; + }; + //function (optional) - setup some logic for the chart + func?: (chart: HighchartsChartObject) => void; } //Instantiated Chart interface HighChartsNGChart extends HighChartsNGConfig { - //This is a simple way to access all the Highcharts API that is not currently managed by this directive. - getHighcharts(): HighchartsChartObject; + //This is a simple way to access all the Highcharts API that is not currently managed by this directive. + getHighcharts(): HighchartsChartObject; } \ No newline at end of file From 2e8850e4d90f4a41a0901cbded737f865a0867f5 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 26 Aug 2015 06:00:31 +0500 Subject: [PATCH 23/86] lodash: changed _.capitalize() method --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index bb7a665606..3ec1bb1a37 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1755,7 +1755,9 @@ result = _.uniqueId(); result = _.camelCase('Foo Bar'); result = _('Foo Bar').camelCase(); +// _.capitalize result = _.capitalize('fred'); +result = _('fred').capitalize(); // _.deburr result = _.deburr('déjà vu'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 43ba61f3b9..e87b3eadf3 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7583,8 +7583,16 @@ declare module _ { camelCase(): string; } + //_.capitalize interface LoDashStatic { - capitalize(str?: string): string; + capitalize(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.capitalize + */ + capitalize(): string; } //_.deburr From 5c4be3d2ae5fa3e81aa682733af238b1e335a656 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 26 Aug 2015 06:08:06 +0500 Subject: [PATCH 24/86] lodash: changed _.isNull() method --- lodash/lodash-tests.ts | 9 ++++++--- lodash/lodash.d.ts | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index bb7a665606..23edca9341 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1260,6 +1260,12 @@ result = _(undefined).isNaN(); result = _.isNative(Array.prototype.push); result = _(Array.prototype.push).isNative(); +// _.isNull +result = _.isNull(any); +result = _(1).isNull(); +result = _([]).isNull(); +result = _({}).isNull(); + // _.isNumber result = _.isNumber(any); result = _(1).isNumber(); @@ -1502,9 +1508,6 @@ result = _(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn); result = _.eq(testEqArray, testEqOtherArray, testEqCustomizerFn); result = _(testEqArray).eq(testEqOtherArray, testEqCustomizerFn); -result = _.isNull(null); -result = _.isNull(undefined); - result = _.isObject({}); result = _.isObject([1, 2, 3]); result = _.isObject(1); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 43ba61f3b9..03aacca507 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6346,6 +6346,23 @@ declare module _ { isNative(): boolean; } + //_.isNull + interface LoDashStatic { + /** + * Checks if value is null. + * @param value The value to check. + * @return Returns true if value is null, else false. + **/ + isNull(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isNull + */ + isNull(): boolean; + } + //_.isNumber interface LoDashStatic { /** @@ -7163,16 +7180,6 @@ declare module _ { thisArg?: any): boolean; } - //_.isNull - interface LoDashStatic { - /** - * Checks if value is null. - * @param value The value to check. - * @return True if the value is null, else false. - **/ - isNull(value?: any): boolean; - } - //_.isObject interface LoDashStatic { /** From 534746f21901ac44b5fc90113649f615ab24d86d Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 26 Aug 2015 14:35:44 +0900 Subject: [PATCH 25/86] fix indent level --- .../{sequelize-test.ts => sequelize-tests.ts} | 5 +- sequelize/sequelize.d.ts | 370 +++++++++--------- 2 files changed, 189 insertions(+), 186 deletions(-) rename sequelize/{sequelize-test.ts => sequelize-tests.ts} (99%) diff --git a/sequelize/sequelize-test.ts b/sequelize/sequelize-tests.ts similarity index 99% rename from sequelize/sequelize-test.ts rename to sequelize/sequelize-tests.ts index e5656c76e8..2651453d6e 100644 --- a/sequelize/sequelize-test.ts +++ b/sequelize/sequelize-tests.ts @@ -47,11 +47,14 @@ interface GTaskAttributes { revision? : number; name? : string; } -interface GTaskInstance extends Sequelize.Instance {} +interface GTaskInstance extends Sequelize.Instance { + upRevision(): void; +} var GTask = s.define( 'task', { revision : Sequelize.INTEGER, name : Sequelize.STRING }); GUser.hasMany(GTask); +GTask.create({ revision: 1, name: 'test' }).then( (gtask) => gtask.upRevision() ); // diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 4c2294e6f7..0e84373a6e 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -256,13 +256,13 @@ declare module "sequelize" { * user.getProfilePicture() // gets you only the profile picture * * User.findAll({ - * where: ..., - * include: [ - * { model: Picture }, // load all pictures - * { model: Picture, as: 'ProfilePicture' }, // load the profile picture. Notice that the spelling must be - * the exact same as the one in the association - * ] - * }) + * where: ..., + * include: [ + * { model: Picture }, // load all pictures + * { model: Picture, as: 'ProfilePicture' }, // load the profile picture. Notice that the spelling must be + * the exact same as the one in the association + * ] + * }) * ``` * To get full control over the foreign key column added by sequelize, you can use the `foreignKey` option. It * can either be a string, that specifies the name, or and object type definition, @@ -276,11 +276,11 @@ declare module "sequelize" { * * ```js * User.hasMany(Picture, { - * foreignKey: { - * name: 'uid', - * allowNull: false - * } - * }) + * foreignKey: { + * name: 'uid', + * allowNull: false + * } + * }) * ``` * * This specifies that the `uid` column can not be null. In most cases this will already be covered by the @@ -293,10 +293,10 @@ declare module "sequelize" { * * ```js * user.getPictures({ - * where: { - * format: 'jpg' - * } - * }) + * where: { + * format: 'jpg' + * } + * }) * ``` * * There are several ways to update and add new assoications. Continuing with our example of users and @@ -371,8 +371,8 @@ declare module "sequelize" { * started yet: * ```js * var UserProjects = sequelize.define('userprojects', { - * started: Sequelize.BOOLEAN - * }) + * started: Sequelize.BOOLEAN + * }) * User.hasMany(Project, { through: UserProjects }) * Project.hasMany(User, { through: UserProjects }) * ``` @@ -387,8 +387,8 @@ declare module "sequelize" { * * ```js * p1.userprojects { - * started: true - * } + * started: true + * } * user.setProjects([p1, p2], {started: false}) // The default value is false, but p1 overrides that. * ``` * @@ -396,9 +396,9 @@ declare module "sequelize" { * available as an object with the name of the through model. * ```js * user.getProjects().then(function (projects) { - * var p1 = projects[0] - * p1.userprojects.started // Is this project started yet? - * }) + * var p1 = projects[0] + * p1.userprojects.started // Is this project started yet? + * }) * ``` * * @param target The model that will be associated with hasOne relationship @@ -421,8 +421,8 @@ declare module "sequelize" { * the project has been started yet: * ```js * var UserProjects = sequelize.define('userprojects', { - * started: Sequelize.BOOLEAN - * }) + * started: Sequelize.BOOLEAN + * }) * User.belongsToMany(Project, { through: UserProjects }) * Project.belongsToMany(User, { through: UserProjects }) * ``` @@ -436,8 +436,8 @@ declare module "sequelize" { * * ```js * p1.userprojects { - * started: true - * } + * started: true + * } * user.setProjects([p1, p2], {started: false}) // The default value is false, but p1 overrides that. * ``` * @@ -445,9 +445,9 @@ declare module "sequelize" { * available as an object with the name of the through model. * ```js * user.getProjects().then(function (projects) { - * var p1 = projects[0] - * p1.userprojects.started // Is this project started yet? - * }) + * var p1 = projects[0] + * p1.userprojects.started // Is this project started yet? + * }) * ``` * * @param target The model that will be associated with hasOne relationship @@ -813,15 +813,15 @@ declare module "sequelize" { * * ```js * sequelize.define('Model', { - * foreign_id: { - * type: Sequelize.INTEGER, - * references: { - * model: OtherModel, - * key: 'id', - * deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE - * } - * } - * }); + * foreign_id: { + * type: Sequelize.INTEGER, + * references: { + * model: OtherModel, + * key: 'id', + * deferrable: Sequelize.Deferrable.INITIALLY_IMMEDIATE + * } + * } + * }); * ``` * * The constraints can be configured in a transaction like this. It will @@ -1074,16 +1074,16 @@ declare module "sequelize" { * ```js * // Method 1 * sequelize.define(name, { attributes }, { - * hooks: { - * beforeBulkCreate: function () { - * // can be a single function - * }, - * beforeValidate: [ - * function () {}, - * function() {} // Or an array of several - * ] - * } - * }) + * hooks: { + * beforeBulkCreate: function () { + * // can be a single function + * }, + * beforeValidate: [ + * function () {}, + * function() {} // Or an array of several + * ] + * } + * }) * * // Method 2 * Model.hook('afterDestroy', function () {}) @@ -2439,32 +2439,32 @@ declare module "sequelize" { * Apply a scope created in `define` to the model. First let's look at how to create scopes: * ```js * var Model = sequelize.define('model', attributes, { - * defaultScope: { - * where: { - * username: 'dan' - * }, - * limit: 12 - * }, - * scopes: { - * isALie: { - * where: { - * stuff: 'cake' - * } - * }, - * complexFunction: function(email, accessLevel) { - * return { - * where: { - * email: { - * $like: email - * }, - * accesss_level { - * $gte: accessLevel - * } - * } - * } - * } - * } - * }) + * defaultScope: { + * where: { + * username: 'dan' + * }, + * limit: 12 + * }, + * scopes: { + * isALie: { + * where: { + * stuff: 'cake' + * } + * }, + * complexFunction: function(email, accessLevel) { + * return { + * where: { + * email: { + * $like: email + * }, + * accesss_level { + * $gte: accessLevel + * } + * } + * } + * } + * } + * }) * ``` * Now, since you defined a default scope, every time you do Model.find, the default scope is appended to * your query. Here's a couple of examples: @@ -2490,11 +2490,11 @@ declare module "sequelize" { * __Simple search using AND and =__ * ```js * Model.findAll({ - * where: { - * attr1: 42, - * attr2: 'cake' - * } - * }) + * where: { + * attr1: 42, + * attr2: 'cake' + * } + * }) * ``` * ```sql * WHERE attr1 = 42 AND attr2 = 'cake' @@ -2504,21 +2504,21 @@ declare module "sequelize" { * ```js * * Model.findAll({ - * where: { - * attr1: { - * gt: 50 - * }, - * attr2: { - * lte: 45 - * }, - * attr3: { - * in: [1,2,3] - * }, - * attr4: { - * ne: 5 - * } - * } - * }) + * where: { + * attr1: { + * gt: 50 + * }, + * attr2: { + * lte: 45 + * }, + * attr3: { + * in: [1,2,3] + * }, + * attr4: { + * ne: 5 + * } + * } + * }) * ``` * ```sql * WHERE attr1 > 50 AND attr2 <= 45 AND attr3 IN (1,2,3) AND attr4 != 5 @@ -2529,14 +2529,14 @@ declare module "sequelize" { * __Queries using OR__ * ```js * Model.findAll({ - * where: Sequelize.and( - * { name: 'a project' }, - * Sequelize.or( - * { id: [1,2,3] }, - * { id: { gt: 10 } } - * ) - * ) - * }) + * where: Sequelize.and( + * { name: 'a project' }, + * Sequelize.or( + * { id: [1,2,3] }, + * { id: { gt: 10 } } + * ) + * ) + * }) * ``` * ```sql * WHERE name = 'a project' AND (id` IN (1,2,3) OR id > 10) @@ -2587,12 +2587,12 @@ declare module "sequelize" { * * ```js * Model.findAndCountAll({ - * where: ..., - * limit: 12, - * offset: 12 - * }).then(function (result) { - * ... - * }) + * where: ..., + * limit: 12, + * offset: 12 + * }).then(function (result) { + * ... + * }) * ``` * In the above example, `result.rows` will contain rows 13 through 24, while `result.count` will return * the @@ -2605,11 +2605,11 @@ declare module "sequelize" { * Suppose you want to find all users who have a profile attached: * ```js * User.findAndCountAll({ - * include: [ - * { model: Profile, required: true} - * ], - * limit 3 - * }); + * include: [ + * { model: Profile, required: true} + * ], + * limit 3 + * }); * ``` * Because the include for `Profile` has `required` set it will result in an inner join, and only the users * who have a profile will be counted. If we remove `required` from the include, both users with and @@ -3149,7 +3149,7 @@ declare module "sequelize" { /** * A string or a data type */ - type: string | DataTypeAbstract; + type: string | DataTypeAbstract; /** * If true, the column will get a unique constraint. If a string is provided, the column will be part of a @@ -3218,11 +3218,11 @@ declare module "sequelize" { * * ```js * sequelize.define('model', { - * states: { - * type: Sequelize.ENUM, - * values: ['active', 'pending', 'deleted'] - * } - * }) + * states: { + * type: Sequelize.ENUM, + * values: ['active', 'pending', 'deleted'] + * } + * }) * ``` */ values? : Array; @@ -3265,7 +3265,7 @@ declare module "sequelize" { * The type of query you are executing. The query type affects how results are formatted before they are * passed back. The type is a string, but `Sequelize.QueryTypes` is provided as convenience shortcuts. */ - type?: string; + type?: string; /** * If true, transforms objects with `.` separated property names into nested objects using @@ -4042,8 +4042,8 @@ declare module "sequelize" { * Convert a user's username to upper case * ```js * instance.updateAttributes({ - * username: self.sequelize.fn('upper', self.sequelize.col('username')) - * }) + * username: self.sequelize.fn('upper', self.sequelize.col('username')) + * }) * ``` * @param fn The function you want to call * @param args All further arguments will be passed as arguments to the function @@ -4211,22 +4211,22 @@ declare module "sequelize" { * * ```js * sequelize.define('modelName', { - * columnA: { - * type: Sequelize.BOOLEAN, - * validate: { - * is: ["[a-z]",'i'], // will only allow letters - * max: 23, // only allow values <= 23 - * isIn: { - * args: [['en', 'zh']], - * msg: "Must be English or Chinese" - * } - * }, - * field: 'column_a' - * // Other attributes here - * }, - * columnB: Sequelize.STRING, - * columnC: 'MY VERY OWN COLUMN TYPE' - * }) + * columnA: { + * type: Sequelize.BOOLEAN, + * validate: { + * is: ["[a-z]",'i'], // will only allow letters + * max: 23, // only allow values <= 23 + * isIn: { + * args: [['en', 'zh']], + * msg: "Must be English or Chinese" + * } + * }, + * field: 'column_a' + * // Other attributes here + * }, + * columnB: Sequelize.STRING, + * columnC: 'MY VERY OWN COLUMN TYPE' + * }) * * sequelize.models.modelName // The model will now be available in models under the name given to define * ``` @@ -4297,12 +4297,12 @@ declare module "sequelize" { * * ```js * sequelize.query('SELECT...').spread(function (results, metadata) { - * // Raw query - use spread - * }); + * // Raw query - use spread + * }); * * sequelize.query('SELECT...', { type: sequelize.QueryTypes.SELECT }).then(function (results) { - * // SELECT query - use then - * }) + * // SELECT query - use then + * }) * ``` * * @param sql @@ -4417,12 +4417,12 @@ declare module "sequelize" { * * ```js * sequelize.transaction().then(function (t) { - * return User.find(..., { transaction: t}).then(function (user) { - * return user.updateAttributes(..., { transaction: t}); - * }) - * .then(t.commit.bind(t)) - * .catch(t.rollback.bind(t)); - * }) + * return User.find(..., { transaction: t}).then(function (user) { + * return user.updateAttributes(..., { transaction: t}); + * }) + * .then(t.commit.bind(t)) + * .catch(t.rollback.bind(t)); + * }) * ``` * * A syntax for automatically committing or rolling back based on the promise chain resolution is also @@ -4430,15 +4430,15 @@ declare module "sequelize" { * * ```js * sequelize.transaction(function (t) { // Note that we use a callback rather than a promise.then() - * return User.find(..., { transaction: t}).then(function (user) { - * return user.updateAttributes(..., { transaction: t}); - * }); - * }).then(function () { - * // Commited - * }).catch(function (err) { - * // Rolled back - * console.error(err); - * }); + * return User.find(..., { transaction: t}).then(function (user) { + * return user.updateAttributes(..., { transaction: t}); + * }); + * }).then(function () { + * // Commited + * }).catch(function (err) { + * // Rolled back + * console.error(err); + * }); * ``` * * If you have [CLS](https://github.com/othiym23/node-continuation-local-storage) enabled, the transaction @@ -4555,27 +4555,27 @@ declare module "sequelize" { * * ```js * { - * READ_UNCOMMITTED: "READ UNCOMMITTED", - * READ_COMMITTED: "READ COMMITTED", - * REPEATABLE_READ: "REPEATABLE READ", - * SERIALIZABLE: "SERIALIZABLE" - * } + * READ_UNCOMMITTED: "READ UNCOMMITTED", + * READ_COMMITTED: "READ COMMITTED", + * REPEATABLE_READ: "REPEATABLE READ", + * SERIALIZABLE: "SERIALIZABLE" + * } * ``` * * Pass in the desired level as the first argument: * * ```js * return sequelize.transaction({ - * isolationLevel: Sequelize.Transaction.SERIALIZABLE - * }, function (t) { - * - * // your transactions - * - * }).then(function(result) { - * // transaction has been committed. Do something after the commit if required. - * }).catch(function(err) { - * // do something with the err. - * }); + * isolationLevel: Sequelize.Transaction.SERIALIZABLE + * }, function (t) { + * + * // your transactions + * + * }).then(function(result) { + * // transaction has been committed. Do something after the commit if required. + * }).catch(function(err) { + * // do something with the err. + * }); * ``` * * @see ISOLATION_LEVELS @@ -4597,23 +4597,23 @@ declare module "sequelize" { * ```js * t1 // is a transaction * Model.findAll({ - * where: ..., - * transaction: t1, - * lock: t1.LOCK... - * }); + * where: ..., + * transaction: t1, + * lock: t1.LOCK... + * }); * ``` * * Postgres also supports specific locks while eager loading by using OF: * ```js * UserModel.findAll({ - * where: ..., - * include: [TaskModel, ...], - * transaction: t1, - * lock: { - * level: t1.LOCK..., - * of: UserModel - * } - * }); + * where: ..., + * include: [TaskModel, ...], + * transaction: t1, + * lock: { + * level: t1.LOCK..., + * of: UserModel + * } + * }); * ``` * UserModel will be locked but TaskModel won't! */ From 745b182be1dc7fe33d460661dab6ab2cbda449e7 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 26 Aug 2015 14:40:47 +0900 Subject: [PATCH 26/86] modify type of refarences model --- sequelize/sequelize.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index 0e84373a6e..d14f9711c2 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -3123,7 +3123,7 @@ declare module "sequelize" { /** * If this column references another table, provide it here as a Model, or a string */ - model?: Model; + model?: string | Model; /** * The column of the foreign table that this column references From 080810fc043c55222a44ab68fdc82c419057df6e Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 26 Aug 2015 14:41:24 +0900 Subject: [PATCH 27/86] modify return type of Instance methods --- sequelize/sequelize.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index d14f9711c2..41e8410aec 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -1563,7 +1563,7 @@ declare module "sequelize" { * @param options.plain If set to true, included instances will be returned as plain objects */ get( key : string, options? : { plain? : boolean, clone? : boolean } ) : any; - get( options? : { plain? : boolean, clone? : boolean } ) : Object; + get( options? : { plain? : boolean, clone? : boolean } ) : TAttributes; /** * Set is used to update values on the instance (the sequelize representation of the instance that is, @@ -1716,7 +1716,7 @@ declare module "sequelize" { * Convert the instance to a JSON representation. Proxies to calling `get` with no keys. This means get all * values gotten from the DB, and apply all custom getters. */ - toJSON() : Object; + toJSON() : TAttributes; } From bb1b99052bf1d697f0368fbff56898bc1f5a525c Mon Sep 17 00:00:00 2001 From: Roman Salnikov Date: Wed, 26 Aug 2015 11:07:48 +0500 Subject: [PATCH 28/86] Add submit method definition to form-data This method is currently missing. Here is just a basic interface to pass type checks. If you'd help me figure out how to depend on Node TSD, I'd try to make signature more correct, and return http or https response instead of just `any`. Also planning to add `params` object interface. --- form-data/form-data.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/form-data/form-data.d.ts b/form-data/form-data.d.ts index 98dc1567df..2af4565ccb 100644 --- a/form-data/form-data.d.ts +++ b/form-data/form-data.d.ts @@ -11,5 +11,6 @@ declare module "form-data" { getHeaders(): Object; // TODO expand pipe pipe(to: any): any; + submit(params: string|Object, callback: (error: any, response: any) => void): any; } } From 5037a214342644ce5425c74d41fd1721b2a07a08 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Wed, 26 Aug 2015 10:58:39 +0100 Subject: [PATCH 29/86] Fix #5499 Policies need to be static --- vortex-web-client/vortex-web-client-tests.ts | 4 +- vortex-web-client/vortex-web-client.d.ts | 69 ++++++++------------ 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/vortex-web-client/vortex-web-client-tests.ts b/vortex-web-client/vortex-web-client-tests.ts index 216e268c5e..bf6f72bbc2 100644 --- a/vortex-web-client/vortex-web-client-tests.ts +++ b/vortex-web-client/vortex-web-client-tests.ts @@ -7,7 +7,7 @@ var tqos = new dds.TopicQos(); var chatTopic = new dds.Topic(0, 'ChatMessage', tqos); runtime.registerTopic(chatTopic); -var writerQos = new dds.DataWriterQos(); +var writerQos = new dds.DataWriterQos(dds.Partition("chatroom"), dds.Reliability.Reliable, dds.Durability.Persistent); var writer = new dds.DataWriter(runtime, chatTopic, writerQos); writer.write({ @@ -15,7 +15,7 @@ writer.write({ msg : "Hello World!" }); -var readerQos = new dds.DataReaderQos(); +var readerQos = new dds.DataReaderQos(dds.Partition("chatroom"), dds.Reliability.Reliable, dds.Durability.Persistent); var reader = new dds.DataReader(runtime, chatTopic, readerQos); reader.addListener(function(msg) { diff --git a/vortex-web-client/vortex-web-client.d.ts b/vortex-web-client/vortex-web-client.d.ts index de665c7800..b432eff3f0 100644 --- a/vortex-web-client/vortex-web-client.d.ts +++ b/vortex-web-client/vortex-web-client.d.ts @@ -39,11 +39,11 @@ declare module DDS { /** * KeepAll - KEEP_ALL qos policy */ - KeepAll:any; + static KeepAll:any; /** * KeepLast - KEEP_LAST qos policy */ - KeepLast:any; + static KeepLast:any; } /** @@ -62,51 +62,37 @@ declare module DDS { /** * Reliable - 'Reliable' reliability policy */ - Reliable:any; + static Reliable:any; /** * BestEffort - 'BestEffort' reliability policy */ - BestEffort:any; + static BestEffort:any; } /** - * Partition policy + * Create new partition policy + * + * @param policies - partition names + * @example var qos = Partition('p1', 'p2') */ - export class Partition implements Policy { - /** - * Create new partition policy - * - * @param policies - partition names - * @example var qos = Partition('p1', 'p2') - */ - constructor(...policies:string[]); - } + export function Partition(...policies:string[]):Policy; /** - * Content Filter policy + * Create new content filter policy + * + * @param expr - filter expression + * @example var filter = ContentFilter("x>10 AND y<50") */ - export class ContentFilter implements Policy { - /** - * Create new content filter policy - * - * @param expr - filter expression - * @example var filter = ContentFilter("x>10 AND y<50") - */ - constructor(expr:string); - } + export function ContentFilter(expr:string):Policy; + /** - * Time Filter policy + * Create new time filter policy + * + * @param period - time duration (unit ?) + * @example var filter = TimeFilter(100) */ - export class TimeFilter implements Policy { - /** - * Create new content filter policy - * - * @param period - time duration (unit ?) - * @example var filter = TimeFilter(100) - */ - constructor(period:number); - } + export function TimeFilter(period:number):Policy; /** * Durability Policy @@ -125,19 +111,19 @@ declare module DDS { /** * Volatile - Volatile durability policy */ - Volatile:any; + static Volatile:any; /** * TransientLocal - TransientLocal durability policy */ - TransientLocal:any; + static TransientLocal:any; /** * Transient - Transient durability policy */ - Transient:any; + static Transient:any; /** * Persistent - Persistent durability policy */ - Persistent:any; + static Persistent:any; } @@ -473,7 +459,7 @@ declare module DDS { export var runtime:{ Runtime : Runtime; - } + }; export var VERSION:string; } @@ -482,7 +468,4 @@ declare module DDS { * Defines the core Vortex-Web-Client javascript library. It includes the JavaScript API for DDS. This API allows * web applications to share data among them as well as with native DDS applications. */ -declare -var dds:typeof DDS; - - +declare var dds:typeof DDS; From df00f78b09f81a87ed45204df6e53aa9dbe6d073 Mon Sep 17 00:00:00 2001 From: Chris Wrench Date: Wed, 26 Aug 2015 14:19:08 +0100 Subject: [PATCH 30/86] Add Offline definitions Fixes #5556. --- offline-js/offline-js-tests.ts | 40 ++++++++++++++++++++++ offline-js/offline-js.d.ts | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 offline-js/offline-js-tests.ts create mode 100644 offline-js/offline-js.d.ts diff --git a/offline-js/offline-js-tests.ts b/offline-js/offline-js-tests.ts new file mode 100644 index 0000000000..82af46683b --- /dev/null +++ b/offline-js/offline-js-tests.ts @@ -0,0 +1,40 @@ +// Test file for offline-js. +/// + +Offline.options = { + checkOnLoad: false, + interceptRequests: true, + checks: { + xhr: { url: '/connection-test' }, + image: { url: 'my-image.gif' }, + active: 'image' + }, + reconnect: { + initialDelay: 3, + delay: 60 + }, + requests: true, + game: false +}; + +Offline.check(); + +Offline.state; + +var handler = () => {}, + context = {}; + +Offline.on("up", handler, context); +Offline.on("down", handler, context); +Offline.on("confirmed-up", handler, context); +Offline.on("confirmed-down", handler, context); +Offline.on("checking", handler, context); +Offline.on("reconnect:started", handler, context); +Offline.on("reconnect:stopped", handler, context); +Offline.on("reconnect:tick", handler, context); +Offline.on("reconnect:connecting", handler, context); +Offline.on("reconnect:failure", handler, context); +Offline.on("requests:flush", handler, context); +Offline.on("requests:hold", handler, context); + +Offline.off("up", handler); \ No newline at end of file diff --git a/offline-js/offline-js.d.ts b/offline-js/offline-js.d.ts new file mode 100644 index 0000000000..1f8dd63d76 --- /dev/null +++ b/offline-js/offline-js.d.ts @@ -0,0 +1,62 @@ +// Type definitions for Offline 0.7.14 +// Project: https://github.com/HubSpot/offline +// Definitions by: Chris Wrench +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Offline: { + options: OfflineOptions; + check: () => void; + state: string; + on(event: string, handler: (e: Event) => any, context?: any): void; + on(event: "up", handler: (e: Event) => any, context?: any): void; + on(event: "down", handler: (e: Event) => any, context?: any): void; + on(event: "confirmed-up", handler: (e: Event) => any, context?: any): void; + on(event: "confirmed-down", handler: (e: Event) => any, context?: any): void; + on(event: "checking", handler: (e: Event) => any, context?: any): void; + on(event: "reconnect:started", handler: (e: Event) => any, context?: any): void; + on(event: "reconnect:stopped", handler: (e: Event) => any, context?: any): void; + on(event: "reconnect:tick", handler: (e: Event) => any, context?: any): void; + on(event: "reconnect:connecting", handler: (e: Event) => any, context?: any): void; + on(event: "reconnect:failure", handler: (e: Event) => any, context?: any): void; + on(event: "requests:flush", handler: (e: Event) => any, context?: any): void; + on(event: "requests:hold", handler: (e: Event) => any, context?: any): void; + off(event: string, handler?: (e: Event) => any): void; + off(event: "up", handler?: (e: Event) => any): void; + off(event: "down", handler?: (e: Event) => any): void; + off(event: "confirmed-up", handler?: (e: Event) => any): void; + off(event: "confirmed-down", handler?: (e: Event) => any): void; + off(event: "checking", handler?: (e: Event) => any): void; + off(event: "reconnect:started", handler?: (e: Event) => any): void; + off(event: "reconnect:stopped", handler?: (e: Event) => any): void; + off(event: "reconnect:tick", handler?: (e: Event) => any): void; + off(event: "reconnect:connecting", handler?: (e: Event) => any): void; + off(event: "reconnect:failure", handler?: (e: Event) => any): void; + off(event: "requests:flush", handler?: (e: Event) => any): void; + off(event: "requests:hold", handler?: (e: Event) => any): void; +}; + +interface OfflineOptions { + // TODO Should these types be `boolean|Function`? + // The project documentation is not clear here. + checkOnLoad?: boolean; + interceptRequests?: boolean; + requests?: boolean; + game?: boolean; + checks?: OfflineChecks; + reconnect: { + initialDelay: number; + delay: number; + }; +} + +interface OfflineChecks { + // TODO "xhr" and "image" probably have different options. + // However, this is not stated in the project documentation. + xhr?: OfflineCheck; + image?: OfflineCheck; + active?: string; +} + +interface OfflineCheck { + url: string; +} From 3159d3f697522e0d95f50a1b88d77600a4f5559b Mon Sep 17 00:00:00 2001 From: Chris Wrench Date: Wed, 26 Aug 2015 20:53:19 +0100 Subject: [PATCH 31/86] Fix offline-js formatting --- offline-js/offline-js.d.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/offline-js/offline-js.d.ts b/offline-js/offline-js.d.ts index 1f8dd63d76..f52b47e0cf 100644 --- a/offline-js/offline-js.d.ts +++ b/offline-js/offline-js.d.ts @@ -6,8 +6,8 @@ declare var Offline: { options: OfflineOptions; check: () => void; - state: string; - on(event: string, handler: (e: Event) => any, context?: any): void; + state: string; + on(event: "up", handler: (e: Event) => any, context?: any): void; on(event: "down", handler: (e: Event) => any, context?: any): void; on(event: "confirmed-up", handler: (e: Event) => any, context?: any): void; @@ -20,7 +20,8 @@ declare var Offline: { on(event: "reconnect:failure", handler: (e: Event) => any, context?: any): void; on(event: "requests:flush", handler: (e: Event) => any, context?: any): void; on(event: "requests:hold", handler: (e: Event) => any, context?: any): void; - off(event: string, handler?: (e: Event) => any): void; + on(event: string, handler: (e: Event) => any, context?: any): void; + off(event: "up", handler?: (e: Event) => any): void; off(event: "down", handler?: (e: Event) => any): void; off(event: "confirmed-up", handler?: (e: Event) => any): void; @@ -32,11 +33,12 @@ declare var Offline: { off(event: "reconnect:connecting", handler?: (e: Event) => any): void; off(event: "reconnect:failure", handler?: (e: Event) => any): void; off(event: "requests:flush", handler?: (e: Event) => any): void; - off(event: "requests:hold", handler?: (e: Event) => any): void; + off(event: "requests:hold", handler?: (e: Event) => any): void; + off(event: string, handler?: (e: Event) => any): void; }; interface OfflineOptions { - // TODO Should these types be `boolean|Function`? + // TODO Should these types be `boolean|Function`? // The project documentation is not clear here. checkOnLoad?: boolean; interceptRequests?: boolean; @@ -50,8 +52,8 @@ interface OfflineOptions { } interface OfflineChecks { - // TODO "xhr" and "image" probably have different options. - // However, this is not stated in the project documentation. + // TODO "xhr" and "image" probably have different options. + // However, this is not stated in the project documentation. xhr?: OfflineCheck; image?: OfflineCheck; active?: string; From ab7877b6622c655e9b2e6b07b442d244a5ef643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andy=20Hawkins=20=E2=80=94=20=28=CC=90=CC=85=CC=96=CC=A3?= =?UTF-8?q?=CD=95=CC=A0=CC=AC=CC=AD=CC=9E=CC=AAi=CC=89=CD=AE=CC=AD=CC=A3?= =?UTF-8?q?=CD=88=CC=AA=CC=A0s=CD=91=CD=8C=CD=8B=CD=AA=CC=83=CC=8D=CC=B3?= =?UTF-8?q?=CC=B3=CC=A6=CC=9E=CC=B0=CC=9C=CC=9E=CC=B3=20=CC=81=CD=91=CD=A8?= =?UTF-8?q?=CD=84=CC=8E=CC=8B=CD=AE=CD=8A=CC=80=CC=A9=CC=98n=CC=83=CC=88?= =?UTF-8?q?=CD=AE=CD=A6=CC=81=CD=AB=CD=90=CD=9B=CD=94=CC=A3=CD=85=CD=85?= =?UTF-8?q?=CD=93=CC=ACo=CC=90=CD=86=CC=BD=CC=A9=CC=A6=CC=B3=CC=A0=CC=99?= =?UTF-8?q?=CC=97=CC=AF=CC=BAt=CD=82=CD=A9=CD=8B=CC=85=CD=84=CC=9C=CC=A5?= =?UTF-8?q?=CC=BB=CC=99=CC=9F=CC=BC=CC=9C=20=CD=92=CD=8B=CC=85=CC=81=CD=90?= =?UTF-8?q?=CC=A0=CC=A6=CC=B9=CC=9F=CD=95=CD=95=CC=B1=CD=89a=CC=84=CD=A6?= =?UTF-8?q?=CC=92=CC=8D=CD=8B=CC=9F=CC=BB=CC=B1=20=CD=A8=CD=A9=CD=8A=CD=82?= =?UTF-8?q?=CC=89=CD=85=CC=97=CC=9E=CD=9Ah=CD=A3=CD=94=CC=BC=CD=9A=CC=A9?= =?UTF-8?q?=CD=9A=CC=AA=CC=9D=CC=9Da=CC=92=CC=93=CD=AC=CC=AB=CC=ABc=CC=83?= =?UTF-8?q?=CD=A5=CD=AF=CC=A6=CC=B2=CC=B3=CD=8D=CC=B9k=CC=8A=CC=B2=CD=95?= =?UTF-8?q?=CC=97=CC=96=CC=A4=CC=99=CC=9C=CD=8De=CC=BF=CC=AB=CD=8E=CC=9F?= =?UTF-8?q?=CC=BC=CC=BA=CC=ABr=CC=8A=CC=91=CC=BF=CC=85=CD=AF=CD=99=CD=85?= =?UTF-8?q?=CC=B0=29=CD=86=CC=87=CD=A7=CC=9A=CD=91=CC=AA=CC=96=CD=87=CC=9D?= =?UTF-8?q?=CC=AE=CC=AA=CD=96=CC=A6?= Date: Wed, 26 Aug 2015 16:38:26 -0400 Subject: [PATCH 32/86] Update to fix AMD/UMD module imports --- stripe/stripe.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index ca589e133e..7771b092bb 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -1,6 +1,6 @@ -// Type definitions for stripe +// Type definitions for stripe (AMD/UMD compatible) // Project: https://stripe.com/ -// Definitions by: Eric J. Smith +// Definitions by: Andy Hawkins , Eric J. Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StripeStatic { @@ -11,6 +11,7 @@ interface StripeStatic { cardType(cardNumber: string): string; getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void): void; card: StripeCardData; + createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } interface StripeTokenData { @@ -57,8 +58,9 @@ interface StripeCardData { address_state?: string; address_zip?: string; address_country?: string; - - createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; } declare var Stripe: StripeStatic; +declare module "Stripe" { + export = StripeStatic; +} From c4a713cfeecbb7e26fed4984611bbb35054867ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andy=20Hawkins=20=E2=80=94=20=28=CC=90=CC=85=CC=96=CC=A3?= =?UTF-8?q?=CD=95=CC=A0=CC=AC=CC=AD=CC=9E=CC=AAi=CC=89=CD=AE=CC=AD=CC=A3?= =?UTF-8?q?=CD=88=CC=AA=CC=A0s=CD=91=CD=8C=CD=8B=CD=AA=CC=83=CC=8D=CC=B3?= =?UTF-8?q?=CC=B3=CC=A6=CC=9E=CC=B0=CC=9C=CC=9E=CC=B3=20=CC=81=CD=91=CD=A8?= =?UTF-8?q?=CD=84=CC=8E=CC=8B=CD=AE=CD=8A=CC=80=CC=A9=CC=98n=CC=83=CC=88?= =?UTF-8?q?=CD=AE=CD=A6=CC=81=CD=AB=CD=90=CD=9B=CD=94=CC=A3=CD=85=CD=85?= =?UTF-8?q?=CD=93=CC=ACo=CC=90=CD=86=CC=BD=CC=A9=CC=A6=CC=B3=CC=A0=CC=99?= =?UTF-8?q?=CC=97=CC=AF=CC=BAt=CD=82=CD=A9=CD=8B=CC=85=CD=84=CC=9C=CC=A5?= =?UTF-8?q?=CC=BB=CC=99=CC=9F=CC=BC=CC=9C=20=CD=92=CD=8B=CC=85=CC=81=CD=90?= =?UTF-8?q?=CC=A0=CC=A6=CC=B9=CC=9F=CD=95=CD=95=CC=B1=CD=89a=CC=84=CD=A6?= =?UTF-8?q?=CC=92=CC=8D=CD=8B=CC=9F=CC=BB=CC=B1=20=CD=A8=CD=A9=CD=8A=CD=82?= =?UTF-8?q?=CC=89=CD=85=CC=97=CC=9E=CD=9Ah=CD=A3=CD=94=CC=BC=CD=9A=CC=A9?= =?UTF-8?q?=CD=9A=CC=AA=CC=9D=CC=9Da=CC=92=CC=93=CD=AC=CC=AB=CC=ABc=CC=83?= =?UTF-8?q?=CD=A5=CD=AF=CC=A6=CC=B2=CC=B3=CD=8D=CC=B9k=CC=8A=CC=B2=CD=95?= =?UTF-8?q?=CC=97=CC=96=CC=A4=CC=99=CC=9C=CD=8De=CC=BF=CC=AB=CD=8E=CC=9F?= =?UTF-8?q?=CC=BC=CC=BA=CC=ABr=CC=8A=CC=91=CC=BF=CC=85=CD=AF=CD=99=CD=85?= =?UTF-8?q?=CC=B0=29=CD=86=CC=87=CD=A7=CC=9A=CD=91=CC=AA=CC=96=CD=87=CC=9D?= =?UTF-8?q?=CC=AE=CC=AA=CD=96=CC=A6?= Date: Wed, 26 Aug 2015 16:41:20 -0400 Subject: [PATCH 33/86] fix header --- stripe/stripe.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 7771b092bb..96d8758bc7 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe (AMD/UMD compatible) +// Type definitions for stripe // Project: https://stripe.com/ // Definitions by: Andy Hawkins , Eric J. Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped From 8b244197ae005a85f5fe10338676e51e70a45a42 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Thu, 27 Aug 2015 01:20:05 +0100 Subject: [PATCH 34/86] Create jquery-urlparam.d.ts --- jquery-urlparam/jquery-urlparam.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 jquery-urlparam/jquery-urlparam.d.ts diff --git a/jquery-urlparam/jquery-urlparam.d.ts b/jquery-urlparam/jquery-urlparam.d.ts new file mode 100644 index 0000000000..497f9fda5c --- /dev/null +++ b/jquery-urlparam/jquery-urlparam.d.ts @@ -0,0 +1,8 @@ +// Type definitions for jquery-urlparam +// Project: https://gist.github.com/stpettersens/e1f4478f299b6f4905c1 +// Definitions by: Sam Saint-Pettersen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JQueryStatic { + urlParam(variable: string): string; +} From 65d6b9b507bdcfdf814cdb183a1922e93f547b81 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Thu, 27 Aug 2015 01:21:08 +0100 Subject: [PATCH 35/86] Create jquery-urlparam-tests.ts --- jquery-urlparam/jquery-urlparam-tests.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 jquery-urlparam/jquery-urlparam-tests.ts diff --git a/jquery-urlparam/jquery-urlparam-tests.ts b/jquery-urlparam/jquery-urlparam-tests.ts new file mode 100644 index 0000000000..5ad4d26d5f --- /dev/null +++ b/jquery-urlparam/jquery-urlparam-tests.ts @@ -0,0 +1,4 @@ +/// +/// + +console.log($.urlParam('variable')); From 0b2232d9414d363e7e9a1ed238ea0c4394959b58 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 27 Aug 2015 06:16:17 +0500 Subject: [PATCH 36/86] lodash: changed _.isBoolean() method --- lodash/lodash-tests.ts | 8 ++++++-- lodash/lodash.d.ts | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index bb7a665606..1cc61685b6 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1207,6 +1207,12 @@ result = _(1).isArray(); result = _([]).isArray(); result = _({}).isArray(); +// _.isBoolean +result = _.isBoolean(any); +result = _(1).isBoolean(); +result = _([]).isBoolean(); +result = _({}).isBoolean(); + // _.isDate result = _.isDate(any); result = _(42).isDate(); @@ -1473,8 +1479,6 @@ interface FirstSecond { } result = _.invert({ 'first': 'moe', 'second': 'larry' }); -result = _.isBoolean(null); - result = _.isElement(document.body); // _.isEqual (alias: _.eq) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 43ba61f3b9..f4ba8e4285 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6196,6 +6196,23 @@ declare module _ { isArray(): boolean; } + //_.isBoolean + interface LoDashStatic { + /** + * Checks if value is classified as a boolean primitive or object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isBoolean(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isBoolean + */ + isBoolean(): boolean; + } + //_.isDate interface LoDashStatic { /** @@ -7063,16 +7080,6 @@ declare module _ { invert(object: any): any; } - //_.isBoolean - interface LoDashStatic { - /** - * Checks if value is a boolean value. - * @param value The value to check. - * @return True if the value is a boolean value, else false. - **/ - isBoolean(value?: any): boolean; - } - //_.isElement interface LoDashStatic { /** From c9b2b234a5f8f28df50ded178be61786f2204518 Mon Sep 17 00:00:00 2001 From: Jason Saelhof Date: Wed, 26 Aug 2015 22:07:11 -0600 Subject: [PATCH 37/86] Add missing PlayPropsConfig definition and some missing properties of the Sound object --- soundjs/soundjs.d.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index 8990634674..445006cabf 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -142,7 +142,21 @@ declare module createjs { export class HTMLAudioTagPool { - } + } + + export class PlayPropsConfig + { + delay:number; + duration:number; + interrupt:string; + loop:number; + offset:number; + pan:number; + startTime:number; + volume:number; + static create( value:PlayPropsConfig|any ): PlayPropsConfig; + set ( props:any ): PlayPropsConfig; + } export class Sound extends EventDispatcher { @@ -160,8 +174,10 @@ declare module createjs { static PLAY_INITED: string; static PLAY_INTERRUPTED: string; static PLAY_SUCCEEDED: string; - static SUPPORTED_EXTENSIONS: string[]; - + static SUPPORTED_EXTENSIONS: string[]; + static muted: boolean; + static volume: number; + static capabilities: any; // methods static createInstance(src: string): AbstractSoundInstance; From 0f0e62958cd7c30337c976c270cfde455f26d45c Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Thu, 27 Aug 2015 14:19:14 +0100 Subject: [PATCH 38/86] Add lastError to Sinon-Chrome --- sinon-chrome/sinon-chrome.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sinon-chrome/sinon-chrome.d.ts b/sinon-chrome/sinon-chrome.d.ts index eddb32be41..f5aa2344f2 100644 --- a/sinon-chrome/sinon-chrome.d.ts +++ b/sinon-chrome/sinon-chrome.d.ts @@ -411,6 +411,7 @@ declare module SinonChrome.runtime { export var id: string; export var getURL: Sinon.SinonSpy; + export var lastError: { message?: string }; } declare module SinonChrome.sessions { From 2309881fef1581fce21248031b18dfc93adc36f9 Mon Sep 17 00:00:00 2001 From: Lars Magnusson Date: Thu, 27 Aug 2015 16:48:34 +0200 Subject: [PATCH 39/86] Underscore: Add types for functions extendOwn() and assign() --- underscore/underscore-tests.ts | 2 ++ underscore/underscore.d.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index f469d3bea0..13410c23b8 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -177,6 +177,8 @@ _.pairs({ one: 1, two: 2, three: 3 }); _.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" }); _.functions(_); _.extend({ name: 'moe' }, { age: 50 }); +_.extendOwn({ name: 'moe'}, { age: 50 }); +_.assign({ name: 'moe'}, { age: 50 }); _.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name'); _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 4aed7a855f..1f8faf2e24 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1236,6 +1236,20 @@ interface UnderscoreStatic { destination: any, ...sources: any[]): any; + /** + * Like extend, but only copies own properties over to the destination object. (alias: assign) + */ + extendOwn( + destination: any, + ...source: any[]): any; + + /** + * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) + */ + assign( + destination: any, + ...source: any[]): any; + /** * Return a copy of the object, filtered to only have values for the whitelisted keys * (or array of valid keys). From 8cd6b403d3d3db8c8014c1a0a16186b224662f4c Mon Sep 17 00:00:00 2001 From: Adam Santaniello Date: Thu, 27 Aug 2015 11:38:55 -0400 Subject: [PATCH 40/86] Update angular-signalr-hub.d.ts Fixed problem with parentheses --- angular-signalr-hub/angular-signalr-hub.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-signalr-hub/angular-signalr-hub.d.ts b/angular-signalr-hub/angular-signalr-hub.d.ts index 1edae69c7a..3027941061 100644 --- a/angular-signalr-hub/angular-signalr-hub.d.ts +++ b/angular-signalr-hub/angular-signalr-hub.d.ts @@ -18,7 +18,7 @@ declare module ngSignalr { connection: SignalR; proxy: HubProxy; - on(event: string, fn: ((...args: any[]) => void)): void; + on(event: string, fn: (...args: any[]) => void): void; invoke(method: string, ...args: any[]): JQueryDeferred; disconnect(): void; connect(): JQueryPromise; @@ -70,4 +70,4 @@ declare module ngSignalr { */ stateChanged?: (state: SignalRStateChange) => void; } -} \ No newline at end of file +} From 57e0d06f65221edfa3da4c9bf9f33e659a501195 Mon Sep 17 00:00:00 2001 From: "Krueger, Brandon" Date: Thu, 27 Aug 2015 15:00:20 -0500 Subject: [PATCH 41/86] IRouteAdditionalConfigurationOptions.auth can have either property strategies or strategy -- both are optional --- hapi/hapi-8.2.0.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hapi/hapi-8.2.0.d.ts b/hapi/hapi-8.2.0.d.ts index 8d3da2620b..80fcc4357d 100644 --- a/hapi/hapi-8.2.0.d.ts +++ b/hapi/hapi-8.2.0.d.ts @@ -390,7 +390,8 @@ declare module "hapi" { 'try'same as 'optional' but allows for invalid authentication. */ mode: string; /** a string array of strategy names in order they should be attempted.If only one strategy is used, strategy can be used instead with the single string value.Defaults to the default authentication strategy which is available only when a single strategy is configured. */ - strategies: string | Array; + strategies?: string | Array; + strategy?: string; /** if set, the payload (in requests other than 'GET' and 'HEAD') is authenticated after it is processed.Requires a strategy with payload authentication support (e.g.Hawk).Cannot be set to a value other than 'required' when the scheme sets the options.payload to true.Available values: falseno payload authentication.This is the default value. 'required'payload authentication required.This is the default value when the scheme sets options.payload to true. From e63ff8f99a020c7a7ffa860e85c3d0eaac435726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Le=20Dorze?= Date: Thu, 27 Aug 2015 22:10:18 +0200 Subject: [PATCH 42/86] Verify in crypto extends WritableStream --- node/node-0.11.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index cd55bdfb1c..a6aa3c970e 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -1094,7 +1094,7 @@ declare module "crypto" { sign(private_key: string, output_format: string): string; } export function createVerify(algorith: string): Verify; - interface Verify { + interface Verify extends NodeJS.WritableStream { update(data: any): void; verify(object: string, signature: string, signature_format?: string): boolean; } From cbadcb1b110d246e5e0f4012b1ab54e7f5633782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Le=20Dorze?= Date: Thu, 27 Aug 2015 22:43:14 +0200 Subject: [PATCH 43/86] Signer is writable stream in crypto --- node/node-0.11.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index a6aa3c970e..839ce2e41b 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -1089,7 +1089,7 @@ declare module "crypto" { setAutoPadding(auto_padding: boolean): void; } export function createSign(algorithm: string): Signer; - interface Signer { + interface Signer extends NodeJS.WritableStream { update(data: any): void; sign(private_key: string, output_format: string): string; } From d14a6d94a642db133d6aeaca64f075033bba12c9 Mon Sep 17 00:00:00 2001 From: Roman Salnikov Date: Fri, 28 Aug 2015 15:09:58 +0500 Subject: [PATCH 44/86] Add definition for missing replyWithError method in nock https://github.com/pgte/nock/blob/a407b73ac8f0daa947dccf4a29b86b8f99138157/lib/scope.js#L62 --- nock/nock.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/nock/nock.d.ts b/nock/nock.d.ts index 3cd92e65af..44d7080a03 100644 --- a/nock/nock.d.ts +++ b/nock/nock.d.ts @@ -56,6 +56,7 @@ declare module "nock" { reply(responseCode: number, body?: Object, headers?: Object): Scope; reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope; replyWithFile(responseCode: number, fileName: string): Scope; + replyWithError(errorMessage: string): Scope; defaultReplyHeaders(headers: Object): Scope; From d92492b8537d8e1eeac58bc6cc30ff7439d634f8 Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 28 Aug 2015 23:51:58 +0900 Subject: [PATCH 45/86] fix vortex-web-client/vortex-web-client.d.ts --- vortex-web-client/vortex-web-client.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vortex-web-client/vortex-web-client.d.ts b/vortex-web-client/vortex-web-client.d.ts index de665c7800..bb038a6bd6 100644 --- a/vortex-web-client/vortex-web-client.d.ts +++ b/vortex-web-client/vortex-web-client.d.ts @@ -482,7 +482,4 @@ declare module DDS { * Defines the core Vortex-Web-Client javascript library. It includes the JavaScript API for DDS. This API allows * web applications to share data among them as well as with native DDS applications. */ -declare -var dds:typeof DDS; - - +declare var dds:typeof DDS; From ef81ae6648fd0f3519e463c898433424f00b78e3 Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 28 Aug 2015 23:55:35 +0900 Subject: [PATCH 46/86] fix loglevel/loglevel.d.ts --- loglevel/loglevel.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loglevel/loglevel.d.ts b/loglevel/loglevel.d.ts index 01b80b7222..9f3c53f5a0 100644 --- a/loglevel/loglevel.d.ts +++ b/loglevel/loglevel.d.ts @@ -98,5 +98,4 @@ declare module loglevel { export function noConflict():any; } -declare -var log:typeof loglevel; +declare var log:typeof loglevel; From c88ead53b7fa6caece42ddc5db065c6c5d1888fb Mon Sep 17 00:00:00 2001 From: "chocolatechipui@sourcebits.com" Date: Fri, 28 Aug 2015 11:56:07 -0700 Subject: [PATCH 47/86] Update for pub/sub types. --- chocolatechipjs/chocolatechipjs.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chocolatechipjs/chocolatechipjs.d.ts b/chocolatechipjs/chocolatechipjs.d.ts index 6a45863b09..8ba5cc25f3 100644 --- a/chocolatechipjs/chocolatechipjs.d.ts +++ b/chocolatechipjs/chocolatechipjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for chocolatechip v4.0.3 +// Type definitions for chocolatechip v4.0.4 // Project: https://github.com/chocolatechipui/ChocolateChipJS // Definitions by: Robert Biggs // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -456,7 +456,7 @@ interface ChocolateChipStatic { * @data any You can receive any type: string, number, array, object, etc. * @return any */ - subscribe(topic: string, callback: (topic: string, data: any) => boolean): boolean; + subscribe(topic: string, callback: (topic: string, data: any) => any): boolean; /** * Unsubscribe from a topic. Pass this the topic you wish to unsubscribe from. The subscription will be terminated immediately. @@ -1480,3 +1480,5 @@ interface Window { } declare var $: ChocolateChipStatic; declare var fetch: fetch; + +declare var chocolatechipjs: ChocolateChipStatic; \ No newline at end of file From 9c6860963e667984597ffe12d111968f4a153caa Mon Sep 17 00:00:00 2001 From: Holly Leary Date: Fri, 28 Aug 2015 13:48:21 -0700 Subject: [PATCH 48/86] Update hapi.d.ts Add 'isBoom: boolean' in order to know whether the response has an error or not. --- hapi/hapi.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 519a0ff27e..3fc5dca036 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -1314,6 +1314,7 @@ declare module "hapi" { return reply.continue(); });*/ export class Response extends Events.EventEmitter { + isBoom: boolean; /** the HTTP response status code. Defaults to 200 (except for errors).*/ statusCode: number; /** an object containing the response headers where each key is a header field name. Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepare for transmission.*/ From 65ae47ea66e92bbed1d881995cd8969f190fdc46 Mon Sep 17 00:00:00 2001 From: Sam Saint-Pettersen Date: Sat, 29 Aug 2015 02:43:10 +0100 Subject: [PATCH 49/86] Update jquery-urlparam.d.ts --- jquery-urlparam/jquery-urlparam.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery-urlparam/jquery-urlparam.d.ts b/jquery-urlparam/jquery-urlparam.d.ts index 497f9fda5c..af37cd0366 100644 --- a/jquery-urlparam/jquery-urlparam.d.ts +++ b/jquery-urlparam/jquery-urlparam.d.ts @@ -3,6 +3,8 @@ // Definitions by: Sam Saint-Pettersen // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + interface JQueryStatic { urlParam(variable: string): string; } From 8617e7b3c94a8354e37ebd6cdc3e4eab6f59d8f0 Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Sat, 29 Aug 2015 09:19:39 +0300 Subject: [PATCH 50/86] Update node-mysql-wrapper.d.ts --- node-mysql-wrapper/node-mysql-wrapper.d.ts | 208 ++++++++++----------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/node-mysql-wrapper/node-mysql-wrapper.d.ts b/node-mysql-wrapper/node-mysql-wrapper.d.ts index 55cd039e86..6f792d96de 100644 --- a/node-mysql-wrapper/node-mysql-wrapper.d.ts +++ b/node-mysql-wrapper/node-mysql-wrapper.d.ts @@ -3,129 +3,129 @@ // Definitions by: Makis Maropoulos // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// /// declare module "node-mysql-wrapper" { - import Mysql = require("mysql"); + import * as Mysql from 'mysql'; + import * as Promise from 'bluebird'; + import {EventEmitter} from 'events'; - function MySQLWrapperBuilder(connection: string | Mysql.IConnection, ...useOnlyTables: string[]): MySQLWrapper; + var EQUAL_TO_PROPERTY_SYMBOL: string; - enum EVENT_TYPES { - INSERT, UPDATE, DELETE, SAVE + interface Map { + [index: string]: T; } - interface MySQLConnection { - new (connection: string | Mysql.IConnection): MySQLConnection; + class MysqlUtil { + constructor(); + static copyObject(object: T): T; + static toObjectProperty(columnKey: string): string; + static toRowProperty(objectKey: string): string; + static forEachValue(map: Map, callback: (value: T) => U): U; + static forEachKey(map: Map, callback: (key: string) => U): U; + } - create(connectionUri: string): void; - create(connection: Mysql.IConnection): void; + interface ICriteria { + rawCriteriaObject: any; + tables: string[]; + noDatabaseProperties: string[]; + whereClause: string; + } + + class Criteria implements ICriteria { + rawCriteriaObject: any; + tables: string[]; + noDatabaseProperties: string[]; + whereClause: string; + constructor(rawCriteriaObject: any, tables: string[], noDatabaseProperties: string[], whereClause: string); + } + + class CriteriaBuilder { + private _table; + constructor(table: MysqlTable); + build(rawCriteriaObject: any): Criteria; + } + + class MysqlConnection extends EventEmitter { + connection: Mysql.IConnection; + eventTypes: string[]; + tableNamesToUseOnly: any[]; + tables: MysqlTable[]; + constructor(connection: string | Mysql.IConnection); + create(connection: string | Mysql.IConnection): void; attach(connection: Mysql.IConnection): void; - end(callback: () => void): void; + end(callback?: (error: any) => void): void; destroy(): void; - link(callback?: () => void): Promise; - connect(callback?: () => void): Promise; - - useOnly(...useOnlyTables: string[]): void; - - fetchDatabaseInfornation(): Promise; - + link(readyCallback?: () => void): Promise; + useOnly(...tables: any[]): void; + fetchDatabaseInfornation(): Promise; escape(val: string): string; - notice(tableWhichCalled: string, queryStr: string, parsedResults: Object[]): void; - fireEvent(tableWhichCalled: string, queryStr: string, parsedResults: Object[]): void; - - watch(tableName: string, evtType: EVENT_TYPES | string, callback: (parsedResults: Object[]) => void): void; - on(tableName: string, evtType: EVENT_TYPES | string, callback: (parsedResults: Object[]) => void): void; - unwatch(tableName: string, evtType: EVENT_TYPES | string, callbackToRemove: () => void): void; - off(tableName: string, evtType: EVENT_TYPES | string, callbackToRemove: () => void): void; - - query(mysqlQuery: Mysql.IQueryFunction): void; - - table(tableName: string): MySQLTable; + notice(tableWhichCalled: string, queryStr: string, parsedResults: any[]): void; + watch(tableName: string, evtType: any, callback: (parsedResults: any[]) => void): void; + unwatch(tableName: string, evtType: string, callbackToRemove: (parsedResults: any[]) => void): void; + query(queryStr: string, callback: (err: Mysql.IError, results: any) => any, queryArguments?: any[]): void; + table(tableName: string): MysqlTable; } - - interface MySQLTable { - new (tableName: string, connection: MySQLConnection): MySQLTable; - - setColumns(columns: string[]): void; - - setPrimaryKey(primaryKeyColumnName: string): void; - - toString(): string; - - model(jsObject: Object): MySQLModel; - - watch(evtType: EVENT_TYPES | string, callback: (parsedResults: Object[]) => void): void; - on(evtType: EVENT_TYPES | string, callback: (parsedResults: Object[]) => void): void; - unwatch(evtType: EVENT_TYPES|string, callbackToRemove: () => void): void; - off(evtType: EVENT_TYPES|string, callbackToRemove: () => void): void; - - ///START DYNAMIC METHODS FOR TABLES CANNOT BE PRE-DEFINED WITH DYNAMIC WAY, YET, SO: - find(jsObject: Object, callback?: (results: Object[]) => void): Promise; - save(jsObject: Object, callback?: (results: Object[]) => void): Promise; - remove(jsObject: Object, callback?: (results: Object[]) => void): Promise; - delete(jsObject: Object, callback?: (results: Object[]) => void): Promise; - safeDelete(jsObject: Object, callback?: (results: Object[]) => void): Promise; - ///END - findAll(callback?: (results: Object[]) => void): Promise; - - extend(functionName: string, functionToBeSupported: () => any): void; - + + class MysqlTable { + private _name; + private _connection; + private _columns; + private _primaryKey; + private _criteriaBuilder; + constructor(tableName: string, connection: MysqlConnection); + columns: string[]; + primaryKey: string; + connection: MysqlConnection; + name: string; + on(evtType: string, callback: (parsedResults: any[]) => void): void; + off(evtType: string, callbackToRemove: (parsedResults: any[]) => void): void; has(extendedFunctionName: string): boolean; - + extend(functionName: string, theFunction: (...args: any[]) => any): void; + objectFromRow(row: any): any; + rowFromObject(obj: any): any; + getRowAsArray(jsObject: any): Array; + getPrimaryKeyValue(jsObject: any): number | string; + parseQueryResult(result: any, criteria: ICriteria): Promise; + find(criteriaRawJsObject: any, callback?: (_results: T[]) => any): Promise; + findById(id: number | string, callback?: (result: T) => any): Promise; + findAll(callback?: (_results: T[]) => any): Promise; + save(criteriaRawJsObject: any, callback?: (_result: any) => any): Promise; + safeRemove(id: number | string, callback?: (_result: { + affectedRows: number; + table: string; + }) => any): Promise<{ + affectedRows: number; + table: string; + }>; + remove(criteriaRawJsObject: any, callback?: (_result: { + affectedRows: number; + table: string; + }) => any): Promise<{ + affectedRows: number; + table: string; + }>; } - interface MySQLModel { - - new (table: MySQLTable, jsObject: Object): MySQLModel; - - toObjectProperty(columnKey: string): string; - toRowProperty(objectKey: string): string; - - create(jsObject: Object): MySQLModel; - reUse(jsObject: Object): MySQLModel; - - toRow(): void; - getRawObject(): Object; - - parseTable(mysqlTableToSearch: String, parentObject: Object): Promise; - parseResult(result: Object, tablesToSearch: string[]): Promise; - - find(parentObj?: Object): Promise; - findAll(): Promise; - save(): Promise; - safeDelete(): Promise; - remove(): Promise; - delete(): Promise; - - } - - interface MySQLWrapper { - new (connection?: MySQLConnection): MySQLWrapper; - - setConnection(connection: MySQLConnection): void; - - useOnly(...useOnlyTables: string[]): void; - - has(tableName: string): boolean; - has(tableName: string, methodName: string): boolean; - + class MysqlWrapper { + connection: MysqlConnection; + readyListenerCallbacks: Function[]; + constructor(connection?: MysqlConnection); + static when(..._promises: Promise[]): Promise; + setConnection(connection: MysqlConnection): void; + useOnly(...useTables: any[]): void; + has(tableName: string, functionName?: string): boolean; ready(callback: () => void): void; + table(tableName: string): MysqlTable; noticeReady(): void; - removeReadyListener(callback: () => any): void; - - query: Mysql.IQueryFunction; - + removeReadyListener(callback: () => void): void; + query(queryStr: string, callback: (err: Mysql.IError, results: any) => any, queryArguments?: any[]): void; destroy(): void; - end(callback?: () => void): void; - - when(): Promise; - - ///START: WE CANNOT PRE-DEFINE THE DYNAMIC TABLES INTO PROPERTIES, SO WE USE INDEX(STRING-TABLENAME) TO GET A TABLE - table(tableName: string): MySQLTable; - ///END + end(maybeAcallbackError: (err: any) => void): void; } - export = MySQLWrapperBuilder; + function wrap(mysqlUrlOrObjectOrMysqlAlreadyConnection: Mysql.IConnection | string, ...useTables: any[]): MysqlWrapper; + } From a234874167a7d6634fdce467fb3f9afd2a655daf Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Sat, 29 Aug 2015 09:19:59 +0300 Subject: [PATCH 51/86] Update node-mysql-wrapper-tests.ts --- .../node-mysql-wrapper-tests.ts | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/node-mysql-wrapper/node-mysql-wrapper-tests.ts b/node-mysql-wrapper/node-mysql-wrapper-tests.ts index 700c1ee6ed..35acec27f8 100644 --- a/node-mysql-wrapper/node-mysql-wrapper-tests.ts +++ b/node-mysql-wrapper/node-mysql-wrapper-tests.ts @@ -1,18 +1,63 @@ /// import wrapper = require("node-mysql-wrapper"); -var db = wrapper("mysql://kataras:pass@127.0.0.1/taglub?debug=false&charset=utf8"); +var db = wrapper.wrap("mysql://kataras:pass@127.0.0.1/taglub?debug=false&charset=utf8"); + + + + +class User { //or interface + userId: number; + username: string; + mail: string; + comments: Comment[]; +} + +interface Comment { + commentId: number; + content: string; + +} db.ready(() => { - db.table("users").on("insert", (parsedResults) => { + var usersDb = db.table("users"); + + usersDb.findById(16, (_user) => { + console.log("TEST1: \n"); + console.log("FOUND USER WITH USERNAME: " + _user.username); + }); + + /* OR usersDb.findById(18).then(_user=> { + console.log("FOUND USER WITH USERNAME: " + _user.username); + }, (err) => { console.log("ERROR ON FETCHING FINDBY ID: " + err) }); + */ + + usersDb.find({ userId: 18, comments: { userId: '=' } }, _users=> { + var _user = _users[0]; + console.log("TEST2: \n"); + console.log(_user.username + " with "); + console.log(_user.comments.length + " comments "); + _user.comments.forEach(_comment=> { + console.log("--------------\n" + _comment.content); + }); }); - db.table("users").findAll().then((results) => { - console.dir(results); + usersDb.safeRemove(5620, answer=> { + console.log("TEST 3: \n"); + console.log(answer.affectedRows + ' (1) has removed from table: ' + answer.table); + }); - db.table("users").find({ userId: 18 }, (results) => { - console.dir(results[0]); + var auser = new User(); + auser.username = ' just a username'; + auser.mail = ' just an email'; + + usersDb.save(auser, newUser=> { + console.log("TEST 4: \n"); + console.log("NEW USER HAS CREATED WITH NEW USER ID: " + newUser.userId); + }); + + }); From 54862b49b1c7eed6c92c01bb18a01af872ca2281 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 29 Aug 2015 19:20:55 +0900 Subject: [PATCH 52/86] Add BrowserWindow.isDevToolsOpened() https://github.com/atom/electron/blob/master/docs/api/browser-window.md#winisdevtoolsopened --- github-electron/github-electron-main-tests.ts | 3 +++ github-electron/github-electron.d.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index d353dfeb31..9b65ba29cf 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -44,6 +44,9 @@ app.on('ready', () => { // and load the index.html of the app. mainWindow.loadUrl(`file://${__dirname}/index.html`); + mainWindow.openDevTools() + var opened: boolean = mainWindow.isDevToolsOpened() + mainWindow.toggleDevTools() // Emitted when the window is closed. mainWindow.on('closed', () => { // Dereference the window object, usually you would store windows diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 5df526bfcb..bcf281121c 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -356,6 +356,10 @@ declare module GitHubElectron { * Closes the developer tools. */ closeDevTools(): void; + /** + * Returns whether the developer tools are opened. + */ + isDevToolsOpened(): boolean; /** * Toggle the developer tools. */ From 44db8b563316354d4a6c7a418fe86d377e6f6142 Mon Sep 17 00:00:00 2001 From: Oskar Karlsson Date: Sat, 29 Aug 2015 14:23:05 +0200 Subject: [PATCH 53/86] Update stream interface for Bunyan To support period and count for `rotating-file` type. --- bunyan/bunyan-test.ts | 4 +++- bunyan/bunyan.d.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bunyan/bunyan-test.ts b/bunyan/bunyan-test.ts index c10c6c6e0b..2575f043d8 100644 --- a/bunyan/bunyan-test.ts +++ b/bunyan/bunyan-test.ts @@ -40,7 +40,9 @@ var options:bunyan.LoggerOptions = { type: 'rotating-file', path: '/tmp/test2.log', level: bunyan.INFO, - closeOnExit: false + closeOnExit: false, + period: '1d', + count: 3 }, { type: 'raw', stream: process.stderr, diff --git a/bunyan/bunyan.d.ts b/bunyan/bunyan.d.ts index e491b8cd34..081b8a0924 100644 --- a/bunyan/bunyan.d.ts +++ b/bunyan/bunyan.d.ts @@ -65,6 +65,8 @@ declare module "bunyan" { path?: string; stream?: NodeJS.WritableStream | Stream; closeOnExit?: boolean; + period?: string; + count?: number; } export var stdSerializers:Serializers; From 3131c7cf55148a0136c38694c163c593dea01697 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 29 Aug 2015 21:34:08 +0900 Subject: [PATCH 54/86] Add os-locale.d.ts --- os-locale/os-locale-tests.ts | 8 ++++++++ os-locale/os-locale.d.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 os-locale/os-locale-tests.ts create mode 100644 os-locale/os-locale.d.ts diff --git a/os-locale/os-locale-tests.ts b/os-locale/os-locale-tests.ts new file mode 100644 index 0000000000..65763a112a --- /dev/null +++ b/os-locale/os-locale-tests.ts @@ -0,0 +1,8 @@ +/// + +import osLocale, { sync } from 'os-locale'; + +osLocale((err: any, locale: string) => { +}); + +var locale: string = sync(); diff --git a/os-locale/os-locale.d.ts b/os-locale/os-locale.d.ts new file mode 100644 index 0000000000..17933ae673 --- /dev/null +++ b/os-locale/os-locale.d.ts @@ -0,0 +1,12 @@ +// Type definitions for os-locale 1.2.1 +// Project: https://github.com/sindresorhus/os-locale +// Definitions by: Aya Morisawa +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "os-locale" { + function osLocale(cb: (err: any, locale: string) => void): void; + function osLocaleSync(): string; + + export { osLocaleSync as sync }; + export default osLocale; +} From 5c070aa2c2c46184233eab6002cc99a593cb9354 Mon Sep 17 00:00:00 2001 From: Roger Chen Date: Sat, 29 Aug 2015 07:54:02 -0700 Subject: [PATCH 55/86] Add cache property for select2 ajax options --- select2/select2-tests.ts | 3 ++- select2/select2.d.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/select2/select2-tests.ts b/select2/select2-tests.ts index d3a21b188e..b63d3cc1e7 100644 --- a/select2/select2-tests.ts +++ b/select2/select2-tests.ts @@ -56,6 +56,7 @@ $("#e6").select2({ ajax: { url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json", dataType: 'jsonp', + cache: false, data: function (term, page) { return { q: term, @@ -195,4 +196,4 @@ $("#e8").select2("enable", false); $("#e8").select2("readonly", false); $("#e8").select2('container'); $("#e8").select2('onSortStart'); -$("#e8").select2('onSortEnd'); \ No newline at end of file +$("#e8").select2('onSortEnd'); diff --git a/select2/select2.d.ts b/select2/select2.d.ts index 0b4543596f..259dd16cf8 100644 --- a/select2/select2.d.ts +++ b/select2/select2.d.ts @@ -26,6 +26,7 @@ interface Select2AjaxOptions { url?: any; dataType?: string; quietMillis?: number; + cache?: boolean; data?: (term: string, page: number, context: any) => any; results?: (term: any, page: number, context: any) => any; } From 2442ad1ae6cc72d9062176c50412dd27fa07451c Mon Sep 17 00:00:00 2001 From: tkQubo Date: Sat, 29 Aug 2015 02:57:45 +0900 Subject: [PATCH 56/86] Add ssh2 --- ssh2/ssh2-tests.ts | 428 +++++++++++++++++++++++++++++++++++++++++++++ ssh2/ssh2.d.ts | 346 ++++++++++++++++++++++++++++++++++++ 2 files changed, 774 insertions(+) create mode 100644 ssh2/ssh2-tests.ts create mode 100644 ssh2/ssh2.d.ts diff --git a/ssh2/ssh2-tests.ts b/ssh2/ssh2-tests.ts new file mode 100644 index 0000000000..1c59b13054 --- /dev/null +++ b/ssh2/ssh2-tests.ts @@ -0,0 +1,428 @@ +/// + +import * as ssh2 from 'ssh2'; + +declare var inspect: any; + +// +// # Client Examples +// + +// Authenticate using keys and execute uptime on a server: + +var Client = require('ssh2').Client; + +var conn = new Client(); +conn.on('ready', () => { + console.log('Client :: ready'); + conn.exec('uptime', (err: Error, stream: ssh2.Channel) => { + if (err) throw err; + stream + .on('close', (code: any, signal: any) => { + console.log('Stream :: close :: code: ' + code + ', signal: ' + signal); + conn.end(); + }).on('data', (data: any) => { + console.log('STDOUT: ' + data); + }).stderr.on('data', (data: any) => { + console.log('STDERR: ' + data); + }); + }); +}).connect({ + host: '192.168.100.100', + port: 22, + username: 'frylock', + privateKey: require('fs').readFileSync('/here/is/my/key') +}); + +// Authenticate using keys and start an interactive shell session: + +var Client = require('ssh2').Client; + +var conn = new Client(); +conn.on('ready', () => { + console.log('Client :: ready'); + conn.shell( (err: Error, stream: ssh2.Channel) => { + if (err) throw err; + stream.on('close', () => { + console.log('Stream :: close'); + conn.end(); + }).on('data', (data: any) => { + console.log('STDOUT: ' + data); + }).stderr.on('data', (data: any) => { + console.log('STDERR: ' + data); + }); + stream.end('ls -l\nexit\n'); + }); +}).connect({ + host: '192.168.100.100', + port: 22, + username: 'frylock', + privateKey: require('fs').readFileSync('/here/is/my/key') +}); + +// Authenticate using password and send an HTTP request to port 80 on the server: + +var Client = require('ssh2').Client; + +var conn = new Client(); +conn.on('ready', () => { + console.log('Client :: ready'); + conn.forwardOut('192.168.100.102', 8000, '127.0.0.1', 80, (err: Error, stream: ssh2.Channel) => { + if (err) throw err; + stream.on('close', () => { + console.log('TCP :: CLOSED'); + conn.end(); + }).on('data', (data: any) => { + console.log('TCP :: DATA: ' + data); + }).end([ + 'HEAD / HTTP/1.1', + 'User-Agent: curl/7.27.0', + 'Host: 127.0.0.1', + 'Accept: */*', + 'Connection: close', + '', + '' + ].join('\r\n')); + }); +}).connect({ + host: '192.168.100.100', + port: 22, + username: 'frylock', + password: 'nodejsrules' +}); + +// Authenticate using password and forward remote connections on port 8000 to us: + +var Client = require('ssh2').Client; + +var conn = new Client(); +conn.on('ready', () => { + console.log('Client :: ready'); + conn.forwardIn('127.0.0.1', 8000, (err: Error) => { + if (err) throw err; + console.log('Listening for connections on server on port 8000!'); + }); +}).on('tcp connection', (info: any, accept: Function, reject: Function) => { + console.log('TCP :: INCOMING CONNECTION:'); + console.dir(info); + accept().on('close', () => { + console.log('TCP :: CLOSED'); + }).on('data', (data: any) => { + console.log('TCP :: DATA: ' + data); + }).end([ + 'HTTP/1.1 404 Not Found', + 'Date: Thu, 15 Nov 2012 02:07:58 GMT', + 'Server: ForwardedConnection', + 'Content-Length: 0', + 'Connection: close', + '', + '' + ].join('\r\n')); +}).connect({ + host: '192.168.100.100', + port: 22, + username: 'frylock', + password: 'nodejsrules' +}); + +// Authenticate using password and get a directory listing via SFTP: + +var Client = require('ssh2').Client; + +var conn = new Client(); +conn.on('ready', () => { + console.log('Client :: ready'); + conn.sftp( (err: Error, sftp: any) => { + if (err) throw err; + sftp.readdir('foo', (err: Error, list: any) => { + if (err) throw err; + console.dir(list); + conn.end(); + }); + }); +}).connect({ + host: '192.168.100.100', + port: 22, + username: 'frylock', + password: 'nodejsrules' +}); + +// Connection hopping: + +var Client = require('ssh2').Client; + +var conn1 = new Client(), + conn2 = new Client(); + +conn1.on('ready', () => { + console.log('FIRST :: connection ready'); + conn1.exec('nc 192.168.1.2 22', (err: Error, stream: ssh2.Channel) => { + if (err) { + console.log('FIRST :: exec error: ' + err); + return conn1.end(); + } + conn2.connect({ + sock: stream, + username: 'user2', + password: 'password2', + }); + }); +}).connect({ + host: '192.168.1.1', + username: 'user1', + password: 'password1', +}); + +conn2.on('ready', () => { + console.log('SECOND :: connection ready'); + conn2.exec('uptime', (err: Error, stream: ssh2.Channel) => { + if (err) { + console.log('SECOND :: exec error: ' + err); + return conn1.end(); + } + stream.on('end', () => { + conn1.end(); // close parent (and this) connection + }).on('data', (data: any) => { + console.log(data.toString()); + }); + }); +}); + +// Forward X11 connections (xeyes): + +var net = require('net'), + Client = require('ssh2').Client; + +var conn = new Client(); + +conn.on('x11', (info: any, accept: any, reject: any) => { + var xserversock = new net.Socket(); + xserversock.on('connect', () => { + var xclientsock = accept(); + xclientsock.pipe(xserversock).pipe(xclientsock); + }); + // connects to localhost:0.0 + xserversock.connect(6000, 'localhost'); +}); + +conn.on('ready', () => { + conn.exec('xeyes', { x11: true }, (err: Error, stream: ssh2.Channel) => { + if (err) throw err; + var code = 0; + stream.on('end', () => { + if (code !== 0) + console.log('Do you have X11 forwarding enabled on your SSH server?'); + conn.end(); + }).on('exit', (exitcode: number) => { + code = exitcode; + }); + }); +}).connect({ + host: '192.168.1.1', + username: 'foo', + password: 'bar' +}); + +// Dynamic (1:1) port forwarding using a SOCKSv5 proxy (using socksv5): + +var socks = require('socksv5'), + Client = require('ssh2').Client; + +var ssh_config = { + host: '192.168.100.1', + port: 22, + username: 'nodejs', + password: 'rules' +}; + +socks.createServer( (info: any, accept: any, deny: any) => { + // NOTE: you could just use one ssh2 client connection for all forwards, but + // you could run into server-imposed limits if you have too many forwards open + // at any given time + var conn = new Client(); + conn.on('ready', () => { + conn.forwardOut(info.srcAddr, + info.srcPort, + info.dstAddr, + info.dstPort, + (err: Error, stream: ssh2.Channel) => { + if (err) { + conn.end(); + return deny(); + } + + var clientSocket: any; + if (clientSocket = accept(true)) { + stream.pipe(clientSocket).pipe(stream).on('close', () => { + conn.end(); + }); + } else + conn.end(); + }); + }).on('error', (err: Error) => { + deny(); + }).connect(ssh_config); +}).listen(1080, 'localhost', () => { + console.log('SOCKSv5 proxy server started on port 1080'); +}).useAuth(socks.auth.None()); + +// Invoke an arbitrary subsystem (netconf in this example): + +var Client = require('ssh2').Client, + xmlhello = ''+ + ''+ + ' '+ + ' urn:ietf:params:netconf:base:1.0'+ + ' '+ + ']]>]]>'; + +var conn = new Client(); + +conn.on('ready', () => { + console.log('Client :: ready'); + conn.subsys('netconf', (err: Error, stream: ssh2.Channel) => { + if (err) throw err; + stream.on('data', (data: any) => { + console.log(data); + }).write(xmlhello); + }); +}).connect({ + host: '1.2.3.4', + port: 22, + username: 'blargh', + password: 'honk' +}); + +// +// # Server Examples +// + +// Only allow password and public key authentication and command execution: + +var fs = require('fs'), + crypto = require('crypto'); +var buffersEqual = require('buffer-equal-constant-time'), + //ssh2 = require('ssh2'), + utils = ssh2.utils; + +var pubKey = utils.genPublicKey(utils.parseKey(fs.readFileSync('user.pub'))); + +new ssh2.Server({ + privateKey: fs.readFileSync('host.key') +}, (client: any) => { + console.log('Client connected!'); + + client.on('authentication', (ctx: any) => { + if (ctx.method === 'password' + && ctx.username === 'foo' + && ctx.password === 'bar') + ctx.accept(); + else if (ctx.method === 'publickey' + && ctx.key.algo === pubKey.fulltype + && buffersEqual(ctx.key.data, pubKey.public)) { + if (ctx.signature) { + var verifier = crypto.createVerify(ctx.sigAlgo); + verifier.update(ctx.blob); + if (verifier.verify(pubKey.publicOrig, ctx.signature, 'binary')) + ctx.accept(); + else + ctx.reject(); + } else { + // if no signature present, that means the client is just checking + // the validity of the given public key + ctx.accept(); + } + } else + ctx.reject(); + }).on('ready', () => { + console.log('Client authenticated!'); + + client.on('session', (accept: any, reject: any) => { + var session = accept(); + session.once('exec', (accept: any, reject: any, info: any) => { + console.log('Client wants to execute: ' + inspect(info.command)); + var stream = accept(); + stream.stderr.write('Oh no, the dreaded errors!\n'); + stream.write('Just kidding about the errors!\n'); + stream.exit(0); + stream.end(); + }); + }); + }).on('end', () => { + console.log('Client disconnected'); + }); +}).listen(0, '127.0.0.1', () => { + console.log('Listening on port ' + this.address().port); + }); + +// SFTP only server: + +var fs = require('fs'); +//var ssh2 = require('ssh2'); +var OPEN_MODE = ssh2.SFTP_OPEN_MODE, + STATUS_CODE = ssh2.SFTP_STATUS_CODE; + +new ssh2.Server({ + privateKey: fs.readFileSync('host.key') +}, (client: any) => { + console.log('Client connected!'); + + client.on('authentication', (ctx: any) => { + if (ctx.method === 'password' + && ctx.username === 'foo' + && ctx.password === 'bar') + ctx.accept(); + else + ctx.reject(); + }).on('ready', () => { + console.log('Client authenticated!'); + + client.on('session', (accept: any, reject: any) => { + var session = accept(); + session.on('sftp', (accept: any, reject: any) => { + console.log('Client SFTP session'); + var openFiles: any = {}; + var handleCount = 0; + // `sftpStream` is an `SFTPStream` instance in server mode + // see: https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md + var sftpStream = accept(); + sftpStream.on('OPEN', (reqid: any, filename: any, flags: any, attrs: any) => { + // only allow opening /tmp/foo.txt for writing + if (filename !== '/tmp/foo.txt' || !(flags & OPEN_MODE.WRITE)) + return sftpStream.status(reqid, STATUS_CODE.FAILURE); + // create a fake handle to return to the client, this could easily + // be a real file descriptor number for example if actually opening + // the file on the disk + var handle = new Buffer(4); + openFiles[handleCount] = true; + handle.writeUInt32BE(handleCount++, 0, true); + sftpStream.handle(reqid, handle); + console.log('Opening file for write') + }).on('WRITE', (reqid: any, handle: any, offset: any, data: any) => { + if (handle.length !== 4 || !openFiles[handle.readUInt32BE(0, true)]) + return sftpStream.status(reqid, STATUS_CODE.FAILURE); + // fake the write + sftpStream.status(reqid, STATUS_CODE.OK); + var inspected = require('util').inspect(data); + console.log('Write to file at offset %d: %s', offset, inspected); + }).on('CLOSE', (reqid: any, handle: any) => { + var fnum: any; + if (handle.length !== 4 || !openFiles[(fnum = handle.readUInt32BE(0, true))]) + return sftpStream.status(reqid, STATUS_CODE.FAILURE); + delete openFiles[fnum]; + sftpStream.status(reqid, STATUS_CODE.OK); + console.log('Closing file'); + }); + }); + }); + }).on('end', () => { + console.log('Client disconnected'); + }); +}).listen(0, '127.0.0.1', () => { + console.log('Listening on port ' + this.address().port); + }); + + + + + diff --git a/ssh2/ssh2.d.ts b/ssh2/ssh2.d.ts new file mode 100644 index 0000000000..8701046172 --- /dev/null +++ b/ssh2/ssh2.d.ts @@ -0,0 +1,346 @@ +// Type definitions for ssh2 +// Project: https://github.com/mscdex/ssh2 +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "ssh2" { + import stream = require('stream'); + + namespace ssh2 { + interface Client { + Server: ServerStatic; + new(): Client; + /** + * SFTPStream.STATUS_CODE from ssh2-streams. + */ + SFTP_STATUS_CODE: Sftp.StatusCode; + /** + * SFTPStream.OPEN_MODE from ssh2-streams. + */ + SFTP_OPEN_MODE: Sftp.OpenMode; + //TODO: Type ssh2-streams + /** + * utility methods from ssh2-streams. + */ + utils: Utils; + + connect(config: ConnectConfig): void; + end(): void; + destroy(): void; + exec(command: string, options: ExecOption, callback: ChannelCallback): boolean; + exec(command: string, callback: ChannelCallback): boolean; + shell(window: boolean|PseudoTtySettings, options: boolean|number|X11Settings, callback: ChannelCallback): boolean; + shell(window: boolean|PseudoTtySettings, callback: ChannelCallback): boolean; + shell(callback: ChannelCallback): boolean; + subsys(subsystem: string, callback: ChannelCallback): boolean; + sftp(callback: SftpCallback): boolean; + forwardIn(bindAddr: string, bindPort: number, callback?: ForwardInCallback): boolean; + unforwardIn(bindAddr: string, bindPort: number, callback?: ErrorCallback): boolean; + forwardOut(srcIP: string, srcPort: number, dstIP: string, dstPort: number, callback: ChannelCallback): boolean; + openssh_noMoreSessions(callback?: ErrorCallback): boolean; + openssh_forwardInStreamLocal(socketPath: string, callback?: ErrorCallback): boolean; + openssh_unforwardInStreamLocal(socketPath: string, callback?: ErrorCallback): boolean; + openssh_forwardOutStreamLocal(socketPath: string, callback?: ChannelCallback): boolean; + } + + interface ConnectConfig { + /** + * @description Hostname or IP address of the server. + * @default 'localhost' + */ + host?: string; + /** + * @description Port number of the server. + * @default 22 + */ + port?: number; + /** + * @description Only connect via resolved IPv4 address for `host`. + * @default false + */ + forceIPv4?: boolean; + /** + * @description Only connect via resolved IPv6 address for `host`. + * @default false + */ + forceIPv6?: boolean; + /** + * @description 'md5' or 'sha1'. The host's key is hashed using this method and passed to the **hostVerifier** function. + * @default (none) + */ + hostHash?: string; + /** + * @description Function that is passed a string hex hash of the host's key for verification purposes. + * Return `true` to continue with the handshake or `false` to reject and disconnect. + */ + hostVerifier?: (keyHash: string) => boolean; + /** + * @description Username for authentication. + */ + username?: string; + /** + * @description Password for password-based user authentication. + */ + password?: string; + /** + * @description Path to ssh-agent's UNIX socket for ssh-agent-based user authentication. + * Windows users: set to 'pageant' for authenticating with Pageant or (actual) path to a cygwin "UNIX socket." + */ + agent?: string; + /** + * @description Buffer or string that contains a private key for either key-based or hostbased user authentication (OpenSSH format). + */ + privateKey?: Buffer|string; + /** + * @description For an encrypted private key, this is the passphrase used to decrypt it. + */ + passphrase?: string; + /** + * @description Along with **localUsername** and **privateKey**, set this to a non-empty string for hostbased user authentication. + */ + localHostname?: string; + /** + * @description Along with **localHostname** and **privateKey**, set this to a non-empty string for hostbased user authentication. + */ + localUsername?: string; + /** + * @description Try keyboard-interactive user authentication if primary user authentication method fails. + * If you set this to `true`, you need to handle the `keyboard-interactive` event. + */ + tryKeyboard: boolean; + /** + * @description How often (in milliseconds) to send SSH-level keepalive packets to the server + * (in a similar way as OpenSSH's ServerAliveInterval config option). Set to 0 to disable. + * @default 0 + */ + keepaliveInterval?: number; + /** + * @description How many consecutive, unanswered SSH-level keepalive packets that can be sent to the server + * before disconnection (similar to OpenSSH's ServerAliveCountMax config option). + * @default 3 + */ + keepaliveCountMax?: number; + /** + * @description How long (in milliseconds) to wait for the SSH handshake to complete. + * @default 20000 + */ + readyTimeout?: number; + /** + * @description Performs a strict server vendor check before sending vendor-specific requests, + * etc. (e.g. check for OpenSSH server when using `openssh_noMoreSessions()`) + * @default true + */ + strictVendor?: boolean; + /** + * A ReadableStream to use for communicating with the server instead of creating and using a new TCP connection (useful for connection hopping). + */ + sock?: NodeJS.ReadableStream; + /** + * @description Set to `true` to use OpenSSH agent forwarding (`auth-agent@openssh.com`) for the life of the connection. `agent` must also be set to use this feature. + * @default false + */ + agentForward?: boolean; + /** + * @description Set this to a function that receives a single string argument to get detailed (local) debug information. + */ + debug: (information: string) => any; + } + + interface ExecOption { + /** + * @description An environment to use for the execution of the command. + */ + env?: any; + /** + * @description Set to true to allocate a pseudo-tty with defaults, or an object containing specific pseudo-tty settings + * (see 'Pseudo-TTY settings'). Setting up a pseudo-tty can be useful when working with remote processes + * that expect input from an actual terminal (e.g. sudo's password prompt). + */ + pty?: boolean|PseudoTtySettings; + /** + * @description Set to true to use defaults below, set to a number to specify a specific screen number, + * or an object. + */ + x11?: boolean|number|X11Settings; + } + + interface X11Settings { + /** + * Allow just a single connection? + * @default false + */ + single?: boolean; + /** + * Screen number to use + * @default 0 + */ + screen?: number; + } + + interface PseudoTtySettings { + /** + * @description * Number of rows + * @default 24 + */ + rows?: number; + /** + * @description * Number of columns + * @default 80 + */ + cols?: number; + /** + * @description * Height in pixels + * @default 480 + */ + height?: number; + /** + * @description * Width in pixels + * @default 640 + */ + width?: number; + /** + * @description The value to use for $TERM + * @default 'vt100' + */ + term?: string; + } + + interface ForwardInCallback { + (err?: Error, bindPort?: number): void; + } + + interface ChannelCallback { + (err?: Error, channel?: Channel): void; + } + + interface SftpCallback { + (err?: Error, sftp?: Sftp.Wrapper): void; + } + + interface ErrorCallback { + (err?: Error): void; + } + + interface Channel extends stream.Duplex { + new(info?: any, client?: any, options?: any): Channel; + eof(): boolean; + close(): boolean; + destroy(): void; + setWindow(rows: number, cols: number, height: number, width: number): boolean; + signal(signalName: string): boolean; + exit(name: string, coreDumped: boolean, msg: string): boolean; + exit(status: number): boolean; + stderr?: ServerStderr; + + // EventEmitter overrides + addListener(event: string, listener: Function): Channel; + on(event: string, listener: Function): Channel; + once(event: string, listener: Function): Channel; + removeListener(event: string, listener: Function): Channel; + removeAllListeners(event?: string): Channel; + } + + interface ServerStderr extends NodeJS.WritableStream { + new(channel: Channel): ServerStderr; + } + + interface ServerStatic { + new(config: ServerConfig, listener?: any): Server; + createServer(config: ServerConfig, listener?: any): Server; + KEEPALIVE_INTERVAL: number; + KEEPALIVE_CLIENT_INTERVAL: number; + KEEPALIVE_CLIENT_COUNT_MAX: number; + } + + interface Server extends NodeJS.EventEmitter { + listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; + listen(port: number, hostname?: string, callback?: Function): Server; + listen(path: string, callback?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + address(): { port: number; family: string; address: string; }; + getConnections(callback: any): any; //TODO: No type + close(callback?: Function): Server; + ref(): void; + unref(): void; + } + + interface ServerConfig { + /** + * @description Buffer or string that contains the host private key (OpenSSH format). + */ + privateKey: Buffer|string; + /** + * @description For an encrypted host private key, this is the passphrase used to decrypt it. + */ + passphrase?: string; + /** + * @description A message that is sent to clients immediately upon connection, before handshaking begins. + */ + banner?: string; + /** + * @description A custom server software name/version identifier. + * @default 'ssh2js' + moduleVersion + 'srv' + */ + indent?: string; + /** + * @description This is the highWaterMark to use for the parser stream. + * @default 32 * 1024 + */ + highWaterMark?: number; + /** + * @description Set this to a function that receives a single string argument to get detailed (local) debug information. + */ + debug?: (information: string) => any; + } + + // utility methods from ssh2-streams. + interface Utils { + iv_inc: Function; + isStreamCipher: Function; + isGCM: Function; + readInt: Function; + readString: Function; + parseKey: Function; + genPublicKey: Function; + convertPPKPrivate: Function; + verifyPPKMAC: Function; + decryptKey: Function; + } + + namespace Sftp { + // SFTPStream.STATUS_CODE from ssh2-streams. + interface StatusCode { + OK: number; + EOF: number; + NO_SUCH_FILE: number; + PERMISSION_DENIED: number; + FAILURE: number; + BAD_MESSAGE: number; + NO_CONNECTION: number; + CONNECTION_LOST: number; + OP_UNSUPPORTED: number; + } + + // SFTPStream.OPEN_MODE from ssh2-streams. + interface OpenMode { + READ: number; + WRITE: number; + APPEND: number; + CREAT: number; + TRUNC: number; + EXCL: number; + } + + interface Wrapper extends NodeJS.EventEmitter { + //TODO: extends `ssh2-streams.SFTPStream` + } + } + } + + var ssh2: ssh2.Client; + + export = ssh2; +} + From 088658482ca04f6178f1d7a52d322f568383fe74 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Sat, 29 Aug 2015 22:39:12 -0300 Subject: [PATCH 57/86] union --- bowser/bowser.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bowser/bowser.d.ts b/bowser/bowser.d.ts index afd15fa5db..834532d374 100644 --- a/bowser/bowser.d.ts +++ b/bowser/bowser.d.ts @@ -42,7 +42,7 @@ declare module BowserModule { /** Grade X browser */ x: boolean; name: string; - version: string; + version: string|number; osversion: string|number; } From c0fe9460e7a62b2d54abbe59ae1e81ddf744bca8 Mon Sep 17 00:00:00 2001 From: Artem Kozlov Date: Mon, 31 Aug 2015 10:28:26 +0200 Subject: [PATCH 58/86] Update ol.source.Vector. Add more ol.style defs. --- openlayers/openlayers-tests.ts | 8 ++ openlayers/openlayers.d.ts | 230 ++++++++++++++++++++++++++++++++- 2 files changed, 235 insertions(+), 3 deletions(-) diff --git a/openlayers/openlayers-tests.ts b/openlayers/openlayers-tests.ts index 2e518e0856..3effa928aa 100644 --- a/openlayers/openlayers-tests.ts +++ b/openlayers/openlayers-tests.ts @@ -33,6 +33,7 @@ var featureFormat: ol.format.Feature; var geometry: ol.geom.Geometry; var loadingstrategy: ol.LoadingStrategy; var tilegrid: ol.tilegrid.TileGrid; +var vector: ol.source.Vector; // // ol.Attribution @@ -112,6 +113,13 @@ geometryResult.getClosestPoint(coordinate, coordinate); extent = geometryResult.getExtent(); geometryResult.getExtent(extent); +// +// ol.source +// +vector = new ol.source.Vector({ + features: [feature] +}); + // // ol.Feature // diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index 39091a8490..9974ef9ebd 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -1,4 +1,4 @@ -// Type definitions for OpenLayers v3.6.0 +// Type definitions for OpenLayers v3.6.0 // Project: http://openlayers.org/ // Definitions by: Wouter Goedhart // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -88,6 +88,21 @@ declare module olx { targetSize?: number; } + /** + * Object literal with config options for the map logo. + */ + interface LogoOptions { + /** + * Link url for the logo. Will be followed when the logo is clicked. + */ + href: string; + + /** + * Image src for the logo + */ + src: string; + } + interface MapOptions { /** Controls initially added to the map. If not specified, ol.control.defaults() is used. */ @@ -382,6 +397,21 @@ declare module olx { } } + module interaction { + interface DefaultsOptions { + altShiftDragRotate?: boolean; + doubleClickZoom?: boolean; + keyboard?: boolean; + mouseWheelZoom?: boolean; + shiftDragZoom?: boolean; + dragPan?: boolean; + pinchRotate?: boolean; + pinchZoom?: boolean; + zoomDelta?: number; + zoomDuration?: number; + } + } + module layer { interface BaseOptions { @@ -527,6 +557,97 @@ declare module olx { } } + module source { + + interface VectorOptions { + /** + * Attributions. + */ + attributions?: Array; + + /** + * Features. If provided as {@link ol.Collection}, the features in the source + * and the collection will stay in sync. + */ + features?: Array | ol.Collection; + + /** + * The feature format used by the XHR feature loader when `url` is set. + * Required if `url` is set, otherwise ignored. Default is `undefined`. + */ + format?: ol.format.Feature; + + /** + * The loader function used to load features, from a remote source for example. + * Note that the source will create and use an XHR feature loader when `url` is + * set. + */ + loader?: ol.FeatureLoader; + + /** + * Logo. + */ + logo?: string | olx.LogoOptions; + + /** + * The loading strategy to use. By default an {@link ol.loadingstrategy.all} + * strategy is used, a one-off strategy which loads all features at once. + */ + strategy?: ol.LoadingStrategy; + + /** + * Setting this option instructs the source to use an XHR loader (see + * {@link ol.featureloader.xhr}) and an {@link ol.loadingstrategy.all} for a + * one-off download of all features from that URL. + * Requires `format` to be set as well. + */ + url?: string; + + /** + * By default, an RTree is used as spatial index. When features are removed and + * added frequently, and the total number of features is low, setting this to + * `false` may improve performance. + */ + useSpatialIndex?: boolean; + + /** + * Wrap the world horizontally. Default is `true`. For vector editing across the + * -180° and 180° meridians to work properly, this should be set to `false`. The + * resulting geometry coordinates will then exceed the world bounds. + */ + wrapX?: boolean; + } + } + + module style { + + interface FillOptions { + color?: ol.Color | string; + } + + interface StyleOptions { + geometry?: string | ol.geom.Geometry | ol.style.GeometryFunction; + fill?: ol.style.Fill; + image?: ol.style.Image; + stroke?: ol.style.Stroke; + text?: ol.style.Text; + zIndex?: number; + } + + interface TextOptions { + font?: string; + offsetX?: number; + offsetY?: number; + scale?: number; + rotation?: number; + text?: string; + textAlign?: string; + textBaseline?: string; + fill?: ol.style.Fill; + stroke?: ol.style.Stroke; + } + } + module tilegrid { interface TileGridOptions { @@ -2551,13 +2672,16 @@ declare module ol { class MultiPolygon { } - class Point { + class Point extends SimpleGeometry { + constructor(coordinates: ol.Coordinate, layout?: geom.GeometryLayout); + getCoordinates(): ol.Coordinate; + setCoordinates(coordinates: ol.Coordinate, opt?: geom.GeometryLayout): void; } class Polygon { } - class SimpleGeometry { + class SimpleGeometry extends Geometry { } } @@ -2625,6 +2749,8 @@ declare module ol { class Snap { } + + function defaults(opts: olx.interaction.DefaultsOptions): ol.Collection; } module layer { @@ -3155,6 +3281,14 @@ declare module ol { } class Vector { + constructor(opts: olx.source.VectorOptions) + + /** + * Get the extent of the features currently in the source. + */ + getExtent(): ol.Extent; + + getFeaturesInExtent(extent: ol.Extent): ol.Feature[]; } class VectorEvent { @@ -3187,7 +3321,21 @@ declare module ol { class Circle { } + /** + * Set fill style for vector features. + */ class Fill { + + constructor(opt_options?: olx.style.FillOptions); + + getColor(): ol.Color | string; + + /** + * Set the color. + */ + setColor(color: ol.Color | string): void; + + getChecksum(): string; } class Icon { @@ -3196,6 +3344,10 @@ declare module ol { class Image { } + interface GeometryFunction { + (feature: Feature): ol.geom.Geometry + } + class RegularShape { } @@ -3203,10 +3355,82 @@ declare module ol { constructor(); } + /** + * Container for vector feature rendering styles. Any changes made to the style + * or its children through `set*()` methods will not take effect until the + * feature, layer or FeatureOverlay that uses the style is re-rendered. + */ class Style { + constructor(opts: olx.style.StyleOptions); } + /** + * Set text style for vector features. + */ class Text { + constructor(opt?: olx.style.TextOptions); + + getFont(): string; + getOffsetX(): number; + getOffsetY(): number; + getFill(): Fill; + getRotation(): number; + getScale(): number; + getStroke(): Stroke; + getText(): string; + getTextAlign(): string; + getTextBaseline(): string; + + /** + * Set the font. + */ + setFont(font: string): void; + + /** + * Set the x offset. + */ + setOffsetX(offsetX: number): void; + + /** + * Set the y offset. + */ + setOffsetY(offsetY: number): void; + + /** + * Set the fill. + */ + setFill(fill: Fill): void; + + /** + * Set the rotation. + */ + setRotation(rotation: number): void; + + /** + * Set the scale. + */ + setScale(scale: number): void; + + /** + * Set the stroke. + * + */ + setStroke(stroke: Stroke): void; + + /** + * Set the text. + */ + setText(text: string): void; + + /** + * Set the text alignment. + */ + setTextAlign(textAlign: string): void; + + /** + * Set the text baseline. + */ + setTextBaseline(textBaseline: string): void; } /** From 29173d7b55d7a1ab3b0ae7d63f8dafdf34cea106 Mon Sep 17 00:00:00 2001 From: tkQubo Date: Mon, 31 Aug 2015 22:25:36 +0900 Subject: [PATCH 59/86] Add gulp-espower --- gulp-espower/gulp-espower-tests.ts | 15 +++++++++++++++ gulp-espower/gulp-espower.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 gulp-espower/gulp-espower-tests.ts create mode 100644 gulp-espower/gulp-espower.d.ts diff --git a/gulp-espower/gulp-espower-tests.ts b/gulp-espower/gulp-espower-tests.ts new file mode 100644 index 0000000000..9240ee82d9 --- /dev/null +++ b/gulp-espower/gulp-espower-tests.ts @@ -0,0 +1,15 @@ +/// +/// + + +import espower = require('gulp-espower'); +import * as gulp from 'gulp'; + +gulp.src('src/*.coffee') + .pipe(espower()) + .pipe(gulp.dest('out')); + + +gulp.src('src/*.coffee') + .pipe(espower({ patterns: ['assert(value, [message])'] })) + .pipe(gulp.dest('out')); diff --git a/gulp-espower/gulp-espower.d.ts b/gulp-espower/gulp-espower.d.ts new file mode 100644 index 0000000000..984afad9ca --- /dev/null +++ b/gulp-espower/gulp-espower.d.ts @@ -0,0 +1,27 @@ +// Type definitions for gulp-espower +// Project: https://github.com/power-assert-js/gulp-espower +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-espower" { + + namespace espower { + interface Espower { + /** + * @param options Target patterns for power assert feature instrumentation. + */ + (options?: Options): NodeJS.ReadWriteStream; + } + + interface Options { + patterns: string[]; + } + } + + var espower: espower.Espower; + + export = espower; +} + From 4b0e61182b3f39c80d68ea65a35599bdd56c014a Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 1 Sep 2015 02:25:16 +0900 Subject: [PATCH 60/86] apply tsfmt --- offline-js/offline-js-tests.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/offline-js/offline-js-tests.ts b/offline-js/offline-js-tests.ts index 82af46683b..d43f091fa6 100644 --- a/offline-js/offline-js-tests.ts +++ b/offline-js/offline-js-tests.ts @@ -4,11 +4,11 @@ Offline.options = { checkOnLoad: false, interceptRequests: true, - checks: { - xhr: { url: '/connection-test' }, - image: { url: 'my-image.gif' }, - active: 'image' - }, + checks: { + xhr: { url: '/connection-test' }, + image: { url: 'my-image.gif' }, + active: 'image' + }, reconnect: { initialDelay: 3, delay: 60 @@ -21,7 +21,7 @@ Offline.check(); Offline.state; -var handler = () => {}, +var handler = () => { }, context = {}; Offline.on("up", handler, context); @@ -37,4 +37,4 @@ Offline.on("reconnect:failure", handler, context); Offline.on("requests:flush", handler, context); Offline.on("requests:hold", handler, context); -Offline.off("up", handler); \ No newline at end of file +Offline.off("up", handler); From 410dcba2f1c9306fd04f2453caa34d5e9102bb11 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Mon, 31 Aug 2015 16:14:18 -0700 Subject: [PATCH 61/86] chore(typescript): updated angular2 files --- angular2/angular2-2.0.0-alpha.36.d.ts | 5920 +++++++++++++++++++++++++ angular2/angular2.d.ts | 317 +- angular2/router-2.0.0-alpha.36.d.ts | 689 +++ angular2/router.d.ts | 22 +- 4 files changed, 6851 insertions(+), 97 deletions(-) create mode 100644 angular2/angular2-2.0.0-alpha.36.d.ts create mode 100644 angular2/router-2.0.0-alpha.36.d.ts diff --git a/angular2/angular2-2.0.0-alpha.36.d.ts b/angular2/angular2-2.0.0-alpha.36.d.ts new file mode 100644 index 0000000000..0c7b8609ef --- /dev/null +++ b/angular2/angular2-2.0.0-alpha.36.d.ts @@ -0,0 +1,5920 @@ +// Type definitions for Angular v2.0.0-alpha.36 +// Project: http://angular.io/ +// Definitions by: angular team +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// *********************************************************** +// This file is generated by the Angular build process. +// Please do not create manual edits or send pull requests +// modifying this file. +// *********************************************************** + +// angular2/angular2 depends transitively on these libraries. +// If you don't have them installed you can install them using TSD +// https://github.com/DefinitelyTyped/tsd + +/// +/// + + +interface List extends Array {} +interface Map {} +interface StringMap extends Map {} + +declare module ng { + // See https://github.com/Microsoft/TypeScript/issues/1168 + class BaseException /* extends Error */ { + message: string; + stack: string; + toString(): string; + } + interface InjectableReference {} +} + + + + +/** + * The `angular2` is the single place to import all of the individual types. + */ +declare module ng { + + /** + * Declare reusable UI building blocks for an application. + * + * Each Angular component requires a single `@Component` and at least one `@View` annotation. The + * `@Component` + * annotation specifies when a component is instantiated, and which properties and hostListeners it + * binds to. + * + * When a component is instantiated, Angular + * - creates a shadow DOM for the component. + * - loads the selected template into the shadow DOM. + * - creates all the injectable objects configured with `bindings` and `viewBindings`. + * + * All template expressions and statements are then evaluated against the component instance. + * + * For details on the `@View` annotation, see {@link ViewMetadata}. + * + * ## Example + * + * ``` + * @Component({ + * selector: 'greet' + * }) + * @View({ + * template: 'Hello {{name}}!' + * }) + * class Greet { + * name: string; + * + * constructor() { + * this.name = 'World'; + * } + * } + * ``` + */ + class ComponentMetadata extends DirectiveMetadata { + + + /** + * Defines the used change detection strategy. + * + * When a component is instantiated, Angular creates a change detector, which is responsible for + * propagating + * the component's bindings. + * + * The `changeDetection` property defines, whether the change detection will be checked every time + * or only when the component + * tells it to do so. + */ + changeDetection: string; + + + /** + * Defines the set of injectable objects that are visible to its view dom children. + * + * ## Simple Example + * + * Here is an example of a class that can be injected: + * + * ``` + * class Greeter { + * greet(name:string) { + * return 'Hello ' + name + '!'; + * } + * } + * + * @Directive({ + * selector: 'needs-greeter' + * }) + * class NeedsGreeter { + * greeter:Greeter; + * + * constructor(greeter:Greeter) { + * this.greeter = greeter; + * } + * } + * + * @Component({ + * selector: 'greet', + * viewBindings: [ + * Greeter + * ] + * }) + * @View({ + * template: ``, + * directives: [NeedsGreeter] + * }) + * class HelloWorld { + * } + * + * ``` + */ + viewBindings: List; + } + + + /** + * Directives allow you to attach behavior to elements in the DOM. + * + * {@link DirectiveMetadata}s with an embedded view are called {@link ComponentMetadata}s. + * + * A directive consists of a single directive annotation and a controller class. When the + * directive's `selector` matches + * elements in the DOM, the following steps occur: + * + * 1. For each directive, the `ElementInjector` attempts to resolve the directive's constructor + * arguments. + * 2. Angular instantiates directives for each matched element using `ElementInjector` in a + * depth-first order, + * as declared in the HTML. + * + * ## Understanding How Injection Works + * + * There are three stages of injection resolution. + * - *Pre-existing Injectors*: + * - The terminal {@link Injector} cannot resolve dependencies. It either throws an error or, if + * the dependency was + * specified as `@Optional`, returns `null`. + * - The platform injector resolves browser singleton resources, such as: cookies, title, + * location, and others. + * - *Component Injectors*: Each component instance has its own {@link Injector}, and they follow + * the same parent-child hierarchy + * as the component instances in the DOM. + * - *Element Injectors*: Each component instance has a Shadow DOM. Within the Shadow DOM each + * element has an `ElementInjector` + * which follow the same parent-child hierarchy as the DOM elements themselves. + * + * When a template is instantiated, it also must instantiate the corresponding directives in a + * depth-first order. The + * current `ElementInjector` resolves the constructor dependencies for each directive. + * + * Angular then resolves dependencies as follows, according to the order in which they appear in the + * {@link ViewMetadata}: + * + * 1. Dependencies on the current element + * 2. Dependencies on element injectors and their parents until it encounters a Shadow DOM boundary + * 3. Dependencies on component injectors and their parents until it encounters the root component + * 4. Dependencies on pre-existing injectors + * + * + * The `ElementInjector` can inject other directives, element-specific special objects, or it can + * delegate to the parent + * injector. + * + * To inject other directives, declare the constructor parameter as: + * - `directive:DirectiveType`: a directive on the current element only + * - `@Host() directive:DirectiveType`: any directive that matches the type between the current + * element and the + * Shadow DOM root. + * - `@Query(DirectiveType) query:QueryList`: A live collection of direct child + * directives. + * - `@QueryDescendants(DirectiveType) query:QueryList`: A live collection of any + * child directives. + * + * To inject element-specific special objects, declare the constructor parameter as: + * - `element: ElementRef` to obtain a reference to logical element in the view. + * - `viewContainer: ViewContainerRef` to control child template instantiation, for + * {@link DirectiveMetadata} directives only + * - `bindingPropagation: BindingPropagation` to control change detection in a more granular way. + * + * ## Example + * + * The following example demonstrates how dependency injection resolves constructor arguments in + * practice. + * + * + * Assume this HTML template: + * + * ``` + *
      + *
      + *
      + *
      + *
      + *
      + *
      + *
      + *
      + *
      + * ``` + * + * With the following `dependency` decorator and `SomeService` injectable class. + * + * ``` + * @Injectable() + * class SomeService { + * } + * + * @Directive({ + * selector: '[dependency]', + * properties: [ + * 'id: dependency' + * ] + * }) + * class Dependency { + * id:string; + * } + * ``` + * + * Let's step through the different ways in which `MyDirective` could be declared... + * + * + * ### No injection + * + * Here the constructor is declared with no arguments, therefore nothing is injected into + * `MyDirective`. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor() { + * } + * } + * ``` + * + * This directive would be instantiated with no dependencies. + * + * + * ### Component-level injection + * + * Directives can inject any injectable instance from the closest component injector or any of its + * parents. + * + * Here, the constructor declares a parameter, `someService`, and injects the `SomeService` type + * from the parent + * component's injector. + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(someService: SomeService) { + * } + * } + * ``` + * + * This directive would be instantiated with a dependency on `SomeService`. + * + * + * ### Injecting a directive from the current element + * + * Directives can inject other directives declared on the current element. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(dependency: Dependency) { + * expect(dependency.id).toEqual(3); + * } + * } + * ``` + * This directive would be instantiated with `Dependency` declared at the same element, in this case + * `dependency="3"`. + * + * ### Injecting a directive from any ancestor elements + * + * Directives can inject other directives declared on any ancestor element (in the current Shadow + * DOM), i.e. on the current element, the + * parent element, or its parents. + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Host() dependency: Dependency) { + * expect(dependency.id).toEqual(2); + * } + * } + * ``` + * + * `@Host` checks the current element, the parent, as well as its parents recursively. If + * `dependency="2"` didn't + * exist on the direct parent, this injection would + * have returned + * `dependency="1"`. + * + * + * ### Injecting a live collection of direct child directives + * + * + * A directive can also query for other child directives. Since parent directives are instantiated + * before child directives, a directive can't simply inject the list of child directives. Instead, + * the directive injects a {@link QueryList}, which updates its contents as children are added, + * removed, or moved by a directive that uses a {@link ViewContainerRef} such as a `ng-for`, an + * `ng-if`, or an `ng-switch`. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Query(Dependency) dependencies:QueryList) { + * } + * } + * ``` + * + * This directive would be instantiated with a {@link QueryList} which contains `Dependency` 4 and + * 6. Here, `Dependency` 5 would not be included, because it is not a direct child. + * + * ### Injecting a live collection of descendant directives + * + * By passing the descendant flag to `@Query` above, we can include the children of the child + * elements. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Query(Dependency, {descendants: true}) dependencies:QueryList) { + * } + * } + * ``` + * + * This directive would be instantiated with a Query which would contain `Dependency` 4, 5 and 6. + * + * ### Optional injection + * + * The normal behavior of directives is to return an error when a specified dependency cannot be + * resolved. If you + * would like to inject `null` on unresolved dependency instead, you can annotate that dependency + * with `@Optional()`. + * This explicitly permits the author of a template to treat some of the surrounding directives as + * optional. + * + * ``` + * @Directive({ selector: '[my-directive]' }) + * class MyDirective { + * constructor(@Optional() dependency:Dependency) { + * } + * } + * ``` + * + * This directive would be instantiated with a `Dependency` directive found on the current element. + * If none can be + * found, the injector supplies `null` instead of throwing an error. + * + * ## Example + * + * Here we use a decorator directive to simply define basic tool-tip behavior. + * + * ``` + * @Directive({ + * selector: '[tooltip]', + * properties: [ + * 'text: tooltip' + * ], + * host: { + * '(mouseenter)': 'onMouseEnter()', + * '(mouseleave)': 'onMouseLeave()' + * } + * }) + * class Tooltip{ + * text:string; + * overlay:Overlay; // NOT YET IMPLEMENTED + * overlayManager:OverlayManager; // NOT YET IMPLEMENTED + * + * constructor(overlayManager:OverlayManager) { + * this.overlay = overlay; + * } + * + * onMouseEnter() { + * // exact signature to be determined + * this.overlay = this.overlayManager.open(text, ...); + * } + * + * onMouseLeave() { + * this.overlay.close(); + * this.overlay = null; + * } + * } + * ``` + * In our HTML template, we can then add this behavior to a `
      ` or any other element with the + * `tooltip` selector, + * like so: + * + * ``` + *
      + * ``` + * + * Directives can also control the instantiation, destruction, and positioning of inline template + * elements: + * + * A directive uses a {@link ViewContainerRef} to instantiate, insert, move, and destroy views at + * runtime. + * The {@link ViewContainerRef} is created as a result of `