diff --git a/.travis.yml b/.travis.yml
index d138403cc..acfc5176f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- - 0.10
+ - "0.10"
notifications:
email: false
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 0fa132294..10ebf956d 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -8,11 +8,13 @@ All definitions files include a header with the author and editors, so at some p
* [Ace Cloud9 Editor](http://ace.ajax.org/) (by [Diullei Gomes](https://github.com/Diullei))
* [Add To Home Screen](http://cubiq.org/add-to-home-screen) (by [James Wilkins](http://www.codeplex.com/site/users/view/jamesnw))
* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/))
-* [AngularAgility](https://github.com/AngularAgility/AngularAgility) (by [Roland Zwaga](https://github.com/rolandzwaga)
+* [AngularAgility](https://github.com/AngularAgility/AngularAgility) (by [Roland Zwaga](https://github.com/rolandzwaga))
+* [AngularBootstrapLightbox](https://github.com/compact/angular-bootstrap-lightbox) (by [Roland Zwaga](https://github.com/rolandzwaga))
* [AngularFire](https://www.firebase.com/docs/angular/reference.html) (by [Dénes Harmath](https://github.com/thSoft))
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
* [angularLocalStorage](https://github.com/agrublev/angularLocalStorage) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib))
+* [Angular Hotkeys](https://github.com/chieffancypants/angular-hotkeys/) (by [Jason Zhao](https://github.com/jlz27))
* [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong))
* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib))
* [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted))
@@ -28,6 +30,8 @@ All definitions files include a header with the author and editors, so at some p
* [aws-sdk-js](https://github.com/aws/aws-sdk-js) (by [midknight41](https://github.com/midknight41))
* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm))
+* [big.js](https://github.com/MikeMcl/big.js) (by [Steve Ognibene](https://github.com/nycdotnet))
+* [BigInt](https://github.com/Evgenus/BigInt) (by [Eugene Chernyshov](https://github.com/Evgenus))
* [BigInteger](https://github.com/peterolson/BigInteger.js) (by [Ingo Bürk](https://github.com/Airblader))
* [BigScreen](http://brad.is/coding/BigScreen/) (by [Douglas Eichelberger](https://github.com/dduugg))
* [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds))
@@ -38,9 +42,11 @@ All definitions files include a header with the author and editors, so at some p
* [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/))
* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby))
+* [bucks](https://github.com/CyberAgent/bucks.js) (by [Shunsuke Ohtani](https://github.com/zaneli))
* [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker))
* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle))
* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov))
+* [Chroma.js](https://github.com/gka/chroma.js) (by [Sebastian Brückner](https://github.com/invliD))
* [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber) and [otiai10](https://github.com/otiai10))
* [Chrome App](http://developer.chrome.com/apps/) (by [Adam Lay](https://github.com/AdamLay))
* [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik))
@@ -79,6 +85,7 @@ All definitions files include a header with the author and editors, so at some p
* [File API: Directories and System](http://www.w3.org/TR/file-system-api/) (by [Kon](http://phyzkit.net/))
* [File API: Writer](http://www.w3.org/TR/file-writer-api/) (by [Kon](http://phyzkit.net/))
* [Finch](https://github.com/stoodder/finchjs) (by [David Sichau](https://github.com/DavidSichau/))
+* [fingerprintjs](https://github.com/Valve/fingerprintjs) (by [Shunsuke Ohtani](https://github.com/zaneli))
* [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (by [Boris Yankov](https://github.com/borisyankov))
* [Firebase](https://www.firebase.com/docs/javascript/firebase) (by [Vincent Bortone](https://github.com/vbortone))
* [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame))
@@ -110,6 +117,7 @@ All definitions files include a header with the author and editors, so at some p
* [Google Url Shortener](https://developers.google.com/url-shortener/) (by [Frank M](https://github.com/sgtfrankieboy))
* [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov))
* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
+* [HashMap](https://github.com/flesler/hashmap) (by [Rafał Wrzeszcz](https://wrzasq.pl))
* [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home))
* [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home))
* [HelloJS](http://adodson.com/hello.js) (by [Pavel Zika](https://github.com/PavelPZ))
@@ -118,17 +126,21 @@ All definitions files include a header with the author and editors, so at some p
* [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee))
* [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov))
* [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn))
+* [htmlparser2](https://github.com/fb55/htmlparser2/) (by [James Roland Cabresos](https://github.com/staticfunction))
+* [http-string-parser](https://github.com/apiaryio/http-string-parser) (by [MIZUNE Pine](https://github.com/pine613))
* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac))
* [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter))
* [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz))
* [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov))
* [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz))
* [interact.js](http://github.com/taye/interact.js) (by [Douglas Eichelberger](https://github.com/dduugg))
+* [Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) (by [Douglas Eichelberger](https://github.com/dduugg))
* [Ionic-Cordova](https://github.com/driftyco/) (by [Hendrik Maus](https://github.com/hendrikmaus))
* [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski))
* [IxJS (Interactive extensions)](https://github.com/Reactive-Extensions/IxJS) (by [Igor Oleinikov](https://github.com/Igorbek))
* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/))
* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov))
+* [Jasmine-data_driven_tests](https://github.com/gburghardt/jasmine-data_driven_tests) (by [Anthony MacKinnon](https://github.com/AnthonyMacKinnon))
* [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac))
* [jDataView](https://github.com/jDataView/jDataView) (by [Ingvar Stepanyan](https://github.com/RReverser))
* [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel))
@@ -164,6 +176,7 @@ All definitions files include a header with the author and editors, so at some p
* [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/))
* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
* [jQuery.pjax](https://github.com/defunkt/jquery-pjax) (by [Junle Li](https://github.com/lijunle))
+* [jQuery.pjax.falsandtru](https://github.com/falsandtru/jquery.pjax.js/) (by [NewNotMoon](http://new.not-moon.net/))
* [jQuery.pnotify](http://sciactive.github.io/pnotify/) (by [David Sichau](https://github.com/DavidSichau/))
* [jQuery.postMessage](http://benalman.com/projects/jquery-postmessage-plugin/) (by [Junle Li](https://github.com/lijunle))
* [jQuery.prettyphoto](https://github.com/scaron/prettyphoto) (by [Paul Gaske](https://github.com/pgaske))
@@ -185,6 +198,7 @@ All definitions files include a header with the author and editors, so at some p
* [js-git](https://github.com/creationix/js-git) (by [Bart van der Schoor](https://github.com/Bartvds))
* [js-url](https://github.com/websanova/js-url) (by [MIZUNE Pine](https://github.com/pine613))
* [js-yaml](https://github.com/nodeca/js-yaml) (by [Bart van der Schoor](https://github.com/Bartvds/))
+* [jsbn](http://www-cs-students.stanford.edu/%7Etjw/jsbn/) (by [Eugene Chernyshov](https://github.com/Evgenus))
* [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz))
* [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk))
* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/))
@@ -236,15 +250,19 @@ All definitions files include a header with the author and editors, so at some p
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
* [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee))
* [mongoose](http://mongoosejs.com/) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
+* [morgan](https://github.com/expressjs/morgan/) (by [James Roland Cabresos](https://github.com/staticfunction/))
* [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz))
* [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki))
* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov))
+* [mysql](https://github.com/felixge/node-mysql) (by [William Johnston](https://github.com/wjohnsto))
* [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo))
+* [needle](https://github.com/tomas/needle) (by [San Chen](https://github.com/bigsan))
* [noble](https://github.com/sandeepmistry/noble) (by [Seon-Wook Park](https://github.com/swook))
* [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici))
* [Node.js](http://nodejs.org/) (from TypeScript samples)
* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov))
* [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd))
+* [node-form](https://github.com/rsamec/form) (by [Roman Samec](https://github.com/rsamec))
* [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame))
* [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo))
* [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown))
@@ -253,10 +271,12 @@ All definitions files include a header with the author and editors, so at some p
* [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker))
* [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel))
* [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/))
+* [object-path](https://github.com/mariocasciaro/object-path) (by [Paulo Cesar](https://github.com/pocesar/))
* [ocLazyLoad](https://github.com/ocombe/ocLazyLoad) (by [Roland Zwaga](https://github.com/rolandzwaga/))
* [OpenLayers](https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/))
* [Optimist](https://github.com/substack/node-optimist) (by [Carlos Ballesteros Velasco](https://github.com/soywiz))
* [Passport](http://passportjs.org/) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
+* [passport-facebook](https://github.com/jaredhanson/passport-facebook) (by [James Roland Cabresos](https://github.com/staticfunction/))
* [passport-strategy](https://github.com/jaredhanson/passport-strategy) (by [Lior Mualem](https://github.com/liorm))
* [pathwatcher](http://atom.github.io/node-pathwatcher/) (by [vvakame](https://github.com/vvakame))
* [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin))
@@ -270,10 +290,14 @@ All definitions files include a header with the author and editors, so at some p
* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH))
* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/))
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
+* [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli))
+* [promise-pool](https://github.com/vilic/promise-pool) (by [VILIC VANE](https://github.com/vilic))
* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar)
* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds))
+* [q-retry](https://github.com/vilic/q-retry) (by [VILIC VANE](https://github.com/vilic))
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo))
+* [Recaptcha.js](https://www.google.com/recaptcha) (by [Brent Jenkins](https://github.com/brentj73))
* [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski))
* [Riot.js](https://github.com/moot/riotjs) (by [vvakame](https://github.com/vvakame))
* [Restify](https://github.com/mcavage/node-restify) (by [Bret Little](https://github.com/blittle))
@@ -284,16 +308,18 @@ All definitions files include a header with the author and editors, so at some p
* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall))
* [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov))
* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/))
-* [rtree.js] (https://github.com/leaflet-extras/RTree) (by [Omede Firouz](https://github.com/oefirouz))
+* [rtree.js](https://github.com/leaflet-extras/RTree) (by [Omede Firouz](https://github.com/oefirouz))
* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov))
* [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong))
* [Semver](https://github.com/isaacs/node-semver) (by [Bart van der Schoor](https://github.com/Bartvds))
* [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428))
* [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com))
+* [ShellJS](http://shelljs.org) (by [Niklas Mollenhauer](https://github.com/nikeee))
* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov))
* [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame))
* [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u))
+* [sjcl](http://crypto.stanford.edu/sjcl/) (by [Eugene Chernyshov](https://github.com/Evgenus))
* [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin))
* [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley) and [Drew Noakes](https://drewnoakes.com))
* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr))
@@ -301,6 +327,7 @@ All definitions files include a header with the author and editors, so at some p
* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev))
* [sockjs-node](https://github.com/sockjs/sockjs-node) (by [Phil McCloghry-Laing](https://github.com/pmccloghrylaing))
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
+* [source-map](https://github.com/mozilla/source-map) (by [Morten Houston Ludvigsen](https://github.com/MortenHoustonLudvigsen))
* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov))
* [sqlite3](https://github.com/mapbox/node-sqlite3) (by [Nick Malaguti](https://github.com/nmalaguti))
* [status-bar](https://github.com/atom/status-bar) (by [vvakame](https://github.com/vvakame))
@@ -314,6 +341,7 @@ All definitions files include a header with the author and editors, so at some p
* [Tags Manager](http://welldonethings.com/tags/manager) (by [Vincent Bortone](https://github.com/vbortone))
* [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com))
* [text-buffer](https://github.com/atom/text-buffer) (by [vvakame](https://github.com/vvakame))
+* [text-encoding](https://github.com/inexorabletash/text-encoding) (by [MIZUNE Pine](https://github.com/pine613))
* [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/))
* [TimelineJS](https://github.com/NUKnightLab/TimelineJS) (by [Roland Zwaga](https://github.com/rolandzwaga))
* [timezonecomplete](https://github.com/SpiritIT/timezonecomplete) (by [Rogier Schouten](https://github.com/rogierschouten))
diff --git a/angular-agility/angular-agility.d.ts b/angular-agility/angular-agility.d.ts
index c11aff0b0..872971aed 100644
--- a/angular-agility/angular-agility.d.ts
+++ b/angular-agility/angular-agility.d.ts
@@ -41,7 +41,7 @@ declare module aa {
[settingName: string]: any;
}
- export interface IFormExtensionsProvider extends ng.auto.IProvider {
+ export interface IFormExtensionsProvider extends ng.IServiceProvider {
defaultLabelStrategy:string;
defaultFieldGroupStrategy:string;
defaultValMsgPlacementStrategy:string;
@@ -88,7 +88,7 @@ declare module aa {
message:string;
}
- export interface INotifyConfigProvider extends ng.auto.IProvider {
+ export interface INotifyConfigProvider extends ng.IServiceProvider {
notifyConfigs:any;
defaultTargetContainerName:string;
defaultNotifyConfig:string;
diff --git a/angular-bootstrap-lightbox/angular-bootstrap-lightbox-tests.ts b/angular-bootstrap-lightbox/angular-bootstrap-lightbox-tests.ts
new file mode 100644
index 000000000..21e9b2ce9
--- /dev/null
+++ b/angular-bootstrap-lightbox/angular-bootstrap-lightbox-tests.ts
@@ -0,0 +1,35 @@
+///
+
+var imageList:angular.bootstrap.lightbox.ILightboxImageInfo[] = [];
+imageList.push({
+ url: 'url1',
+ width: 100,
+ height: 100
+});
+imageList.push({
+ url: 'url2',
+ width: 100,
+ height: 100,
+ thumbUrl: 'thumbUrl',
+ caption: 'caption'
+});
+
+var lightBox:angular.bootstrap.lightbox.ILightbox = {};
+lightBox.openModal(imageList, 0);
+
+var provider:angular.bootstrap.lightbox.ILightBoxProvider = {};
+provider.templateUrl = 'templateUrl';
+provider.calculateImageDimensionLimits = (dimensions:angular.bootstrap.lightbox.IImageDimensionParameter):angular.bootstrap.lightbox.IImageDimensionLimits=> {
+ return {
+ minWidth: 100,
+ minHeight: 100,
+ maxWidth: dimensions.windowWidth - 102,
+ maxHeight: dimensions.windowHeight - 136
+ };
+};
+provider.calculateModalDimensions = (dimensions:angular.bootstrap.lightbox.IModalDimensionsParameter):angular.bootstrap.lightbox.IModalDimensions=> {
+ return {
+ width: Math.max(500, dimensions.imageDisplayWidth + 42),
+ height: Math.max(500, dimensions.imageDisplayHeight + 76)
+ };
+ };
\ No newline at end of file
diff --git a/angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts b/angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts
new file mode 100644
index 000000000..299967bdd
--- /dev/null
+++ b/angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts
@@ -0,0 +1,51 @@
+// Type definitions for angular-bootstrap-lightbox
+// Project: https://github.com/compact/angular-bootstrap-lightbox
+// Definitions by: Roland Zwaga
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module angular.bootstrap.lightbox {
+
+ export interface ILightboxImageInfo {
+ url: string;
+ width: number;
+ height: number;
+ thumbUrl?: string;
+ caption?: string;
+ }
+
+ export interface IImageDimensionLimits {
+ minWidth?: number;
+ minHeight?: number;
+ maxWidth?: number;
+ maxHeight?: number;
+ }
+
+ export interface IImageDimensionParameter {
+ windowWidth:number;
+ windowHeight:number;
+ imageWidth:number;
+ imageHeight:number;
+ }
+
+ export interface IModalDimensionsParameter {
+ windowWidth:number;
+ windowHeight:number;
+ imageDisplayWidth:number;
+ imageDisplayHeight:number;
+ }
+
+ export interface IModalDimensions {
+ width:number;
+ height:number;
+ }
+
+ export interface ILightbox {
+ openModal(images:ILightboxImageInfo[], index:number):void;
+ }
+
+ export interface ILightBoxProvider {
+ templateUrl:string;
+ calculateImageDimensionLimits:(dimensions:IImageDimensionParameter)=>IImageDimensionLimits;
+ calculateModalDimensions:(dimensions:IModalDimensionsParameter)=>IModalDimensions;
+ }
+}
\ No newline at end of file
diff --git a/angular-hotkeys/angular-hotkeys-tests.ts b/angular-hotkeys/angular-hotkeys-tests.ts
new file mode 100644
index 000000000..a065d4b21
--- /dev/null
+++ b/angular-hotkeys/angular-hotkeys-tests.ts
@@ -0,0 +1,25 @@
+///
+///
+
+var scope: ng.IScope;
+var hotkeyProvider: ng.hotkeys.HotkeysProvider;
+var hotkeyObj: ng.hotkeys.Hotkey;
+
+hotkeyProvider.add("mod+s", "saves a file", (event: Event, hotkey: ng.hotkeys.Hotkey) => {} );
+hotkeyProvider.add(hotkeyObj);
+hotkeyProvider.bindTo(scope);
+hotkeyProvider.del("mod+s");
+hotkeyProvider.get("mod+s");
+hotkeyProvider.toggleCheatSheet();
+
+hotkeyProvider.add(hotkeyObj.combo, hotkeyObj.description ,hotkeyObj.callback);
+
+hotkeyProvider.bindTo(scope)
+ .add(hotkeyObj)
+ .add(hotkeyObj)
+ .add({
+ combo: 'w',
+ description: 'blah blah',
+ callback: function() {}
+ });
+
diff --git a/angular-hotkeys/angular-hotkeys.d.ts b/angular-hotkeys/angular-hotkeys.d.ts
new file mode 100644
index 000000000..f209fbe08
--- /dev/null
+++ b/angular-hotkeys/angular-hotkeys.d.ts
@@ -0,0 +1,40 @@
+// Type definitions for angular-hotkeys
+// Project: https://github.com/chieffancypants/angular-hotkeys
+// Definitions by: Jason Zhao
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module ng.hotkeys {
+
+ interface HotkeysProvider {
+ template: string;
+ includeCheatSheet: boolean;
+ cheatSheetHotkey: string;
+ cheatSheetDescription: string;
+
+ add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void;
+
+ add(hotkeyObj: ng.hotkeys.Hotkey): void;
+
+ bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained;
+
+ del(combo: string): void;
+
+ get(combo: string): ng.hotkeys.Hotkey;
+
+ toggleCheatSheet(): void;
+ }
+
+ interface HotkeysProviderChained {
+ add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): HotkeysProviderChained;
+
+ add(hotkeyObj: ng.hotkeys.Hotkey): HotkeysProviderChained;
+ }
+
+ interface Hotkey {
+ combo: string;
+ description?: string;
+ callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void;
+ }
+}
diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts
index 37c9e49bc..5ca9ecde4 100644
--- a/angular-protractor/angular-protractor-tests.ts
+++ b/angular-protractor/angular-protractor-tests.ts
@@ -153,21 +153,36 @@ function TestProtractor() {
ptor.debugger();
+ var webElement: protractor.WebElement = ptor.findElement(by.css('.class'));
+ var promise: webdriver.promise.Promise;
+ promise = ptor.findElements(by.css('.class'));
+ promise = ptor.isElementPresent(by.css('.class'));
+ promise = ptor.isElementPresent(webElement);
+
ptor.clearMockModules();
ptor.addMockModule('name', 'script');
ptor.addMockModule('name', function() {});
+ ptor.removeMockModule('name');
ptor.waitForAngular();
var elementFinder: protractor.ElementFinder;
+ var elementArrayFinder: protractor.ElementArrayFinder;
elementFinder = ptor.element(by.id('ABC'));
elementFinder = ptor.$('.class');
- var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
-
- var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
+ elementArrayFinder = ptor.$$('.class');
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
+ ptor.setLocation('webaddress.com');
+
+ promise = ptor.get('webaddress.com');
+ promise = ptor.get('webdaddress.com', 45);
+ ptor.refresh();
+ ptor.refresh(45);
+ var navigation: webdriver.WebDriverNavigation = ptor.navigate();
+ ptor.pause();
+ ptor.pause(8080);
}
function TestElement() {
@@ -180,6 +195,7 @@ function TestElementFinder() {
var promise: webdriver.promise.Promise;
promise = elementFinder.click();
+ promise = elementFinder.allowAnimations('string');
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
promise = elementFinder.getTagName();
promise = elementFinder.getCssValue('display');
@@ -195,19 +211,49 @@ function TestElementFinder() {
promise = elementFinder.getOuterHtml();
promise = elementFinder.getInnerHtml();
promise = elementFinder.isElementPresent(by.id('id'));
- promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
- promise = elementFinder.findElements(by.className('class'));
- promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
+ promise = elementFinder.$('.class');
promise = elementFinder.$$('.class');
promise = elementFinder.evaluate('expression');
promise = elementFinder.isPresent();
var webElement: webdriver.WebElement;
+}
- webElement = elementFinder.$('.class');
- webElement = elementFinder.findElement(by.id('id'));
- webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
- webElement = elementFinder.find();
+function TestElementArrayFinder() {
+ var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
+ var promise: webdriver.promise.Promise;
+ var elementFinder: protractor.ElementFinder;
+
+ var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
+ elementFinder = elementArrayFinder.get(42);
+ elementFinder = elementArrayFinder.first();
+ elementFinder = elementArrayFinder.last();
+ promise = elementArrayFinder.count();
+ promise = elementArrayFinder.asElementFinders_();
+ elementArrayFinder.each(function(element: protractor.ElementFinder){
+ // nothing
+ });
+ elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
+ // nothing
+ });
+ elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
+ return element.getText().then((text: string) => {
+ return text === "foo";
+ });
+ });
+ elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder){
+ return element.getText().then((text: string) => {
+ return accumulator + ',' + text;
+ });
+ }, '');
+ elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
+ return element.getText().then((text: string) => {
+ return accumulator + ',' + text;
+ });
+ }, '');
+ elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
+ //nothing
+ });
}
// This function tests the angular specific locator strategies.
@@ -216,29 +262,19 @@ function TestLocatorStrategies() {
var webElement: webdriver.WebElement;
// Protractor Specific Locators
+ protractor.By.addLocator('customLocator', 'script');
+ protractor.By.addLocator('customLocator2', function(){
+ // nothing
+ });
webElement = ptor.findElement(protractor.By.binding('binding'));
- webElement = ptor.findElement(protractor.By.select('select'));
- webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
- webElement = ptor.findElement(protractor.By.input('input'));
+ webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
webElement = ptor.findElement(protractor.By.model('model'));
- webElement = ptor.findElement(protractor.By.textarea('textarea'));
webElement = ptor.findElement(protractor.By.repeater('repeater'));
+ webElement = ptor.findElement(protractor.By.repeater('repeater').column(0));
+ webElement = ptor.findElement(protractor.By.repeater('repeater').row(0));
+ webElement = ptor.findElement(protractor.By.repeater('repeater').row(0).column(0));
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
-}
-
-// This function tests the methods that were added to the base WebElement class
-function TestWebElements() {
- var ptor: protractor.Protractor = protractor.getInstance();
-
- var webElement: protractor.WebElement;
- var promise: webdriver.promise.Promise;
-
- webElement = ptor.findElement(by.id('id')).$('.class');
- promise = ptor.findElement(by.id('id')).$$('.class');
- promise = ptor.findElement(by.id('id')).evaluate('something');
-
- webElement = webElement.findElement(by.id('id')).$('.class');
- promise = webElement.findElement(by.id('id')).$$('.class');
- promise = webElement.findElement(by.id('id')).evaluate('something');
+ webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
+ webElement = ptor.findElement(protractor.By.options('options'));
}
diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts
index 3c3c0981f..2de49a0a4 100644
--- a/angular-protractor/angular-protractor.d.ts
+++ b/angular-protractor/angular-protractor.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Angular Protractor 0.17.0
+// Type definitions for Angular Protractor 1.0.0-rc4
// Project: https://github.com/angular/protractor
// Definitions by: Bill Armstrong
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -25,71 +25,7 @@ declare module protractor {
class CommandName extends webdriver.CommandName {}
class Key extends webdriver.Key {}
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
-
- class WebElement extends webdriver.WebElement {
- /**
- * Shortcut for querying the document directly with css.
- *
- * @param {string} selector a css selector
- * @see webdriver.WebElement.findElement
- * @return {!protractor.WebElement}
- */
- $(selector: string): protractor.WebElement;
-
- /**
- * Shortcut for querying the document directly with css.
- *
- * @param {string} selector a css selector
- * @see webdriver.WebElement.findElements
- * @return {!webdriver.promise.Promise} A promise that will be resolved to an
- * array of the located {@link webdriver.WebElement}s.
- */
- $$(selector: string): webdriver.promise.Promise;
-
- /**
- * Evalates the input as if it were on the scope of the current element.
- * @param {string} expression
- *
- * @return {!webdriver.promise.Promise} A promise that will resolve to the
- * evaluated expression. The result will be resolved as in
- * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
- * be resolved as is, functions will be converted to string, and elements
- * will be returned as a WebElement.
- */
- evaluate(expression: string): webdriver.promise.Promise;
-
- /**
- * Schedule a command to find a descendant of this element. If the element
- * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
- * be returned by the driver. Unlike other commands, this error cannot be
- * suppressed. In other words, scheduling a command to find an element doubles
- * as an assert that the element is present on the page. To test whether an
- * element is present on the page, use {@code #isElementPresent} instead.
- *
- * The search criteria for find an element may either be a
- * {@code webdriver.Locator} object, or a simple JSON object whose sole key
- * is one of the accepted locator strategies, as defined by
- * {@code webdriver.Locator.Strategy}. For example, the following two
- * statements are equivalent:
- *
- * var e1 = element.findElement(By.id('foo'));
- * var e2 = element.findElement({id:'foo'});
- *
- *
- * Note that JS locator searches cannot be restricted to a subtree. All such
- * searches are delegated to this instance's parent WebDriver.
- *
- * @param {webdriver.Locator|Object.} locator The locator
- * strategy to use when searching for the element.
- * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
- * using a JavaScript locator. Otherwise ignored.
- * @return {protractor.WebElement} A WebElement that can be used to issue
- * commands against the located element. If the element is not found, the
- * element will be invalidated and all scheduled commands aborted.
- */
- findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
- findElement(locator: any, ...var_args: any[]): protractor.WebElement;
- }
+ class WebElement extends webdriver.WebElement {}
module command {
class Command extends webdriver.Command {}
@@ -273,13 +209,140 @@ declare module protractor {
}
//endregion
-
+ /**
+ * Use as: element(locator)
+ *
+ * The ElementFinder can be treated as a WebElement for most purposes, in
+ * particular, you may perform actions (i.e. click, getText) on them as you
+ * would a WebElement. ElementFinders extend Promise, and once an action
+ * is performed on an ElementFinder, the latest result from the chain can be
+ * accessed using then. Unlike a WebElement, an ElementFinder will wait for
+ * angular to settle before performing finds or actions.
+ *
+ * ElementFinder can be used to build a chain of locators that is used to find
+ * an element. An ElementFinder does not actually attempt to find the element
+ * until an action is called, which means they can be set up in helper files
+ * before the page is available.
+ *
+ * @param {webdriver.Locator} locator An element locator.
+ * @return {ElementFinder}
+ */
interface Element {
(locator: webdriver.Locator): ElementFinder;
+
+ /**
+ * ElementArrayFinder is used for operations on an array of elements (as opposed
+ * to a single element).
+ *
+ * @param {webdriver.Locator} locator An element locator.
+ * @return {ElementArrayFinder}
+ */
all(locator: webdriver.Locator): ElementArrayFinder;
}
interface ElementFinder {
+ /**
+ * Use as: element(locator).element(locator)
+ * Calls to element may be chained to find elements within a parent.
+ *
+ * @param {webdriver.Locator} locator The locator that will be used to find descendents.
+ *
+ * @return {protractor.ElementFinder} The descendent element found by the locator
+ */
+ element(locator: webdriver.Locator): protractor.ElementFinder;
+
+ /**
+ * Use as: element(locator).all(locator)
+ * Calls to element may be chained to find an array of elements within a parent.
+ *
+ * @param {webdriver.Locator} locator The locator that will be used to find descendents.
+ *
+ * @return {protractor.ElementArrayFinder} The descendent elements found by the locator
+ */
+ all(locator: webdriver.Locator): protractor.ElementArrayFinder;
+
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElement
+ * @return {!protractor.WebElement}
+ */
+ $(selector: string): protractor.WebElement;
+
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElements
+ * @return {!webdriver.promise.Promise} A promise that will be resolved to an
+ * array of the located {@link webdriver.WebElement}s.
+ */
+ $$(selector: string): webdriver.promise.Promise;
+
+ /**
+ * Use as: element(locator).isPresent()
+ * Determine whether the element is present on the page.
+ *
+ * @return {protractor.ElementFinder} Which resolves to whether the element is present on the page.
+ */
+ isPresent(): webdriver.promise.Promise;
+
+ /**
+ * Override for WebElement.prototype.isElementPresent so that protractor waits
+ * for Angular to settle before making the check.
+ *
+ * @see ElementFinder.isPresent
+ * @return {!webdriver.promise.Promise} which resolves to whether the element is present on the page.
+ */
+ isElementPresent(locator: webdriver.Locator): webdriver.promise.Promise;
+
+ /**
+ * Return this ElementFinder's locator.
+ *
+ * @return {webdriver.Locator}
+ */
+ locator(): webdriver.Locator;
+
+ /**
+ * Use as: element(locator).getWebElement()
+ * Returns the WebElement represented by this ElementFinder.
+ * Throws the WebDriver error if the element doesn't exist.
+ * If index is null, it makes sure that there is only one underlying WebElement
+ * described by the chain of locators and issues a warning otherwise.
+ * If index is not null, it retrieves the WebElement specified by the index..
+ * @return {webdriver.WebElement} The WebElement represented by the ElementFinder.
+ */
+ getWebElement(): webdriver.WebElement;
+
+ /**
+ * Evalates the input as if it were on the scope of the current element.
+ * @param {string} expression
+ *
+ * @return {!webdriver.promise.Promise} A promise that will resolve to the
+ * evaluated expression. The result will be resolved as in
+ * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
+ * be resolved as is, functions will be converted to string, and elements
+ * will be returned as a WebElement.
+ */
+ evaluate(expression: string): webdriver.promise.Promise;
+
+ /**
+ * Determine if animation is allowed on the current element.
+ * @param {string} value
+ *
+ * @return {ElementFinder} which resolves to whether animation is allowed.
+ */
+ allowAnimations(value: string): webdriver.promise.Promise;
+
+ /**
+ * Access the underlying actionResult of ElementFinder. Implementation allows ElementFinder to be used as a webdriver.promise.Promise.
+ * @param {function(webdriver.promise.Promise)} fn Function which takes the value of the underlying actionResult.
+ *
+ * @return {webdriver.promise.Promise} Promise which contains the results of evaluating fn.
+ */
+ then(fn: IThenFunction): webdriver.promise.Promise;
+
/**
* Schedules a command to click on this element.
* @return {!webdriver.promise.Promise} A promise that will be resolved when
@@ -460,113 +523,163 @@ declare module protractor {
getInnerHtml(): webdriver.promise.Promise;
/**
- * Schedules a command to test if there is at least one descendant of this
- * element that matches the given search criteria.
- *
- *
Note that JS locator searches cannot be restricted to a subtree of the
- * DOM. All such searches are delegated to this instance's parent WebDriver.
- *
- * @param {webdriver.Locator|Object.} locator The locator
- * strategy to use when searching for the element.
- * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
- * using a JavaScript locator. Otherwise ignored.
- * @return {!webdriver.promise.Promise} A promise that will be resolved with
- * whether an element could be located on the page.
+ * @return {!webdriver.promise.Promise.} A promise
+ * that resolves to this element's JSON representation as defined by the
+ * WebDriver wire protocol.
+ * @see http://code.google.com/p/selenium/wiki/JsonWireProtocol
*/
- isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
- isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
-
- /**
- * Schedules a command to find all of the descendants of this element that match
- * the given search criteria.
- *
- * Note that JS locator searches cannot be restricted to a subtree. All such
- * searches are delegated to this instance's parent WebDriver.
- *
- * @param {webdriver.Locator|Object.} locator The locator
- * strategy to use when searching for the elements.
- * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
- * using a JavaScript locator. Otherwise ignored.
- * @return {!webdriver.promise.Promise} A promise that will be resolved with an
- * array of located {@link webdriver.WebElement}s.
- */
- findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
- findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
-
- /**
- * Shortcut for querying the document directly with css.
- *
- * @param {string} selector a css selector
- * @see webdriver.WebElement.findElement
- * @return {!protractor.WebElement}
- */
- $(selector: string): protractor.WebElement;
-
- /**
- * Shortcut for querying the document directly with css.
- *
- * @param {string} selector a css selector
- * @see webdriver.WebElement.findElements
- * @return {!webdriver.promise.Promise} A promise that will be resolved to an
- * array of the located {@link webdriver.WebElement}s.
- */
- $$(selector: string): webdriver.promise.Promise;
-
- /**
- * Schedule a command to find a descendant of this element. If the element
- * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
- * be returned by the driver. Unlike other commands, this error cannot be
- * suppressed. In other words, scheduling a command to find an element doubles
- * as an assert that the element is present on the page. To test whether an
- * element is present on the page, use {@code #isElementPresent} instead.
- *
- * The search criteria for find an element may either be a
- * {@code webdriver.Locator} object, or a simple JSON object whose sole key
- * is one of the accepted locator strategies, as defined by
- * {@code webdriver.Locator.Strategy}. For example, the following two
- * statements are equivalent:
- *
- * var e1 = element.findElement(By.id('foo'));
- * var e2 = element.findElement({id:'foo'});
- *
- *
- * Note that JS locator searches cannot be restricted to a subtree. All such
- * searches are delegated to this instance's parent WebDriver.
- *
- * @param {webdriver.Locator|Object.} locator The locator
- * strategy to use when searching for the element.
- * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
- * using a JavaScript locator. Otherwise ignored.
- * @return {protractor.WebElement} A WebElement that can be used to issue
- * commands against the located element. If the element is not found, the
- * element will be invalidated and all scheduled commands aborted.
- */
- findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
- findElement(locator: any, ...var_args: any[]): protractor.WebElement;
-
- /**
- * Evalates the input as if it were on the scope of the current element.
- * @param {string} expression
- *
- * @return {!webdriver.promise.Promise} A promise that will resolve to the
- * evaluated expression. The result will be resolved as in
- * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
- * be resolved as is, functions will be converted to string, and elements
- * will be returned as a WebElement.
- */
- evaluate(expression: string): webdriver.promise.Promise;
-
- find(): protractor.WebElement;
-
- isPresent(): webdriver.promise.Promise;
+ toWireValue(): webdriver.promise.Promise;
}
- interface ElementArrayFinder{
+ interface IThenFunction {
+ (promiseResult: any): any;
+ }
+
+
+ interface ElementArrayFinder {
+ /**
+ * Use as: element.all(locator).getWebElements()
+ * Returns the array of WebElements represented by this ElementArrayFinder.
+ *
+ * @return {Array.} Array of WebElements represented by this ElementArrayFinder
+ */
+ getWebElements(): webdriver.WebElement[];
+
+ /**
+ * Use as: element.all(locator).get(index)
+ * Get an element found by the locator by index. The index starts at 0. This does not actually retrieve the underlying element.
+ *
+ * @param {number} index Element index.
+ *
+ * @return {protractor.ElementFinder} Finder representing element at the given index
+ */
+ get(index: number): protractor.ElementFinder;
+
+
+ /**
+ * Use as: element.all(locator).first()
+ * Get the first matching element for the locator. This does not actually retrieve the underlying element.
+ *
+ * @return {Protractor.ElementFinder} Finder representing the first matching element
+ */
+ first(): protractor.ElementFinder;
+
+ /**
+ * Use as: element.all(locator).last()
+ * Get the last matching element for the locator. This does not actually retrieve the underlying element.
+ *
+ * @return {Protractor.ElementFinder} Finder representing the last matching element
+ */
+ last(): protractor.ElementFinder;
+
+ /**
+ * Use as: element.all(locator).getWebElements()
+ * Returns the array of WebElements represented by this ElementArrayFinder.
+ *
+ * @return {!webdriver.promise.Promise} The array of WebElements represented by this ElementArrayFinder
+ */
count(): webdriver.promise.Promise;
- get(index: number): protractor.WebElement;
- first(): protractor.WebElement;
- last(): protractor.WebElement;
- then(fn: (value: any) => any): webdriver.promise.Promise;
+
+ /**
+ * Use as: element.all(locator).each(eachFunction)
+ * Calls the input function on each ElementFinder found by the locator.
+ *
+ * @param {function(ElementFinder)} fn Input function.
+ */
+ each(fn: IEachFunction): void;
+
+ /**
+ * Use as: element.all(locator).map(mapFunction)
+ * Apply a map function to each element found using the locator. The callback receives the ElementFinder as the first argument and the index as a second arg.
+ *
+ * @param {function(ElementFinder, number)} mapFn Map function that will be applied to each element.
+ *
+ * @return {!webdriver.promise.Promise} A promise that resolves to an array of values returned by the map function.
+ */
+ map(mapFn: IMapFunction): webdriver.promise.Promise;
+
+ /**
+ * Use as: element.all(locator).filter(filterFn)
+ * Apply a filter function to each element found using the locator. Returns promise of a new array with all elements that pass the filter function. The filter function receives the ElementFinder as the first argument and the index as a second arg.
+ *
+ * @param {function(ElementFinder, number): webdriver.promise.Promise} filterFn Filter function that will test if an element should be returned. filterFn should return a promise that resolves to a boolean.
+ *
+ * @return {!webdriver.promise.Promise} A promise that resolves to an array of ElementFinders that satisfy the filter function.
+ */
+ filter(func: IFilterFunction): webdriver.promise.Promise;
+
+ /**
+ * Use as: element.all(locator).reduce(reduceFn)
+ * Apply a reduce function against an accumulator and every element found using the locator (from left-to-right).
+ * The reduce function has to reduce every element into a single value (the accumulator).
+ * Returns promise of the accumulator.
+ * The reduce function receives the accumulator, current ElementFinder, the index, and the entire array of ElementFinders, respectively.
+ *
+ * @param {function(number, ElementFinder, number, Array.): webdriver.promise.Promise} reduceFn Reduce function that reduces every element into a single value.
+ * @param {*} initialValue Initial value of the accumulator.
+ *
+ * @return {!webdriver.promise.Promise} A promise that resolves to the final value of the accumulator.
+ */
+ reduce(func: IReductionFunction, initialValue: any): webdriver.promise.Promise;
+
+ /**
+ * Represents the ElementArrayFinder as an array of ElementFinders.
+ *
+ * @return {!webdriver.promise.Promise} Return a promise, which resolves to a list (array)
+ * of ElementFinders specified by the locator.
+ */
+ asElementFinders_(): webdriver.promise.Promise;
+
+
+ /**
+ * Find the elements specified by the locator. The input function is passed
+ * to the resulting promise, which resolves to an array of ElementFinders.
+ *
+ * Use as: element.all(locator).then(thenFunction)
+ *
+ * Find a button by text.
*
- * // Returns the DIV for the second cat.
- * var secondCat = element(by.repeater("cat in pets").row(2));
- * // Returns the SPAN for the first cat's name.
- * var firstCatName = element(
- * by.repeater("cat in pets").row(1).column("{{cat.name}}"));
- * // Returns a promise that resolves to an array of WebElements from a column
- * var ages = element(
- * by.repeater("cat in pets").column("{{cat.age}}"));
- * // Returns a promise that resolves to an array of WebElements containing
- * // all rows of the repeater.
- * var rows = element(by.repeater("cat in pets"));
+ * Usage:
+ *
+ * element(by.buttonText('Save'));
+ *
+ * @param {string} searchText
+ * @return {webdriver.Locator}
*/
- repeater(repeatDescriptor: string): webdriver.Locator;
-
buttonText(searchText: string): webdriver.Locator;
+
+ /**
+ * Find a button by partial text.
+ *
+ * Usage:
+ *
+ * element(by.partialButtonText('Save'));
+ *
+ * @param {string} searchText
+ * @return {webdriver.Locator}
+ */
partialButtonText(searchText: string): webdriver.Locator;
+
+ /**
+ * Find elements inside an ng-repeat.
+ *
+ * Usage:
+ *
+ * {{cat.name}}
+ * {{cat.age}}
+ *
+ *
+ *
+ * {{$index}}
+ *
+ *
+ *
{{book.name}}
+ *
{{book.blurb}}
+ *
+ *
+ * // Returns the DIV for the second cat.
+ * var secondCat = element(by.repeater('cat in pets').row(1));
+ *
+ * // Returns the SPAN for the first cat's name.
+ * var firstCatName = element(by.repeater('cat in pets').
+ * row(0).column('{{cat.name}}'));
+ *
+ * // Returns a promise that resolves to an array of WebElements from a column
+ * var ages = element.all(
+ * by.repeater('cat in pets').column('{{cat.age}}'));
+ *
+ * // Returns a promise that resolves to an array of WebElements containing
+ * // all top level elements repeated by the repeater. For 2 pets rows resolves
+ * // to an array of 2 elements.
+ * var rows = element.all(by.repeater('cat in pets'));
+ *
+ * // Returns a promise that resolves to an array of WebElements containing all
+ * // the elements with a binding to the book's name.
+ * var divs = element.all(by.repeater('book in library').column('book.name'));
+ *
+ * // Returns a promise that resolves to an array of WebElements containing
+ * // the DIVs for the second book.
+ * var bookInfo = element.all(by.repeater('book in library').row(1));
+ *
+ * // Returns the H4 for the first book's name.
+ * var firstBookName = element(by.repeater('book in library').
+ * row(0).column('{{book.name}}'));
+ *
+ * // Returns a promise that resolves to an array of WebElements containing
+ * // all top level elements repeated by the repeater. For 2 books divs
+ * // resolves to an array of 4 elements.
+ * var divs = element.all(by.repeater('book in library'));
+ */
+ repeater(repeatDescriptor: string): RepeaterLocator;
+
+ /**
+ * Find elements by CSS which contain a certain string.
+ *
+ * @view
+ *
+ *
Dog
+ *
Cat
+ *
+ *
+ * @example
+ * // Returns the DIV for the dog, but not cat.
+ * var dog = element(by.cssContainingText('.pet', 'Dog'));
+ *
+ * @param cssSelector {string}
+ * @param searchText {string}
+ * @return {webdriver.Locator}
+ */
+ cssContainingText(cssSelector: string, searchText: string): webdriver.Locator;
+
+ /**
+ * Find an element by ng-options expression.
+ *
+ * Usage:
+ *
+ *
+ * var allOptions = element.all(by.options('c for c in colors'));
+ * expect(allOptions.count()).toEqual(2);
+ * var firstOption = allOptions.first();
+ * expect(firstOption.getText()).toEqual('red');
+ *
+ * @param {string} optionsDescriptor ng-options expression.
+ * @return {webdriver.Locator}
+ */
+ options(optionsDescriptor: string): webdriver.Locator;
}
var By: IProtractorLocatorStrategy;
@@ -718,6 +922,43 @@ declare module protractor {
//region Methods
+ /**
+ * Instruct webdriver to wait until Angular has finished rendering and has
+ * no outstanding $http calls before continuing.
+ *
+ * @return {!webdriver.promise.Promise} A promise that will resolve to the
+ * scripts return value.
+ */
+ waitForAngular(): webdriver.promise.Promise;
+
+ /**
+ * Waits for Angular to finish rendering before searching for elements.
+ * @see webdriver.WebDriver.findElement
+ *
+ * @param {webdriver.Locator} locator The locator used to find the element.
+ * @return {!webdriver.WebElement}
+ */
+ findElement(locator: webdriver.Locator): protractor.WebElement;
+
+ /**
+ * Waits for Angular to finish rendering before searching for elements.
+ * @see webdriver.WebDriver.findElements
+ *
+ * @param {webdriver.Locator} locator The locator used to find the elements.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved to an
+ * array of the located {@link webdriver.WebElement}s.
+ */
+ findElements(locator: webdriver.Locator): webdriver.promise.Promise;
+
+ /**
+ * Tests if an element is present on the page.
+ * @see webdriver.WebDriver.isElementPresent
+ * @return {!webdriver.promise.Promise} A promise that will resolve to whether
+ * the element is present on the page.
+ */
+ isElementPresent(locatorOrElement: webdriver.Locator): webdriver.promise.Promise;
+ isElementPresent(locatorOrElement: any): webdriver.promise.Promise;
+
/**
* Helper function for finding elements.
*
@@ -739,40 +980,71 @@ declare module protractor {
*/
$$(cssLocator: string): ElementArrayFinder;
- /**
- * Instruct webdriver to wait until Angular has finished rendering and has
- * no outstanding $http calls before continuing.
- *
- * @return {!webdriver.promise.Promise} A promise that will resolve to the
- * scripts return value.
- */
- waitForAngular(): webdriver.promise.Promise;
-
- /**
- * Wrap a webdriver.WebElement with protractor specific functionality.
- *
- * @param {webdriver.WebElement} element
- * @return {protractor.WebElement} the wrapped web element.
- */
- wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
-
/**
* Add a module to load before Angular whenever Protractor.get is called.
* Modules will be registered after existing modules already on the page,
* so any module registered here will override preexisting modules with the same
* name.
*
- * @param {!string} name The name of the module to load or override.
- * @param {!string|Function} script The JavaScript to load the module.
+ * @param {string} name The name of the module to load or override.
+ * @param {string|Function} script The JavaScript to load the module.
+ * @param {...*} varArgs Any additional arguments will be provided to
+ * the script and may be referenced using the `arguments` object.
*/
- addMockModule(name: string, script: string): void;
- addMockModule(name: string, script: any): void;
+ addMockModule(name: string, script: string, ...varArgs: any[]): void;
+ addMockModule(name: string, script: any, ...varArgs: any[]): void;
/**
* Clear the list of registered mock modules.
*/
clearMockModules(): void;
+ /**
+ * Remove a registered mock module.
+ * @param {!string} name The name of the module to remove.
+ */
+ removeMockModule(name: string): void;
+
+ /**
+ * See webdriver.WebDriver.get
+ *
+ * Navigate to the given destination and loads mock modules before
+ * Angular. Assumes that the page being loaded uses Angular.
+ * If you need to access a page which does not have Angular on load, use
+ * the wrapped webdriver directly.
+ *
+ * @param {string} destination Destination URL.
+ * @param {number=} opt_timeout Number of seconds to wait for Angular to start.
+ */
+ get(destination: string, opt_timeout?: number): webdriver.promise.Promise;
+
+ /**
+ * See webdriver.WebDriver.refresh
+ *
+ * Makes a full reload of the current page and loads mock modules before
+ * Angular. Assumes that the page being loaded uses Angular.
+ * If you need to access a page which does not have Angular on load, use
+ * the wrapped webdriver directly.
+ *
+ * @param {number=} opt_timeout Number of seconds to wait for Angular to start.
+ */
+ refresh(opt_timeout?: number): void;
+
+ /**
+ * Mixin navigation methods back into the navigation object so that
+ * they are invoked as before, i.e. driver.navigate().refresh()
+ */
+ navigate(): webdriver.WebDriverNavigation;
+
+ /**
+ * Browse to another page using in-page navigation.
+ *
+ * @param {string} url In page URL using the same syntax as $location.url()
+ * @returns {!webdriver.promise.Promise} A promise that will resolve once
+ * page has been changed.
+ */
+ setLocation(url: string): webdriver.promise.Promise;
+
/**
* Returns the current absolute url from AngularJS.
*/
@@ -799,43 +1071,14 @@ declare module protractor {
debugger(): void;
/**
- * Schedule a command to find an element on the page. If the element cannot be
- * found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
- * by the driver. Unlike other commands, this error cannot be suppressed. In
- * other words, scheduling a command to find an element doubles as an assert
- * that the element is present on the page. To test whether an element is
- * present on the page, use {@code #isElementPresent} instead.
+ * Beta (unstable) pause function for debugging webdriver tests. Use
+ * browser.pause() in your test to enter the protractor debugger from that
+ * point in the control flow.
+ * Does not require changes to the command line (no need to add 'debug').
*
- *
The search criteria for find an element may either be a
- * {@code webdriver.Locator} object, or a simple JSON object whose sole key
- * is one of the accepted locator strategies, as defined by
- * {@code webdriver.Locator.Strategy}. For example, the following two statements
- * are equivalent:
- *
- * var e1 = driver.findElement(By.id('foo'));
- * var e2 = driver.findElement({id:'foo'});
- *
- *
- *
When running in the browser, a WebDriver cannot manipulate DOM elements
- * directly; it may do so only through a {@link webdriver.WebElement} reference.
- * This function may be used to generate a WebElement from a DOM element. A
- * reference to the DOM element will be stored in a known location and this
- * driver will attempt to retrieve it through {@link #executeScript}. If the
- * element cannot be found (eg, it belongs to a different document than the
- * one this instance is currently focused on), a
- * {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
- *
- * @param {!(webdriver.Locator|Object.|Element)} locatorOrElement The
- * locator strategy to use when searching for the element, or the actual
- * DOM element to be located by the server.
- * @param {...} var_args Arguments to pass to {@code #executeScript} if using a
- * JavaScript locator. Otherwise ignored.
- * @return {!protractor.WebElement} A WebElement that can be used to issue
- * commands against the located element. If the element is not found, the
- * element will be invalidated and all scheduled commands aborted.
+ * @param {=number} opt_debugPort Optional port to use for the debugging process
*/
- findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
- findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
+ pause(opt_debugPort?: number): void;
//endregion
}
@@ -863,9 +1106,19 @@ declare module protractor {
}
+interface cssSelectorHelper {
+ (cssLocator: string): protractor.ElementFinder;
+}
+
+interface cssArraySelectorHelper {
+ (cssLocator: string): protractor.ElementArrayFinder;
+}
+
declare var browser: protractor.Protractor;
declare var by: protractor.IProtractorLocatorStrategy;
declare var element: protractor.Element;
+declare var $: cssSelectorHelper;
+declare var $$: cssArraySelectorHelper;
declare module 'protractor' {
export = protractor;
diff --git a/angular-protractor/legacy/angular-protractor-0.17.0-tests.ts b/angular-protractor/legacy/angular-protractor-0.17.0-tests.ts
new file mode 100644
index 000000000..dfd413d0e
--- /dev/null
+++ b/angular-protractor/legacy/angular-protractor-0.17.0-tests.ts
@@ -0,0 +1,244 @@
+///
+
+function TestWebDriverExports() {
+ var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
+ var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
+
+ var button: protractor.Button = new protractor.Button();
+ var baseButton: webdriver.Button = button;
+
+ var key: string = protractor.Key.ADD;
+ var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
+
+ var driver: protractor.WebDriver = new protractor.Builder().
+ withCapabilities(protractor.Capabilities.chrome()).
+ build();
+ var baseDriver: webdriver.WebDriver = driver;
+
+ var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
+ var baseAction: webdriver.ActionSequence = action;
+
+ var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
+ var baseAlert: webdriver.Alert = alert;
+
+ var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
+ var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
+
+ var browser: string = protractor.Browser.ANDROID;
+
+ var builder: protractor.Builder = new protractor.Builder();
+ var baseBuilder: webdriver.Builder = builder;
+
+ var capability: string = protractor.Capability.BROWSER_NAME;
+
+ var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
+ var baseCapabilities: webdriver.Capabilities = capabilities;
+
+ var commandName: string = protractor.CommandName.CLICK_ELEMENT;
+
+ var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
+ var baseCommand: webdriver.Command = command;
+
+ var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
+ var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
+
+ var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
+ var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
+
+ var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
+ var baseWebElement: webdriver.WebElement = webElement;
+
+ var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
+ var baseLocator: webdriver.Locator = locator;
+
+ var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
+ var baseSession: webdriver.Session = session;
+
+ locator = protractor.By.name('name');
+
+ // logging module
+
+ var levelName: string = protractor.logging.LevelName.ALL;
+ var loggingType: string = protractor.logging.Type.CLIENT;
+
+ var level: webdriver.logging.Level = protractor.logging.Level.ALL;
+
+ var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
+ var baseEntry: webdriver.logging.Entry = entry;
+
+ level = protractor.logging.getLevel('DEBUG');
+
+ protractor.logging.Preferences = { a: 123 };
+
+ // promise module
+
+ var promise: protractor.promise.Promise = new protractor.promise.Promise();
+ var basePromise: webdriver.promise.Promise = promise;
+
+ var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
+ var baseDeferred: webdriver.promise.Deferred = deferred;
+
+ var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
+ var baseFlow: webdriver.promise.ControlFlow = flow;
+
+ protractor.promise.asap(promise, function(value: any){ return true; });
+ protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
+
+ promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
+
+ flow = protractor.promise.controlFlow();
+
+ promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
+
+ deferred = protractor.promise.defer(function() {});
+ deferred = protractor.promise.defer(function(reason?: any) {});
+
+ promise = protractor.promise.delayed(123);
+
+ promise = protractor.promise.fulfilled();
+ promise = protractor.promise.fulfilled({a: 123});
+
+ promise = protractor.promise.fullyResolved({a: 123});
+
+ var isPromise: boolean = protractor.promise.isPromise('ABC');
+
+ promise = protractor.promise.rejected({a: 123});
+
+ protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
+
+ promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
+
+ // error module
+
+ var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
+ var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
+ var baseError: webdriver.error.Error = error;
+
+ // process module
+
+ var isNative: boolean = protractor.process.isNative();
+ var value: string;
+
+ value = protractor.process.getEnv('name');
+ value = protractor.process.getEnv('name', 'default');
+
+ protractor.process.setEnv('name', 'value');
+ protractor.process.setEnv('name', 123);
+
+}
+
+function TestProtractor() {
+ var ptor: protractor.Protractor;
+ var driver: webdriver.WebDriver = new webdriver.Builder().
+ withCapabilities(webdriver.Capabilities.chrome()).
+ build();
+
+ ptor = new protractor.Protractor(driver);
+ ptor = new protractor.Protractor(driver, 'baseUrl');
+ ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
+ ptor = protractor.getInstance();
+ protractor.setInstance(ptor);
+
+ ptor = protractor.wrapDriver(driver);
+ ptor = protractor.wrapDriver(driver, 'baseUrl');
+ ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
+
+ ptor = browser;
+
+ driver = ptor.driver;
+ var baseUrl: string = ptor.baseUrl;
+ var rootEl: string = ptor.rootEl;
+ var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
+ var params: any = ptor.params;
+
+ ptor.debugger();
+
+ ptor.clearMockModules();
+ ptor.addMockModule('name', 'script');
+ ptor.addMockModule('name', function() {});
+ ptor.waitForAngular();
+
+ var elementFinder: protractor.ElementFinder;
+
+ elementFinder = ptor.element(by.id('ABC'));
+ elementFinder = ptor.$('.class');
+
+ var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
+
+ var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
+
+ var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
+}
+
+function TestElement() {
+ var elementFinder: protractor.ElementFinder = element(by.id('id'));
+ var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
+}
+
+function TestElementFinder() {
+ var elementFinder: protractor.ElementFinder = element(by.id('id'));
+ var promise: webdriver.promise.Promise;
+
+ promise = elementFinder.click();
+ promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
+ promise = elementFinder.getTagName();
+ promise = elementFinder.getCssValue('display');
+ promise = elementFinder.getAttribute('atribute');
+ promise = elementFinder.getText();
+ promise = elementFinder.getSize();
+ promise = elementFinder.getLocation();
+ promise = elementFinder.isEnabled();
+ promise = elementFinder.isSelected();
+ promise = elementFinder.submit();
+ promise = elementFinder.clear();
+ promise = elementFinder.isDisplayed();
+ promise = elementFinder.getOuterHtml();
+ promise = elementFinder.getInnerHtml();
+ promise = elementFinder.isElementPresent(by.id('id'));
+ promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
+ promise = elementFinder.findElements(by.className('class'));
+ promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
+ promise = elementFinder.$$('.class');
+ promise = elementFinder.evaluate('expression');
+ promise = elementFinder.isPresent();
+
+ var webElement: webdriver.WebElement;
+
+ webElement = elementFinder.$('.class');
+ webElement = elementFinder.findElement(by.id('id'));
+ webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
+ webElement = elementFinder.find();
+}
+
+// This function tests the angular specific locator strategies.
+function TestLocatorStrategies() {
+ var ptor: protractor.Protractor = protractor.getInstance();
+ var webElement: webdriver.WebElement;
+
+ // Protractor Specific Locators
+ webElement = ptor.findElement(protractor.By.binding('binding'));
+ webElement = ptor.findElement(protractor.By.select('select'));
+ webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
+ webElement = ptor.findElement(protractor.By.input('input'));
+ webElement = ptor.findElement(protractor.By.model('model'));
+ webElement = ptor.findElement(protractor.By.textarea('textarea'));
+ webElement = ptor.findElement(protractor.By.repeater('repeater'));
+ webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
+ webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
+}
+
+// This function tests the methods that were added to the base WebElement class
+function TestWebElements() {
+ var ptor: protractor.Protractor = protractor.getInstance();
+
+ var webElement: protractor.WebElement;
+ var promise: webdriver.promise.Promise;
+
+ webElement = ptor.findElement(by.id('id')).$('.class');
+ promise = ptor.findElement(by.id('id')).$$('.class');
+ promise = ptor.findElement(by.id('id')).evaluate('something');
+
+ webElement = webElement.findElement(by.id('id')).$('.class');
+ promise = webElement.findElement(by.id('id')).$$('.class');
+ promise = webElement.findElement(by.id('id')).evaluate('something');
+}
diff --git a/angular-protractor/legacy/angular-protractor-0.17.0.d.ts b/angular-protractor/legacy/angular-protractor-0.17.0.d.ts
new file mode 100644
index 000000000..38458b493
--- /dev/null
+++ b/angular-protractor/legacy/angular-protractor-0.17.0.d.ts
@@ -0,0 +1,906 @@
+// Type definitions for Angular Protractor 0.17.0
+// Project: https://github.com/angular/protractor
+// Definitions by: Bill Armstrong
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module protractor {
+ //region Wrapped webdriver Items
+
+ class AbstractBuilder extends webdriver.AbstractBuilder {}
+ class ActionSequence extends webdriver.ActionSequence {}
+ class Alert extends webdriver.Alert {}
+ class Builder extends webdriver.Builder {}
+ class Button extends webdriver.Button {}
+ class Capabilities extends webdriver.Capabilities {}
+ class Command extends webdriver.Command {}
+ class EventEmitter extends webdriver.EventEmitter {}
+ class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {}
+ class Locator extends webdriver.Locator {}
+ class Session extends webdriver.Session {}
+ class WebDriver extends webdriver.WebDriver {}
+ class Browser extends webdriver.Browser {}
+ class Capability extends webdriver.Capability {}
+ class CommandName extends webdriver.CommandName {}
+ class Key extends webdriver.Key {}
+ class UnhandledAlertError extends webdriver.UnhandledAlertError {}
+
+ class WebElement extends webdriver.WebElement {
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElement
+ * @return {!protractor.WebElement}
+ */
+ $(selector: string): protractor.WebElement;
+
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElements
+ * @return {!webdriver.promise.Promise} A promise that will be resolved to an
+ * array of the located {@link webdriver.WebElement}s.
+ */
+ $$(selector: string): webdriver.promise.Promise;
+
+ /**
+ * Evalates the input as if it were on the scope of the current element.
+ * @param {string} expression
+ *
+ * @return {!webdriver.promise.Promise} A promise that will resolve to the
+ * evaluated expression. The result will be resolved as in
+ * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
+ * be resolved as is, functions will be converted to string, and elements
+ * will be returned as a WebElement.
+ */
+ evaluate(expression: string): webdriver.promise.Promise;
+
+ /**
+ * Schedule a command to find a descendant of this element. If the element
+ * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
+ * be returned by the driver. Unlike other commands, this error cannot be
+ * suppressed. In other words, scheduling a command to find an element doubles
+ * as an assert that the element is present on the page. To test whether an
+ * element is present on the page, use {@code #isElementPresent} instead.
+ *
+ * The search criteria for find an element may either be a
+ * {@code webdriver.Locator} object, or a simple JSON object whose sole key
+ * is one of the accepted locator strategies, as defined by
+ * {@code webdriver.Locator.Strategy}. For example, the following two
+ * statements are equivalent:
+ *
+ * var e1 = element.findElement(By.id('foo'));
+ * var e2 = element.findElement({id:'foo'});
+ *
+ *
+ * Note that JS locator searches cannot be restricted to a subtree. All such
+ * searches are delegated to this instance's parent WebDriver.
+ *
+ * @param {webdriver.Locator|Object.} locator The locator
+ * strategy to use when searching for the element.
+ * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
+ * using a JavaScript locator. Otherwise ignored.
+ * @return {protractor.WebElement} A WebElement that can be used to issue
+ * commands against the located element. If the element is not found, the
+ * element will be invalidated and all scheduled commands aborted.
+ */
+ findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
+ findElement(locator: any, ...var_args: any[]): protractor.WebElement;
+ }
+
+ module command {
+ class Command extends webdriver.Command {}
+ class CommandName extends webdriver.CommandName {}
+ }
+
+ module error {
+ class Error extends webdriver.error.Error {}
+ class ErrorCode extends webdriver.error.ErrorCode {}
+ }
+
+ module events {
+ class EventEmitter extends webdriver.EventEmitter {}
+ }
+
+ module logging {
+ var Preferences: any;
+
+ class LevelName extends webdriver.logging.LevelName {}
+ class Type extends webdriver.logging.Type {}
+ class Level extends webdriver.logging.Level {}
+ class Entry extends webdriver.logging.Entry {}
+
+ function getLevel(nameOrValue: string): webdriver.logging.Level;
+ function getLevel(nameOrValue: number): webdriver.logging.Level;
+ }
+
+ module promise {
+ class Promise extends webdriver.promise.Promise {}
+ class Deferred extends webdriver.promise.Deferred {}
+ class ControlFlow extends webdriver.promise.ControlFlow {}
+
+ /**
+ * @return {!webdriver.promise.ControlFlow} The currently active control flow.
+ */
+ function controlFlow(): webdriver.promise.ControlFlow;
+
+ /**
+ * Creates a new control flow. The provided callback will be invoked as the
+ * first task within the new flow, with the flow as its sole argument. Returns
+ * a promise that resolves to the callback result.
+ * @param {function(!webdriver.promise.ControlFlow)} callback The entry point
+ * to the newly created flow.
+ * @return {!webdriver.promise.Promise} A promise that resolves to the callback
+ * result.
+ */
+ function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise;
+
+ /**
+ * Determines whether a {@code value} should be treated as a promise.
+ * Any object whose "then" property is a function will be considered a promise.
+ *
+ * @param {*} value The value to test.
+ * @return {boolean} Whether the value is a promise.
+ */
+ function isPromise(value: any): boolean;
+
+ /**
+ * Creates a promise that will be resolved at a set time in the future.
+ * @param {number} ms The amount of time, in milliseconds, to wait before
+ * resolving the promise.
+ * @return {!webdriver.promise.Promise} The promise.
+ */
+ function delayed(ms: number): webdriver.promise.Promise;
+
+ /**
+ * Creates a new deferred object.
+ * @param {Function=} opt_canceller Function to call when cancelling the
+ * computation of this instance's value.
+ * @return {!webdriver.promise.Deferred} The new deferred object.
+ */
+ function defer(opt_canceller?: any): webdriver.promise.Deferred;
+
+ /**
+ * Creates a promise that has been resolved with the given value.
+ * @param {*=} opt_value The resolved value.
+ * @return {!webdriver.promise.Promise} The resolved promise.
+ */
+ function fulfilled(opt_value?: any): webdriver.promise.Promise;
+
+ /**
+ * Creates a promise that has been rejected with the given reason.
+ * @param {*=} opt_reason The rejection reason; may be any value, but is
+ * usually an Error or a string.
+ * @return {!webdriver.promise.Promise} The rejected promise.
+ */
+ function rejected(opt_reason?: any): webdriver.promise.Promise;
+
+ /**
+ * Wraps a function that is assumed to be a node-style callback as its final
+ * argument. This callback takes two arguments: an error value (which will be
+ * null if the call succeeded), and the success value as the second argument.
+ * If the call fails, the returned promise will be rejected, otherwise it will
+ * be resolved with the result.
+ * @param {!Function} fn The function to wrap.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * result of the provided function's callback.
+ */
+ function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise;
+
+ /**
+ * Registers an observer on a promised {@code value}, returning a new promise
+ * that will be resolved when the value is. If {@code value} is not a promise,
+ * then the return promise will be immediately resolved.
+ * @param {*} value The value to observe.
+ * @param {Function=} opt_callback The function to call when the value is
+ * resolved successfully.
+ * @param {Function=} opt_errback The function to call when the value is
+ * rejected.
+ * @return {!webdriver.promise.Promise} A new promise.
+ */
+ function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
+
+ /**
+ * Invokes the appropriate callback function as soon as a promised
+ * {@code value} is resolved. This function is similar to
+ * {@code webdriver.promise.when}, except it does not return a new promise.
+ * @param {*} value The value to observe.
+ * @param {Function} callback The function to call when the value is
+ * resolved successfully.
+ * @param {Function=} opt_errback The function to call when the value is
+ * rejected.
+ */
+ function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void;
+
+ /**
+ * Returns a promise that will be resolved with the input value in a
+ * fully-resolved state. If the value is an array, each element will be fully
+ * resolved. Likewise, if the value is an object, all keys will be fully
+ * resolved. In both cases, all nested arrays and objects will also be
+ * fully resolved. All fields are resolved in place; the returned promise will
+ * resolve on {@code value} and not a copy.
+ *
+ * Warning: This function makes no checks against objects that contain
+ * cyclical references:
+ *
+ * var value = {};
+ * value['self'] = value;
+ * webdriver.promise.fullyResolved(value); // Stack overflow.
+ *
+ * @param {*} value The value to fully resolve.
+ * @return {!webdriver.promise.Promise} A promise for a fully resolved version
+ * of the input value.
+ */
+ function fullyResolved(value: any): webdriver.promise.Promise;
+
+ /**
+ * Changes the default flow to use when no others are active.
+ * @param {!webdriver.promise.ControlFlow} flow The new default flow.
+ * @throws {Error} If the default flow is not currently active.
+ */
+ function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
+
+ }
+
+ module process {
+
+ /**
+ * Queries for a named environment variable.
+ * @param {string} name The name of the environment variable to look up.
+ * @param {string=} opt_default The default value if the named variable is not
+ * defined.
+ * @return {string} The queried environment variable.
+ */
+ function getEnv(name: string, opt_default?: string): string;
+
+ /**
+ * @return {boolean} Whether the current process is Node's native process
+ * object.
+ */
+ function isNative(): boolean;
+
+ /**
+ * Sets an environment value. If the new value is either null or undefined, the
+ * environment variable will be cleared.
+ * @param {string} name The value to set.
+ * @param {*} value The new value; will be coerced to a string.
+ */
+ function setEnv(name: string, value: any): void;
+
+ }
+
+ //endregion
+
+ interface Element {
+ (locator: webdriver.Locator): ElementFinder;
+ all(locator: webdriver.Locator): ElementArrayFinder;
+ }
+
+ interface ElementFinder {
+ /**
+ * Schedules a command to click on this element.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved when
+ * the click command has completed.
+ */
+ click(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to type a sequence on the DOM element represented by this
+ * instance.
+ *
+ * Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
+ * processed in the keysequence, that key state is toggled until one of the
+ * following occurs:
+ *
+ *
The modifier key is encountered again in the sequence. At this point the
+ * state of the key is toggled (along with the appropriate keyup/down events).
+ *
+ *
The {@code webdriver.Key.NULL} key is encountered in the sequence. When
+ * this key is encountered, all modifier keys current in the down state are
+ * released (with accompanying keyup events). The NULL key can be used to
+ * simulate common keyboard shortcuts:
+ *
+ * element.sendKeys("text was",
+ * webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
+ * "now text is");
+ * // Alternatively:
+ * element.sendKeys("text was",
+ * webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
+ * "now text is");
+ *
+ *
The end of the keysequence is encountered. When there are no more keys
+ * to type, all depressed modifier keys are released (with accompanying keyup
+ * events).
+ *
+ *
+ * Note: On browsers where native keyboard events are not yet
+ * supported (e.g. Firefox on OS X), key events will be synthesized. Special
+ * punctionation keys will be synthesized according to a standard QWERTY en-us
+ * keyboard layout.
+ *
+ * @param {...string} var_args The sequence of keys to
+ * type. All arguments will be joined into a single sequence (var_args is
+ * permitted for convenience).
+ * @return {!webdriver.promise.Promise} A promise that will be resolved when all
+ * keys have been typed.
+ */
+ sendKeys(...var_args: string[]): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to query for the tag/node name of this element.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * element's tag name.
+ */
+ getTagName(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to query for the computed style of the element
+ * represented by this instance. If the element inherits the named style from
+ * its parent, the parent will be queried for its value. Where possible, color
+ * values will be converted to their hex representation (e.g. #00ff00 instead of
+ * rgb(0, 255, 0)).
+ *
+ * Warning: the value returned will be as the browser interprets it, so
+ * it may be tricky to form a proper assertion.
+ *
+ * @param {string} cssStyleProperty The name of the CSS style property to look
+ * up.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * requested CSS value.
+ */
+ getCssValue(cssStyleProperty: string): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to query for the value of the given attribute of the
+ * element. Will return the current value even if it has been modified after the
+ * page has been loaded. More exactly, this method will return the value of the
+ * given attribute, unless that attribute is not present, in which case the
+ * value of the property with the same name is returned. If neither value is
+ * set, null is returned. The "style" attribute is converted as best can be to a
+ * text representation with a trailing semi-colon. The following are deemed to
+ * be "boolean" attributes and will be returned as thus:
+ *
+ *
Finally, the following commonly mis-capitalized attribute/property names
+ * are evaluated as expected:
+ *
+ *
"class"
+ *
"readonly"
+ *
+ * @param {string} attributeName The name of the attribute to query.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * attribute's value.
+ */
+ getAttribute(attributeName: string): webdriver.promise.Promise;
+
+ /**
+ * Get the visible (i.e. not hidden by CSS) innerText of this element, including
+ * sub-elements, without any leading or trailing whitespace.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * element's visible text.
+ */
+ getText(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to compute the size of this element's bounding box, in
+ * pixels.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * element's size as a {@code {width:number, height:number}} object.
+ */
+ getSize(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to compute the location of this element in page space.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved to the
+ * element's location as a {@code {x:number, y:number}} object.
+ */
+ getLocation(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to query whether the DOM element represented by this
+ * instance is enabled, as dicted by the {@code disabled} attribute.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with
+ * whether this element is currently enabled.
+ */
+ isEnabled(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to query whether this element is selected.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with
+ * whether this element is currently selected.
+ */
+ isSelected(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to submit the form containing this element (or this
+ * element if it is a FORM element). This command is a no-op if the element is
+ * not contained in a form.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved when
+ * the form has been submitted.
+ */
+ submit(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to clear the {@code value} of this element. This command
+ * has no effect if the underlying DOM element is neither a text INPUT element
+ * nor a TEXTAREA element.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved when
+ * the element has been cleared.
+ */
+ clear(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to test whether this element is currently displayed.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with
+ * whether this element is currently visible on the page.
+ */
+ isDisplayed(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to retrieve the outer HTML of this element.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with
+ * the element's outer HTML.
+ */
+ getOuterHtml(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to retrieve the inner HTML of this element.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with the
+ * element's inner HTML.
+ */
+ getInnerHtml(): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to test if there is at least one descendant of this
+ * element that matches the given search criteria.
+ *
+ *
Note that JS locator searches cannot be restricted to a subtree of the
+ * DOM. All such searches are delegated to this instance's parent WebDriver.
+ *
+ * @param {webdriver.Locator|Object.} locator The locator
+ * strategy to use when searching for the element.
+ * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
+ * using a JavaScript locator. Otherwise ignored.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with
+ * whether an element could be located on the page.
+ */
+ isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
+ isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
+
+ /**
+ * Schedules a command to find all of the descendants of this element that match
+ * the given search criteria.
+ *
+ * Note that JS locator searches cannot be restricted to a subtree. All such
+ * searches are delegated to this instance's parent WebDriver.
+ *
+ * @param {webdriver.Locator|Object.} locator The locator
+ * strategy to use when searching for the elements.
+ * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
+ * using a JavaScript locator. Otherwise ignored.
+ * @return {!webdriver.promise.Promise} A promise that will be resolved with an
+ * array of located {@link webdriver.WebElement}s.
+ */
+ findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
+ findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
+
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElement
+ * @return {!protractor.WebElement}
+ */
+ $(selector: string): protractor.WebElement;
+
+ /**
+ * Shortcut for querying the document directly with css.
+ *
+ * @param {string} selector a css selector
+ * @see webdriver.WebElement.findElements
+ * @return {!webdriver.promise.Promise} A promise that will be resolved to an
+ * array of the located {@link webdriver.WebElement}s.
+ */
+ $$(selector: string): webdriver.promise.Promise;
+
+ /**
+ * Schedule a command to find a descendant of this element. If the element
+ * cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
+ * be returned by the driver. Unlike other commands, this error cannot be
+ * suppressed. In other words, scheduling a command to find an element doubles
+ * as an assert that the element is present on the page. To test whether an
+ * element is present on the page, use {@code #isElementPresent} instead.
+ *
+ * The search criteria for find an element may either be a
+ * {@code webdriver.Locator} object, or a simple JSON object whose sole key
+ * is one of the accepted locator strategies, as defined by
+ * {@code webdriver.Locator.Strategy}. For example, the following two
+ * statements are equivalent:
+ *
+ * var e1 = element.findElement(By.id('foo'));
+ * var e2 = element.findElement({id:'foo'});
+ *
+ *
+ * Note that JS locator searches cannot be restricted to a subtree. All such
+ * searches are delegated to this instance's parent WebDriver.
+ *
+ * @param {webdriver.Locator|Object.} locator The locator
+ * strategy to use when searching for the element.
+ * @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
+ * using a JavaScript locator. Otherwise ignored.
+ * @return {protractor.WebElement} A WebElement that can be used to issue
+ * commands against the located element. If the element is not found, the
+ * element will be invalidated and all scheduled commands aborted.
+ */
+ findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
+ findElement(locator: any, ...var_args: any[]): protractor.WebElement;
+
+ /**
+ * Evalates the input as if it were on the scope of the current element.
+ * @param {string} expression
+ *
+ * @return {!webdriver.promise.Promise} A promise that will resolve to the
+ * evaluated expression. The result will be resolved as in
+ * {@link webdriver.WebDriver.executeScript}. In summary - primitives will
+ * be resolved as is, functions will be converted to string, and elements
+ * will be returned as a WebElement.
+ */
+ evaluate(expression: string): webdriver.promise.Promise;
+
+ /**
+ * Use as: element(locator).element(locator)
+ * Calls to element may be chained to find elements within a parent.
+ *
+ * @param {webdriver.Locator} The locator that will be used to find descendents.
+ *
+ * @return {protractor.ElementFinder} the descendent element found by the locator
+ */
+ element(locator: webdriver.Locator): protractor.ElementFinder;
+
+ /**
+ * Use as: element(locator).all(locator)
+ * Calls to element may be chained to find an array of elements within a parent.
+ *
+ * @param {webdriver.Locator} The locator that will be used to find descendents.
+ *
+ * @return {protractor.ElementArrayFinder} the descendent elements found by the locator
+ */
+ all(locator: webdriver.Locator): protractor.ElementArrayFinder;
+
+ find(): protractor.WebElement;
+
+ isPresent(): webdriver.promise.Promise;
+ }
+
+ interface ElementArrayFinder{
+ count(): webdriver.promise.Promise;
+ get(index: number): protractor.WebElement;
+ first(): protractor.WebElement;
+ last(): protractor.WebElement;
+ then(fn: (value: any) => any): webdriver.promise.Promise;
+ }
+
+ class LocatorWithColumn extends webdriver.Locator {
+ column(index: number): webdriver.Locator;
+ }
+
+ class RepeaterLocator extends LocatorWithColumn {
+ row(index: number): LocatorWithColumn;
+ }
+
+ interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
+ /**
+ * Add a locator to this instance of ProtractorBy. This locator can then be
+ * used with element(by.()).
+ *
+ * @param {string} name
+ * @param {function|string} script A script to be run in the context of
+ * the browser. This script will be passed an array of arguments
+ * that begins with the element scoping the search, and then
+ * contains any args passed into the locator. It should return
+ * an array of elements.
+ */
+ addLocator(name: string, script: any): void;
+
+ /**
+ * Usage:
+ * {{status}}
+ * var status = element(by.binding('{{status}}'));
+ */
+ binding(bindingDescriptor: string): webdriver.Locator;
+
+ /**
+ * Usage:
+ *
+ * element(by.select("user"));
+ */
+ select(model: string): webdriver.Locator;
+
+ /**
+ * Usage:
+ *
+ * element(by.selectedOption("user"));
+ */
+ selectedOption(model: string): webdriver.Locator;
+
+ /**
+ * @DEPRECATED - use 'model' instead.
+ * Usage:
+ *
+ * element(by.input('user'));
+ */
+ input(model: string): webdriver.Locator;
+
+ /**
+ * Usage:
+ *
+ * element(by.model('user'));
+ */
+ model(model: string): webdriver.Locator;
+
+ /**
+ * Usage:
+ *
+ * element(by.textarea("user"));
+ */
+ textarea(model: string): webdriver.Locator;
+
+ /**
+ * Usage:
+ *
+ * {{cat.name}}
+ * {{cat.age}}
+ *
+ *
+ * // Returns the DIV for the second cat.
+ * var secondCat = element(by.repeater("cat in pets").row(2));
+ * // Returns the SPAN for the first cat's name.
+ * var firstCatName = element(
+ * by.repeater("cat in pets").row(1).column("{{cat.name}}"));
+ * // Returns a promise that resolves to an array of WebElements from a column
+ * var ages = element(
+ * by.repeater("cat in pets").column("{{cat.age}}"));
+ * // Returns a promise that resolves to an array of WebElements containing
+ * // all rows of the repeater.
+ * var rows = element(by.repeater("cat in pets"));
+ */
+ repeater(repeatDescriptor: string): RepeaterLocator;
+
+ buttonText(searchText: string): webdriver.Locator;
+
+ partialButtonText(searchText: string): webdriver.Locator;
+ }
+
+ var By: IProtractorLocatorStrategy;
+
+ class Protractor extends webdriver.WebDriver {
+
+ //region Constructors
+
+ /**
+ * @param {webdriver.WebDriver} webdriver
+ * @param {string=} opt_baseUrl A base URL to run get requests against.
+ * @param {string=body} opt_rootElement Selector element that has an ng-app in
+ * scope.
+ * @constructor
+ */
+ constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string);
+
+ //endregion
+
+ //region Properties
+
+ /**
+ * The wrapped webdriver instance. Use this to interact with pages that do
+ * not contain Angular (such as a log-in screen).
+ *
+ * @type {webdriver.WebDriver}
+ */
+ driver: webdriver.WebDriver;
+
+ /**
+ * All get methods will be resolved against this base URL. Relative URLs are =
+ * resolved the way anchor tags resolve.
+ *
+ * @type {string}
+ */
+ baseUrl: string;
+
+ /**
+ * The css selector for an element on which to find Angular. This is usually
+ * 'body' but if your ng-app is on a subsection of the page it may be
+ * a subelement.
+ *
+ * @type {string}
+ */
+ rootEl: string;
+
+ /**
+ * If true, Protractor will not attempt to synchronize with the page before
+ * performing actions. This can be harmful because Protractor will not wait
+ * until $timeouts and $http calls have been processed, which can cause
+ * tests to become flaky. This should be used only when necessary, such as
+ * when a page continuously polls an API using $timeout.
+ *
+ * @type {boolean}
+ */
+ ignoreSynchronization: boolean;
+
+ /**
+ * An object that holds custom test parameters.
+ *
+ * @type {Object}
+ */
+ params: any;
+
+ //endregion
+
+ //region Methods
+
+ /**
+ * Helper function for finding elements.
+ *
+ * @type {function(webdriver.Locator): ElementFinder}
+ */
+ element(locator: webdriver.Locator): ElementFinder;
+
+ /**
+ * Helper function for finding elements by css.
+ *
+ * @type {function(string): ElementFinder}
+ */
+ $(cssLocator: string): ElementFinder;
+
+ /**
+ * Helper function for finding arrays of elements by css.
+ *
+ * @type {function(string): ElementArrayFinder}
+ */
+ $$(cssLocator: string): ElementArrayFinder;
+
+ /**
+ * Instruct webdriver to wait until Angular has finished rendering and has
+ * no outstanding $http calls before continuing.
+ *
+ * @return {!webdriver.promise.Promise} A promise that will resolve to the
+ * scripts return value.
+ */
+ waitForAngular(): webdriver.promise.Promise;
+
+ /**
+ * Wrap a webdriver.WebElement with protractor specific functionality.
+ *
+ * @param {webdriver.WebElement} element
+ * @return {protractor.WebElement} the wrapped web element.
+ */
+ wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
+
+ /**
+ * Add a module to load before Angular whenever Protractor.get is called.
+ * Modules will be registered after existing modules already on the page,
+ * so any module registered here will override preexisting modules with the same
+ * name.
+ *
+ * @param {!string} name The name of the module to load or override.
+ * @param {!string|Function} script The JavaScript to load the module.
+ */
+ addMockModule(name: string, script: string): void;
+ addMockModule(name: string, script: any): void;
+
+ /**
+ * Clear the list of registered mock modules.
+ */
+ clearMockModules(): void;
+
+ /**
+ * Returns the current absolute url from AngularJS.
+ */
+ getLocationAbsUrl(): webdriver.promise.Promise;
+
+ /**
+ * Pauses the test and injects some helper functions into the browser, so that
+ * debugging may be done in the browser console.
+ *
+ * This should be used under node in debug mode, i.e. with
+ * protractor debug
+ *
+ * While in the debugger, commands can be scheduled through webdriver by
+ * entering the repl:
+ * debug> repl
+ * Press Ctrl + C to leave rdebug repl
+ * > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));
+ * > ptor.debugger();
+ * debug> c
+ *
+ * This will run the sendKeys command as the next task, then re-enter the
+ * debugger.
+ */
+ debugger(): void;
+
+ /**
+ * Schedule a command to find an element on the page. If the element cannot be
+ * found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
+ * by the driver. Unlike other commands, this error cannot be suppressed. In
+ * other words, scheduling a command to find an element doubles as an assert
+ * that the element is present on the page. To test whether an element is
+ * present on the page, use {@code #isElementPresent} instead.
+ *
+ *
The search criteria for find an element may either be a
+ * {@code webdriver.Locator} object, or a simple JSON object whose sole key
+ * is one of the accepted locator strategies, as defined by
+ * {@code webdriver.Locator.Strategy}. For example, the following two statements
+ * are equivalent:
+ *
+ * var e1 = driver.findElement(By.id('foo'));
+ * var e2 = driver.findElement({id:'foo'});
+ *
+ *
+ *
When running in the browser, a WebDriver cannot manipulate DOM elements
+ * directly; it may do so only through a {@link webdriver.WebElement} reference.
+ * This function may be used to generate a WebElement from a DOM element. A
+ * reference to the DOM element will be stored in a known location and this
+ * driver will attempt to retrieve it through {@link #executeScript}. If the
+ * element cannot be found (eg, it belongs to a different document than the
+ * one this instance is currently focused on), a
+ * {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
+ *
+ * @param {!(webdriver.Locator|Object.|Element)} locatorOrElement The
+ * locator strategy to use when searching for the element, or the actual
+ * DOM element to be located by the server.
+ * @param {...} var_args Arguments to pass to {@code #executeScript} if using a
+ * JavaScript locator. Otherwise ignored.
+ * @return {!protractor.WebElement} A WebElement that can be used to issue
+ * commands against the located element. If the element is not found, the
+ * element will be invalidated and all scheduled commands aborted.
+ */
+ findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
+ findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
+
+ //endregion
+ }
+
+ /**
+ * Create a new instance of Protractor by wrapping a webdriver instance.
+ *
+ * @param {webdriver.WebDriver} webdriver The configured webdriver instance.
+ * @param {string=} opt_baseUrl A URL to prepend to relative gets.
+ * @return {Protractor}
+ */
+ function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;
+
+ /**
+ * Set a singleton instance of protractor.
+ * @param {Protractor} ptor
+ */
+ function setInstance(ptor: Protractor): void;
+
+ /**
+ * Get the singleton instance.
+ * @return {Protractor}
+ */
+ function getInstance(): Protractor;
+
+}
+
+interface cssSelectorHelper {
+ (cssLocator: string): protractor.ElementFinder;
+}
+
+declare var browser: protractor.Protractor;
+declare var by: protractor.IProtractorLocatorStrategy;
+declare var element: protractor.Element;
+declare var $: cssSelectorHelper;
+declare var $$: cssSelectorHelper;
+
+declare module 'protractor' {
+ export = protractor;
+}
diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts
index 313ef8635..4b8da8449 100644
--- a/angular-translate/angular-translate.d.ts
+++ b/angular-translate/angular-translate.d.ts
@@ -33,13 +33,14 @@ declare module ng.translate {
}
interface ITranslateService {
- (key: string, ...params: string[]): ng.IPromise;
+ (translationId: string, interpolateParams?: any, interpolationId?: string): ng.IPromise;
+ (translationId: string[], interpolateParams?: any, interpolationId?: string): ng.IPromise<{ [key: string]: string }>;
cloakClassName(): string;
cloakClassName(name: string): ITranslateProvider;
fallbackLanguage(langKey?: string): string;
fallbackLanguage(langKey?: string[]): string;
instant(translationId: string, interpolateParams?: any, interpolationId?: string): string;
- instant(translationId: string[], interpolateParams?: any, interpolationId?: string): string;
+ instant(translationId: string[], interpolateParams?: any, interpolationId?: string): { [key: string]: string };
isPostCompilingEnabled(): boolean;
preferredLanguage(): string;
proposedLanguage(): string;
diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts
index 081d35723..005bf8b90 100644
--- a/angular-ui/angular-ui-router.d.ts
+++ b/angular-ui/angular-ui-router.d.ts
@@ -11,8 +11,9 @@ declare module ng.ui {
name?: string;
template?: any;
templateUrl?: any;
- templateProvider?: () => string;
+ templateProvider?: any;
controller?: any;
+ controllerAs?: string;
controllerProvider?: any;
resolve?: {};
url?: string;
diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts
index 6db753e1f..2591c006e 100644
--- a/angularjs/angular-mocks.d.ts
+++ b/angularjs/angular-mocks.d.ts
@@ -33,9 +33,7 @@ declare module ng {
inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
// see http://docs.angularjs.org/api/angular.mock.module
- module(...modules: string[]): any;
- module(...modules: Function[]): any;
- module(modules: Object): any;
+ module(...modules: any[]): any;
// see http://docs.angularjs.org/api/angular.mock.TzDate
TzDate(offset: number, timestamp: number): Date;
diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts
index 37dae22f4..0627f80be 100644
--- a/angularjs/angular-tests.ts
+++ b/angularjs/angular-tests.ts
@@ -7,27 +7,27 @@
* (c) 2012 Witold Szczerba
* License: MIT
*/
-angular.module('http-auth-interceptor', [])
- .provider('authService', function () {
- /**
- * Holds all the requests which failed due to 401 response,
- * so they can be re-requested in future, once login is completed.
- */
- var buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = [];
+class AuthService {
+ /**
+ * Holds all the requests which failed due to 401 response,
+ * so they can be re-requested in future, once login is completed.
+ */
+ buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = [];
- /**
- * Required by HTTP interceptor.
- * Function is attached to provider to be invisible for regular users of this service.
- */
- this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) {
- buffer.push({
- config: config,
- deferred: deferred
- });
- }
+ /**
+ * Required by HTTP interceptor.
+ * Function is attached to provider to be invisible for regular users of this service.
+ */
+ pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred) {
+ this.buffer.push({
+ config: config,
+ deferred: deferred
+ });
+ }
- this.$get = ['$rootScope', '$injector', function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
+ $get = [
+ '$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
var $http: ng.IHttpService; //initialized later because of circular dependency problem
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) {
$http = $http || $injector.get('$http');
@@ -36,20 +36,25 @@ angular.module('http-auth-interceptor', [])
});
}
function retryAll() {
- for (var i = 0; i < buffer.length; ++i) {
- retry(buffer[i].config, buffer[i].deferred);
+ for (var i = 0; i < this.buffer.length; ++i) {
+ retry(this.buffer[i].config, this.buffer[i].deferred);
}
- buffer = [];
+ this.buffer = [];
}
- return {
+ return {
loginConfirmed: function () {
$rootScope.$broadcast('event:auth-loginConfirmed');
retryAll();
}
}
- }]
- })
+ }
+ ];
+}
+
+angular.module('http-auth-interceptor', [])
+
+ .provider('authService', AuthService)
/**
* $http interceptor.
@@ -95,6 +100,7 @@ module HttpAndRegularPromiseTests {
theAnswer: number;
letters: string[];
snack: string;
+ nothing?: string;
}
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
@@ -139,6 +145,12 @@ module HttpAndRegularPromiseTests {
dPromise.then((snack: string) => {
$scope.snack = snack;
});
+
+ // $q.when may be called without arguments
+ var ePromise: ng.IPromise = $q.when();
+ ePromise.then(() => {
+ $scope.nothing = "really nothing";
+ });
}
// Test that we can pass around a type-checked success/error Promise Callback
@@ -176,7 +188,8 @@ mod.factory(My.Namespace);
mod.filter('name', function ($scope: ng.IScope) { })
mod.filter('name', ['$scope', function ($scope: ng.IScope) { }])
mod.filter(My.Namespace);
-mod.provider('name', function ($scope: ng.IScope) { })
+mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } })
+mod.provider('name', TestProvider);
mod.provider('name', ['$scope', function ($scope: ng.IScope) { }])
mod.provider(My.Namespace);
mod.service('name', function ($scope: ng.IScope) { })
@@ -189,6 +202,13 @@ mod.value('name', 23);
mod.value('name', "23");
mod.value(My.Namespace);
+class TestProvider implements ng.IServiceProvider {
+ constructor(private $scope: ng.IScope) {
+ }
+
+ $get() {
+ }
+}
// Promise signature tests
var foo: ng.IPromise;
@@ -211,11 +231,11 @@ foo.then((x) => {
}).then((x) => {
// Object is inferred here
x.a = 123;
- //Try a promise
+ //Try a promise
var y: ng.IPromise;
- return y;
+ return y;
}).then((x) => {
- // x is infered to be a number, which is the resolved value of a promise
+ // x is infered to be a number, which is the resolved value of a promise
x.toFixed();
});
@@ -231,6 +251,15 @@ httpFoo.then((x) => {
});
+function test_angular_forEach() {
+ var values: { [key: string]: string } = { name: 'misko', gender: 'male' };
+ var log: string[] = [];
+ angular.forEach(values, function (value, key) {
+ this.push(key + ': ' + value);
+ }, log);
+ //expect(log).toEqual(['name: misko', 'gender: male']);
+}
+
// angular.element() tests
var element = angular.element("div.myApp");
var scope: ng.IScope = element.scope();
@@ -251,3 +280,323 @@ test_IAttributes({
},
$attr: {}
});
+
+class SampleDirective implements ng.IDirective {
+ public restrict = 'A';
+ name = 'doh';
+
+ compile(templateElement: ng.IAugmentedJQuery) {
+ return {
+ post: this.link
+ };
+ }
+
+ static instance():ng.IDirective {
+ return new SampleDirective();
+ }
+
+ link(scope: ng.IScope) {
+
+ }
+}
+
+class SampleDirective2 implements ng.IDirective {
+ public restrict = 'EAC';
+
+ compile(templateElement: ng.IAugmentedJQuery) {
+ return {
+ pre: this.link
+ };
+ }
+
+ static instance():ng.IDirective {
+ return new SampleDirective2();
+ }
+
+ link(scope: ng.IScope) {
+
+ }
+}
+
+angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
+
+// test from https://docs.angularjs.org/guide/directive
+angular.module('docsSimpleDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ template: 'Name: {{customer.name}} Address: {{customer.address}}'
+ };
+ });
+
+angular.module('docsTemplateUrlDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsRestrictDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsScopeProblemExample', [])
+ .controller('NaomiController', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .controller('IgorController', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Igor',
+ address: '123 Somewhere'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsIsolateScopeDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
+ $scope.igor = { name: 'Igor', address: '123 Somewhere' };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ customerInfo: '=info'
+ },
+ templateUrl: 'my-customer-iso.html'
+ };
+ });
+
+angular.module('docsIsolationExample', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
+ $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ customerInfo: '=info'
+ },
+ templateUrl: 'my-customer-plus-vojta.html'
+ };
+ });
+
+angular.module('docsTimeDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.format = 'M/d/yy h:mm:ss a';
+ }])
+ .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) {
+
+ return {
+ link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) {
+ var format: any,
+ timeoutId: any;
+
+ function updateTime() {
+ element.text(dateFilter(new Date(), format));
+ }
+
+ scope.$watch(attrs['myCurrentTime'], function (value: any) {
+ format = value;
+ updateTime();
+ });
+
+ element.on('$destroy', function () {
+ $interval.cancel(timeoutId);
+ });
+
+ // start the UI update process; save the timeoutId for canceling
+ timeoutId = $interval(function () {
+ updateTime(); // update DOM
+ }, 1000);
+ }
+ };
+ }]);
+
+angular.module('docsTransclusionDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.name = 'Tobias';
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ templateUrl: 'my-dialog.html'
+ };
+ });
+
+angular.module('docsTransclusionExample', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.name = 'Tobias';
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {},
+ templateUrl: 'my-dialog.html',
+ link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) {
+ scope['name'] = 'Jeff';
+ }
+ };
+ });
+
+angular.module('docsIsoFnBindExample', [])
+ .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) {
+ $scope.name = 'Tobias';
+ $scope.hideDialog = function () {
+ $scope.dialogIsHidden = true;
+ $timeout(function () {
+ $scope.dialogIsHidden = false;
+ }, 2000);
+ };
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {
+ 'close': '&onClose'
+ },
+ templateUrl: 'my-dialog-close.html'
+ };
+ });
+
+angular.module('dragModule', [])
+ .directive('myDraggable', ['$document', function($document: any) {
+ return function(scope: any, element: any, attr: any) {
+ var startX = 0, startY = 0, x = 0, y = 0;
+
+ element.css({
+ position: 'relative',
+ border: '1px solid red',
+ backgroundColor: 'lightgrey',
+ cursor: 'pointer'
+ });
+
+ element.on('mousedown', function(event: any) {
+ // Prevent default dragging of selected content
+ event.preventDefault();
+ startX = event.pageX - x;
+ startY = event.pageY - y;
+ $document.on('mousemove', mousemove);
+ $document.on('mouseup', mouseup);
+ });
+
+ function mousemove(event: any) {
+ y = event.pageY - startY;
+ x = event.pageX - startX;
+ element.css({
+ top: y + 'px',
+ left: x + 'px'
+ });
+ }
+
+ function mouseup() {
+ $document.off('mousemove', mousemove);
+ $document.off('mouseup', mouseup);
+ }
+ };
+ }]);
+
+angular.module('docsTabsExample', [])
+ .directive('myTabs', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {},
+ controller: function($scope: ng.IScope) {
+ var panes: any = $scope['panes'] = [];
+
+ $scope['select'] = function(pane: any) {
+ angular.forEach(panes, function(pane: any) {
+ pane.selected = false;
+ });
+ pane.selected = true;
+ };
+
+ this.addPane = function(pane: any) {
+ if (panes.length === 0) {
+ $scope['select'](pane);
+ }
+ panes.push(pane);
+ };
+ },
+ templateUrl: 'my-tabs.html'
+ };
+ })
+ .directive('myPane', function() {
+ return {
+ require: '^myTabs',
+ restrict: 'E',
+ transclude: true,
+ scope: {
+ title: '@'
+ },
+ link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
+ tabsCtrl.addPane(scope);
+ },
+ templateUrl: 'my-pane.html'
+ };
+ });
+
+interface copyExampleUser {
+ name?: string;
+ email?: string;
+ gender?: string;
+}
+
+interface copyExampleScope {
+
+ user: copyExampleUser;
+ master: copyExampleUser;
+ update: (copyExampleUser: copyExampleUser) => any;
+ reset: () => any;
+}
+
+angular.module('copyExample', [])
+ .controller('ExampleController', ['$scope', function ($scope: copyExampleScope) {
+ $scope.master = { };
+
+ $scope.update = function (user) {
+ // Example with 1 argument
+ $scope.master = angular.copy(user);
+ };
+
+ $scope.reset = function () {
+ // Example with 2 arguments
+ angular.copy($scope.master, $scope.user);
+ };
+
+ $scope.reset();
+ }]);
\ No newline at end of file
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index d6b649a33..0fc44d976 100755
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Angular JS 1.2+
+// Type definitions for Angular JS 1.3+
// Project: http://angularjs.org
// Definitions by: Diego Vilar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -18,6 +18,15 @@ interface Function {
///////////////////////////////////////////////////////////////////////////////
declare module ng {
+ // not directly implemented, but ensures that constructed class implements $get
+ interface IServiceProviderClass {
+ new(...args: any[]): IServiceProvider;
+ }
+
+ interface IServiceProviderFactory {
+ (...args: any[]): IServiceProvider;
+ }
+
// All service providers extend this interface
interface IServiceProvider {
$get: any;
@@ -33,11 +42,55 @@ declare module ng {
bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService;
bootstrap(element: Element, modules?: any[]): auto.IInjectorService;
bootstrap(element: Document, modules?: any[]): auto.IInjectorService;
- copy(source: any, destination?: any): any;
+
+ /**
+ * Creates a deep copy of source, which should be an object or an array.
+ *
+ * - If no destination is supplied, a copy of the object or array is created.
+ * - If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it.
+ * - If source is not an object or array (inc. null and undefined), source is returned.
+ * - If source is identical to 'destination' an exception will be thrown.
+ *
+ * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined.
+ * @param destination Destination into which the source is copied. If provided, must be of the same type as source.
+ */
+ copy(source: T, destination?: T): T;
+
element: IAugmentedJQueryStatic;
equals(value1: any, value2: any): boolean;
extend(destination: any, ...sources: any[]): any;
+
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
+ forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
+ forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
+
fromJson(json: string): any;
identity(arg?: any): any;
injector(modules?: any[]): auto.IInjectorService;
@@ -56,7 +109,7 @@ declare module ng {
* The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
*
* When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved.
- *
+ *
* @param name The name of the module to create or retrieve.
* @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
* @param configFn Optional configuration function for the module.
@@ -88,19 +141,19 @@ declare module ng {
animation(object: Object): IModule;
/**
* Use this method to register work which needs to be performed on module loading.
- *
+ *
* @param configFn Execute this function on module load. Useful for service configuration.
*/
config(configFn: Function): IModule;
/**
* Use this method to register work which needs to be performed on module loading.
- *
+ *
* @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
*/
config(inlineAnnotatedFunction: any[]): IModule;
/**
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
- *
+ *
* @param name The name of the constant.
* @param value The constant value.
*/
@@ -108,36 +161,36 @@ declare module ng {
constant(object: Object): IModule;
/**
* The $controller service is used by Angular to create new controllers.
- *
+ *
* This provider allows controller registration via the register method.
- *
+ *
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
*/
controller(name: string, controllerConstructor: Function): IModule;
/**
* The $controller service is used by Angular to create new controllers.
- *
+ *
* This provider allows controller registration via the register method.
- *
+ *
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
*/
controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
controller(object : Object): IModule;
- directive(name: string, directiveFactory: Function): IModule;
+ directive(name: string, directiveFactory: IDirectiveFactory): IModule;
directive(name: string, inlineAnnotatedFunction: any[]): IModule;
directive(object: Object): IModule;
/**
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
- *
+ *
* @param name The name of the instance.
* @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
*/
factory(name: string, $getFn: Function): IModule;
/**
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
- *
+ *
* @param name The name of the instance.
* @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
*/
@@ -146,9 +199,10 @@ declare module ng {
filter(name: string, filterFactoryFunction: Function): IModule;
filter(name: string, inlineAnnotatedFunction: any[]): IModule;
filter(object: Object): IModule;
- provider(name: string, serviceProviderConstructor: Function): IModule;
+ provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
+ provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
- provider(name: string, providerObject: auto.IProvider): IModule;
+ provider(name: string, providerObject: IServiceProvider): IModule;
provider(object: Object): IModule;
/**
* Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
@@ -211,21 +265,31 @@ declare module ng {
$attr: Object;
}
- ///////////////////////////////////////////////////////////////////////////
- // FormController
- // see http://docs.angularjs.org/api/ng.directive:form.FormController
- ///////////////////////////////////////////////////////////////////////////
+ /**
+ * form.FormController - type in module ng
+ * see https://docs.angularjs.org/api/ng/type/form.FormController
+ */
interface IFormController {
+
+ /**
+ * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272
+ */
+ [name: string]: any;
+
$pristine: boolean;
$dirty: boolean;
$valid: boolean;
$invalid: boolean;
+ $submitted: boolean;
$error: any;
$addControl(control: ng.INgModelController): void;
$removeControl(control: ng.INgModelController): void;
$setValidity(validationErrorKey: string, isValid: boolean, control: ng.INgModelController): void;
$setDirty(): void;
$setPristine(): void;
+ $commitViewValue(): void;
+ $rollbackViewValue(): void;
+ $setSubmitted(): void;
}
///////////////////////////////////////////////////////////////////////////
@@ -238,19 +302,38 @@ declare module ng {
// Documentation states viewValue and modelValue to be a string but other
// types do work and it's common to use them.
$setViewValue(value: any): void;
+ $validate(): void;
+ $setTouched(): void;
+ $setUntouched(): void;
+ $rollbackViewValue(): void;
+ $commitViewValue(revalidate?: boolean): void;
+ $isEmpty(value: any): boolean;
+
$viewValue: any;
$modelValue: any;
$parsers: IModelParser[];
$formatters: IModelFormatter[];
+ $viewChangeListeners: IModelViewChangeListener[];
$error: any;
+ $name: string;
+
+ $touched: boolean;
+ $untouched: boolean;
+
+ $validators: IModelValidators;
+
$pristine: boolean;
$dirty: boolean;
$valid: boolean;
$invalid: boolean;
}
+ interface IModelValidators {
+ [index: string]: (...args: any[]) => boolean;
+ }
+
interface IModelParser {
(value: any): any;
}
@@ -259,11 +342,15 @@ declare module ng {
(value: any): any;
}
+ interface IModelViewChangeListener {
+ (): void;
+ }
+
///////////////////////////////////////////////////////////////////////////
- // Scope
- // see http://docs.angularjs.org/api/ng.$rootScope.Scope
+ // Scope and RootScope
+ // see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and http://docs.angularjs.org/api/ng.$rootScope
///////////////////////////////////////////////////////////////////////////
- interface IScope {
+ interface IRootScopeService {
$apply(): any;
$apply(exp: string): any;
$apply(exp: (scope: IScope) => any): any;
@@ -300,14 +387,19 @@ declare module ng {
$parent: IScope;
$root: IRootScopeService;
+ this: IRootScopeService;
- $id: string;
+ $id: number;
// Hidden members
$$isolateBindings: any;
$$phase: any;
}
+ interface IScope extends IRootScopeService {
+ [index: string]: any;
+ }
+
interface IAngularEvent {
targetScope: IScope;
currentScope: IScope;
@@ -527,17 +619,17 @@ declare module ng {
interface IQService {
/**
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
- *
+ *
* Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
- *
+ *
* @param promises An array or hash of promises.
*/
all(promises: IPromise[]): IPromise;
/**
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
- *
+ *
* Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
- *
+ *
* @param promises An array or hash of promises.
*/
all(promises: { [id: string]: IPromise; }): IPromise<{ [id: string]: any }>;
@@ -547,24 +639,30 @@ declare module ng {
defer(): IDeferred;
/**
* Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it.
- *
+ *
* When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject.
- *
+ *
* @param reason Constant, message, exception or an object representing the rejection reason.
*/
reject(reason?: any): IPromise;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
- *
+ *
* @param value Value or a promise
*/
when(value: IPromise): IPromise;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
- *
+ *
* @param value Value or a promise
*/
when(value: T): IPromise;
+ /**
+ * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
+ *
+ * @param value Value or a promise
+ */
+ when(): IPromise;
}
interface IPromise {
@@ -649,7 +747,7 @@ declare module ng {
aHrefSanitizationWhitelist(): RegExp;
aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
-
+
imgSrcSanitizationWhitelist(): RegExp;
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
}
@@ -689,7 +787,7 @@ declare module ng {
}
/**
- * HttpService
+ * HttpService
* see http://docs.angularjs.org/api/ng/service/$http
*/
interface IHttpService {
@@ -700,7 +798,7 @@ declare module ng {
/**
* Shortcut method to perform GET request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param config Optional configuration object
*/
@@ -708,7 +806,7 @@ declare module ng {
/**
* Shortcut method to perform DELETE request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param config Optional configuration object
*/
@@ -716,7 +814,7 @@ declare module ng {
/**
* Shortcut method to perform HEAD request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param config Optional configuration object
*/
@@ -724,7 +822,7 @@ declare module ng {
/**
* Shortcut method to perform JSONP request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param config Optional configuration object
*/
@@ -732,7 +830,7 @@ declare module ng {
/**
* Shortcut method to perform POST request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param data Request content
* @param config Optional configuration object
@@ -741,7 +839,7 @@ declare module ng {
/**
* Shortcut method to perform PUT request.
- *
+ *
* @param url Relative or absolute URL specifying the destination of the request
* @param data Request content
* @param config Optional configuration object
@@ -761,12 +859,12 @@ declare module ng {
/**
* Object describing the request to be made and how it should be processed.
- * see http://docs.angularjs.org/api/ng/service/$http#usage
+ * see http://docs.angularjs.org/api/ng/service/$http#usage
*/
interface IRequestShortcutConfig {
/**
* {Object.}
- * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
+ * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
*/
params?: any;
@@ -797,7 +895,7 @@ declare module ng {
withCredentials?: boolean;
/**
- * {string|Object}
+ * {string|Object}
* Data to be sent as the request message data.
*/
data?: any;
@@ -828,7 +926,7 @@ declare module ng {
/**
* Object describing the request to be made and how it should be processed.
- * see http://docs.angularjs.org/api/ng/service/$http#usage
+ * see http://docs.angularjs.org/api/ng/service/$http#usage
*/
interface IRequestConfig extends IRequestShortcutConfig {
/**
@@ -904,12 +1002,6 @@ declare module ng {
///////////////////////////////////////////////////////////////////////////
interface ITemplateCacheService extends ICacheObject {}
- ///////////////////////////////////////////////////////////////////////////
- // RootScopeService
- // see http://docs.angularjs.org/api/ng.$rootScope
- ///////////////////////////////////////////////////////////////////////////
- interface IRootScopeService extends IScope {}
-
///////////////////////////////////////////////////////////////////////////
// SCEService
// see http://docs.angularjs.org/api/ng.$sce
@@ -969,21 +1061,38 @@ declare module ng {
// and http://docs.angularjs.org/guide/directive
///////////////////////////////////////////////////////////////////////////
- interface IDirective{
- compile?:
- (templateElement: IAugmentedJQuery,
- templateAttributes: IAttributes,
- transclude: ITranscludeFunction
- ) => any;
- controller?: any;
- controllerAs?: string;
- link?:
- (scope: IScope,
+ interface IDirectiveFactory {
+ (...args: any[]): IDirective;
+ }
+
+ interface IDirectiveLinkFn {
+ (
+ scope: IScope,
instanceElement: IAugmentedJQuery,
instanceAttributes: IAttributes,
controller: any,
transclude: ITranscludeFunction
- ) => void;
+ ): void;
+ }
+
+ interface IDirectivePrePost {
+ pre?: IDirectiveLinkFn;
+ post?: IDirectiveLinkFn;
+ }
+
+ interface IDirectiveCompileFn {
+ (
+ templateElement: IAugmentedJQuery,
+ templateAttributes: IAttributes,
+ transclude: ITranscludeFunction
+ ): IDirectivePrePost;
+ }
+
+ interface IDirective {
+ compile?: IDirectiveCompileFn;
+ controller?: any;
+ controllerAs?: string;
+ link?: IDirectiveLinkFn;
name?: string;
priority?: number;
replace?: boolean;
@@ -1047,9 +1156,6 @@ declare module ng {
// AUTO module (angular.js)
///////////////////////////////////////////////////////////////////////////
export module auto {
- interface IProvider {
- $get: any;
- }
///////////////////////////////////////////////////////////////////////
// InjectorService
@@ -1059,7 +1165,7 @@ declare module ng {
annotate(fn: Function): string[];
annotate(inlineAnnotatedFunction: any[]): string[];
get(name: string): any;
- has(name: string): boolean;
+ has(name: string): boolean;
instantiate(typeConstructor: Function, locals?: any): any;
invoke(inlineAnnotatedFunction: any[]): any;
invoke(func: Function, context?: any, locals?: any): any;
@@ -1075,7 +1181,7 @@ declare module ng {
// constant(name: string, value: any): any;
/**
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
- *
+ *
* @param name The name of the constant.
* @param value The constant value.
*/
@@ -1083,19 +1189,19 @@ declare module ng {
/**
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
- *
+ *
* @param name The name of the service to decorate.
* @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
- *
+ *
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
*/
decorator(name: string, decorator: Function): void;
/**
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
- *
+ *
* @param name The name of the service to decorate.
* @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
- *
+ *
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
*/
decorator(name: string, inlineAnnotatedFunction: any[]): void;
diff --git a/angularjs/legacy/angular-1.2-tests.ts b/angularjs/legacy/angular-1.2-tests.ts
new file mode 100644
index 000000000..d0f60609a
--- /dev/null
+++ b/angularjs/legacy/angular-1.2-tests.ts
@@ -0,0 +1,571 @@
+///
+
+// issue: https://github.com/borisyankov/DefinitelyTyped/issues/369
+// https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js
+/**
+ * @license HTTP Auth Interceptor Module for AngularJS
+ * (c) 2012 Witold Szczerba
+ * License: MIT
+ */
+
+class AuthService {
+ /**
+ * Holds all the requests which failed due to 401 response,
+ * so they can be re-requested in future, once login is completed.
+ */
+ buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = [];
+
+ /**
+ * Required by HTTP interceptor.
+ * Function is attached to provider to be invisible for regular users of this service.
+ */
+ pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred) {
+ this.buffer.push({
+ config: config,
+ deferred: deferred
+ });
+ }
+
+ $get = [
+ '$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
+ var $http: ng.IHttpService; //initialized later because of circular dependency problem
+ function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) {
+ $http = $http || $injector.get('$http');
+ $http(config).then(function (response) {
+ deferred.resolve(response);
+ });
+ }
+ function retryAll() {
+ for (var i = 0; i < this.buffer.length; ++i) {
+ retry(this.buffer[i].config, this.buffer[i].deferred);
+ }
+ this.buffer = [];
+ }
+
+ return {
+ loginConfirmed: function () {
+ $rootScope.$broadcast('event:auth-loginConfirmed');
+ retryAll();
+ }
+ }
+ }
+ ];
+}
+
+angular.module('http-auth-interceptor', [])
+
+ .provider('authService', AuthService)
+
+/**
+ * $http interceptor.
+ * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
+ */
+ .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) {
+
+ var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) {
+ function success(response: ng.IHttpPromiseCallbackArg) {
+ return response;
+ }
+
+ function error(response: ng.IHttpPromiseCallbackArg) {
+ if (response.status === 401) {
+ var deferred = $q.defer();
+ authServiceProvider.pushToBuffer(response.config, deferred);
+ $rootScope.$broadcast('event:auth-loginRequired');
+ return deferred.promise;
+ }
+ // otherwise
+ return $q.reject(response);
+ }
+
+ return function (promise: ng.IHttpPromise) {
+ return promise.then(success, error);
+ }
+
+ }];
+ $httpProvider.responseInterceptors.push(interceptor);
+ }]);
+
+
+module HttpAndRegularPromiseTests {
+ interface Person {
+ firstName: string;
+ lastName: string;
+ }
+
+ interface ExpectedResponse extends Person { }
+
+ interface SomeControllerScope extends ng.IScope {
+ person: Person;
+ theAnswer: number;
+ letters: string[];
+ snack: string;
+ nothing?: string;
+ }
+
+ var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
+ $http.get("http://somewhere/some/resource")
+ .success((data: ExpectedResponse) => {
+ $scope.person = data;
+ });
+
+ $http.get("http://somewhere/some/resource")
+ .then((response: ng.IHttpPromiseCallbackArg) => {
+ // typing lost, so something like
+ // var i: number = response.data
+ // would type check
+ $scope.person = response.data;
+ });
+
+ $http.get("http://somewhere/some/resource")
+ .then((response: ng.IHttpPromiseCallbackArg) => {
+ // typing lost, so something like
+ // var i: number = response.data
+ // would NOT type check
+ $scope.person = response.data;
+ });
+
+ var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" });
+ aPromise.then((person: Person) => {
+ $scope.person = person;
+ });
+
+ var bPromise: ng.IPromise = $q.when(42);
+ bPromise.then((answer: number) => {
+ $scope.theAnswer = answer;
+ });
+
+ var cPromise: ng.IPromise = $q.when(["a", "b", "c"]);
+ cPromise.then((letters: string[]) => {
+ $scope.letters = letters;
+ });
+
+ // When $q.when is passed an IPromise, it returns an IPromise
+ var dPromise: ng.IPromise = $q.when($q.when("ALBATROSS!"));
+ dPromise.then((snack: string) => {
+ $scope.snack = snack;
+ });
+
+ // $q.when may be called without arguments
+ var ePromise: ng.IPromise = $q.when();
+ ePromise.then(() => {
+ $scope.nothing = "really nothing";
+ });
+ }
+
+ // Test that we can pass around a type-checked success/error Promise Callback
+ var anotherController: Function = ($scope: SomeControllerScope, $http:
+ ng.IHttpService, $q: ng.IQService) => {
+
+ var buildFooData: Function = () => 42;
+
+ var doFoo: Function = (callback: ng.IHttpPromiseCallback) => {
+ $http.get('/foo', buildFooData())
+ .success(callback);
+ }
+
+ doFoo((data: any) => console.log(data));
+ }
+}
+
+// Test for AngularJS Syntax
+
+module My.Namespace {
+ export var x: any; // need to export something for module to kick in
+}
+
+// IModule Registering Test
+var mod = angular.module('tests', []);
+mod.controller('name', function ($scope: ng.IScope) { })
+mod.controller('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.controller(My.Namespace);
+mod.directive('name', function ($scope: ng.IScope) { })
+mod.directive('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.directive(My.Namespace);
+mod.factory('name', function ($scope: ng.IScope) { })
+mod.factory('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.factory(My.Namespace);
+mod.filter('name', function ($scope: ng.IScope) { })
+mod.filter('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.filter(My.Namespace);
+mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } })
+mod.provider('name', TestProvider);
+mod.provider('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.provider(My.Namespace);
+mod.service('name', function ($scope: ng.IScope) { })
+mod.service('name', ['$scope', function ($scope: ng.IScope) { }])
+mod.service(My.Namespace);
+mod.constant('name', 23);
+mod.constant('name', "23");
+mod.constant(My.Namespace);
+mod.value('name', 23);
+mod.value('name', "23");
+mod.value(My.Namespace);
+
+class TestProvider implements ng.IServiceProvider {
+ constructor(private $scope: ng.IScope) {
+ }
+
+ $get() {
+ }
+}
+
+// Promise signature tests
+var foo: ng.IPromise;
+foo.then((x) => {
+ // x is inferred to be a number
+ return "asdf";
+}).then((x) => {
+ // x is inferred to be string
+ x.length;
+ return 123;
+}).then((x) => {
+ // x is infered to be a number
+ x.toFixed();
+ return;
+}).then((x) => {
+ // x is infered to be void
+ // Typescript will prevent you to actually use x as a local variable
+ // Try object:
+ return { a: 123 };
+}).then((x) => {
+ // Object is inferred here
+ x.a = 123;
+ //Try a promise
+ var y: ng.IPromise;
+ return y;
+}).then((x) => {
+ // x is infered to be a number, which is the resolved value of a promise
+ x.toFixed();
+});
+
+
+var httpFoo: ng.IHttpPromise;
+httpFoo.then((x) => {
+ // When returning a promise the generic type must be inferred.
+ var innerPromise : ng.IPromise;
+ return innerPromise;
+}).then((x) => {
+ // must still be number.
+ x.toFixed();
+});
+
+
+function test_angular_forEach() {
+ var values: { [key: string]: string } = { name: 'misko', gender: 'male' };
+ var log: string[] = [];
+ angular.forEach(values, function (value, key) {
+ this.push(key + ': ' + value);
+ }, log);
+ //expect(log).toEqual(['name: misko', 'gender: male']);
+}
+
+// angular.element() tests
+var element = angular.element("div.myApp");
+var scope: ng.IScope = element.scope();
+var isolateScope: ng.IScope = element.isolateScope();
+
+
+
+function test_IAttributes(attributes: ng.IAttributes){
+ return attributes;
+}
+
+test_IAttributes({
+ $addClass: function (classVal){},
+ $removeClass: function(classVal){},
+ $set: function(key, value){},
+ $observe: function(name, fn){
+ return fn;
+ },
+ $attr: {}
+});
+
+class SampleDirective implements ng.IDirective {
+ public restrict = 'A';
+ name = 'doh';
+
+ compile(templateElement: ng.IAugmentedJQuery) {
+ return {
+ post: this.link
+ };
+ }
+
+ static instance():ng.IDirective {
+ return new SampleDirective();
+ }
+
+ link(scope: ng.IScope) {
+
+ }
+}
+
+class SampleDirective2 implements ng.IDirective {
+ public restrict = 'EAC';
+
+ compile(templateElement: ng.IAugmentedJQuery) {
+ return {
+ pre: this.link
+ };
+ }
+
+ static instance():ng.IDirective {
+ return new SampleDirective2();
+ }
+
+ link(scope: ng.IScope) {
+
+ }
+}
+
+angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
+
+// test from https://docs.angularjs.org/guide/directive
+angular.module('docsSimpleDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ template: 'Name: {{customer.name}} Address: {{customer.address}}'
+ };
+ });
+
+angular.module('docsTemplateUrlDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsRestrictDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsScopeProblemExample', [])
+ .controller('NaomiController', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Naomi',
+ address: '1600 Amphitheatre'
+ };
+ }])
+ .controller('IgorController', ['$scope', function($scope: any) {
+ $scope.customer = {
+ name: 'Igor',
+ address: '123 Somewhere'
+ };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ templateUrl: 'my-customer.html'
+ };
+ });
+
+angular.module('docsIsolateScopeDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
+ $scope.igor = { name: 'Igor', address: '123 Somewhere' };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ customerInfo: '=info'
+ },
+ templateUrl: 'my-customer-iso.html'
+ };
+ });
+
+angular.module('docsIsolationExample', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
+ $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' };
+ }])
+ .directive('myCustomer', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ customerInfo: '=info'
+ },
+ templateUrl: 'my-customer-plus-vojta.html'
+ };
+ });
+
+angular.module('docsTimeDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.format = 'M/d/yy h:mm:ss a';
+ }])
+ .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) {
+
+ return {
+ link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) {
+ var format: any,
+ timeoutId: any;
+
+ function updateTime() {
+ element.text(dateFilter(new Date(), format));
+ }
+
+ scope.$watch(attrs['myCurrentTime'], function (value: any) {
+ format = value;
+ updateTime();
+ });
+
+ element.on('$destroy', function () {
+ $interval.cancel(timeoutId);
+ });
+
+ // start the UI update process; save the timeoutId for canceling
+ timeoutId = $interval(function () {
+ updateTime(); // update DOM
+ }, 1000);
+ }
+ };
+ }]);
+
+angular.module('docsTransclusionDirective', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.name = 'Tobias';
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ templateUrl: 'my-dialog.html'
+ };
+ });
+
+angular.module('docsTransclusionExample', [])
+ .controller('Controller', ['$scope', function($scope: any) {
+ $scope.name = 'Tobias';
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {},
+ templateUrl: 'my-dialog.html',
+ link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) {
+ scope['name'] = 'Jeff';
+ }
+ };
+ });
+
+angular.module('docsIsoFnBindExample', [])
+ .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) {
+ $scope.name = 'Tobias';
+ $scope.hideDialog = function () {
+ $scope.dialogIsHidden = true;
+ $timeout(function () {
+ $scope.dialogIsHidden = false;
+ }, 2000);
+ };
+ }])
+ .directive('myDialog', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {
+ 'close': '&onClose'
+ },
+ templateUrl: 'my-dialog-close.html'
+ };
+ });
+
+angular.module('dragModule', [])
+ .directive('myDraggable', ['$document', function($document: any) {
+ return function(scope: any, element: any, attr: any) {
+ var startX = 0, startY = 0, x = 0, y = 0;
+
+ element.css({
+ position: 'relative',
+ border: '1px solid red',
+ backgroundColor: 'lightgrey',
+ cursor: 'pointer'
+ });
+
+ element.on('mousedown', function(event: any) {
+ // Prevent default dragging of selected content
+ event.preventDefault();
+ startX = event.pageX - x;
+ startY = event.pageY - y;
+ $document.on('mousemove', mousemove);
+ $document.on('mouseup', mouseup);
+ });
+
+ function mousemove(event: any) {
+ y = event.pageY - startY;
+ x = event.pageX - startX;
+ element.css({
+ top: y + 'px',
+ left: x + 'px'
+ });
+ }
+
+ function mouseup() {
+ $document.off('mousemove', mousemove);
+ $document.off('mouseup', mouseup);
+ }
+ };
+ }]);
+
+angular.module('docsTabsExample', [])
+ .directive('myTabs', function() {
+ return {
+ restrict: 'E',
+ transclude: true,
+ scope: {},
+ controller: function($scope: ng.IScope) {
+ var panes: any = $scope['panes'] = [];
+
+ $scope['select'] = function(pane: any) {
+ angular.forEach(panes, function(pane: any) {
+ pane.selected = false;
+ });
+ pane.selected = true;
+ };
+
+ this.addPane = function(pane: any) {
+ if (panes.length === 0) {
+ $scope['select'](pane);
+ }
+ panes.push(pane);
+ };
+ },
+ templateUrl: 'my-tabs.html'
+ };
+ })
+ .directive('myPane', function() {
+ return {
+ require: '^myTabs',
+ restrict: 'E',
+ transclude: true,
+ scope: {
+ title: '@'
+ },
+ link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
+ tabsCtrl.addPane(scope);
+ },
+ templateUrl: 'my-pane.html'
+ };
+ });
diff --git a/angularjs/legacy/angular-1.2.d.ts b/angularjs/legacy/angular-1.2.d.ts
new file mode 100644
index 000000000..a1a4cb15b
--- /dev/null
+++ b/angularjs/legacy/angular-1.2.d.ts
@@ -0,0 +1,1182 @@
+// Type definitions for Angular JS 1.2+
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+declare var angular: ng.IAngularStatic;
+
+// Support for painless dependency injection
+interface Function {
+ $inject?: string[];
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// ng module (angular.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng {
+
+ // not directly implemented, but ensures that constructed class implements $get
+ interface IServiceProviderClass {
+ new(...args: any[]): IServiceProvider;
+ }
+
+ interface IServiceProviderFactory {
+ (...args: any[]): IServiceProvider;
+ }
+
+ // All service providers extend this interface
+ interface IServiceProvider {
+ $get: any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AngularStatic
+ // see http://docs.angularjs.org/api
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAngularStatic {
+ bind(context: any, fn: Function, ...args: any[]): Function;
+ bootstrap(element: string, modules?: any[]): auto.IInjectorService;
+ bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService;
+ bootstrap(element: Element, modules?: any[]): auto.IInjectorService;
+ bootstrap(element: Document, modules?: any[]): auto.IInjectorService;
+ copy(source: any, destination?: any): any;
+ element: IAugmentedJQueryStatic;
+ equals(value1: any, value2: any): boolean;
+ extend(destination: any, ...sources: any[]): any;
+
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
+ forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
+ forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
+ /**
+ * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
+ *
+ * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
+ *
+ * @param obj Object to iterate over.
+ * @param iterator Iterator function.
+ * @param context Object to become context (this) for the iterator function.
+ */
+ forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
+
+ fromJson(json: string): any;
+ identity(arg?: any): any;
+ injector(modules?: any[]): auto.IInjectorService;
+ isArray(value: any): boolean;
+ isDate(value: any): boolean;
+ isDefined(value: any): boolean;
+ isElement(value: any): boolean;
+ isFunction(value: any): boolean;
+ isNumber(value: any): boolean;
+ isObject(value: any): boolean;
+ isString(value: any): boolean;
+ isUndefined(value: any): boolean;
+ lowercase(str: string): string;
+
+ /**
+ * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
+ *
+ * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved.
+ *
+ * @param name The name of the module to create or retrieve.
+ * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
+ * @param configFn Optional configuration function for the module.
+ */
+ module(
+ name: string,
+ requires?: string[],
+ configFn?: Function): IModule;
+
+ noop(...args: any[]): void;
+ toJson(obj: any, pretty?: boolean): string;
+ uppercase(str: string): string;
+ version: {
+ full: string;
+ major: number;
+ minor: number;
+ dot: number;
+ codename: string;
+ };
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Module
+ // see http://docs.angularjs.org/api/angular.Module
+ ///////////////////////////////////////////////////////////////////////////
+ interface IModule {
+ animation(name: string, animationFactory: Function): IModule;
+ animation(name: string, inlineAnnotatedFunction: any[]): IModule;
+ animation(object: Object): IModule;
+ /**
+ * Use this method to register work which needs to be performed on module loading.
+ *
+ * @param configFn Execute this function on module load. Useful for service configuration.
+ */
+ config(configFn: Function): IModule;
+ /**
+ * Use this method to register work which needs to be performed on module loading.
+ *
+ * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
+ */
+ config(inlineAnnotatedFunction: any[]): IModule;
+ /**
+ * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
+ *
+ * @param name The name of the constant.
+ * @param value The constant value.
+ */
+ constant(name: string, value: any): IModule;
+ constant(object: Object): IModule;
+ /**
+ * The $controller service is used by Angular to create new controllers.
+ *
+ * This provider allows controller registration via the register method.
+ *
+ * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
+ * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
+ */
+ controller(name: string, controllerConstructor: Function): IModule;
+ /**
+ * The $controller service is used by Angular to create new controllers.
+ *
+ * This provider allows controller registration via the register method.
+ *
+ * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
+ * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
+ */
+ controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
+ controller(object : Object): IModule;
+ directive(name: string, directiveFactory: IDirectiveFactory): IModule;
+ directive(name: string, inlineAnnotatedFunction: any[]): IModule;
+ directive(object: Object): IModule;
+ /**
+ * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
+ *
+ * @param name The name of the instance.
+ * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
+ */
+ factory(name: string, $getFn: Function): IModule;
+ /**
+ * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
+ *
+ * @param name The name of the instance.
+ * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
+ */
+ factory(name: string, inlineAnnotatedFunction: any[]): IModule;
+ factory(object: Object): IModule;
+ filter(name: string, filterFactoryFunction: Function): IModule;
+ filter(name: string, inlineAnnotatedFunction: any[]): IModule;
+ filter(object: Object): IModule;
+ provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
+ provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
+ provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
+ provider(name: string, providerObject: IServiceProvider): IModule;
+ provider(object: Object): IModule;
+ /**
+ * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
+ */
+ run(initializationFunction: Function): IModule;
+ /**
+ * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
+ */
+ run(inlineAnnotatedFunction: any[]): IModule;
+ service(name: string, serviceConstructor: Function): IModule;
+ service(name: string, inlineAnnotatedConstructor: any[]): IModule;
+ service(object: Object): IModule;
+ /**
+ * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service.
+
+ Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator.
+ *
+ * @param name The name of the instance.
+ * @param value The value.
+ */
+ value(name: string, value: any): IModule;
+ value(object: Object): IModule;
+
+ // Properties
+ name: string;
+ requires: string[];
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Attributes
+ // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAttributes {
+ // this is necessary to be able to access the scoped attributes. it's not very elegant
+ // because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
+ // this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
+ [name: string]: any;
+
+ // Adds the CSS class value specified by the classVal parameter to the
+ // element. If animations are enabled then an animation will be triggered
+ // for the class addition.
+ $addClass(classVal: string): void;
+
+ // Removes the CSS class value specified by the classVal parameter from the
+ // element. If animations are enabled then an animation will be triggered for
+ // the class removal.
+ $removeClass(classVal: string): void;
+
+ // Set DOM element attribute value.
+ $set(key: string, value: any): void;
+
+ // Observes an interpolated attribute.
+ // The observer function will be invoked once during the next $digest
+ // following compilation. The observer is then invoked whenever the
+ // interpolated value changes.
+ $observe(name: string, fn:(value?:any)=>any): Function;
+
+ // A map of DOM element attribute names to the normalized name. This is needed
+ // to do reverse lookup from normalized name back to actual name.
+ $attr: Object;
+ }
+
+ /**
+ * form.FormController - type in module ng
+ * see https://docs.angularjs.org/api/ng/type/form.FormController
+ */
+ interface IFormController {
+
+ /**
+ * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272
+ */
+ [name: string]: any;
+
+ $pristine: boolean;
+ $dirty: boolean;
+ $valid: boolean;
+ $invalid: boolean;
+ $error: any;
+ $addControl(control: ng.INgModelController): void;
+ $removeControl(control: ng.INgModelController): void;
+ $setValidity(validationErrorKey: string, isValid: boolean, control: ng.INgModelController): void;
+ $setDirty(): void;
+ $setPristine(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // NgModelController
+ // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
+ ///////////////////////////////////////////////////////////////////////////
+ interface INgModelController {
+ $render(): void;
+ $setValidity(validationErrorKey: string, isValid: boolean): void;
+ // Documentation states viewValue and modelValue to be a string but other
+ // types do work and it's common to use them.
+ $setViewValue(value: any): void;
+ $viewValue: any;
+
+ $modelValue: any;
+
+ $parsers: IModelParser[];
+ $formatters: IModelFormatter[];
+ $viewChangeListeners: IModelViewChangeListener[];
+ $error: any;
+ $pristine: boolean;
+ $dirty: boolean;
+ $valid: boolean;
+ $invalid: boolean;
+ }
+
+ interface IModelParser {
+ (value: any): any;
+ }
+
+ interface IModelFormatter {
+ (value: any): any;
+ }
+
+ interface IModelViewChangeListener {
+ (): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Scope and RootScope
+ // see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and http://docs.angularjs.org/api/ng.$rootScope
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRootScopeService {
+ $apply(): any;
+ $apply(exp: string): any;
+ $apply(exp: (scope: IScope) => any): any;
+
+ $broadcast(name: string, ...args: any[]): IAngularEvent;
+ $destroy(): void;
+ $digest(): void;
+ $emit(name: string, ...args: any[]): IAngularEvent;
+
+ // Documentation says exp is optional, but actual implementaton counts on it
+ $eval(expression: string, args?: Object): any;
+ $eval(expression: (scope: IScope) => any, args?: Object): any;
+
+ // Documentation says exp is optional, but actual implementaton counts on it
+ $evalAsync(expression: string): void;
+ $evalAsync(expression: (scope: IScope) => any): void;
+
+ // Defaults to false by the implementation checking strategy
+ $new(isolate?: boolean): IScope;
+
+ $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function;
+
+ $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function;
+ $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
+ $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function;
+ $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
+
+ $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
+ $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
+
+ $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
+ $watchGroup(watchExpressions: {(scope: IScope) : any}[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
+
+ $parent: IScope;
+
+ $root: IRootScopeService;
+ this: IRootScopeService;
+
+ $id: string;
+
+ // Hidden members
+ $$isolateBindings: any;
+ $$phase: any;
+ }
+
+ interface IScope extends IRootScopeService {
+ [index: string]: any;
+ }
+
+ interface IAngularEvent {
+ targetScope: IScope;
+ currentScope: IScope;
+ name: string;
+ preventDefault: Function;
+ defaultPrevented: boolean;
+
+ // Available only events that were $emit-ted
+ stopPropagation?: Function;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // WindowService
+ // see http://docs.angularjs.org/api/ng.$window
+ ///////////////////////////////////////////////////////////////////////////
+ interface IWindowService extends Window {
+ [key: string]: any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // BrowserService
+ // TODO undocumented, so we need to get it from the source code
+ ///////////////////////////////////////////////////////////////////////////
+ interface IBrowserService {
+ [key: string]: any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TimeoutService
+ // see http://docs.angularjs.org/api/ng.$timeout
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITimeoutService {
+ (func: Function, delay?: number, invokeApply?: boolean): IPromise;
+ cancel(promise: IPromise): boolean;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // IntervalService
+ // see http://docs.angularjs.org/api/ng.$interval
+ ///////////////////////////////////////////////////////////////////////////
+ interface IIntervalService {
+ (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise;
+ cancel(promise: IPromise): boolean;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // FilterService
+ // see http://docs.angularjs.org/api/ng.$filter
+ // see http://docs.angularjs.org/api/ng.$filterProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IFilterService {
+ (name: string): Function;
+ }
+
+ interface IFilterProvider extends IServiceProvider {
+ register(name: string, filterFactory: Function): IServiceProvider;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LocaleService
+ // see http://docs.angularjs.org/api/ng.$locale
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILocaleService {
+ id: string;
+
+ // These are not documented
+ // Check angular's i18n files for exemples
+ NUMBER_FORMATS: ILocaleNumberFormatDescriptor;
+ DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor;
+ pluralCat: (num: any) => string;
+ }
+
+ interface ILocaleNumberFormatDescriptor {
+ DECIMAL_SEP: string;
+ GROUP_SEP: string;
+ PATTERNS: ILocaleNumberPatternDescriptor[];
+ CURRENCY_SYM: string;
+ }
+
+ interface ILocaleNumberPatternDescriptor {
+ minInt: number;
+ minFrac: number;
+ maxFrac: number;
+ posPre: string;
+ posSuf: string;
+ negPre: string;
+ negSuf: string;
+ gSize: number;
+ lgSize: number;
+ }
+
+ interface ILocaleDateTimeFormatDescriptor {
+ MONTH: string[];
+ SHORTMONTH: string[];
+ DAY: string[];
+ SHORTDAY: string[];
+ AMPMS: string[];
+ medium: string;
+ short: string;
+ fullDate: string;
+ longDate: string;
+ mediumDate: string;
+ shortDate: string;
+ mediumTime: string;
+ shortTime: string;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LogService
+ // see http://docs.angularjs.org/api/ng.$log
+ // see http://docs.angularjs.org/api/ng.$logProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILogService {
+ debug: ILogCall;
+ error: ILogCall;
+ info: ILogCall;
+ log: ILogCall;
+ warn: ILogCall;
+ }
+
+ interface ILogProvider {
+ debugEnabled(enabled: boolean): ILogProvider;
+ debugEnabled(): boolean;
+ }
+
+ // We define this as separete interface so we can reopen it later for
+ // the ngMock module.
+ interface ILogCall {
+ (...args: any[]): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ParseService
+ // see http://docs.angularjs.org/api/ng.$parse
+ // see http://docs.angularjs.org/api/ng.$parseProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IParseService {
+ (expression: string): ICompiledExpression;
+ }
+
+ interface IParseProvider {
+ logPromiseWarnings(): boolean;
+ logPromiseWarnings(value: boolean): IParseProvider;
+
+ unwrapPromises(): boolean;
+ unwrapPromises(value: boolean): IParseProvider;
+ }
+
+ interface ICompiledExpression {
+ (context: any, locals?: any): any;
+
+ // If value is not provided, undefined is gonna be used since the implementation
+ // does not check the parameter. Let's force a value for consistency. If consumer
+ // whants to undefine it, pass the undefined value explicitly.
+ assign(context: any, value: any): any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LocationService
+ // see http://docs.angularjs.org/api/ng.$location
+ // see http://docs.angularjs.org/api/ng.$locationProvider
+ // see http://docs.angularjs.org/guide/dev_guide.services.$location
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILocationService {
+ absUrl(): string;
+ hash(): string;
+ hash(newHash: string): ILocationService;
+ host(): string;
+ path(): string;
+ path(newPath: string): ILocationService;
+ port(): number;
+ protocol(): string;
+ replace(): ILocationService;
+ search(): any;
+ search(parametersMap: any): ILocationService;
+ search(parameter: string, parameterValue: any): ILocationService;
+ url(): string;
+ url(url: string): ILocationService;
+ }
+
+ interface ILocationProvider extends IServiceProvider {
+ hashPrefix(): string;
+ hashPrefix(prefix: string): ILocationProvider;
+ html5Mode(): boolean;
+
+ // Documentation states that parameter is string, but
+ // implementation tests it as boolean, which makes more sense
+ // since this is a toggler
+ html5Mode(active: boolean): ILocationProvider;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // DocumentService
+ // see http://docs.angularjs.org/api/ng.$document
+ ///////////////////////////////////////////////////////////////////////////
+ interface IDocumentService extends IAugmentedJQuery {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ExceptionHandlerService
+ // see http://docs.angularjs.org/api/ng.$exceptionHandler
+ ///////////////////////////////////////////////////////////////////////////
+ interface IExceptionHandlerService {
+ (exception: Error, cause?: string): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RootElementService
+ // see http://docs.angularjs.org/api/ng.$rootElement
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRootElementService extends JQuery {}
+
+ /**
+ * $q - service in module ng
+ * A promise/deferred implementation inspired by Kris Kowal's Q.
+ * See http://docs.angularjs.org/api/ng/service/$q
+ */
+ interface IQService {
+ /**
+ * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
+ *
+ * Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
+ *
+ * @param promises An array or hash of promises.
+ */
+ all(promises: IPromise[]): IPromise;
+ /**
+ * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
+ *
+ * Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
+ *
+ * @param promises An array or hash of promises.
+ */
+ all(promises: { [id: string]: IPromise; }): IPromise<{ [id: string]: any }>;
+ /**
+ * Creates a Deferred object which represents a task which will finish in the future.
+ */
+ defer(): IDeferred;
+ /**
+ * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it.
+ *
+ * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject.
+ *
+ * @param reason Constant, message, exception or an object representing the rejection reason.
+ */
+ reject(reason?: any): IPromise;
+ /**
+ * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
+ *
+ * @param value Value or a promise
+ */
+ when(value: IPromise): IPromise;
+ /**
+ * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
+ *
+ * @param value Value or a promise
+ */
+ when(value: T): IPromise;
+ /**
+ * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
+ *
+ * @param value Value or a promise
+ */
+ when(): IPromise;
+ }
+
+ interface IPromise {
+ then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise;
+ then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise;
+ then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult, notifyCallback?: (state: any) => any): IPromise;
+
+
+ catch(onRejected: (reason: any) => IHttpPromise): IPromise;
+ catch(onRejected: (reason: any) => IPromise): IPromise;
+ catch(onRejected: (reason: any) => TResult): IPromise;
+
+ finally(finallyCallback: ()=>any):IPromise;
+ }
+
+ interface IDeferred {
+ resolve(value?: T): void;
+ reject(reason?: any): void;
+ notify(state?:any): void;
+ promise: IPromise;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AnchorScrollService
+ // see http://docs.angularjs.org/api/ng.$anchorScroll
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAnchorScrollService {
+ (): void;
+ }
+
+ interface IAnchorScrollProvider extends IServiceProvider {
+ disableAutoScrolling(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // CacheFactoryService
+ // see http://docs.angularjs.org/api/ng.$cacheFactory
+ ///////////////////////////////////////////////////////////////////////////
+ interface ICacheFactoryService {
+ // Lets not foce the optionsMap to have the capacity member. Even though
+ // it's the ONLY option considered by the implementation today, a consumer
+ // might find it useful to associate some other options to the cache object.
+ //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject;
+ (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject;
+
+ // Methods bellow are not documented
+ info(): any;
+ get (cacheId: string): ICacheObject;
+ }
+
+ interface ICacheObject {
+ info(): {
+ id: string;
+ size: number;
+
+ // Not garanteed to have, since it's a non-mandatory option
+ //capacity: number;
+ };
+ put(key: string, value?: any): void;
+ get (key: string): any;
+ remove(key: string): void;
+ removeAll(): void;
+ destroy(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // CompileService
+ // see http://docs.angularjs.org/api/ng.$compile
+ // see http://docs.angularjs.org/api/ng.$compileProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ICompileService {
+ (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
+ (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
+ (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
+ }
+
+ interface ICompileProvider extends IServiceProvider {
+ directive(name: string, directiveFactory: Function): ICompileProvider;
+
+ // Undocumented, but it is there...
+ directive(directivesMap: any): ICompileProvider;
+
+ aHrefSanitizationWhitelist(): RegExp;
+ aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
+
+ imgSrcSanitizationWhitelist(): RegExp;
+ imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
+ }
+
+ interface ICloneAttachFunction {
+ // Let's hint but not force cloneAttachFn's signature
+ (clonedElement?: JQuery, scope?: IScope): any;
+ }
+
+ // This corresponds to the "publicLinkFn" returned by $compile.
+ interface ITemplateLinkingFunction {
+ (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
+ }
+
+ // This corresponds to $transclude (and also the transclude function passed to link).
+ interface ITranscludeFunction {
+ // If the scope is provided, then the cloneAttachFn must be as well.
+ (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;
+ // If one argument is provided, then it's assumed to be the cloneAttachFn.
+ (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ControllerService
+ // see http://docs.angularjs.org/api/ng.$controller
+ // see http://docs.angularjs.org/api/ng.$controllerProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IControllerService {
+ // Although the documentation doesn't state this, locals are optional
+ (controllerConstructor: Function, locals?: any): any;
+ (controllerName: string, locals?: any): any;
+ }
+
+ interface IControllerProvider extends IServiceProvider {
+ register(name: string, controllerConstructor: Function): void;
+ register(name: string, dependencyAnnotatedConstructor: any[]): void;
+ }
+
+ /**
+ * HttpService
+ * see http://docs.angularjs.org/api/ng/service/$http
+ */
+ interface IHttpService {
+ /**
+ * Object describing the request to be made and how it should be processed.
+ */
+ (config: IRequestConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform GET request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param config Optional configuration object
+ */
+ get(url: string, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform DELETE request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param config Optional configuration object
+ */
+ delete(url: string, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform HEAD request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param config Optional configuration object
+ */
+ head(url: string, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform JSONP request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param config Optional configuration object
+ */
+ jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform POST request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param data Request content
+ * @param config Optional configuration object
+ */
+ post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Shortcut method to perform PUT request.
+ *
+ * @param url Relative or absolute URL specifying the destination of the request
+ * @param data Request content
+ * @param config Optional configuration object
+ */
+ put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise;
+
+ /**
+ * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
+ */
+ defaults: IRequestConfig;
+
+ /**
+ * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
+ */
+ pendingRequests: any[];
+ }
+
+ /**
+ * Object describing the request to be made and how it should be processed.
+ * see http://docs.angularjs.org/api/ng/service/$http#usage
+ */
+ interface IRequestShortcutConfig {
+ /**
+ * {Object.}
+ * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
+ */
+ params?: any;
+
+ /**
+ * Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent.
+ */
+ headers?: any;
+
+ /**
+ * Name of HTTP header to populate with the XSRF token.
+ */
+ xsrfHeaderName?: string;
+
+ /**
+ * Name of cookie containing the XSRF token.
+ */
+ xsrfCookieName?: string;
+
+ /**
+ * {boolean|Cache}
+ * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
+ */
+ cache?: any;
+
+ /**
+ * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information.
+ */
+ withCredentials?: boolean;
+
+ /**
+ * {string|Object}
+ * Data to be sent as the request message data.
+ */
+ data?: any;
+
+ /**
+ * {function(data, headersGetter)|Array.}
+ * Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version.
+ */
+ transformRequest?: any;
+
+ /**
+ * {function(data, headersGetter)|Array.}
+ * Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version.
+ */
+ transformResponse?: any;
+
+ /**
+ * {number|Promise}
+ * Timeout in milliseconds, or promise that should abort the request when resolved.
+ */
+ timeout?: any;
+
+ /**
+ * See requestType.
+ */
+ responseType?: string;
+ }
+
+ /**
+ * Object describing the request to be made and how it should be processed.
+ * see http://docs.angularjs.org/api/ng/service/$http#usage
+ */
+ interface IRequestConfig extends IRequestShortcutConfig {
+ /**
+ * HTTP method (e.g. 'GET', 'POST', etc)
+ */
+ method: string;
+ /**
+ * Absolute or relative URL of the resource that is being requested.
+ */
+ url: string;
+ }
+
+ interface IHttpPromiseCallback {
+ (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void;
+ }
+
+ interface IHttpPromiseCallbackArg {
+ data?: T;
+ status?: number;
+ headers?: (headerName: string) => string;
+ config?: IRequestConfig;
+ statusText?: string;
+ }
+
+ interface IHttpPromise extends IPromise {
+ success(callback: IHttpPromiseCallback): IHttpPromise;
+ error(callback: IHttpPromiseCallback): IHttpPromise;
+ then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
+ then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
+ }
+
+ interface IHttpProvider extends IServiceProvider {
+ defaults: IRequestConfig;
+ interceptors: any[];
+ responseInterceptors: any[];
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // HttpBackendService
+ // see http://docs.angularjs.org/api/ng.$httpBackend
+ // You should never need to use this service directly.
+ ///////////////////////////////////////////////////////////////////////////
+ interface IHttpBackendService {
+ // XXX Perhaps define callback signature in the future
+ (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // InterpolateService
+ // see http://docs.angularjs.org/api/ng.$interpolate
+ // see http://docs.angularjs.org/api/ng.$interpolateProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IInterpolateService {
+ (text: string, mustHaveExpression?: boolean): IInterpolationFunction;
+ endSymbol(): string;
+ startSymbol(): string;
+ }
+
+ interface IInterpolationFunction {
+ (context: any): string;
+ }
+
+ interface IInterpolateProvider extends IServiceProvider {
+ startSymbol(): string;
+ startSymbol(value: string): IInterpolateProvider;
+ endSymbol(): string;
+ endSymbol(value: string): IInterpolateProvider;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TemplateCacheService
+ // see http://docs.angularjs.org/api/ng.$templateCache
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITemplateCacheService extends ICacheObject {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEService
+ // see http://docs.angularjs.org/api/ng.$sce
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEService {
+ getTrusted(type: string, mayBeTrusted: any): any;
+ getTrustedCss(value: any): any;
+ getTrustedHtml(value: any): any;
+ getTrustedJs(value: any): any;
+ getTrustedResourceUrl(value: any): any;
+ getTrustedUrl(value: any): any;
+ parse(type: string, expression: string): (context: any, locals: any) => any;
+ parseAsCss(expression: string): (context: any, locals: any) => any;
+ parseAsHtml(expression: string): (context: any, locals: any) => any;
+ parseAsJs(expression: string): (context: any, locals: any) => any;
+ parseAsResourceUrl(expression: string): (context: any, locals: any) => any;
+ parseAsUrl(expression: string): (context: any, locals: any) => any;
+ trustAs(type: string, value: any): any;
+ trustAsHtml(value: any): any;
+ trustAsJs(value: any): any;
+ trustAsResourceUrl(value: any): any;
+ trustAsUrl(value: any): any;
+ isEnabled(): boolean;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEProvider
+ // see http://docs.angularjs.org/api/ng.$sceProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEProvider extends IServiceProvider {
+ enabled(value: boolean): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEDelegateService
+ // see http://docs.angularjs.org/api/ng.$sceDelegate
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEDelegateService {
+ getTrusted(type: string, mayBeTrusted: any): any;
+ trustAs(type: string, value: any): any;
+ valueOf(value: any): any;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEDelegateProvider
+ // see http://docs.angularjs.org/api/ng.$sceDelegateProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEDelegateProvider extends IServiceProvider {
+ resourceUrlBlacklist(blacklist: any[]): void;
+ resourceUrlWhitelist(whitelist: any[]): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Directive
+ // see http://docs.angularjs.org/api/ng.$compileProvider#directive
+ // and http://docs.angularjs.org/guide/directive
+ ///////////////////////////////////////////////////////////////////////////
+
+ interface IDirectiveFactory {
+ (...args: any[]): IDirective;
+ }
+
+ interface IDirectiveLinkFn {
+ (
+ scope: IScope,
+ instanceElement: IAugmentedJQuery,
+ instanceAttributes: IAttributes,
+ controller: any,
+ transclude: ITranscludeFunction
+ ): void;
+ }
+
+ interface IDirectivePrePost {
+ pre?: IDirectiveLinkFn;
+ post?: IDirectiveLinkFn;
+ }
+
+ interface IDirectiveCompileFn {
+ (
+ templateElement: IAugmentedJQuery,
+ templateAttributes: IAttributes,
+ transclude: ITranscludeFunction
+ ): IDirectivePrePost;
+ }
+
+ interface IDirective {
+ compile?: IDirectiveCompileFn;
+ controller?: any;
+ controllerAs?: string;
+ link?: IDirectiveLinkFn;
+ name?: string;
+ priority?: number;
+ replace?: boolean;
+ require?: any;
+ restrict?: string;
+ scope?: any;
+ template?: any;
+ templateUrl?: any;
+ terminal?: boolean;
+ transclude?: any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // angular.element
+ // when calling angular.element, angular returns a jQuery object,
+ // augmented with additional methods like e.g. scope.
+ // see: http://docs.angularjs.org/api/angular.element
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAugmentedJQueryStatic extends JQueryStatic {
+ (selector: string, context?: any): IAugmentedJQuery;
+ (element: Element): IAugmentedJQuery;
+ (object: {}): IAugmentedJQuery;
+ (elementArray: Element[]): IAugmentedJQuery;
+ (object: JQuery): IAugmentedJQuery;
+ (func: Function): IAugmentedJQuery;
+ (array: any[]): IAugmentedJQuery;
+ (): IAugmentedJQuery;
+ }
+
+ interface IAugmentedJQuery extends JQuery {
+ // TODO: events, how to define?
+ //$destroy
+
+ find(selector: string): IAugmentedJQuery;
+ find(element: any): IAugmentedJQuery;
+ find(obj: JQuery): IAugmentedJQuery;
+
+ controller(name: string): any;
+ injector(): any;
+ scope(): IScope;
+ isolateScope(): IScope;
+
+ inheritedData(key: string, value: any): JQuery;
+ inheritedData(obj: { [key: string]: any; }): JQuery;
+ inheritedData(key?: string): any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // AnimateService
+ // see http://docs.angularjs.org/api/ng.$animate
+ ///////////////////////////////////////////////////////////////////////
+ interface IAnimateService {
+ addClass(element: JQuery, className: string, done?: Function): void;
+ enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
+ leave(element: JQuery, done?: Function): void;
+ move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
+ removeClass(element: JQuery, className: string, done?: Function): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AUTO module (angular.js)
+ ///////////////////////////////////////////////////////////////////////////
+ export module auto {
+
+ ///////////////////////////////////////////////////////////////////////
+ // InjectorService
+ // see http://docs.angularjs.org/api/AUTO.$injector
+ ///////////////////////////////////////////////////////////////////////
+ interface IInjectorService {
+ annotate(fn: Function): string[];
+ annotate(inlineAnnotatedFunction: any[]): string[];
+ get(name: string): any;
+ has(name: string): boolean;
+ instantiate(typeConstructor: Function, locals?: any): any;
+ invoke(inlineAnnotatedFunction: any[]): any;
+ invoke(func: Function, context?: any, locals?: any): any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // ProvideService
+ // see http://docs.angularjs.org/api/AUTO.$provide
+ ///////////////////////////////////////////////////////////////////////
+ interface IProvideService {
+ // Documentation says it returns the registered instance, but actual
+ // implementation does not return anything.
+ // constant(name: string, value: any): any;
+ /**
+ * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
+ *
+ * @param name The name of the constant.
+ * @param value The constant value.
+ */
+ constant(name: string, value: any): void;
+
+ /**
+ * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
+ *
+ * @param name The name of the service to decorate.
+ * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
+ *
+ * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
+ */
+ decorator(name: string, decorator: Function): void;
+ /**
+ * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
+ *
+ * @param name The name of the service to decorate.
+ * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
+ *
+ * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
+ */
+ decorator(name: string, inlineAnnotatedFunction: any[]): void;
+ factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider;
+ factory(name: string, inlineAnnotatedFunction: any[]): ng.IServiceProvider;
+ provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider;
+ provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider;
+ service(name: string, constructor: Function): ng.IServiceProvider;
+ value(name: string, value: any): ng.IServiceProvider;
+ }
+
+ }
+}
diff --git a/async/async-tests.ts b/async/async-tests.ts
index 9b0c8e7ee..9a563276a 100644
--- a/async/async-tests.ts
+++ b/async/async-tests.ts
@@ -26,10 +26,11 @@ async.map(data, asyncProcess, function (err, results) {
var openFiles = ['file1', 'file2'];
var saveFile = function () { }
-async.forEach(openFiles, saveFile, function (err) { });
+async.each(openFiles, saveFile, function (err) { });
+async.eachSeries(openFiles, saveFile, function (err) { });
var documents, requestApi;
-async.forEachLimit(documents, 20, requestApi, function (err) { });
+async.eachLimit(documents, 20, requestApi, function (err) { });
async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
diff --git a/async/async.d.ts b/async/async.d.ts
index d1d592629..994ed1799 100644
--- a/async/async.d.ts
+++ b/async/async.d.ts
@@ -34,9 +34,9 @@ interface AsyncQueue {
interface Async {
// Collections
- forEach(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
- forEachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
- forEachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ each(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ eachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
+ eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void;
map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any;
mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any;
filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any;
diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts
index 6b40bb509..506fd7bb6 100644
--- a/backbone/backbone-tests.ts
+++ b/backbone/backbone-tests.ts
@@ -113,9 +113,12 @@ class EmployeeCollection extends Backbone.Collection {
class Book extends Backbone.Model {
title: string;
author: string;
+ published: boolean;
}
class Library extends Backbone.Collection {
+ // This model definition is here only to test type compatibility of the model, but it
+ // is not necessary in working code as it is automatically inferred through generics.
model: typeof Book;
}
@@ -123,31 +126,31 @@ class Books extends Backbone.Collection { }
function test_collection() {
- var books = new Library();
+ var books = new Books();
- books.each(book => {
- book.get("title");
- });
+ var book1: Book = new Book({ title: "Title 1", author: "Mike" });
+ books.add(book1);
- var titles = books.map(book => {
- return book.get("title");
- });
+ // Objects can be added to collection by casting to model type.
+ // Compiler will check if object properties are valid for the cast.
+ // This gives better type checking than declaring an `any` overload.
+ books.add({ title: "Title 2", author: "Mikey" });
- var publishedBooks = books.filter(book => {
- return book.get("published") === true;
- });
-
- var alphabetical = books.sortBy((book: Book): number => {
- return null;
- });
-
- var model: Book = new Book({title: "Test", author: "Mike"});
- books.add(model);
- var model2: Book = model.collection.first();
- if (model !== model2) {
+ var model: Book = book1.collection.first();
+ if (model !== book1) {
throw new Error("Error");
}
+ books.each(book =>
+ book.get("title"));
+
+ var titles = books.map(book =>
+ book.get("title"));
+
+ var publishedBooks = books.filter(book =>
+ book.get("published") === true);
+
+ var alphabetical = books.sortBy((book: Book): number => null);
}
//////////
diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts
index db104f480..270b949aa 100644
--- a/backbone/backbone.d.ts
+++ b/backbone/backbone.d.ts
@@ -113,8 +113,23 @@ declare module Backbone {
fetch(options?: ModelFetchOptions): JQueryXHR;
- get(attributeName: string): any;
- set(attributeName: string, value: any, options?: ModelSetOptions): Model;
+ /**
+ * For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
+ * @example
+ * get name(): string {
+ * return super.get("name");
+ * }
+ **/
+ /*private*/ get(attributeName: string): any;
+
+ /**
+ * For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
+ * @example
+ * set name(value: string) {
+ * super.set("name", value);
+ * }
+ **/
+ /*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
set(obj: any, options?: ModelSetOptions): Model;
change(): any;
@@ -170,7 +185,12 @@ declare module Backbone {
add(model: TModel, options?: AddOptions): Collection;
add(models: TModel[], options?: AddOptions): Collection;
at(index: number): TModel;
+ /**
+ * Get a model from a collection, specified by an id, a cid, or by passing in a model.
+ **/
+ get(id: number): TModel;
get(id: string): TModel;
+ get(id: Model): TModel;
create(attributes: any, options?: ModelSaveOptions): TModel;
pluck(attribute: string): any[];
push(model: TModel, options?: AddOptions): TModel;
@@ -195,12 +215,10 @@ declare module Backbone {
any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean;
collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
chain(): any;
- compact(): TModel[];
contains(value: any): boolean;
countBy(iterator: (element: TModel, index: number) => any): _.Dictionary;
countBy(attribute: string): _.Dictionary;
detect(iterator: (item: any) => boolean, context?: any): any; // ???
- difference(...model: TModel[]): TModel[];
drop(): TModel;
drop(n: number): TModel[];
each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
@@ -209,7 +227,6 @@ declare module Backbone {
find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel;
first(): TModel;
first(n: number): TModel[];
- flatten(shallow?: boolean): TModel[];
foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any;
groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary;
@@ -219,7 +236,6 @@ declare module Backbone {
initial(): TModel;
initial(n: number): TModel[];
inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
- intersection(...model: TModel[]): TModel[];
isEmpty(object: any): boolean;
invoke(methodName: string, arguments?: any[]): any;
last(): TModel;
@@ -228,7 +244,6 @@ declare module Backbone {
map(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[];
max(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
min(iterator?: (element: TModel, index: number) => any, context?: any): TModel;
- object(...values: any[]): any[];
reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any;
select(iterator: any, context?: any): any[];
size(): number;
@@ -237,8 +252,6 @@ declare module Backbone {
sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[];
sortBy(attribute: string, context?: any): TModel[];
sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number;
- range(stop: number, step?: number): any;
- range(start: number, stop: number, step?: number): any;
reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[];
reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[];
rest(): TModel;
@@ -246,10 +259,7 @@ declare module Backbone {
tail(): TModel;
tail(n: number): TModel[];
toArray(): any[];
- union(...model: TModel[]): TModel[];
- uniq(isSorted?: boolean, iterator?: (element: TModel, index: number) => boolean): TModel[];
without(...values: any[]): TModel[];
- zip(...model: TModel[]): TModel[];
}
class Router extends Events {
@@ -329,7 +339,6 @@ declare module Backbone {
model: TModel;
collection: Collection;
//template: (json, options?) => string;
- make(tagName: string, attrs?: any, opts?: any): View;
setElement(element: HTMLElement, delegate?: boolean): View;
setElement(element: JQuery, delegate?: boolean): View;
id: string;
@@ -355,11 +364,11 @@ declare module Backbone {
function sync(method: string, model: Model, options?: JQueryAjaxSettings): any;
function ajax(options?: JQueryAjaxSettings): JQueryXHR;
var emulateHTTP: boolean;
- var emulateJSONBackbone: boolean;
+ var emulateJSON: boolean;
// Utility
function noConflict(): typeof Backbone;
- function setDomLibrary(jQueryNew: any): any;
+ var $: JQueryStatic;
}
declare module "backbone" {
diff --git a/big.js/big.js-tests.ts b/big.js/big.js-tests.ts
new file mode 100644
index 000000000..6de9ee7cc
--- /dev/null
+++ b/big.js/big.js-tests.ts
@@ -0,0 +1,233 @@
+// Type definitions for big.js
+// Project: https://github.com/MikeMcl/big.js/
+// Definitions by: Steve Ognibene
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
+/*
+
+ Tests include code from http://mikemcl.github.io/big.js/
+
+ Minor changes have been made such as adding variable definitions where required.
+
+*/
+
+function constructorTests() {
+ var x = new Big(9) // '9'
+ var y = new Big(x) // '9'
+ var d = Big(435.345) // 'new' is optional
+ var e = Big('435.345') // 'new' is optional
+ var a = new Big('5032485723458348569331745.33434346346912144534543')
+ var b = new Big('4.321e+4') // '43210'
+ var c = new Big('-735.0918e-430') // '-7.350918e-428'
+}
+
+function staticPropertiesTests() {
+ Big.DP = 40;
+ Big.RM = 3;
+ Big.RM = BigJsLibrary.RoundingMode.RoundAwayFromZero;
+}
+
+function absTests() {
+ var x = new Big(-0.8);
+ x.abs(); // '0.8'
+}
+
+function cmpTests() {
+ var x = new Big(6);
+ var y = new Big(5);
+ x.cmp(y); // 1
+ y.cmp(x.minus(1)); // 0
+}
+
+function divTests() {
+ var x = new Big(355);
+ var y = new Big(113);
+ x.div(y); // '3.14159292035398230088'
+ Big.DP = 2;
+ x.div(y); // '3.14'
+ x.div(5); // '71'
+}
+
+function eqTests() {
+ 0 === 1e-324; // true
+ var x = new Big(0);
+ x.eq('1e-324'); // false
+ Big(-0).eq(x); // true ( -0 === 0 )
+}
+
+function gtTests() {
+ 0.1 > 0.3 - 0.2; // true
+ var x = new Big(0.1);
+ x.gt(Big(0.3).minus(0.2)); // false
+ Big(0).gt(x); // false
+}
+
+function gteTests() {
+ 0.3 - 0.2 >= 0.1; // false
+ var x = new Big(0.3).minus(0.2);
+ x.gte(0.1); // true
+ Big(1).gte(x); // true
+}
+
+function ltTests() {
+ 0.3 - 0.2 < 0.1; // true
+ var x = new Big(0.3).minus(0.2);
+ x.lt(0.1); // false
+ Big(0).lt(x); // true
+}
+
+function lteTests() {
+ 0.1 <= 0.3 - 0.2; // false
+ var x = new Big(0.1);
+ x.lte(Big(0.3).minus(0.2)); // true
+ Big(-1).lte(x); // true
+}
+
+function minusTests() {
+ 0.3 - 0.1; // 0.19999999999999998
+ var x = new Big(0.3);
+ x.minus(0.1); // '0.2'
+}
+
+function modTests() {
+ 1 % 0.9 // 0.09999999999999998
+ var x = Big(1);
+ x.mod(0.9) // '0.1'
+}
+
+function plusTests() {
+ 0.1 + 0.2 // 0.30000000000000004
+ var x = new Big(0.1)
+ var y = x.plus(0.2) // '0.3'
+ Big(0.7).plus(x).plus(y) // '1'
+}
+
+function powTests() {
+ Math.pow(0.7, 2) // 0.48999999999999994
+ var x = new Big(0.7)
+ x.pow(2) // '0.49'
+ Big.DP = 20
+ Big(3).pow(-2) // '0.11111111111111111111'
+
+ new Big(123.456).pow(1000).toString().length // 5099
+ new Big(2).pow(1e+6) // Time taken (Node.js): 9 minutes 34 secs.
+}
+
+function roundTests() {
+ var x = 123.45
+ Math.round(x) // 123
+ var y = new Big(x)
+ y.round() // '123'
+ y.round(2) // '123.45'
+ y.round(10) // '123.45'
+ y.round(1, 0) // '123.4'
+ y.round(1, 1) // '123.5'
+ y.round(1, 2) // '123.4'
+ y.round(1, 3) // '123.5'
+ y // '123.45'
+}
+
+function sqrtTests() {
+ var x = new Big(16)
+ x.sqrt() // '4'
+ var y = new Big(3)
+ y.sqrt() // '1.73205080756887729353'
+}
+
+function timesTests() {
+ 0.6 * 3 // 1.7999999999999998
+ var x = new Big(0.6)
+ var y = x.times(3) // '1.8'
+ Big('7e+500').times(y) // '1.26e+501'
+}
+
+function toExponentialTests() {
+ var x = 45.6
+ var y = new Big(x)
+ x.toExponential() // '4.56e+1'
+ y.toExponential() // '4.56e+1'
+ x.toExponential(0) // '5e+1'
+ y.toExponential(0) // '5e+1'
+ x.toExponential(1) // '4.6e+1'
+ y.toExponential(1) // '4.6e+1'
+ x.toExponential(3) // '4.560e+1'
+ y.toExponential(3) // '4.560e+1'
+}
+
+function toFixedTests() {
+ var x = 45.6
+ var y = new Big(x)
+ x.toFixed() // '46'
+ y.toFixed() // '45.6'
+ y.toFixed(0) // '46'
+ x.toFixed(3) // '45.600'
+ y.toFixed(3) // '45.600'
+}
+
+function toPrecisionTests() {
+ var x = 45.6
+ var y = new Big(x)
+ x.toPrecision() // '45.6'
+ y.toPrecision() // '45.6'
+ x.toPrecision(1) // '5e+1'
+ y.toPrecision(1) // '5e+1'
+ x.toPrecision(5) // '45.600'
+ y.toPrecision(5) // '45.600'
+}
+
+function toStringTests() {
+ var x = new Big('9.99e+20')
+ x.toString() // '999000000000000000000'
+ var y = new Big('1E21')
+ x.toString() // '1e+21'
+}
+
+function valueOfTests() {
+ var x = new Big('177.7e+457')
+ x.valueOf() // '1.777e+459'
+}
+
+function toJSONTests() {
+ var x = new Big('177.7e+457')
+ var y = new Big(235.4325)
+ var z = new Big('0.0098074')
+ var str = JSON.stringify([x, y, z])
+
+ var a = new Big('123').toJSON();
+
+ JSON.parse(str, function (k, v) { return k === '' ? v : new Big(v) }) // Returns an array of three Big numbers.
+}
+
+function propertiesTest1() {
+ var x = new Big(0.123) // '0.123'
+ x.toExponential() // '1.23e-1'
+ x.c // '1,2,3'
+ x.e // -1
+ x.s // 1
+
+ var y = new Number(-123.4567000e+2) // '-12345.67'
+ y.toExponential() // '-1.234567e+4'
+ var z = new Big('-123.4567000e+2') // '-12345.67'
+ z.toExponential() // '-1.234567e+4'
+ z.c // '1,2,3,4,5,6,7'
+ z.e // 4
+ z.s // -1
+}
+
+function propertiesTest2() {
+ var x = new Big('1234.000') // '1234'
+ x.toExponential() // '1.234e+3'
+ x.c // '1,2,3,4'
+ x.e // 3
+
+ x.e = -5
+ x // '0.00001234'
+}
+
+function propertiesTest3() {
+ var y = new Big(-0) // '0'
+ y.c // '0' [0].toString()
+ y.e // 0
+ y.s // -1
+}
\ No newline at end of file
diff --git a/big.js/big.js.d.ts b/big.js/big.js.d.ts
new file mode 100644
index 000000000..4f6278a80
--- /dev/null
+++ b/big.js/big.js.d.ts
@@ -0,0 +1,200 @@
+// Type definitions for big.js
+// Project: https://github.com/MikeMcl/big.js/
+// Definitions by: Steve Ognibene
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+declare module BigJsLibrary {
+
+ export enum RoundingMode {
+ RoundTowardsZero = 0,
+ RoundTowardsNearestAwayFromZero = 1,
+ RoundTowardsNearestTowardsEven = 2,
+ RoundAwayFromZero = 3
+ }
+
+ interface BigJS extends BigJS_Constructors {
+ /** The maximum number of decimal places of the results of operations involving division.
+ It is relevant only to the div and sqrt methods, and the pow method when the exponent is negative.
+ @default 40 */
+ DP: number;
+
+ /** The rounding mode used in the above operations and by round, toExponential, toFixed and toPrecision.
+ Default is RoundTowardsNearestAwayFromZero
+ @default 1 */
+ RM: RoundingMode;
+ }
+
+ interface BigJS_Constructors {
+ /** A decimal value. */
+ new (value: number): BigJS;
+ /** A decimal value.
+ String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
+ String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
+ new (value: string): BigJS;
+ /** A decimal value. */
+ new (value: BigJS): BigJS;
+ /** A decimal value. */
+ (value: number): BigJS;
+ /** A decimal value.
+ String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
+ String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
+ (value: string): BigJS;
+ /** A decimal value. */
+ (value: BigJS): BigJS;
+ }
+
+ /** BigJS instance methods */
+ interface BigJS extends BigJS_Constructors {
+ /** Returns a Big number whose value is the absolute value, i.e. the magnitude, of this Big number. */
+ abs(): BigJS;
+
+ /** Compare
+ @returns {Number}
+ 1 = If the value of this Big number is greater than the value of n
+ -1 = If the value of this Big number is less than the value of n
+ 0 = If this Big number and n have the same value */
+ cmp(n: number): number;
+ /** Compare
+ @returns {Number}
+ 1 = If the value of this Big number is greater than the value of n
+ -1 = If the value of this Big number is less than the value of n
+ 0 = If this Big number and n have the same value */
+ cmp(n: string): number;
+ /** Compare
+ @returns {Number}
+ 1 = If the value of this Big number is greater than the value of n
+ -1 = If the value of this Big number is less than the value of n
+ 0 = If this Big number and n have the same value */
+ cmp(n: BigJS): number;
+
+ /** Returns a Big number whose value is the value of this Big number divided by n. */
+ div(n: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number divided by n. */
+ div(n: string): BigJS;
+ /** Returns a Big number whose value is the value of this Big number divided by n. */
+ div(n: BigJS): BigJS;
+
+ /** Returns true if the value of this Big equals the value of n, otherwise returns false. */
+ eq(n: number): boolean;
+ /** Returns true if the value of this Big equals the value of n, otherwise returns false. */
+ eq(n: string): boolean;
+ /** Returns true if the value of this Big equals the value of n, otherwise returns false. */
+ eq(n: BigJS): boolean;
+
+ /** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
+ gt(n: number): boolean;
+ /** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
+ gt(n: string): boolean;
+ /** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
+ gt(n: BigJS): boolean;
+
+ /** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
+ gte(n: number): boolean;
+ /** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
+ gte(n: string): boolean;
+ /** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
+ gte(n: BigJS): boolean;
+
+ /** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
+ lt(n: number): boolean;
+ /** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
+ lt(n: string): boolean;
+ /** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
+ lt(n: BigJS): boolean;
+
+ /** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
+ lte(n: number): boolean;
+ /** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
+ lte(n: string): boolean;
+ /** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
+ lte(n: BigJS): boolean;
+
+ /** Returns a Big number whose value is the value of this Big number minus n. */
+ minus(n: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number minus n. */
+ minus(n: string): BigJS;
+ /** Returns a Big number whose value is the value of this Big number minus n. */
+ minus(n: BigJS): BigJS;
+
+ /** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
+ The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
+ mod(n: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
+ The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
+ mod(n: string): BigJS;
+ /** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
+ The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
+ mod(n: BigJS): BigJS;
+
+ /** Returns a Big number whose value is the value of this Big number plus n. */
+ plus(n: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number plus n. */
+ plus(n: string): BigJS;
+ /** Returns a Big number whose value is the value of this Big number plus n. */
+ plus(n: BigJS): BigJS;
+
+ /** Returns a Big number whose value is the value of this Big number raised to the power exp.
+ If exp is negative and the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM.
+ @param exp integer, -1e+6 to 1e+6 inclusive */
+ pow(exp: number): BigJS;
+
+ /** Returns a Big number whose value is the value of this Big number rounded to a whole number. */
+ round(): BigJS;
+ /** Returns a Big number whose value is the value of this Big number rounded using rounding mode rm to a maximum of dp decimal places.
+ @param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted or is null or undefined, the return value is n rounded to a whole number. */
+ round(dp: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number rounded using rounding mode rm to a maximum of dp decimal places.
+ @param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted or is null or undefined, the return value is n rounded to a whole number.
+ @param rm Rounding mode. If rm is omitted or is null or undefined, the current Big.RM setting is used. */
+ round(dp: number, rm: RoundingMode): BigJS;
+
+ /** Returns a Big number whose value is the square root of this Big number. */
+ sqrt(): BigJS;
+
+ /** Returns a Big number whose value is the value of this Big number times n. */
+ times(n: number): BigJS;
+ /** Returns a Big number whose value is the value of this Big number times n. */
+ times(n: string): BigJS;
+ /** Returns a Big number whose value is the value of this Big number times n. */
+ times(n: BigJS): BigJS;
+
+ /** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp. */
+ toExponential(): string;
+ /** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp.
+ @param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted, or is null or undefined, the number of digits after the decimal point defaults to the minimum number of digits necessary to represent the value exactly. */
+ toExponential(dp: number): string;
+
+ /** Returns a string representing the value of this Big number in normal notation to a fixed number of decimal places dp. */
+ toFixed(): string;
+ /** Returns a string representing the value of this Big number in normal notation to a fixed number of decimal places dp.
+ @param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted, or is null or undefined, then the return value is simply the value in normal notation. This is also unlike Number.prototype.toFixed, which returns the value to zero decimal places. */
+ toFixed(dp: number): string;
+
+ /** Returns a string representing the value of this Big number to the specified number of significant digits sd. */
+ toPrecision(): string;
+ /** Returns a string representing the value of this Big number to the specified number of significant digits sd.
+ @param sd significant digits. If sd is omitted, or is null or undefined, then the return value is the same as .toString(). */
+ toPrecision(sd: number /** number of significant digits (0 to 1e+6 inclusive) */): string;
+
+ /** Returns a string representing the value of this Big number. */
+ toString(): string;
+
+ /** As toString. */
+ valueOf(): string;
+
+ /** As toString. */
+ toJSON(): string;
+
+ /** coefficient (significand) */
+ c: number[];
+
+ /** exponent (Integer, -1e+6 to 1e+6 inclusive) */
+ e: number;
+
+ /** sign (-1 or 1) */
+ s: number;
+ }
+}
+
+declare var Big: BigJsLibrary.BigJS;
\ No newline at end of file
diff --git a/bigint/bigint-tests.ts b/bigint/bigint-tests.ts
new file mode 100644
index 000000000..8ccf2ba4b
--- /dev/null
+++ b/bigint/bigint-tests.ts
@@ -0,0 +1,81 @@
+///
+
+var bi: BigInt.BigInt;
+var num: number;
+var str: string;
+var b: boolean;
+
+BigInt.setRandom(() => { return 0; });
+
+bi = BigInt.add(bi, bi);
+bi = BigInt.addInt(bi, num);
+str = BigInt.bigInt2str(bi, num);
+str = BigInt.bigInt2str(bi, str);
+num = BigInt.bitSize(bi);
+bi = BigInt.dup(bi);
+b = BigInt.equals(bi, bi);
+b = BigInt.equalsInt(bi, num);
+bi = BigInt.expand(bi, num);
+var nums: number[] = BigInt.findPrimes(num);
+bi = BigInt.GCD(bi, bi);
+b = BigInt.greater(bi, bi);
+b = BigInt.greaterShift(bi, bi, num);
+bi = BigInt.int2bigInt(0);
+bi = BigInt.int2bigInt(0, 0);
+bi = BigInt.int2bigInt(0, 0, 0);
+bi = BigInt.inverseMod(bi, bi);
+bi = BigInt.inverseModInt(num, num);
+b = BigInt.isZero(bi);
+b = BigInt.millerRabin(bi, bi);
+b = BigInt.millerRabinInt(num, num);
+bi = BigInt.mod(bi, bi);
+num = BigInt.modInt(bi, num);
+bi = BigInt.mult(bi, bi);
+bi = BigInt.multMod(bi, bi, bi);
+b = BigInt.negative(bi);
+bi = BigInt.powMod(bi, bi, bi);
+bi = BigInt.randBigInt(num, num);
+bi = BigInt.randTruePrime(num);
+bi = BigInt.randProbPrime(num);
+bi = BigInt.str2bigInt(str, num);
+bi = BigInt.str2bigInt(str, num, 0);
+bi = BigInt.str2bigInt(str, num, 0, 0);
+bi = BigInt.str2bigInt(str, str);
+bi = BigInt.str2bigInt(str, str, 0);
+bi = BigInt.str2bigInt(str, str, 0, 0);
+bi = BigInt.sub(bi, bi);
+bi = BigInt.trim(bi, num);
+
+BigInt.addInt_(bi, num);
+BigInt.add_(bi, bi);
+BigInt.copy_(bi, bi);
+num = BigInt.copyInt_(bi, num);
+BigInt.GCD_(bi, bi);
+b = BigInt.inverseMod_(bi, bi);
+BigInt.mod_(bi, bi);
+BigInt.mult_(bi, bi);
+BigInt.multMod_(bi, bi, bi);
+BigInt.powMod_(bi, bi, bi);
+BigInt.randBigInt_(bi, num, num);
+BigInt.randTruePrime_(bi, num);
+BigInt.sub_(bi, bi);
+BigInt.addShift_(bi, bi, num);
+BigInt.carry_(bi);
+BigInt.divide_(bi, bi, bi, bi);
+num = BigInt.divInt_(bi, num);
+BigInt.eGCD_(bi, bi, bi, bi, bi);
+BigInt.halve_(bi);
+BigInt.leftShift_(bi, num);
+BigInt.linComb_(bi, bi, num, num);
+BigInt.linCombShift_(bi, bi, num, num);
+BigInt.mont_(bi, bi, bi, num);
+BigInt.multInt_(bi, num);
+BigInt.rightShift_(bi, num);
+BigInt.squareMod_(bi, bi);
+BigInt.subShift_(bi, bi, num);
+
+function someRandomRealCode() {
+ bi = BigInt.int2bigInt(22, 5);
+ bi = BigInt.str2bigInt("FFFFFFFFFFFFFFFFC90FDAA2", 16);
+ str = BigInt.bigInt2str(bi, 16);
+}
diff --git a/bigint/bigint.d.ts b/bigint/bigint.d.ts
new file mode 100644
index 000000000..b70f20fa4
--- /dev/null
+++ b/bigint/bigint.d.ts
@@ -0,0 +1,371 @@
+// Type definitions for BigInt v5.5.1
+// Project: https://github.com/Evgenus/BigInt
+// Definitions by: Eugene Chernyshov
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module BigInt {
+ export interface BigInt extends Array {
+ }
+
+ export interface IRandom {
+ (): number;
+ }
+
+ export function setRandom(random: IRandom): void;
+
+ /**
+ * bigInt add(x,y)
+ * return (x+y) for bigInts x and y.
+ */
+ export function add(x: BigInt, y: BigInt): BigInt;
+
+ /**
+ * bigInt addInt(x,n)
+ * return (x+n) where x is a bigInt and n is an integer.
+ */
+ export function addInt(x: BigInt, n: number): BigInt;
+
+ interface bigInt2str_T {
+ /**
+ * string bigInt2str(x,base)
+ * return a string form of bigInt x in a given base, with 2 <= base <= 95
+ */
+ (x: BigInt, base: T): string;
+ }
+
+ interface bigInt2strSignature extends bigInt2str_T, bigInt2str_T{
+ }
+
+ export var bigInt2str: bigInt2strSignature;
+
+ /**
+ * int bitSize(x)
+ * return how many bits long the bigInt x is, not counting leading zeros
+ */
+ export function bitSize(x: BigInt): number;
+
+ /**
+ * bigInt dup(x)
+ * return a copy of bigInt x
+ */
+ export function dup(x: BigInt): BigInt;
+
+ /**
+ * boolean equals(x,y)
+ * is the bigInt x equal to the bigint y?
+ */
+ export function equals(x: BigInt, y: BigInt): boolean;
+
+ /**
+ * boolean equalsInt(x,y)
+ * is bigint x equal to integer y?
+ */
+ export function equalsInt(x: BigInt, y: number): boolean;
+
+ /**
+ * bigInt expand(x,n)
+ * return a copy of x with at least n elements, adding leading zeros if needed
+ */
+ export function expand(value: BigInt, n: number): BigInt;
+
+ /**
+ * Array findPrimes(n)
+ * return array of all primes less than integer n
+ */
+ export function findPrimes(n: number): number[];
+
+ /**
+ * bigInt GCD(x,y)
+ * return greatest common divisor of bigInts x and y (each with same number of elements).
+ */
+ export function GCD(x: BigInt, y: BigInt): BigInt;
+
+ /**
+ * boolean greater(x,y)
+ * is x>y? (x and y are nonnegative bigInts)
+ */
+ export function greater(x: BigInt, y: BigInt): boolean;
+
+ /**
+ * boolean greaterShift(x,y,shift)
+ * is (x <<(shift*bpe)) > y?
+ */
+ export function greaterShift(x: BigInt, y: BigInt, shift: number): boolean;
+
+ /**
+ * bigInt int2bigInt(t,n,m)
+ * return a bigInt equal to integer t, with at least n bits and m array elements
+ */
+ export function int2bigInt(t: number, n?: number, m?: number): BigInt;
+
+ /**
+ * bigInt inverseMod(x,n)
+ * return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null
+ */
+ export function inverseMod(x: BigInt, n: BigInt): BigInt;
+
+ /**
+ * int inverseModInt(x,n)
+ * return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse
+ */
+ export function inverseModInt(x: number, n: number): BigInt;
+
+ /**
+ * boolean isZero(x)
+ * is the bigInt x equal to zero?
+ */
+ export function isZero(x: BigInt): boolean;
+
+ /**
+ * boolean millerRabin(x,b)
+ * does one round of Miller-Rabin base integer b say that bigInt x is possibly prime? (b is bigInt, 1=1). If s=1, then the most significant of those n bits is set to 1.
+ */
+ export function randBigInt(n: number, s: number): BigInt;
+
+ /**
+ * bigInt randTruePrime(k)
+ * return a new, random, k-bit, true prime bigInt using Maurer's algorithm.
+ */
+ export function randTruePrime(k: number): BigInt;
+
+ /**
+ * bigInt randProbPrime(k)
+ * return a new, random, k-bit, probable prime bigInt (probability it's composite less than 2^-80).
+ */
+ export function randProbPrime(k: number): BigInt;
+
+ interface str2bigInt_T {
+ /**
+ * bigInt str2bigInt(s,b,n,m)
+ * return a bigInt for number represented in string s in base b with at least n bits and m array elements
+ */
+ (s: string, b: T, n?: number, m?: number): BigInt;
+ }
+
+ interface str2bigIntSignature extends str2bigInt_T, str2bigInt_T {
+ }
+
+ export var str2bigInt: str2bigIntSignature;
+
+ /**
+ * bigInt sub(x,y)
+ * return (x-y) for bigInts x and y. Negative answers will be 2s complement
+ */
+ export function sub(x: BigInt, y: BigInt): BigInt;
+
+ /**
+ * bigInt trim(x,k)
+ * return a copy of x with exactly k leading zero elements
+ */
+ export function trim(x: BigInt, k: number): BigInt;
+
+ /**
+ * void addInt_(x,n)
+ * do x=x+n where x is a bigInt and n is an integer
+ */
+ export function addInt_(x: BigInt, n: number): void;
+
+ /**
+ * void add_(x,y)
+ * do x=x+y for bigInts x and y
+ */
+ export function add_(x: BigInt, y: BigInt): void;
+
+ /**
+ * void copy_(x,y)
+ * do x=y on bigInts x and y
+ */
+ export function copy_(x: BigInt, y: BigInt): void;
+
+ /**
+ * void copyInt_(x,n)
+ * do x=n on bigInt x and integer n
+ */
+ export function copyInt_(x: BigInt, n: number): number;
+
+ /**
+ * void GCD_(x,y)
+ * set x to the greatest common divisor of bigInts x and y, (y is destroyed). (This never overflows its array).
+ */
+ export function GCD_(x: BigInt, y: BigInt): void;
+
+ /**
+ * boolean inverseMod_(x,n)
+ * do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist
+ */
+ export function inverseMod_(x: BigInt, n: BigInt): boolean;
+
+ /**
+ * void mod_(x,n)
+ * do x=x mod n for bigInts x and n. (This never overflows its array).
+ */
+ export function mod_(x: BigInt, n: BigInt): void;
+
+ /**
+ * void mult_(x,y)
+ * do x=x*y for bigInts x and y.
+ */
+ export function mult_(x: BigInt, y: BigInt): void;
+
+ /**
+ * void multMod_(x,y,n)
+ * do x=x*y mod n for bigInts x,y,n.
+ */
+ export function multMod_(x: BigInt, y: BigInt, n: BigInt): void;
+
+ /**
+ * void powMod_(x,y,n)
+ * do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation. 0**0=1.
+ */
+ export function powMod_(x: BigInt, y: BigInt, n: BigInt): void;
+
+ /**
+ * void randBigInt_(b,n,s)
+ * do b = an n-bit random BigInt. if s=1, then nth bit (most significant bit) is set to 1. n>=1.
+ */
+ export function randBigInt_(b: BigInt, n: number, s: number): void;
+
+ /**
+ * void randTruePrime_(ans,k)
+ * do ans = a random k-bit true random prime (not just probable prime) with 1 in the msb.
+ */
+ export function randTruePrime_(ans: BigInt, k: number): void;
+
+ /**
+ * void sub_(x,y)
+ * do x=x-y for bigInts x and y. Negative answers will be 2s complement.
+ */
+ export function sub_(x: BigInt, y: BigInt): void;
+
+ /**
+ * void addShift_(x,y,ys)
+ * do x=x+(y<<(ys*bpe))
+ */
+ export function addShift_(x: BigInt, y: BigInt, ys: number): void;
+
+ /**
+ * void carry_(x)
+ * do carries and borrows so each element of the bigInt x fits in bpe bits.
+ */
+ export function carry_(x: BigInt): void;
+
+ /**
+ * void divide_(x,y,q,r)
+ * divide x by y giving quotient q and remainder r
+ */
+ export function divide_(x: BigInt, y: BigInt, q: BigInt, r: BigInt): void;
+
+ /**
+ * int divInt_(x,n)
+ * do x=floor(x/n) for bigInt x and integer n, and return the remainder. (This never overflows its array).
+ */
+ export function divInt_(x: BigInt, n: number): number;
+
+ /**
+ * void eGCD_(x,y,d,a,b)
+ * sets a,b,d to positive bigInts such that d = GCD_(x,y) = a*x-b*y
+ */
+ export function eGCD_(x: BigInt, y: BigInt, d: BigInt, a: BigInt, b: BigInt): void;
+
+ /**
+ * void halve_(x)
+ * do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement. (This never overflows its array).
+ */
+ export function halve_(x: BigInt): void;
+
+ /**
+ * void leftShift_(x,n)
+ * left shift bigInt x by n bits. n, VILIC VANE , Jonathan Häberle
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "body-parser" {
+ import express = require('express');
+
+ /**
+ * bodyParser: use individual json/urlencoded middlewares
+ * @deprecated
+ */
+
+ function bodyParser(options?: {
+ /**
+ * if deflated bodies will be inflated. (default: true)
+ */
+ inflate?: boolean;
+ /**
+ * maximum request body size. (default: '100kb')
+ */
+ limit?: any;
+ /**
+ * function to verify body content, the parsing can be aborted by throwing an error.
+ */
+ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
+ /**
+ * only parse objects and arrays. (default: true)
+ */
+ strict?: boolean;
+ /**
+ * passed to JSON.parse().
+ */
+ receiver?: (key: string, value: any) => any;
+ /**
+ * parse extended syntax with the qs module. (default: true)
+ */
+ extended?: boolean;
+ }): express.RequestHandler;
+
+ module bodyParser {
+ export function json(options?: {
+ /**
+ * if deflated bodies will be inflated. (default: true)
+ */
+ inflate?: boolean;
+ /**
+ * maximum request body size. (default: '100kb')
+ */
+ limit?: any;
+ /**
+ * request content-type to parse, passed directly to the type-is library. (default: 'json')
+ */
+ type?: any;
+ /**
+ * function to verify body content, the parsing can be aborted by throwing an error.
+ */
+ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
+ /**
+ * only parse objects and arrays. (default: true)
+ */
+ strict?: boolean;
+ /**
+ * passed to JSON.parse().
+ */
+ receiver?: (key: string, value: any) => any;
+ }): express.RequestHandler;
+
+ export function raw(options?: {
+ /**
+ * if deflated bodies will be inflated. (default: true)
+ */
+ inflate?: boolean;
+ /**
+ * maximum request body size. (default: '100kb')
+ */
+ limit?: any;
+ /**
+ * request content-type to parse, passed directly to the type-is library. (default: 'application/octet-stream')
+ */
+ type?: any;
+ /**
+ * function to verify body content, the parsing can be aborted by throwing an error.
+ */
+ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
+ }): express.RequestHandler;
+
+ export function text(options?: {
+ /**
+ * if deflated bodies will be inflated. (default: true)
+ */
+ inflate?: boolean;
+ /**
+ * maximum request body size. (default: '100kb')
+ */
+ limit?: any;
+ /**
+ * request content-type to parse, passed directly to the type-is library. (default: 'text/plain')
+ */
+ type?: any;
+ /**
+ * function to verify body content, the parsing can be aborted by throwing an error.
+ */
+ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
+ /**
+ * the default charset to parse as, if not specified in content-type. (default: 'utf-8')
+ */
+ defaultCharset?: string;
+ }): express.RequestHandler;
+
+ export function urlencoded(options?: {
+ /**
+ * if deflated bodies will be inflated. (default: true)
+ */
+ inflate?: boolean;
+ /**
+ * maximum request body size. (default: '100kb')
+ */
+ limit?: any;
+ /**
+ * request content-type to parse, passed directly to the type-is library. (default: 'urlencoded')
+ */
+ type?: any;
+ /**
+ * function to verify body content, the parsing can be aborted by throwing an error.
+ */
+ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void;
+ /**
+ * parse extended syntax with the qs module. (default: true)
+ */
+ extended?: boolean;
+ }): express.RequestHandler;
+ }
+
+ export = bodyParser;
+}
\ No newline at end of file
diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts
index 5326abaeb..02ac29bf2 100644
--- a/browserify/browserify.d.ts
+++ b/browserify/browserify.d.ts
@@ -22,6 +22,8 @@ interface BrowserifyObject extends NodeJS.EventEmitter {
ignore(file: string): BrowserifyObject;
transform(tr: string): BrowserifyObject;
transform(tr: Function): BrowserifyObject;
+ plugin(plugin: string, opts?: any): BrowserifyObject;
+ plugin(plugin: Function, opts?: any): BrowserifyObject;
}
declare module "browserify" {
@@ -33,4 +35,4 @@ declare module "browserify" {
}): BrowserifyObject;
export = browserify;
-}
\ No newline at end of file
+}
diff --git a/bucks/bucks-tests.ts b/bucks/bucks-tests.ts
new file mode 100644
index 000000000..5ebbd882c
--- /dev/null
+++ b/bucks/bucks-tests.ts
@@ -0,0 +1,222 @@
+///
+
+function add_and_end() {
+ //
+ // new Bucks object
+ //
+ var b = new Bucks();
+
+ //
+ // Add and add several tasks.
+ //
+ b.add(function f1(err, res) {
+
+ return 'a';
+
+ }).add(function f2(err, res, next) {
+
+ // res => 'a'
+ return next(null, 3);
+
+ }).add(function f3(err, res, next) {
+
+ // res => 3
+ return next(new Error('error after 3'));
+
+ }).add(function f4(err, res, next) {
+
+ // err => 'error after 3'
+ return next(null, "recover 4");
+
+ }).add(function f5(err, res) {
+
+ // res => 'recover 4'
+ throw new Error('error in f5');
+
+ }).add(function f6(err, res) {
+
+ // err => 'error in f5'
+ throw err;
+
+ }).add(function f7(err, res) {
+
+ // err => 'error in f5'
+ // ignore and return
+ return "recover 7";
+
+ }).add(function f8(err, res, next) {
+
+ // res => 'recover 7';
+ throw new Error('error in f8');
+
+ }).add(function f9(err, res, next) {
+
+ // err => 'Error in f8'
+ // ignore error
+ return next(null, 'result of 9');
+
+ }).end(function last(err, results) {
+
+ // all of results
+ // are obtained in #end
+
+ // err => null
+
+ // results => [
+ // 'a',
+ // null,
+ // null,
+ // 'recover 4',
+ // null,
+ // null,
+ // 'recover 7',
+ // null,
+ // 'result of 9'
+ // ];
+ });
+}
+
+function then() {
+ var b = new Bucks();
+ b.then(function start() {
+ return 'start';
+ }).then(function second(res, next) {
+ // res => 'start'
+ return next(null, 'second')
+ }).end();
+}
+
+function delay() {
+ var b = new Bucks();
+ b.add(function (){ /** program */ })
+ .delay(1 * 1000) // 1ms
+ .add(function() { /** program */})
+ .end();
+}
+
+function error() {
+ var b = new Bucks();
+ b.then(function start() {
+ throw new Error('error in start');
+ return 'start';
+ }).error(function onError(e, next) {
+ // e => 'error in start'
+ return next();
+ }).end();
+}
+
+function final_errorback_in_end() {
+ //
+ // last error back
+ //
+ var b = new Bucks();
+ b.empty(
+ // add empty task (#end with no task cause error)
+ ).end(function last(err, res) {
+ // error in last callback
+ throw new Error('error in end');
+ }, function finalErrorback(err) {
+ // catch uncaught error in last callback
+ // err => 'error in end'
+ });
+}
+
+function uncaught_error() {
+ try {
+ var b = new Bucks();
+ b.then(function () {
+ throw new Error('error');
+ }).end();
+ } catch(e) {
+ // e => 'error'
+ }
+}
+
+function waterfall() {
+ var t1: Bucks.Task = function t1(err, res) {
+ return 't1';
+ };
+ var t2: Bucks.Task = function t2(err, res) {
+ return 't2';
+ };
+
+ new Bucks().waterfall([t1, t2]).end(function finish(err, ress) {
+ // ress => ['t1', 't2']
+ });
+
+ // same as
+ new Bucks().add(t1).add(t2).end(function finish(err, ress) {
+ // ress => ['t1', 't2']
+ });
+}
+
+function parallel() {
+ var b = new Bucks();
+
+ b.parallel([
+ function task1(err, res) {
+ return "task1";
+ },
+ function task2(err, res, next) {
+ return next(null, "task2");
+ },
+ function task3(err, res, next) {
+ return next(new Error('passed error in task3'));
+ },
+ function task4(err, res, next) {
+ throw new Error('thrown error in task4');
+ }
+ ]).add(function getResults(err, res, next) {
+ // res => {
+ // err: [
+ // null,
+ // null,
+ // [Error: passed error in task3],
+ // [Error: thrown error in task4]
+ // ],
+ // res: [
+ // 'task1',
+ // 'task2',
+ // null,
+ // null
+ // ]
+ // }
+ next();
+ }).end();
+}
+
+function onError() {
+ var onError = function (e: Error, bucks: Bucks.Bucks) {
+ console.log("Custom onError");
+ };
+
+ // Bucks.onError!!
+ Bucks.onError(onError);
+ var b0 = new Bucks();
+ b0
+ .add(function(err, next) {
+ throw new Error('b0');
+ })
+ .end()
+ ;
+}
+
+function dispose() {
+ var b0 = new Bucks();
+
+ b0.dispose = function dispose () {
+ // delete b0.dummy;
+ }
+
+ b0
+ .add(function(err, next) {
+ // b0.dummy = "dummy";
+ next();
+ })
+ .end(null, null)
+ ;
+}
+
+function debug() {
+ Bucks.DEBUG = true;
+}
diff --git a/bucks/bucks.d.ts b/bucks/bucks.d.ts
new file mode 100644
index 000000000..cac3c7121
--- /dev/null
+++ b/bucks/bucks.d.ts
@@ -0,0 +1,113 @@
+// Type definitions for bucks.js 0.8.3
+// Project: https://github.com/CyberAgent/bucks.js
+// Definitions by: Shunsuke Ohtani
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module Bucks {
+
+ interface BucksStatic {
+
+ /**
+ * bucks.js version.
+ */
+ VERSION: string;
+
+ /**
+ * If set `true`, uncaught errors are logged.
+ */
+ DEBUG: boolean;
+
+ /**
+ * Running bucks objects.
+ */
+ running: Bucks[];
+
+ /**
+ * Not yet called `end` bucks object.
+ */
+ living: Bucks[];
+
+ /**
+ * Create bucks object.
+ */
+ new(): Bucks;
+
+ /**
+ * Catch all errors.
+ * @param onError Function called after catching error
+ */
+ onError(onError: (err:Error, bucks:Bucks)=>any): void;
+ }
+
+ interface Bucks {
+
+ /**
+ * Add a task.
+ * @param task Function added async chain
+ */
+ add(task: TaskWithNext): Bucks;
+
+ /**
+ * Add a task called only in case of success.
+ * @param onSuccess Function called only in case of success
+ */
+ then(onSuccess: (res:any, next?:Task)=>any): Bucks;
+
+ /**
+ * Add a empty task.
+ */
+ empty(): Bucks;
+
+ /**
+ * Add a task called only in case of error.
+ * @param onError Function called only in case of error
+ */
+ error(onError: (err:Error, next?:Task)=>any): Bucks;
+
+ /**
+ * Add tasks in asynchronous way and join their results.
+ * @param tasks Functions called in asynchronous way and join their results
+ */
+ parallel(tasks: TaskWithNext[]): Bucks;
+
+ /**
+ * Add tasks in asynchronous way and join their results.
+ * @param tasks Functions added async chain
+ */
+ waterfall(tasks: TaskWithNext[]): Bucks;
+
+ /**
+ * Add delay execution.
+ * @param ms number millisecond for delaying
+ */
+ delay(ms: number): Bucks;
+
+ /**
+ * Called when destroy async chain.
+ */
+ dispose(): void;
+
+ /**
+ * Destroy this object and call last callback function.
+ * @param err If specify err and no callback, throw to execute failure callback
+ */
+ destroy(err?: Error): Bucks;
+
+ /**
+ * Complete creating async chain and start executing.
+ * @param callback Last callback function
+ * @param errback Handler for occurring error in last callback function
+ */
+ end(callback?: Task, errback?: (err:Error)=>any): void;
+ }
+
+ interface TaskWithNext {
+ (err?: Error, res?: any, next?: Task): any;
+ }
+
+ interface Task {
+ (err?: Error, res?: any): any;
+ }
+}
+
+declare var Bucks: Bucks.BucksStatic;
diff --git a/chai-datetime/chai-datetime-tests.ts b/chai-datetime/chai-datetime-tests.ts
index 0b7ff729f..8f8238b4e 100644
--- a/chai-datetime/chai-datetime-tests.ts
+++ b/chai-datetime/chai-datetime-tests.ts
@@ -1,8 +1,8 @@
///
-///
///
var expect = chai.expect;
+var assert = chai.assert;
function test_equalTime(){
var date: Date = new Date(2014, 1, 1);
@@ -44,4 +44,4 @@ function test_afterDate(){
expect(date).to.afterDate(date);
date.should.afterDate(date);
assert.afterDate(date, date);
-}
\ No newline at end of file
+}
diff --git a/chai-fuzzy/chai-fuzzy-assert.d.ts b/chai-fuzzy/chai-fuzzy.d.ts
similarity index 91%
rename from chai-fuzzy/chai-fuzzy-assert.d.ts
rename to chai-fuzzy/chai-fuzzy.d.ts
index f75f99d55..0cbb1741b 100644
--- a/chai-fuzzy/chai-fuzzy-assert.d.ts
+++ b/chai-fuzzy/chai-fuzzy.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Bart van der Schoor
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-///
+///
declare module chai {
interface Assert {
@@ -14,4 +14,4 @@ declare module chai {
jsonOf(act:any, exp:any, msg?:string);
notJsonOf(act:any, exp:any, msg?:string);
}
-}
\ No newline at end of file
+}
diff --git a/chai-fuzzy/chai-fuzzy-assert.d.ts.tscparams b/chai-fuzzy/chai-fuzzy.d.ts.tscparams
similarity index 100%
rename from chai-fuzzy/chai-fuzzy-assert.d.ts.tscparams
rename to chai-fuzzy/chai-fuzzy.d.ts.tscparams
diff --git a/chai/chai-assert-tests.ts b/chai/chai-assert-tests.ts
deleted file mode 100644
index 4dc430f0c..000000000
--- a/chai/chai-assert-tests.ts
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
-
----------
- test extracted from original test suite
- chai original licence follows
----------
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2011-2013 Jake Luer
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-///
-
-//stubs
-
-//tdd
-declare function suite(description: string, action: Function):void;
-declare function test(description: string, action: Function):void;
-declare function err(action: any, msg?: string):void;
-interface FieldObj {
- field: any;
-}
-class Foo {
- constructor() {
-
- }
-}
-
-class CrashyObject {
- inspect (): void {
- throw new Error("Arg's inspect() called even though the test passed");
- }
-}
-
-suite('assert', function () {
-
- test('assert', function () {
- var foo = 'bar';
- assert(foo == 'bar', "expected foo to equal `bar`");
-
- err(function () {
- assert(foo == 'baz', "expected foo to equal `bar`");
- }, "expected foo to equal `bar`");
- });
-
- test('isTrue', function () {
- assert.isTrue(true);
-
- err(function () {
- assert.isTrue(false);
- }, "expected false to be true");
-
- err(function () {
- assert.isTrue(1);
- }, "expected 1 to be true");
-
- err(function () {
- assert.isTrue('test');
- }, "expected 'test' to be true");
- });
-
- test('ok', function () {
- assert.ok(true);
- assert.ok(1);
- assert.ok('test');
-
- err(function () {
- assert.ok(false);
- }, "expected false to be truthy");
-
- err(function () {
- assert.ok(0);
- }, "expected 0 to be truthy");
-
- err(function () {
- assert.ok('');
- }, "expected '' to be truthy");
- });
-
- test('isFalse', function () {
- assert.isFalse(false);
-
- err(function () {
- assert.isFalse(true);
- }, "expected true to be false");
-
- err(function () {
- assert.isFalse(0);
- }, "expected 0 to be false");
- });
-
- test('equal', function () {
- var foo: any;
- assert.equal(foo, undefined);
- });
-
- test('typeof / notTypeOf', function () {
- assert.typeOf('test', 'string');
- assert.typeOf(true, 'boolean');
- assert.typeOf(5, 'number');
-
- err(function () {
- assert.typeOf(5, 'string');
- }, "expected 5 to be a string");
-
- });
-
- test('notTypeOf', function () {
- assert.notTypeOf('test', 'number');
-
- err(function () {
- assert.notTypeOf(5, 'number');
- }, "expected 5 not to be a number");
- });
-
- test('instanceOf', function () {
- assert.instanceOf(new Foo(), Foo);
-
- err(function () {
- assert.instanceOf(5, Foo);
- }, "expected 5 to be an instance of Foo");
- assert.instanceOf(new CrashyObject(), CrashyObject);
- });
-
- test('notInstanceOf', function () {
- assert.notInstanceOf(new Foo(), String);
-
- err(function () {
- assert.notInstanceOf(new Foo(), Foo);
- }, "expected {} to not be an instance of Foo");
- });
-
- test('isObject', function () {
- assert.isObject({});
- assert.isObject(new Foo());
-
- err(function () {
- assert.isObject(true);
- }, "expected true to be an object");
-
- err(function () {
- assert.isObject(Foo);
- }, "expected [Function: Foo] to be an object");
-
- err(function () {
- assert.isObject('foo');
- }, "expected 'foo' to be an object");
- });
-
- test('isNotObject', function () {
- assert.isNotObject(5);
-
- err(function () {
- assert.isNotObject({});
- }, "expected {} not to be an object");
- });
-
- test('notEqual', function () {
- assert.notEqual(3, 4);
-
- err(function () {
- assert.notEqual(5, 5);
- }, "expected 5 to not equal 5");
- });
-
- test('strictEqual', function () {
- assert.strictEqual('foo', 'foo');
-
- err(function () {
- assert.strictEqual('5', 5);
- }, "expected \'5\' to equal 5");
- });
-
- test('notStrictEqual', function () {
- assert.notStrictEqual(5, '5');
-
- err(function () {
- assert.notStrictEqual(5, 5);
- }, "expected 5 to not equal 5");
- });
-
- test('deepEqual', function () {
- assert.deepEqual({tea: 'chai'}, {tea: 'chai'});
-
- err(function () {
- assert.deepEqual({tea: 'chai'}, {tea: 'black'});
- }, "expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
-
- var obja = Object.create({ tea: 'chai' })
- , objb = Object.create({ tea: 'chai' });
-
- assert.deepEqual(obja, objb);
-
- var obj1 = Object.create({tea: 'chai'})
- , obj2 = Object.create({tea: 'black'});
-
- err(function () {
- assert.deepEqual(obj1, obj2);
- }, "expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
- });
-
- test('deepEqual (ordering)', function () {
- var a = { a: 'b', c: 'd' }
- , b = { c: 'd', a: 'b' };
- assert.deepEqual(a, b);
- });
-
- test('deepEqual (circular)', function () {
- var circularObject:any = {}
- , secondCircularObject:any = {};
- circularObject.field = circularObject;
- secondCircularObject.field = secondCircularObject;
-
- assert.deepEqual(circularObject, secondCircularObject);
-
- err(function () {
- secondCircularObject.field2 = secondCircularObject;
- assert.deepEqual(circularObject, secondCircularObject);
- }, "expected { field: [Circular] } to deeply equal { Object (field, field2) }");
- });
-
- test('notDeepEqual', function () {
- assert.notDeepEqual({tea: 'jasmine'}, {tea: 'chai'});
- err(function () {
- assert.notDeepEqual({tea: 'chai'}, {tea: 'chai'});
- }, "expected { tea: \'chai\' } to not deeply equal { tea: \'chai\' }");
- });
-
- test('notDeepEqual (circular)', function () {
- var circularObject:any = {}
- , secondCircularObject:any = { tea: 'jasmine' };
- circularObject.field = circularObject;
- secondCircularObject.field = secondCircularObject;
-
- assert.notDeepEqual(circularObject, secondCircularObject);
-
- err(function () {
- delete secondCircularObject.tea;
- assert.notDeepEqual(circularObject, secondCircularObject);
- }, "expected { field: [Circular] } to not deeply equal { field: [Circular] }");
- });
-
- test('isNull', function () {
- assert.isNull(null);
-
- err(function () {
- assert.isNull(undefined);
- }, "expected undefined to equal null");
- });
-
- test('isNotNull', function () {
- assert.isNotNull(undefined);
-
- err(function () {
- assert.isNotNull(null);
- }, "expected null to not equal null");
- });
-
- test('isUndefined', function () {
- assert.isUndefined(undefined);
-
- err(function () {
- assert.isUndefined(null);
- }, "expected null to equal undefined");
- });
-
- test('isDefined', function () {
- assert.isDefined(null);
-
- err(function () {
- assert.isDefined(undefined);
- }, "expected undefined to not equal undefined");
- });
-
- test('isFunction', function () {
- var func = function () {
- };
- assert.isFunction(func);
-
- err(function () {
- assert.isFunction({});
- }, "expected {} to be a function");
- });
-
- test('isNotFunction', function () {
- assert.isNotFunction(5);
-
- err(function () {
- assert.isNotFunction(function () {
- });
- }, "expected [Function] not to be a function");
- });
-
- test('isArray', function () {
- assert.isArray([]);
- assert.isArray(new Array());
-
- err(function () {
- assert.isArray({});
- }, "expected {} to be an array");
- });
-
- test('isNotArray', function () {
- assert.isNotArray(3);
-
- err(function () {
- assert.isNotArray([]);
- }, "expected [] not to be an array");
-
- err(function () {
- assert.isNotArray(new Array());
- }, "expected [] not to be an array");
- });
-
- test('isString', function () {
- assert.isString('Foo');
- assert.isString(new String('foo'));
-
- err(function () {
- assert.isString(1);
- }, "expected 1 to be a string");
- });
-
- test('isNotString', function () {
- assert.isNotString(3);
- assert.isNotString([ 'hello' ]);
-
- err(function () {
- assert.isNotString('hello');
- }, "expected 'hello' not to be a string");
- });
-
- test('isNumber', function () {
- assert.isNumber(1);
- assert.isNumber(Number('3'));
-
- err(function () {
- assert.isNumber('1');
- }, "expected \'1\' to be a number");
- });
-
- test('isNotNumber', function () {
- assert.isNotNumber('hello');
- assert.isNotNumber([ 5 ]);
-
- err(function () {
- assert.isNotNumber(4);
- }, "expected 4 not to be a number");
- });
-
- test('isBoolean', function () {
- assert.isBoolean(true);
- assert.isBoolean(false);
-
- err(function () {
- assert.isBoolean('1');
- }, "expected \'1\' to be a boolean");
- });
-
- test('isNotBoolean', function () {
- assert.isNotBoolean('true');
-
- err(function () {
- assert.isNotBoolean(true);
- }, "expected true not to be a boolean");
-
- err(function () {
- assert.isNotBoolean(false);
- }, "expected false not to be a boolean");
- });
-
- test('include', function () {
- assert.include('foobar', 'bar');
- assert.include([ 1, 2, 3], 3);
-
- err(function () {
- assert.include('foobar', 'baz');
- }, "expected \'foobar\' to contain \'baz\'");
-
- err(function () {
- assert.include(undefined, 'bar');
- }, "expected an array or string");
- });
-
- test('notInclude', function () {
- assert.notInclude('foobar', 'baz');
- assert.notInclude([ 1, 2, 3 ], 4);
-
- err(function () {
- assert.notInclude('foobar', 'bar');
- }, "expected \'foobar\' to not contain \'bar\'");
-
- err(function () {
- assert.notInclude(undefined, 'bar');
- }, "expected an array or string");
- });
-
- test('lengthOf', function () {
- assert.lengthOf([1, 2, 3], 3);
- assert.lengthOf('foobar', 6);
-
- err(function () {
- assert.lengthOf('foobar', 5);
- }, "expected 'foobar' to have a length of 5 but got 6");
-
- err(function () {
- assert.lengthOf(1, 5);
- }, "expected 1 to have a property \'length\'");
- });
-
- test('match', function () {
- assert.match('foobar', /^foo/);
- assert.notMatch('foobar', /^bar/);
-
- err(function () {
- assert.match('foobar', /^bar/i);
- }, "expected 'foobar' to match /^bar/i");
-
- err(function () {
- assert.notMatch('foobar', /^foo/i);
- }, "expected 'foobar' not to match /^foo/i");
- });
-
- test('property', function () {
- var obj = { foo: { bar: 'baz' } };
- var simpleObj = { foo: 'bar' };
- assert.property(obj, 'foo');
- assert.deepProperty(obj, 'foo.bar');
- assert.notProperty(obj, 'baz');
- assert.notProperty(obj, 'foo.bar');
- assert.notDeepProperty(obj, 'foo.baz');
- assert.deepPropertyVal(obj, 'foo.bar', 'baz');
- assert.deepPropertyNotVal(obj, 'foo.bar', 'flow');
-
- err(function () {
- assert.property(obj, 'baz');
- }, "expected { foo: { bar: 'baz' } } to have a property 'baz'");
-
- err(function () {
- assert.deepProperty(obj, 'foo.baz');
- }, "expected { foo: { bar: 'baz' } } to have a deep property 'foo.baz'");
-
- err(function () {
- assert.notProperty(obj, 'foo');
- }, "expected { foo: { bar: 'baz' } } to not have property 'foo'");
-
- err(function () {
- assert.notDeepProperty(obj, 'foo.bar');
- }, "expected { foo: { bar: 'baz' } } to not have deep property 'foo.bar'");
-
- err(function () {
- assert.propertyVal(simpleObj, 'foo', 'ball');
- }, "expected { foo: 'bar' } to have a property 'foo' of 'ball', but got 'bar'");
-
- err(function () {
- assert.deepPropertyVal(obj, 'foo.bar', 'ball');
- }, "expected { foo: { bar: 'baz' } } to have a deep property 'foo.bar' of 'ball', but got 'baz'");
-
- err(function () {
- assert.propertyNotVal(simpleObj, 'foo', 'bar');
- }, "expected { foo: 'bar' } to not have a property 'foo' of 'bar'");
-
- err(function () {
- assert.deepPropertyNotVal(obj, 'foo.bar', 'baz');
- }, "expected { foo: { bar: 'baz' } } to not have a deep property 'foo.bar' of 'baz'");
- });
-
- test('throws', function () {
- assert.throws(function () {
- throw new Error('foo');
- });
- assert.throws(function () {
- throw new Error('bar');
- }, 'bar');
- assert.throws(function () {
- throw new Error('bar');
- }, /bar/);
- assert.throws(function () {
- throw new Error('bar');
- }, Error);
- assert.throws(function () {
- throw new Error('bar');
- }, Error, 'bar');
-
- err(function () {
- assert.throws(function () {
- throw new Error('foo')
- }, TypeError);
- }, "expected [Function] to throw 'TypeError' but [Error: foo] was thrown")
-
- err(function () {
- assert.throws(function () {
- throw new Error('foo')
- }, 'bar');
- }, "expected [Function] to throw error including 'bar' but got 'foo'")
-
- err(function () {
- assert.throws(function () {
- throw new Error('foo')
- }, Error, 'bar');
- }, "expected [Function] to throw error including 'bar' but got 'foo'")
-
- err(function () {
- assert.throws(function () {
- throw new Error('foo')
- }, TypeError, 'bar');
- }, "expected [Function] to throw 'TypeError' but [Error: foo] was thrown")
-
- err(function () {
- assert.throws(function () {
- });
- }, "expected [Function] to throw an error");
-
- err(function () {
- assert.throws(function () {
- throw new Error('')
- }, 'bar');
- }, "expected [Function] to throw error including 'bar' but got ''");
-
- err(function () {
- assert.throws(function () {
- throw new Error('')
- }, /bar/);
- }, "expected [Function] to throw error matching /bar/ but got ''");
- });
-
- test('doesNotThrow', function () {
- assert.doesNotThrow(function () {
- });
- assert.doesNotThrow(function () {
- }, 'foo');
-
- err(function () {
- assert.doesNotThrow(function () {
- throw new Error('foo');
- });
- }, 'expected [Function] to not throw an error but [Error: foo] was thrown');
- });
-
- test('ifError', function () {
- assert.ifError(false);
- assert.ifError(null);
- assert.ifError(undefined);
-
- err(function () {
- assert.ifError('foo');
- }, "expected \'foo\' to be falsy");
- });
-
- test('operator', function () {
- assert.operator(1, '<', 2);
- assert.operator(2, '>', 1);
- assert.operator(1, '==', 1);
- assert.operator(1, '<=', 1);
- assert.operator(1, '>=', 1);
- assert.operator(1, '!=', 2);
- assert.operator(1, '!==', 2);
-
- err(function () {
- assert.operator(1, '=', 2);
- }, 'Invalid operator "="');
-
- err(function () {
- assert.operator(2, '<', 1);
- }, "expected 2 to be < 1");
-
- err(function () {
- assert.operator(1, '>', 2);
- }, "expected 1 to be > 2");
-
- err(function () {
- assert.operator(1, '==', 2);
- }, "expected 1 to be == 2");
-
- err(function () {
- assert.operator(2, '<=', 1);
- }, "expected 2 to be <= 1");
-
- err(function () {
- assert.operator(1, '>=', 2);
- }, "expected 1 to be >= 2");
-
- err(function () {
- assert.operator(1, '!=', 1);
- }, "expected 1 to be != 1");
-
- err(function () {
- assert.operator(1, '!==', '1');
- }, "expected 1 to be !== \'1\'");
- });
-
- test('closeTo', function () {
- assert.closeTo(1.5, 1.0, 0.5);
- assert.closeTo(10, 20, 20);
- assert.closeTo(-10, 20, 30);
-
- err(function () {
- assert.closeTo(2, 1.0, 0.5);
- }, "expected 2 to be close to 1 +/- 0.5");
-
- err(function () {
- assert.closeTo(-10, 20, 29);
- }, "expected -10 to be close to 20 +/- 29");
- });
-
- test('members', function () {
- assert.includeMembers([1, 2, 3], [2, 3]);
- assert.includeMembers([1, 2, 3], []);
- assert.includeMembers([1, 2, 3], [3]);
-
- err(function () {
- assert.includeMembers([5, 6], [7, 8]);
- }, 'expected [ 5, 6 ] to be a superset of [ 7, 8 ]');
-
- err(function () {
- assert.includeMembers([5, 6], [5, 6, 0]);
- }, 'expected [ 5, 6 ] to be a superset of [ 5, 6, 0 ]');
- });
-
- test('memberEquals', function () {
- assert.sameMembers([], []);
- assert.sameMembers([1, 2, 3], [3, 2, 1]);
- assert.sameMembers([4, 2], [4, 2]);
-
- err(function () {
- assert.sameMembers([], [1, 2]);
- }, 'expected [] to have the same members as [ 1, 2 ]');
-
- err(function () {
- assert.sameMembers([1, 54], [6, 1, 54]);
- }, 'expected [ 1, 54 ] to have the same members as [ 6, 1, 54 ]');
- });
-
-});
diff --git a/chai/chai-assert.d.ts b/chai/chai-assert.d.ts
deleted file mode 100644
index 30ae2deb7..000000000
--- a/chai/chai-assert.d.ts
+++ /dev/null
@@ -1,131 +0,0 @@
-// Type definitions for chai v1.9.0 assert style
-// Project: http://chaijs.com/
-// Definitions by: Bart van der Schoor
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-declare module chai {
- export class AssertionError {
- constructor(message: string, _props?: any, ssf?: Function);
- name: string;
- message: string;
- showDiff: boolean;
- stack: string;
- }
- export function use(plugin: any): void;
-
- export var Assertion: ChaiAssertion;
- export var assert: Assert;
- export var config: ChaiConfig;
-
- export interface ChaiConfig {
- includeStack: boolean;
- }
-
- export interface ChaiAssertion {
- // what?
- }
-
- export interface Assert {
- (express: any, msg?: string):void;
-
- fail(actual?: any, expected?: any, msg?: string, operator?: string):void;
-
- ok(val: any, msg?: string):void;
- notOk(val: any, msg?: string):void;
-
- equal(act: any, exp: any, msg?: string):void;
- notEqual(act: any, exp: any, msg?: string):void;
-
- strictEqual(act: any, exp: any, msg?: string):void;
- notStrictEqual(act: any, exp: any, msg?: string):void;
-
- deepEqual(act: any, exp: any, msg?: string):void;
- notDeepEqual(act: any, exp: any, msg?: string):void;
-
- isTrue(val: any, msg?: string):void;
- isFalse(val: any, msg?: string):void;
-
- isNull(val: any, msg?: string):void;
- isNotNull(val: any, msg?: string):void;
-
- isUndefined(val: any, msg?: string):void;
- isDefined(val: any, msg?: string):void;
-
- isFunction(val: any, msg?: string):void;
- isNotFunction(val: any, msg?: string):void;
-
- isObject(val: any, msg?: string):void;
- isNotObject(val: any, msg?: string):void;
-
- isArray(val: any, msg?: string):void;
- isNotArray(val: any, msg?: string):void;
-
- isString(val: any, msg?: string):void;
- isNotString(val: any, msg?: string):void;
-
- isNumber(val: any, msg?: string):void;
- isNotNumber(val: any, msg?: string):void;
-
- isBoolean(val: any, msg?: string):void;
- isNotBoolean(val: any, msg?: string):void;
-
- typeOf(val: any, type: string, msg?: string):void;
- notTypeOf(val: any, type: string, msg?: string):void;
-
- instanceOf(val: any, type: Function, msg?: string):void;
- notInstanceOf(val: any, type: Function, msg?: string):void;
-
- include(exp: string, inc: any, msg?: string):void;
- include(exp: any[], inc: any, msg?: string):void;
-
- notInclude(exp: string, inc: any, msg?: string):void;
- notInclude(exp: any[], inc: any, msg?: string):void;
-
- match(exp: any, re: RegExp, msg?: string):void;
- notMatch(exp: any, re: RegExp, msg?: string):void;
-
- property(obj: Object, prop: string, msg?: string):void;
- notProperty(obj: Object, prop: string, msg?: string):void;
- deepProperty(obj: Object, prop: string, msg?: string):void;
- notDeepProperty(obj: Object, prop: string, msg?: string):void;
-
- propertyVal(obj: Object, prop: string, val: any, msg?: string):void;
- propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
-
- deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void;
- deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
-
- lengthOf(exp: any, len: number, msg?: string):void;
- //alias frenzy
- throw(fn: Function, msg?: string):void;
- throw(fn: Function, regExp: RegExp):void;
- throw(fn: Function, errType: Function, msg?: string):void;
- throw(fn: Function, errType: Function, regExp: RegExp):void;
-
- throws(fn: Function, msg?: string):void;
- throws(fn: Function, regExp: RegExp):void;
- throws(fn: Function, errType: Function, msg?: string):void;
- throws(fn: Function, errType: Function, regExp: RegExp):void;
-
- Throw(fn: Function, msg?: string):void;
- Throw(fn: Function, regExp: RegExp):void;
- Throw(fn: Function, errType: Function, msg?: string):void;
- Throw(fn: Function, errType: Function, regExp: RegExp):void;
-
- doesNotThrow(fn: Function, msg?: string):void;
- doesNotThrow(fn: Function, regExp: RegExp):void;
- doesNotThrow(fn: Function, errType: Function, msg?: string):void;
- doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void;
-
- operator(val: any, operator: string, val2: any, msg?: string):void;
- closeTo(act: number, exp: number, delta: number, msg?: string):void;
-
- sameMembers(set1: any[], set2: any[], msg?: string):void;
- includeMembers(set1: any[], set2: any[], msg?: string):void;
-
- ifError(val: any, msg?: string):void;
- }
-}
-
-//browser global
-declare var assert:chai.Assert;
diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts
index b559c515d..98d75e8ae 100644
--- a/chai/chai-tests.ts
+++ b/chai/chai-tests.ts
@@ -1,6 +1,7 @@
///
var expect = chai.expect;
+var assert = chai.assert;
declare var err: Function;
function chaiVersion() {
@@ -767,3 +768,623 @@ function members() {
expect([5, 4]).not.members([6, 3]);
expect([5, 4]).not.members([5, 4, 2]);
}
+
+//tdd
+declare function suite(description: string, action: Function):void;
+declare function test(description: string, action: Function):void;
+
+interface FieldObj {
+ field: any;
+}
+class Foo {
+ constructor() {
+
+ }
+}
+
+class CrashyObject {
+ inspect (): void {
+ throw new Error("Arg's inspect() called even though the test passed");
+ }
+}
+
+suite('assert', function () {
+
+ test('assert', function () {
+ var foo = 'bar';
+ assert(foo == 'bar', "expected foo to equal `bar`");
+
+ err(function () {
+ assert(foo == 'baz', "expected foo to equal `bar`");
+ }, "expected foo to equal `bar`");
+ });
+
+ test('isTrue', function () {
+ assert.isTrue(true);
+
+ err(function () {
+ assert.isTrue(false);
+ }, "expected false to be true");
+
+ err(function () {
+ assert.isTrue(1);
+ }, "expected 1 to be true");
+
+ err(function () {
+ assert.isTrue('test');
+ }, "expected 'test' to be true");
+ });
+
+ test('ok', function () {
+ assert.ok(true);
+ assert.ok(1);
+ assert.ok('test');
+
+ err(function () {
+ assert.ok(false);
+ }, "expected false to be truthy");
+
+ err(function () {
+ assert.ok(0);
+ }, "expected 0 to be truthy");
+
+ err(function () {
+ assert.ok('');
+ }, "expected '' to be truthy");
+ });
+
+ test('isFalse', function () {
+ assert.isFalse(false);
+
+ err(function () {
+ assert.isFalse(true);
+ }, "expected true to be false");
+
+ err(function () {
+ assert.isFalse(0);
+ }, "expected 0 to be false");
+ });
+
+ test('equal', function () {
+ var foo: any;
+ assert.equal(foo, undefined);
+ });
+
+ test('typeof / notTypeOf', function () {
+ assert.typeOf('test', 'string');
+ assert.typeOf(true, 'boolean');
+ assert.typeOf(5, 'number');
+
+ err(function () {
+ assert.typeOf(5, 'string');
+ }, "expected 5 to be a string");
+
+ });
+
+ test('notTypeOf', function () {
+ assert.notTypeOf('test', 'number');
+
+ err(function () {
+ assert.notTypeOf(5, 'number');
+ }, "expected 5 not to be a number");
+ });
+
+ test('instanceOf', function () {
+ assert.instanceOf(new Foo(), Foo);
+
+ err(function () {
+ assert.instanceOf(5, Foo);
+ }, "expected 5 to be an instance of Foo");
+ assert.instanceOf(new CrashyObject(), CrashyObject);
+ });
+
+ test('notInstanceOf', function () {
+ assert.notInstanceOf(new Foo(), String);
+
+ err(function () {
+ assert.notInstanceOf(new Foo(), Foo);
+ }, "expected {} to not be an instance of Foo");
+ });
+
+ test('isObject', function () {
+ assert.isObject({});
+ assert.isObject(new Foo());
+
+ err(function () {
+ assert.isObject(true);
+ }, "expected true to be an object");
+
+ err(function () {
+ assert.isObject(Foo);
+ }, "expected [Function: Foo] to be an object");
+
+ err(function () {
+ assert.isObject('foo');
+ }, "expected 'foo' to be an object");
+ });
+
+ test('isNotObject', function () {
+ assert.isNotObject(5);
+
+ err(function () {
+ assert.isNotObject({});
+ }, "expected {} not to be an object");
+ });
+
+ test('notEqual', function () {
+ assert.notEqual(3, 4);
+
+ err(function () {
+ assert.notEqual(5, 5);
+ }, "expected 5 to not equal 5");
+ });
+
+ test('strictEqual', function () {
+ assert.strictEqual('foo', 'foo');
+
+ err(function () {
+ assert.strictEqual('5', 5);
+ }, "expected \'5\' to equal 5");
+ });
+
+ test('notStrictEqual', function () {
+ assert.notStrictEqual(5, '5');
+
+ err(function () {
+ assert.notStrictEqual(5, 5);
+ }, "expected 5 to not equal 5");
+ });
+
+ test('deepEqual', function () {
+ assert.deepEqual({tea: 'chai'}, {tea: 'chai'});
+
+ err(function () {
+ assert.deepEqual({tea: 'chai'}, {tea: 'black'});
+ }, "expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
+
+ var obja = Object.create({ tea: 'chai' })
+ , objb = Object.create({ tea: 'chai' });
+
+ assert.deepEqual(obja, objb);
+
+ var obj1 = Object.create({tea: 'chai'})
+ , obj2 = Object.create({tea: 'black'});
+
+ err(function () {
+ assert.deepEqual(obj1, obj2);
+ }, "expected { tea: \'chai\' } to deeply equal { tea: \'black\' }");
+ });
+
+ test('deepEqual (ordering)', function () {
+ var a = { a: 'b', c: 'd' }
+ , b = { c: 'd', a: 'b' };
+ assert.deepEqual(a, b);
+ });
+
+ test('deepEqual (circular)', function () {
+ var circularObject:any = {}
+ , secondCircularObject:any = {};
+ circularObject.field = circularObject;
+ secondCircularObject.field = secondCircularObject;
+
+ assert.deepEqual(circularObject, secondCircularObject);
+
+ err(function () {
+ secondCircularObject.field2 = secondCircularObject;
+ assert.deepEqual(circularObject, secondCircularObject);
+ }, "expected { field: [Circular] } to deeply equal { Object (field, field2) }");
+ });
+
+ test('notDeepEqual', function () {
+ assert.notDeepEqual({tea: 'jasmine'}, {tea: 'chai'});
+ err(function () {
+ assert.notDeepEqual({tea: 'chai'}, {tea: 'chai'});
+ }, "expected { tea: \'chai\' } to not deeply equal { tea: \'chai\' }");
+ });
+
+ test('notDeepEqual (circular)', function () {
+ var circularObject:any = {}
+ , secondCircularObject:any = { tea: 'jasmine' };
+ circularObject.field = circularObject;
+ secondCircularObject.field = secondCircularObject;
+
+ assert.notDeepEqual(circularObject, secondCircularObject);
+
+ err(function () {
+ delete secondCircularObject.tea;
+ assert.notDeepEqual(circularObject, secondCircularObject);
+ }, "expected { field: [Circular] } to not deeply equal { field: [Circular] }");
+ });
+
+ test('isNull', function () {
+ assert.isNull(null);
+
+ err(function () {
+ assert.isNull(undefined);
+ }, "expected undefined to equal null");
+ });
+
+ test('isNotNull', function () {
+ assert.isNotNull(undefined);
+
+ err(function () {
+ assert.isNotNull(null);
+ }, "expected null to not equal null");
+ });
+
+ test('isUndefined', function () {
+ assert.isUndefined(undefined);
+
+ err(function () {
+ assert.isUndefined(null);
+ }, "expected null to equal undefined");
+ });
+
+ test('isDefined', function () {
+ assert.isDefined(null);
+
+ err(function () {
+ assert.isDefined(undefined);
+ }, "expected undefined to not equal undefined");
+ });
+
+ test('isFunction', function () {
+ var func = function () {
+ };
+ assert.isFunction(func);
+
+ err(function () {
+ assert.isFunction({});
+ }, "expected {} to be a function");
+ });
+
+ test('isNotFunction', function () {
+ assert.isNotFunction(5);
+
+ err(function () {
+ assert.isNotFunction(function () {
+ });
+ }, "expected [Function] not to be a function");
+ });
+
+ test('isArray', function () {
+ assert.isArray([]);
+ assert.isArray(new Array());
+
+ err(function () {
+ assert.isArray({});
+ }, "expected {} to be an array");
+ });
+
+ test('isNotArray', function () {
+ assert.isNotArray(3);
+
+ err(function () {
+ assert.isNotArray([]);
+ }, "expected [] not to be an array");
+
+ err(function () {
+ assert.isNotArray(new Array());
+ }, "expected [] not to be an array");
+ });
+
+ test('isString', function () {
+ assert.isString('Foo');
+ assert.isString(new String('foo'));
+
+ err(function () {
+ assert.isString(1);
+ }, "expected 1 to be a string");
+ });
+
+ test('isNotString', function () {
+ assert.isNotString(3);
+ assert.isNotString([ 'hello' ]);
+
+ err(function () {
+ assert.isNotString('hello');
+ }, "expected 'hello' not to be a string");
+ });
+
+ test('isNumber', function () {
+ assert.isNumber(1);
+ assert.isNumber(Number('3'));
+
+ err(function () {
+ assert.isNumber('1');
+ }, "expected \'1\' to be a number");
+ });
+
+ test('isNotNumber', function () {
+ assert.isNotNumber('hello');
+ assert.isNotNumber([ 5 ]);
+
+ err(function () {
+ assert.isNotNumber(4);
+ }, "expected 4 not to be a number");
+ });
+
+ test('isBoolean', function () {
+ assert.isBoolean(true);
+ assert.isBoolean(false);
+
+ err(function () {
+ assert.isBoolean('1');
+ }, "expected \'1\' to be a boolean");
+ });
+
+ test('isNotBoolean', function () {
+ assert.isNotBoolean('true');
+
+ err(function () {
+ assert.isNotBoolean(true);
+ }, "expected true not to be a boolean");
+
+ err(function () {
+ assert.isNotBoolean(false);
+ }, "expected false not to be a boolean");
+ });
+
+ test('include', function () {
+ assert.include('foobar', 'bar');
+ assert.include([ 1, 2, 3], 3);
+
+ err(function () {
+ assert.include('foobar', 'baz');
+ }, "expected \'foobar\' to contain \'baz\'");
+
+ err(function () {
+ assert.include(undefined, 'bar');
+ }, "expected an array or string");
+ });
+
+ test('notInclude', function () {
+ assert.notInclude('foobar', 'baz');
+ assert.notInclude([ 1, 2, 3 ], 4);
+
+ err(function () {
+ assert.notInclude('foobar', 'bar');
+ }, "expected \'foobar\' to not contain \'bar\'");
+
+ err(function () {
+ assert.notInclude(undefined, 'bar');
+ }, "expected an array or string");
+ });
+
+ test('lengthOf', function () {
+ assert.lengthOf([1, 2, 3], 3);
+ assert.lengthOf('foobar', 6);
+
+ err(function () {
+ assert.lengthOf('foobar', 5);
+ }, "expected 'foobar' to have a length of 5 but got 6");
+
+ err(function () {
+ assert.lengthOf(1, 5);
+ }, "expected 1 to have a property \'length\'");
+ });
+
+ test('match', function () {
+ assert.match('foobar', /^foo/);
+ assert.notMatch('foobar', /^bar/);
+
+ err(function () {
+ assert.match('foobar', /^bar/i);
+ }, "expected 'foobar' to match /^bar/i");
+
+ err(function () {
+ assert.notMatch('foobar', /^foo/i);
+ }, "expected 'foobar' not to match /^foo/i");
+ });
+
+ test('property', function () {
+ var obj = { foo: { bar: 'baz' } };
+ var simpleObj = { foo: 'bar' };
+ assert.property(obj, 'foo');
+ assert.deepProperty(obj, 'foo.bar');
+ assert.notProperty(obj, 'baz');
+ assert.notProperty(obj, 'foo.bar');
+ assert.notDeepProperty(obj, 'foo.baz');
+ assert.deepPropertyVal(obj, 'foo.bar', 'baz');
+ assert.deepPropertyNotVal(obj, 'foo.bar', 'flow');
+
+ err(function () {
+ assert.property(obj, 'baz');
+ }, "expected { foo: { bar: 'baz' } } to have a property 'baz'");
+
+ err(function () {
+ assert.deepProperty(obj, 'foo.baz');
+ }, "expected { foo: { bar: 'baz' } } to have a deep property 'foo.baz'");
+
+ err(function () {
+ assert.notProperty(obj, 'foo');
+ }, "expected { foo: { bar: 'baz' } } to not have property 'foo'");
+
+ err(function () {
+ assert.notDeepProperty(obj, 'foo.bar');
+ }, "expected { foo: { bar: 'baz' } } to not have deep property 'foo.bar'");
+
+ err(function () {
+ assert.propertyVal(simpleObj, 'foo', 'ball');
+ }, "expected { foo: 'bar' } to have a property 'foo' of 'ball', but got 'bar'");
+
+ err(function () {
+ assert.deepPropertyVal(obj, 'foo.bar', 'ball');
+ }, "expected { foo: { bar: 'baz' } } to have a deep property 'foo.bar' of 'ball', but got 'baz'");
+
+ err(function () {
+ assert.propertyNotVal(simpleObj, 'foo', 'bar');
+ }, "expected { foo: 'bar' } to not have a property 'foo' of 'bar'");
+
+ err(function () {
+ assert.deepPropertyNotVal(obj, 'foo.bar', 'baz');
+ }, "expected { foo: { bar: 'baz' } } to not have a deep property 'foo.bar' of 'baz'");
+ });
+
+ test('throws', function () {
+ assert.throws(function () {
+ throw new Error('foo');
+ });
+ assert.throws(function () {
+ throw new Error('bar');
+ }, 'bar');
+ assert.throws(function () {
+ throw new Error('bar');
+ }, /bar/);
+ assert.throws(function () {
+ throw new Error('bar');
+ }, Error);
+ assert.throws(function () {
+ throw new Error('bar');
+ }, Error, 'bar');
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('foo')
+ }, TypeError);
+ }, "expected [Function] to throw 'TypeError' but [Error: foo] was thrown")
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('foo')
+ }, 'bar');
+ }, "expected [Function] to throw error including 'bar' but got 'foo'")
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('foo')
+ }, Error, 'bar');
+ }, "expected [Function] to throw error including 'bar' but got 'foo'")
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('foo')
+ }, TypeError, 'bar');
+ }, "expected [Function] to throw 'TypeError' but [Error: foo] was thrown")
+
+ err(function () {
+ assert.throws(function () {
+ });
+ }, "expected [Function] to throw an error");
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('')
+ }, 'bar');
+ }, "expected [Function] to throw error including 'bar' but got ''");
+
+ err(function () {
+ assert.throws(function () {
+ throw new Error('')
+ }, /bar/);
+ }, "expected [Function] to throw error matching /bar/ but got ''");
+ });
+
+ test('doesNotThrow', function () {
+ assert.doesNotThrow(function () {
+ });
+ assert.doesNotThrow(function () {
+ }, 'foo');
+
+ err(function () {
+ assert.doesNotThrow(function () {
+ throw new Error('foo');
+ });
+ }, 'expected [Function] to not throw an error but [Error: foo] was thrown');
+ });
+
+ test('ifError', function () {
+ assert.ifError(false);
+ assert.ifError(null);
+ assert.ifError(undefined);
+
+ err(function () {
+ assert.ifError('foo');
+ }, "expected \'foo\' to be falsy");
+ });
+
+ test('operator', function () {
+ assert.operator(1, '<', 2);
+ assert.operator(2, '>', 1);
+ assert.operator(1, '==', 1);
+ assert.operator(1, '<=', 1);
+ assert.operator(1, '>=', 1);
+ assert.operator(1, '!=', 2);
+ assert.operator(1, '!==', 2);
+
+ err(function () {
+ assert.operator(1, '=', 2);
+ }, 'Invalid operator "="');
+
+ err(function () {
+ assert.operator(2, '<', 1);
+ }, "expected 2 to be < 1");
+
+ err(function () {
+ assert.operator(1, '>', 2);
+ }, "expected 1 to be > 2");
+
+ err(function () {
+ assert.operator(1, '==', 2);
+ }, "expected 1 to be == 2");
+
+ err(function () {
+ assert.operator(2, '<=', 1);
+ }, "expected 2 to be <= 1");
+
+ err(function () {
+ assert.operator(1, '>=', 2);
+ }, "expected 1 to be >= 2");
+
+ err(function () {
+ assert.operator(1, '!=', 1);
+ }, "expected 1 to be != 1");
+
+ err(function () {
+ assert.operator(1, '!==', '1');
+ }, "expected 1 to be !== \'1\'");
+ });
+
+ test('closeTo', function () {
+ assert.closeTo(1.5, 1.0, 0.5);
+ assert.closeTo(10, 20, 20);
+ assert.closeTo(-10, 20, 30);
+
+ err(function () {
+ assert.closeTo(2, 1.0, 0.5);
+ }, "expected 2 to be close to 1 +/- 0.5");
+
+ err(function () {
+ assert.closeTo(-10, 20, 29);
+ }, "expected -10 to be close to 20 +/- 29");
+ });
+
+ test('members', function () {
+ assert.includeMembers([1, 2, 3], [2, 3]);
+ assert.includeMembers([1, 2, 3], []);
+ assert.includeMembers([1, 2, 3], [3]);
+
+ err(function () {
+ assert.includeMembers([5, 6], [7, 8]);
+ }, 'expected [ 5, 6 ] to be a superset of [ 7, 8 ]');
+
+ err(function () {
+ assert.includeMembers([5, 6], [5, 6, 0]);
+ }, 'expected [ 5, 6 ] to be a superset of [ 5, 6, 0 ]');
+ });
+
+ test('memberEquals', function () {
+ assert.sameMembers([], []);
+ assert.sameMembers([1, 2, 3], [3, 2, 1]);
+ assert.sameMembers([4, 2], [4, 2]);
+
+ err(function () {
+ assert.sameMembers([], [1, 2]);
+ }, 'expected [] to have the same members as [ 1, 2 ]');
+
+ err(function () {
+ assert.sameMembers([1, 54], [6, 1, 54]);
+ }, 'expected [ 1, 54 ] to have the same members as [ 6, 1, 54 ]');
+ });
+
+});
diff --git a/chai/chai.d.ts b/chai/chai.d.ts
index 058d55196..fc767c639 100644
--- a/chai/chai.d.ts
+++ b/chai/chai.d.ts
@@ -1,11 +1,25 @@
// Type definitions for chai 1.7.2
// Project: http://chaijs.com/
-// Definitions by: Jed Hunsaker
+// Definitions by: Jed Hunsaker , Bart van der Schoor
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module chai {
+ export class AssertionError {
+ constructor(message: string, _props?: any, ssf?: Function);
+ name: string;
+ message: string;
+ showDiff: boolean;
+ stack: string;
+ }
function expect(target: any, message?: string): Expect;
+
+ export var assert: Assert;
+ export var config: Config;
+
+ export interface Config {
+ includeStack: boolean;
+ }
// Provides a way to extend the internals of Chai
function use(fn: (chai: any, utils: any) => void): any;
@@ -161,6 +175,107 @@ declare module chai {
(constructor: Function, expected?: string, message?: string): Expect;
(constructor: Function, expected?: RegExp, message?: string): Expect;
}
+
+ export interface Assert {
+ (express: any, msg?: string):void;
+
+ fail(actual?: any, expected?: any, msg?: string, operator?: string):void;
+
+ ok(val: any, msg?: string):void;
+ notOk(val: any, msg?: string):void;
+
+ equal(act: any, exp: any, msg?: string):void;
+ notEqual(act: any, exp: any, msg?: string):void;
+
+ strictEqual(act: any, exp: any, msg?: string):void;
+ notStrictEqual(act: any, exp: any, msg?: string):void;
+
+ deepEqual(act: any, exp: any, msg?: string):void;
+ notDeepEqual(act: any, exp: any, msg?: string):void;
+
+ isTrue(val: any, msg?: string):void;
+ isFalse(val: any, msg?: string):void;
+
+ isNull(val: any, msg?: string):void;
+ isNotNull(val: any, msg?: string):void;
+
+ isUndefined(val: any, msg?: string):void;
+ isDefined(val: any, msg?: string):void;
+
+ isFunction(val: any, msg?: string):void;
+ isNotFunction(val: any, msg?: string):void;
+
+ isObject(val: any, msg?: string):void;
+ isNotObject(val: any, msg?: string):void;
+
+ isArray(val: any, msg?: string):void;
+ isNotArray(val: any, msg?: string):void;
+
+ isString(val: any, msg?: string):void;
+ isNotString(val: any, msg?: string):void;
+
+ isNumber(val: any, msg?: string):void;
+ isNotNumber(val: any, msg?: string):void;
+
+ isBoolean(val: any, msg?: string):void;
+ isNotBoolean(val: any, msg?: string):void;
+
+ typeOf(val: any, type: string, msg?: string):void;
+ notTypeOf(val: any, type: string, msg?: string):void;
+
+ instanceOf(val: any, type: Function, msg?: string):void;
+ notInstanceOf(val: any, type: Function, msg?: string):void;
+
+ include(exp: string, inc: any, msg?: string):void;
+ include(exp: any[], inc: any, msg?: string):void;
+
+ notInclude(exp: string, inc: any, msg?: string):void;
+ notInclude(exp: any[], inc: any, msg?: string):void;
+
+ match(exp: any, re: RegExp, msg?: string):void;
+ notMatch(exp: any, re: RegExp, msg?: string):void;
+
+ property(obj: Object, prop: string, msg?: string):void;
+ notProperty(obj: Object, prop: string, msg?: string):void;
+ deepProperty(obj: Object, prop: string, msg?: string):void;
+ notDeepProperty(obj: Object, prop: string, msg?: string):void;
+
+ propertyVal(obj: Object, prop: string, val: any, msg?: string):void;
+ propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
+
+ deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void;
+ deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
+
+ lengthOf(exp: any, len: number, msg?: string):void;
+ //alias frenzy
+ throw(fn: Function, msg?: string):void;
+ throw(fn: Function, regExp: RegExp):void;
+ throw(fn: Function, errType: Function, msg?: string):void;
+ throw(fn: Function, errType: Function, regExp: RegExp):void;
+
+ throws(fn: Function, msg?: string):void;
+ throws(fn: Function, regExp: RegExp):void;
+ throws(fn: Function, errType: Function, msg?: string):void;
+ throws(fn: Function, errType: Function, regExp: RegExp):void;
+
+ Throw(fn: Function, msg?: string):void;
+ Throw(fn: Function, regExp: RegExp):void;
+ Throw(fn: Function, errType: Function, msg?: string):void;
+ Throw(fn: Function, errType: Function, regExp: RegExp):void;
+
+ doesNotThrow(fn: Function, msg?: string):void;
+ doesNotThrow(fn: Function, regExp: RegExp):void;
+ doesNotThrow(fn: Function, errType: Function, msg?: string):void;
+ doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void;
+
+ operator(val: any, operator: string, val2: any, msg?: string):void;
+ closeTo(act: number, exp: number, delta: number, msg?: string):void;
+
+ sameMembers(set1: any[], set2: any[], msg?: string):void;
+ includeMembers(set1: any[], set2: any[], msg?: string):void;
+
+ ifError(val: any, msg?: string):void;
+ }
}
declare module "chai" {
diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts
index df5058f20..cd0be3593 100644
--- a/cheerio/cheerio.d.ts
+++ b/cheerio/cheerio.d.ts
@@ -1,7 +1,6 @@
// Type definitions for Cheerio v0.17.0
// Project: https://github.com/cheeriojs/cheerio
-// Definitions by: Bret Little
-// Definitions by: VILIC VANE
+// Definitions by: Bret Little , VILIC VANE , Wayne Maurer
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Cheerio {
@@ -190,6 +189,11 @@ interface CheerioStatic {
root(): Cheerio;
contains(container: CheerioElement, contained: CheerioElement): boolean;
parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[];
+
+ html(options?: CheerioOptionsInterface): string;
+ html(selector: string, options?: CheerioOptionsInterface): string;
+ html(element: Cheerio, options?: CheerioOptionsInterface): string;
+ html(element: CheerioElement, options?: CheerioOptionsInterface): string;
}
interface CheerioElement {
diff --git a/chroma-js/chroma-js-tests.ts b/chroma-js/chroma-js-tests.ts
new file mode 100644
index 000000000..3240ac11f
--- /dev/null
+++ b/chroma-js/chroma-js-tests.ts
@@ -0,0 +1,120 @@
+///
+
+function test_chroma() {
+ chroma("red");
+ chroma("#ff0000");
+ chroma("#f00");
+ chroma("FF0000");
+ chroma(255, 0, 0);
+ chroma([255, 0, 0]);
+ chroma(0, 1, 0.5, 'hsl');
+ chroma([0, 1, 0.5], 'hsl');
+ chroma(0, 1, 1, 'hsv');
+ chroma("rgb(255,0,0)");
+ chroma("rgb(100%,0%,0%)");
+ chroma("hsl(0,100%,50%)");
+ chroma(53.24, 80.09, 67.20, 'lab');
+ chroma(53.24, 104.55, 40, 'lch');
+ chroma(1, 0, 0, 'gl');
+
+ chroma.hex("#ff0000");
+ chroma.hex("red");
+ chroma.hex("rgb(255, 0, 0)");
+
+ chroma.rgb(255, 0, 0);
+ chroma.hsl(0, 1, 0.5);
+ chroma.hsv(120, 0.5, 0.5);
+ chroma.lab(53.24, 80.09, 67.20);
+ chroma.lch(53.24, 104.55, 40);
+ chroma.gl(1, 0, 0);
+
+ chroma.interpolate('white', 'black', 0) // #ffffff
+ chroma.interpolate('white', 'black', 1) // #000000
+ chroma.interpolate('white', 'black', 0.5) // #7f7f7f
+ chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080
+ chroma.interpolate('white', 'black', 0.5, 'lab') // #777777
+
+ chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)"
+
+ var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']);
+ bezInterpolator(0).hex() // #ffffff
+ bezInterpolator(0.33).hex() // #ffcc67
+ bezInterpolator(0.66).hex() // #b65f1a
+ bezInterpolator(1).hex() // #000000
+
+ chroma.luminance('black') // 0
+ chroma.luminance('white') // 1
+ chroma.luminance('#ff0000') // 0.2126
+
+ chroma.contrast('white', 'navy') // 16.00 – ok
+ chroma.contrast('white', 'yellow') // 1.07 – not ok!
+}
+
+function test_color() {
+ chroma('red').hex() // "#FF0000""
+ chroma('red').rgb() // [255, 0, 0]
+ chroma('red').hsv() // [0, 1, 1]
+ chroma('red').hsl() // [0, 1, 0.5]
+ chroma('red').lab() // [53.2407, 80.0924, 67.2031]
+ chroma('red').lch() // [53.2407, 104.5517, 39.9990]
+ chroma('red').rgba() // [255, 0, 0, 1]
+ chroma('red').css() // "rgb(255,0,0)"
+ chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)"
+ chroma('red').css('hsl') // "hsl(0,100%,50%)"
+ chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)"
+ chroma('blue').css('hsla') // "hsla(240,100%,50%,1)"
+
+ var red = chroma('red');
+ red.alpha(0.5);
+ red.css(); // rgba(255,0,0,0.5);
+
+ chroma('red').darken().hex() // #BC0000
+ chroma('red').brighten().hex() // #FF603B
+ chroma('#eecc99').saturate().hex() // #fcc973
+ chroma('red').desaturate().hex() // #ec3d23
+
+ chroma('black').luminance() // 0
+ chroma('white').luminance() // 1
+ chroma('red').luminance() // 0.2126
+}
+
+function test_scale() {
+ var scale = chroma.scale(['lightyellow', 'navy']);
+ scale(0.5); // #7F7FB0
+
+ chroma.scale('RdYlBu');
+
+ var col = scale(0.5);
+ col.hex(); // #7F7FB0
+ col.rgb(); // [127.5, 127.5, 176]
+
+ scale = chroma.scale(['lightyellow', 'navy']).out('hex');
+ scale(0.5); // "#7F7FB0"
+
+ var scale = chroma.scale(['lightyellow', 'navy']);
+ scale.mode('hsv')(0.5); // #54C08A
+ scale.mode('hsl')(0.5); // #31FF98
+ scale.mode('lab')(0.5); // #967CB2
+ scale.mode('lch')(0.5); // #D26662
+
+ var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]);
+ scale(200); // #7F7FB0
+
+ var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]);
+ scale(98); // #7F7FB0
+ scale(99); // #7F7FB0
+ scale(100); // #AAAAC0
+ scale(101); // #AAAAC0
+
+ chroma.scale(['#eee', '#900']).domain([0, 400], 7);
+ chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log');
+ chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles');
+ chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means');
+ chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100]
+
+ chroma.scale().range(['lightyellow', 'navy']);
+
+ chroma.scale(['lightyellow', 'navy']).correctLightness(true);
+
+ chroma.scale('RdYlGn').domain([0,1], 5).colors()
+}
diff --git a/chroma-js/chroma-js.d.ts b/chroma-js/chroma-js.d.ts
new file mode 100644
index 000000000..94b32ae81
--- /dev/null
+++ b/chroma-js/chroma-js.d.ts
@@ -0,0 +1,317 @@
+// Type definitions for Chroma.js v0.5.6
+// Project: https://github.com/gka/chroma.js
+// Definitions by: Sebastian Brückner
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+/**
+ * Chroma.js is a tiny library for all kinds of color conversions and color scales.
+ */
+declare module Chroma {
+
+ export interface ChromaStatic {
+ /**
+ * Creates a color from a string representation (as supported in CSS).
+ *
+ * @param color The string to convert to a color.
+ * @return the color object.
+ */
+ (color: string): Color;
+
+ /**
+ * Create a color in the specified color space using a, b and c as values.
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ * @return the color object.
+ */
+ (a: number, b: number, c: number, colorSpace?: string): Color;
+
+ /**
+ * Create a color in the specified color space using values.
+ *
+ * @param values An array of values (e.g. [r, g, b, a?]).
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ * @return the color object.
+ */
+ (values: number[], colorSpace?: string): Color;
+
+ /**
+ * Create a color in the specified color space using a, b and c as values.
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ * @return the color object.
+ */
+ color(a: number, b: number, c: number, colorSpace?: string): Color;
+
+ /**
+ * Calculate the contrast ratio of two colors.
+ *
+ * @param color1 The first color.
+ * @param color2 The second color.
+ * @return the contrast ratio.
+ */
+ contrast(color1: Color, color2: Color): number;
+ /**
+ * Calculate the contrast ratio of two colors.
+ *
+ * @param color1 The first color.
+ * @param color2 The second color.
+ * @return the contrast ratio.
+ */
+ contrast(color1: Color, color2: string): number;
+ /**
+ * Calculate the contrast ratio of two colors.
+ *
+ * @param color1 The first color.
+ * @param color2 The second color.
+ * @return the contrast ratio.
+ */
+ contrast(color1: string, color2: Color): number;
+ /**
+ * Calculate the contrast ratio of two colors.
+ *
+ * @param color1 The first color.
+ * @param color2 The second color.
+ * @return the contrast ratio.
+ */
+ contrast(color1: string, color2: string): number;
+
+ /**
+ * Create a color from a hex or string representation (as supported in CSS).
+ *
+ * This is an alias of chroma.hex().
+ *
+ * @param color The string to convert to a color.
+ * @return the color object.
+ */
+ css(color: string): Color;
+
+ /**
+ * Create a color from a hex or string representation (as supported in CSS).
+ *
+ * This is an alias of chroma.css().
+ *
+ * @param color The string to convert to a color.
+ * @return the color object.
+ */
+ hex(color: string): Color;
+
+ rgb(red: number, green: number, blue: number, alpha?: number): Color;
+ hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color;
+ hsv(hue: number, saturation: number, value: number, alpha?: number): Color;
+ lab(lightness: number, a: number, b: number, alpha?: number): Color;
+ lch(lightness: number, chroma: number, hue: number, alpha?: number): Color;
+ gl(red: number, green: number, blue: number, alpha?: number): Color;
+
+ interpolate: InterpolateFunction;
+ mix: InterpolateFunction;
+
+ luminance(color: Color): number;
+ luminance(color: string): number;
+
+ /**
+ * Creates a color scale using a pre-defined color scale.
+ *
+ * @param name The name of the color scale.
+ * @return the resulting color scale.
+ */
+ scale(name: string): Scale;
+
+ /**
+ * Creates a color scale function from the given set of colors.
+ *
+ * @param colors An Array of at least two color names or hex values.
+ * @return the resulting color scale.
+ */
+ scale(colors?: string[]): Scale;
+
+ scales: PredefinedScales;
+ }
+
+ interface InterpolateFunction {
+ (color1: Color, color2: Color, f: number, mode?: string): Color;
+ (color1: Color, color2: string, f: number, mode?: string): Color;
+ (color1: string, color2: Color, f: number, mode?: string): Color;
+ (color1: string, color2: string, f: number, mode?: string): Color;
+
+ bezier(colors: any[]): (t: number) => Color;
+ }
+
+ interface PredefinedScales {
+ [key: string]: Scale;
+
+ cool: Scale;
+ hot: Scale;
+ }
+
+ export interface Color {
+ /**
+ * Creates a color from a string representation (as supported in CSS).
+ *
+ * @param color The string to convert to a color.
+ */
+ new(color: string): Color;
+
+ /**
+ * Create a color in the specified color space using a, b and c as values.
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ */
+ new(a: number, b: number, c: number, colorSpace?: string): Color;
+
+ /**
+ * Create a color in the specified color space using a, b and c as color values and alpha as the alpha value.
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param alpha The alpha value of the color.
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ */
+ new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color;
+
+ /**
+ * Create a color in the specified color space using values.
+ *
+ * @param values An array of values (e.g. [r, g, b, a?]).
+ * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb".
+ */
+ new(values: number[], colorSpace: string): Color;
+
+ /**
+ * Convert this color to CSS hex representation.
+ *
+ * @return this color's hex representation.
+ */
+ hex(): string;
+
+ /**
+ * @return the relative luminance of the color, which is a value between 0 (black) and 1 (white).
+ */
+ luminance(): number;
+
+ /**
+ * @return the X11 name of this color or its hex value if it does not have a name.
+ */
+ name(): string;
+
+ /**
+ * @return the alpha value of the color.
+ */
+ alpha(): number;
+
+ /**
+ * Set the alpha value.
+ *
+ * @param alpha The alpha value.
+ * @return this
+ */
+ alpha(alpha: number): Color;
+
+ css(mode?: string): string;
+
+ interpolate(color: Color, f: number, mode?: string): Color;
+ interpolate(color: string, f: number, mode?: string): Color;
+
+ premultiply(): Color;
+
+ rgb(): number[];
+ rgba(): number[];
+ hsl(): number[];
+ hsv(): number[];
+ lab(): number[];
+ lch(): number[];
+ hsi(): number[];
+ gl(): number[];
+
+ darken(amount?: number): Color;
+ darker(amount: number): Color;
+ brighten(amount?: number): Color;
+ brighter(amount: number): Color;
+ saturate(amount?: number): Color;
+ desaturate(amount?: number): Color;
+
+ toString(): string;
+ }
+
+ export interface Scale {
+ /**
+ * Interpolate a color using the currently set range and domain.
+ *
+ * @param value The value to use for interpolation.
+ * @return the interpolated hex color OR a Color object (depending on the mode set on this Scale).
+ */
+ (value: number): any;
+
+ /**
+ * Retreive all possible colors generated by this scale if it has distinct classes.
+ *
+ * @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex".
+ * @return an array of colors in the type specified by mode.
+ */
+ colors(mode?: string): any[];
+
+ correctLightness(): boolean;
+
+ /**
+ * Enable or disable automatic lightness correction of this scale.
+ *
+ * @param Whether to enable or disable automatic lightness correction.
+ * @return this
+ */
+ correctLightness(enable: boolean): Scale;
+
+ /**
+ * Get the current domain.
+ *
+ * @return The current domain.
+ */
+ domain(): number[];
+
+ /**
+ * Set the domain.
+ *
+ * @param domain An Array of at least two numbers (min and max).
+ * @param classes The number of fixed classes to create between min and max.
+ * @param mode The scale to use. Examples: log, quantiles, k-means.
+ * @return this
+ */
+ domain(domain: number[], classes?: number, mode?: string): Scale;
+
+ /**
+ * Specify in which color space the colors should be interpolated. Defaults to "rgb".
+ * You can use any of the following spaces: rgb, hsv, hsl, lab, lch
+ *
+ * @param colorSpace The color space to use for interpolation.
+ * @return this
+ */
+ mode(colorSpace: string): Scale;
+
+ /**
+ * Set the output mode of this Scale.
+ *
+ * @param mode The output mode to use. Must be one of Color's getters.
+ * @return this
+ */
+ out(mode: string): Scale;
+
+ /**
+ * Set the color range after initialization.
+ *
+ * @param colors An Array of at least two color names or hex values.
+ * @return this
+ */
+ range(colors: string[]): Scale;
+ }
+
+}
+
+declare var chroma: Chroma.ChromaStatic;
diff --git a/chrome/chrome-app-tests.ts b/chrome/chrome-app-tests.ts
index 0ae0ae2af..12dc7b97d 100644
--- a/chrome/chrome-app-tests.ts
+++ b/chrome/chrome-app-tests.ts
@@ -24,4 +24,253 @@ chrome.app.runtime.onLaunched.addListener(function (launchData: runtime.LaunchDa
chrome.app.runtime.onRestarted.addListener(function () { return; });
// Get Current Window
-var currentWindow: cwindow.AppWindow = chrome.app.window.current();
\ No newline at end of file
+var currentWindow: cwindow.AppWindow = chrome.app.window.current();
+
+// Sockets
+// https://developer.chrome.com/apps/sockets_tcp
+function test_socketsTcp(): void {
+ var socketId: number;
+ var properties: chrome.sockets.tcp.SocketProperties = {};
+ var buffer: ArrayBuffer = new ArrayBuffer(256);
+
+ // create
+ chrome.sockets.tcp.create((info) => {
+ socketId = info.socketId;
+ });
+
+ chrome.sockets.tcp.create(properties, (info) => {
+ socketId = info.socketId;
+ });
+
+ // update
+ chrome.sockets.tcp.update(socketId, properties);
+ chrome.sockets.tcp.update(socketId, properties, () => { });
+
+ // setPaused
+ chrome.sockets.tcp.setPaused(socketId, true);
+ chrome.sockets.tcp.setPaused(socketId, true, () => { });
+
+ // setKeepAlive
+ chrome.sockets.tcp.setKeepAlive(socketId, true, (result: number) => { });
+ chrome.sockets.tcp.setKeepAlive(socketId, true, 0, (result: number) => { });
+
+ // setNoDelay
+ chrome.sockets.tcp.setNoDelay(socketId, true, (result: number) => { });
+
+ // connect
+ chrome.sockets.tcp.connect(socketId, "192.168.0.1", 8080, (result: number) => { });
+
+ // disconnect
+ chrome.sockets.tcp.disconnect(socketId);
+ chrome.sockets.tcp.disconnect(socketId, () => { });
+
+ // send
+ chrome.sockets.tcp.send(socketId, buffer, (info: chrome.sockets.tcp.SendInfo) => { });
+
+ // close
+ chrome.sockets.tcp.close(socketId);
+ chrome.sockets.tcp.close(socketId, () => { });
+
+ // getInfo
+ chrome.sockets.tcp.getInfo(socketId, (info: chrome.sockets.tcp.SocketInfo) => { });
+
+ // getSockets
+ chrome.sockets.tcp.getSockets(socketId, (infos: chrome.sockets.tcp.SocketInfo[]) => { });
+}
+
+function test_socketsTcpEvents(): void {
+ chrome.sockets.tcp.onReceive.addListener((info: chrome.sockets.tcp.ReceiveEventArgs) => { });
+ chrome.sockets.tcp.onReceiveError.addListener((info: chrome.sockets.tcp.ReceiveErrorEventArgs) => { });
+}
+
+function testSocketsTcpTypes(): void {
+ // SocketProperties
+ var properties: chrome.sockets.tcp.SocketProperties;
+
+ properties = {
+ };
+
+ properties = {
+ persistent: true,
+ name: "test",
+ bufferSize: 1024
+ };
+
+ // SocketInfo
+ var socketInfo: chrome.sockets.tcp.SocketInfo;
+
+ socketInfo = {
+ socketId: 1,
+ persistent: true,
+ paused: true,
+ connected: false
+ };
+
+ socketInfo.name = "test";
+ socketInfo.bufferSize = 1024;
+ socketInfo.localAddress = "192.168.0.2";
+ socketInfo.localPort = 8000;
+ socketInfo.peerAddress = "192.168.0.3";
+ socketInfo.peerPort = 1000;
+}
+
+// https://developer.chrome.com/apps/sockets_udp
+function test_socketsUdp(): void {
+ var socketId: number;
+ var properties: chrome.sockets.udp.SocketProperties = {};
+ var buffer: ArrayBuffer = new ArrayBuffer(256);
+
+ // create
+ chrome.sockets.udp.create((info) => {
+ socketId = info.socketId;
+ });
+
+ chrome.sockets.udp.create(properties, (info) => {
+ socketId = info.socketId;
+ });
+
+ // update
+ chrome.sockets.udp.update(socketId, properties);
+ chrome.sockets.udp.update(socketId, properties, () => { });
+
+ // setPaused
+ chrome.sockets.udp.setPaused(socketId, true);
+ chrome.sockets.udp.setPaused(socketId, true, () => { });
+
+ // bind
+ chrome.sockets.udp.bind(socketId, "0.0.0.0", 8080, (result: number) => { });
+
+ // send
+ chrome.sockets.udp.send(socketId, buffer, "172.21.0.1", 10080, (info: chrome.sockets.udp.SendInfo) => { });
+
+ // close
+ chrome.sockets.udp.close(socketId);
+ chrome.sockets.udp.close(socketId, () => { });
+
+ // getInfo
+ chrome.sockets.udp.getInfo(socketId, (info: chrome.sockets.udp.SocketInfo) => { });
+
+ // getSockets
+ chrome.sockets.udp.getSockets((infos: chrome.sockets.udp.SocketInfo[]) => { });
+
+ // joinGroup
+ chrome.sockets.udp.joinGroup(socketId, "224.0.0.1", (result: number) => { });
+
+ // leaveGroup
+ chrome.sockets.udp.leaveGroup(socketId, "224.0.0.1", (result: number) => { });
+
+ // setMulticastTimeToLive
+ chrome.sockets.udp.setMulticastTimeToLive(socketId, 100, (result: number) => { });
+
+ // setMulticastLoopbackMode
+ chrome.sockets.udp.setMulticastLoopbackMode(socketId, true, (result: number) => { });
+
+ // getJoinedGroups
+ chrome.sockets.udp.getJoinedGroups(socketId, (groups: string[]) => { });
+}
+
+function test_socketsUdpEvents(): void {
+ chrome.sockets.udp.onReceive.addListener((info: chrome.sockets.udp.ReceiveEventArgs) => { });
+ chrome.sockets.udp.onReceiveError.addListener((info: chrome.sockets.udp.ReceiveErrorEventArgs) => { });
+}
+
+function testSocketsUdpTypes(): void {
+ // SocketProperties
+ var properties: chrome.sockets.udp.SocketProperties;
+
+ properties = {
+ };
+
+ properties = {
+ persistent: true,
+ name: "test",
+ bufferSize: 1024
+ };
+
+ // SocketInfo
+ var socketInfo: chrome.sockets.udp.SocketInfo;
+
+ socketInfo = {
+ socketId: 1,
+ persistent: true,
+ paused: true
+ };
+
+ socketInfo.name = "test";
+ socketInfo.bufferSize = 1024;
+ socketInfo.localAddress = "192.168.0.2";
+ socketInfo.localPort = 8000;
+}
+
+// https://developer.chrome.com/apps/sockets_tcpServer
+function test_socketsTcpServer(): void {
+ var socketId: number;
+ var properties: chrome.sockets.tcpServer.SocketProperties = {};
+ var buffer: ArrayBuffer = new ArrayBuffer(256);
+
+ // create
+ chrome.sockets.tcpServer.create((info) => {
+ socketId = info.socketId;
+ });
+
+ chrome.sockets.tcpServer.create(properties, (info) => {
+ socketId = info.socketId;
+ });
+
+ // update
+ chrome.sockets.tcpServer.update(socketId, properties);
+ chrome.sockets.tcpServer.update(socketId, properties, () => { });
+
+ // setPaused
+ chrome.sockets.tcpServer.setPaused(socketId, true);
+ chrome.sockets.tcpServer.setPaused(socketId, true, () => { });
+
+ // listen
+ chrome.sockets.tcpServer.listen(socketId, "0.0.0.0", 80, (result: number) => { });
+ chrome.sockets.tcpServer.listen(socketId, "0.0.0.0", 80, 128, (result: number) => { });
+
+ // disconnect
+ chrome.sockets.tcp.disconnect(socketId);
+ chrome.sockets.tcp.disconnect(socketId, () => { });
+
+ // close
+ chrome.sockets.udp.close(socketId);
+ chrome.sockets.udp.close(socketId, () => { });
+
+ // getInfo
+ chrome.sockets.udp.getInfo(socketId, (info: chrome.sockets.udp.SocketInfo) => { });
+
+ // getSockets
+ chrome.sockets.tcp.getSockets(socketId, (infos: chrome.sockets.tcp.SocketInfo[]) => { });
+}
+
+function test_socketsTcpServerEvents(): void {
+ chrome.sockets.tcpServer.onAccept.addListener((info: chrome.sockets.tcpServer.AcceptEventArgs) => { });
+ chrome.sockets.tcpServer.onAcceptError.addListener((info: chrome.sockets.tcpServer.AcceptErrorEventArgs) => { });
+}
+
+function testSocketsTcpServerTypes(): void {
+ // SocketProperties
+ var properties: chrome.sockets.tcpServer.SocketProperties;
+
+ properties = {
+ };
+
+ properties = {
+ persistent: true,
+ name: "test"
+ };
+
+ // SocketInfo
+ var socketInfo: chrome.sockets.tcpServer.SocketInfo;
+
+ socketInfo = {
+ socketId: 1,
+ persistent: true,
+ paused: true
+ };
+
+ socketInfo.name = "test";
+ socketInfo.localAddress = "192.168.0.2";
+ socketInfo.localPort = 8000;
+}
diff --git a/chrome/chrome-app.d.ts b/chrome/chrome-app.d.ts
index ad319394f..830b26e4f 100644
--- a/chrome/chrome-app.d.ts
+++ b/chrome/chrome-app.d.ts
@@ -1,6 +1,6 @@
// Type definitions for Chrome packaged application development
// Project: http://developer.chrome.com/apps/
-// Definitions by: Adam Lay
+// Definitions by: Adam Lay , MIZUNE Pine
// Definitions: https://github.com/borisyankov/DefinitelyTyped
////////////////////
@@ -93,3 +93,189 @@ declare module chrome.app.window {
var onMinimized: WindowEvent;
var onRestored: WindowEvent;
}
+
+
+////////////////////
+// Sockets
+////////////////////
+declare module chrome.sockets.tcp {
+ interface CreateInfo {
+ socketId: number;
+ }
+
+ interface SendInfo {
+ resultCode: number;
+ bytesSent?: number;
+ }
+
+ interface Event {
+ addListener(callback: (info: T) => void): void;
+ }
+
+ interface ReceiveEventArgs {
+ socketId: number;
+ data: ArrayBuffer;
+ }
+
+ interface ReceiveErrorEventArgs {
+ socketId: number;
+ resultCode: number;
+ }
+
+ interface SocketProperties {
+ persistent?: boolean;
+ name?: string;
+ bufferSize?: number;
+ }
+
+ interface SocketInfo {
+ socketId: number;
+ persistent: boolean;
+ name?: string;
+ bufferSize?: number;
+ paused: boolean;
+ connected: boolean;
+ localAddress?: string;
+ localPort?: number;
+ peerAddress?: string;
+ peerPort?: number;
+ }
+
+ export function create(callback: (createInfo: CreateInfo) => void): void;
+ export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
+
+ export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
+ export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
+
+ export function setKeepAlive(socketId: number,
+ enable: boolean, callback: (result: number) => void): void;
+ export function setKeepAlive(socketId: number,
+ enable: boolean, delay: number, callback: (result: number) => void): void;
+
+ export function setNoDelay(socketId: number, noDelay: boolean, callback: (result: number) => void): void;
+ export function connect(socketId: number,
+ peerAddress: string, peerPort: number, callback: (result: number) => void): void;
+ export function disconnect(socketId: number, callback?: () => void): void;
+ export function send(socketId: number, data: ArrayBuffer, callback: (sendInfo: SendInfo) => void): void;
+ export function close(socketId: number, callback?: () => void): void;
+ export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
+ export function getSockets(socketId: number, callback: (socketInfos: SocketInfo[]) => void): void;
+
+ var onReceive: Event;
+ var onReceiveError: Event;
+}
+
+declare module chrome.sockets.udp {
+ interface CreateInfo {
+ socketId: number;
+ }
+
+ interface SendInfo {
+ resultCode: number;
+ bytesSent?: number;
+ }
+
+ interface Event {
+ addListener(callback: (info: T) => void): void;
+ }
+
+ interface ReceiveEventArgs {
+ socketId: number;
+ data: ArrayBuffer;
+ remoteAddress: string;
+ remotePort: number;
+ }
+
+ interface ReceiveErrorEventArgs {
+ socketId: number;
+ resultCode: number;
+ }
+
+ interface SocketProperties {
+ persistent?: boolean;
+ name?: string;
+ bufferSize?: number;
+ }
+
+ interface SocketInfo {
+ socketId: number;
+ persistent: boolean;
+ name?: string;
+ bufferSize?: number;
+ paused: boolean;
+ localAddress?: string;
+ localPort?: number;
+ }
+
+ export function create(callback: (createInfo: CreateInfo) => void): void;
+ export function create(properties: SocketProperties,
+ callback: (createInfo: CreateInfo) => void): void;
+
+ export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
+ export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
+ export function bind(socketId: number, address: string, port: number, callback: (result: number) => void): void;
+ export function send(socketId: number, data: ArrayBuffer, address: string, port: number, callback: (sendInfo: SendInfo) => void): void;
+ export function close(socketId: number, callback?: () => void): void;
+ export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
+ export function getSockets(callback: (socketInfos: SocketInfo[]) => void): void;
+ export function joinGroup(socketId: number, address: string, callback: (result: number) => void): void;
+ export function leaveGroup(socketId: number, address: string, callback: (result: number) => void): void;
+ export function setMulticastTimeToLive(socketId: number, ttl: number, callback: (result: number) => void): void;
+ export function setMulticastLoopbackMode(socketId: number, enabled: boolean, callback: (result: number) => void): void;
+ export function getJoinedGroups(socketId: number, callback: (groups: string[]) => void): void;
+
+ var onReceive: Event;
+ var onReceiveError: Event;
+}
+
+declare module chrome.sockets.tcpServer {
+ interface CreateInfo {
+ socketId: number;
+ }
+
+ interface Event {
+ addListener(callback: (info: T) => void): void;
+ }
+
+ interface AcceptEventArgs {
+ socketId: number;
+ clientSocketId: number;
+ }
+
+ interface AcceptErrorEventArgs {
+ socketId: number;
+ resultCode: number;
+ }
+
+ interface SocketProperties {
+ persistent?: boolean;
+ name?: string;
+ }
+
+ interface SocketInfo {
+ socketId: number;
+ persistent: boolean;
+ name?: string;
+ paused: boolean;
+ localAddress?: string;
+ localPort?: number;
+ }
+
+ export function create(callback: (createInfo: CreateInfo) => void): void;
+ export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
+
+ export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
+ export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
+
+ export function listen(socketId: number, address: string,
+ port: number, backlog: number, callback: (result: number) => void): void;
+ export function listen(socketId: number, address: string,
+ port: number, callback: (result: number) => void): void;
+
+ export function disconnect(socketId: number, callback?: () => void): void;
+ export function close(socketId: number, callback?: () => void): void;
+ export function getInfo(socketId: number, callback: (socketInfos: SocketInfo[]) => void): void;
+
+ var onAccept: Event;
+ var onAcceptError: Event;
+}
\ No newline at end of file
diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts
index 796635c27..e7e58dbbc 100755
--- a/chrome/chrome.d.ts
+++ b/chrome/chrome.d.ts
@@ -3,6 +3,8 @@
// Definitions by: Matthew Kimber , otiai10
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
////////////////////
// Alarms
////////////////////
@@ -294,6 +296,7 @@ declare module chrome.contextMenus {
pageUrl: string;
linkUrl?: string;
parentMenuItemId?: any;
+ srcUrl?: string;
}
interface CreateProperties {
@@ -537,6 +540,14 @@ declare module chrome.declarativeWebRequest {
var onRequest: RequestedEvent;
}
+////////////////////
+// DesktopCapture
+////////////////////
+declare module chrome.desktopCapture {
+ export function chooseDesktopMedia(sources: string[], targetTab?: chrome.tabs.Tab, callback?: (streamId: string) => void): void;
+ export function cancelChooseDesktopMedia(desktopMediaRequestId: number): void;
+}
+
////////////////////
// Dev Tools - Inspected Window
////////////////////
@@ -843,8 +854,12 @@ declare module chrome.extension {
type?: string;
}
+ interface LastError {
+ message?: string;
+ }
+
var inIncognitoContext: boolean;
- var lastError: Object;
+ var lastError: LastError;
export function getBackgroundPage(): Window;
export function getURL(path: string): string;
@@ -1487,9 +1502,13 @@ declare module chrome.proxy {
// Runtime
////////////////////
declare module chrome.runtime {
- var lastError: Object;
+ var lastError: LastError;
var id: string;
+ interface LastError {
+ message?: string;
+ }
+
interface ConnectInfo {
name?: string;
}
@@ -1737,6 +1756,27 @@ declare module chrome.socket {
export function getNetworkList(callback: (result: NetworkInterface[]) => void): void;
}
+////////////////////
+// TabCapture
+////////////////////
+declare module chrome.tabCapture {
+ interface CaptureInfo {
+ tabId: number;
+ status: string;
+ fullscreen: boolean;
+ }
+
+ interface CaptureOptions {
+ audio?: boolean;
+ video?: boolean;
+ audioConstraints?: MediaTrackConstraints;
+ videoConstraints?: MediaTrackConstraints;
+ }
+
+ export function capture(options: CaptureOptions, callback: (stream: LocalMediaStream) => void): void;
+ export function getCapturedTabs(callback: (result: CaptureInfo[]) => void): void;
+}
+
////////////////////
// Tabs
////////////////////
diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts
index affee3458..af4b32046 100644
--- a/codemirror/codemirror.d.ts
+++ b/codemirror/codemirror.d.ts
@@ -9,7 +9,7 @@ declare function CodeMirror(callback: (host: HTMLElement) => void , options?: Co
declare module CodeMirror {
export var Pass: any;
- function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.Editor;
+ function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea;
var version: string;
@@ -86,6 +86,11 @@ declare module CodeMirror {
or the line the widget is on require the widget to be redrawn. */
function on(line: LineWidget, eventName: 'redraw', handler: () => void ): void;
function off(line: LineWidget, eventName: 'redraw', handler: () => void ): void;
+
+ /** Various CodeMirror-related objects emit events, which allow client code to react to various situations.
+ Handlers for such events can be registered with the on and off methods on the objects that the event fires on.
+ To fire your own events, use CodeMirror.signal(target, name, args...), where target is a non-DOM-node object. */
+ function signal(target: any, name: string, ...args: any[]): void;
interface Editor {
@@ -369,6 +374,18 @@ declare module CodeMirror {
on(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
off(eventName: 'renderLine', handler: (instance: CodeMirror.Editor, line: number, element: HTMLElement) => void ): void;
}
+
+ interface EditorFromTextArea extends Editor {
+
+ /** Copy the content of the editor into the textarea. */
+ save(): void;
+
+ /** Remove the editor, and restore the original textarea (with the editor's current content). */
+ toTextArea(): void;
+
+ /** Returns the textarea that the instance was based on. */
+ getTextArea(): HTMLTextAreaElement;
+ }
class Doc {
constructor (text: string, mode?: any, firstLineNumber?: number);
diff --git a/compression/compression-tests.ts b/compression/compression-tests.ts
new file mode 100644
index 000000000..ecfcab432
--- /dev/null
+++ b/compression/compression-tests.ts
@@ -0,0 +1,10 @@
+///
+
+import express = require('express');
+import compress = require('compression');
+
+var app = express();
+app.use(compress());
+app.use(compress({
+ threshold: 512
+}));
diff --git a/compression/compression.d.ts b/compression/compression.d.ts
new file mode 100644
index 000000000..00b2e0459
--- /dev/null
+++ b/compression/compression.d.ts
@@ -0,0 +1,20 @@
+// Type definitions for compression
+// Project: https://github.com/expressjs/compression
+// Definitions by: Santi Albo
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "compression" {
+ import express = require('express');
+
+ module e {
+ interface CompressionOptions {
+ threshold?: number;
+ filter?: Function;
+ }
+ }
+
+ function e(options?: e.CompressionOptions): express.RequestHandler;
+ export = e;
+}
\ No newline at end of file
diff --git a/cookie-parser/cookie-parser-tests.ts b/cookie-parser/cookie-parser-tests.ts
new file mode 100644
index 000000000..94e8a9fdb
--- /dev/null
+++ b/cookie-parser/cookie-parser-tests.ts
@@ -0,0 +1,7 @@
+///
+
+import express = require('express');
+import cookieParser = require('cookie-parser');
+
+var app = express();
+app.use(cookieParser('optional secret string'));
diff --git a/cookie-parser/cookie-parser.d.ts b/cookie-parser/cookie-parser.d.ts
new file mode 100644
index 000000000..a4897c5e7
--- /dev/null
+++ b/cookie-parser/cookie-parser.d.ts
@@ -0,0 +1,12 @@
+// Type definitions for cookie-parser
+// Project: https://github.com/expressjs/cookie-parser
+// Definitions by: Santi Albo
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "cookie-parser" {
+ import express = require('express');
+ function e(secret?: string, options?: any): express.RequestHandler;
+ export = e;
+}
\ No newline at end of file
diff --git a/csurf/csurf.d.ts b/csurf/csurf.d.ts
new file mode 100644
index 000000000..cc78f9599
--- /dev/null
+++ b/csurf/csurf.d.ts
@@ -0,0 +1,30 @@
+// Type definitions for csurf
+// Project: https://www.npmjs.org/package/csurf
+// Definitions by: Hiroki Horiuchi
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module Express {
+ export interface Request {
+ csrfToken(): string;
+ }
+}
+
+declare module "csurf" {
+ import express = require('express');
+
+ function csurf(options?: {
+ value?: (req: express.Request) => string;
+ cookie?: csurf.CookieOptions;
+ }): express.RequestHandler;
+
+ module csurf {
+ export interface CookieOptions extends express.CookieOptions {
+ key: string;
+ }
+ }
+
+ export = csurf;
+}
+
diff --git a/d3/d3.d.ts b/d3/d3.d.ts
old mode 100755
new mode 100644
index 598cd9f34..a451a0de5
--- a/d3/d3.d.ts
+++ b/d3/d3.d.ts
@@ -243,7 +243,7 @@ declare module D3 {
*
* @param map Array of objects to get the values from
*/
- values(map: any[]): any[];
+ values(map: any): any[];
/**
* List the key-value entries of an associative array.
*
@@ -417,7 +417,7 @@ declare module D3 {
/*
* The array of built-in interpolator factories
*/
- interpolators: Array;
+ interpolators: Transition.InterpolateFactory[];
/**
* Layouts
*/
@@ -525,11 +525,11 @@ declare module D3 {
/**
* gets the mouse position relative to a specified container.
*/
- mouse(container: any): Array;
+ mouse(container: any): number[];
/**
* gets the touch positions relative to a specified container.
*/
- touches(container: any): Array>;
+ touches(container: any): number[][];
/**
* If the specified value is a function, returns the specified value.
@@ -538,10 +538,12 @@ declare module D3 {
functor(value: (p : R) => T): (p : R) => T;
functor(value: T): (p : any) => T;
- map(object?: any): Map;
- set(array?: Array): Set;
- dispatch(...types: Array