diff --git a/README.md b/README.md
index 3484db60d..2d552bfc1 100755
--- a/README.md
+++ b/README.md
@@ -68,6 +68,7 @@ List of Definitions
* [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))
* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei))
+* [Flight by Twitter](http://flightjs.github.com/flight/) (by [Jonathan Hedrén](https://github.com/jonathanhedren))
* [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov))
* [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros))
* [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk))
@@ -75,8 +76,9 @@ List of Definitions
* [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo))
* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz))
* [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42))
+* [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas))
* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt))
-* [Grunt JS](http://gruntjs.com/) (by [Basarat Ali Syed](https://github.com/basarat))
+* [Grunt JS](http://gruntjs.com/) (by [Jeff May](https://github.com/jeffmay) and [Basarat Ali Syed](https://github.com/basarat))
* [Google API Client](https://code.google.com/p/google-api-javascript-client/) (by [Frank M](https://github.com/sgtfrankieboy))
* [Google App Engine Channel API](https://developers.google.com/appengine/docs/java/channel/javascript) (by [vvakame](https://github.com/vvakame))
* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper))
@@ -93,7 +95,6 @@ List of Definitions
* [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))
-* [Intl](http://www.ecma-international.org/ecma-402/1.0/) (by [Jeffery Grajkowski](http://github.com/pushplay))
* [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski))
* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/))
* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov))
@@ -107,9 +108,10 @@ List of Definitions
* [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton))
* [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/))
* [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos))
-* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/))
+* [jQuery.CLEditor](http://premiumsoftware.net/CLEditor) (by [Jeffery Grajkowski](https://github.com/pushplay))
* [jQuery.clientSideLogging](https://github.com/remybach/jQuery.clientSideLogging/) (by [Diullei Gomes](https://github.com/diullei/))
* [jQuery.Colorbox](http://www.jacklmoore.com/colorbox/) (by [Gidon Junge](https://github.com/gjunge))
+* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/))
* [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode))
* [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/))
* [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix))
@@ -133,6 +135,7 @@ List of Definitions
* [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U))
* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov))
* [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved))
+* [jQuery.base64](https://github.com/yatt/jquery.base64) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki))
* [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/))
@@ -145,7 +148,7 @@ List of Definitions
* [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano))
* [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC))
* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov))
-* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel](https://github.com/JudahGabriel))
+* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel Himango](https://github.com/JudahGabriel))
* [Knockout.Validation](https://github.com/ericmbarnard/Knockout-Validation) (by [Dan Ludwig](https://github.com/danludwig))
* [Knockout.Viewmodel](http://coderenaissance.github.com/knockout.viewmodel/) (by [Oisin Grehan](https://github.com/oising))
* [ko.editables](http://romanych.github.com/ko.editables/) (by [Oisin Grehan](https://github.com/oising))
@@ -156,6 +159,7 @@ List of Definitions
* [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle))
* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder))
* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone))
+* [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel))
* [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle))
* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr))
* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams] (https://github.com/flurg))
@@ -170,7 +174,9 @@ List of Definitions
* [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd))
* [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown))
* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov))
+* [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/))
+* [OpenLayers] (https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/))
* [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin))
* [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin))
* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto))
@@ -238,7 +244,6 @@ Requested Definitions
* [google.visualizations](https://developers.google.com/chart/)
* [Prelude.ls](http://gkz.github.com/prelude-ls/)
* [MooTools](http://mootools.net/)
-* [Lo-Dash](http://lodash.com/)
* [java](https://github.com/nearinfinity/node-java)
* [SVG.js](http://www.svgjs.com/)
diff --git a/_infrastructure/tests/compile-runner.bat b/_infrastructure/tests/compile-runner.bat
new file mode 100644
index 000000000..53e014841
--- /dev/null
+++ b/_infrastructure/tests/compile-runner.bat
@@ -0,0 +1 @@
+tsc runner.ts --out runner.js --module commonjs
\ No newline at end of file
diff --git a/_infrastructure/tests/runner.js b/_infrastructure/tests/runner.js
index fd926bcb1..3721f7e11 100644
--- a/_infrastructure/tests/runner.js
+++ b/_infrastructure/tests/runner.js
@@ -552,10 +552,11 @@ else if (typeof require === "function")
else
return null;
})();
-///
-///
var DefinitelyTyped;
(function (DefinitelyTyped) {
+ ///
+ ///
+ ///
(function (TestManager) {
var path = require('path');
@@ -614,6 +615,10 @@ var DefinitelyTyped;
return Typing;
})();
+ /////////////////////////////////
+ // Given a document root + ts file pattern this class returns:
+ // all the TS files OR just tests OR just definition files
+ /////////////////////////////////
var FileHandler = (function () {
function FileHandler(path, pattern) {
this.path = path;
@@ -659,6 +664,10 @@ var DefinitelyTyped;
return FileHandler;
})();
+ /////////////////////////////////
+ // Timer.start starts a timer
+ // Timer.end stops the timer and sets asString to the pretty print value
+ /////////////////////////////////
var Timer = (function () {
function Timer() {
this.time = 0;
@@ -688,6 +697,9 @@ var DefinitelyTyped;
return Timer;
})();
+ /////////////////////////////////
+ // All the common things that we pring are functions of this class
+ /////////////////////////////////
var Print = (function () {
function Print(version, typings, tsFiles) {
this.version = version;
@@ -707,19 +719,19 @@ var DefinitelyTyped;
this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
};
- Print.prototype.printSyntaxChecking = function () {
+ Print.prototype.printSyntaxCheckingHeader = function () {
this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n');
};
- Print.prototype.printTypingTests = function () {
+ Print.prototype.printTypingTestsHeader = function () {
this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n');
};
- Print.prototype.printSuccess = function () {
+ Print.prototype.printSuccessCharacter = function () {
this.out('\33[36m\33[1m.\33[0m');
};
- Print.prototype.printFailure = function () {
+ Print.prototype.printFailureCharacter = function () {
this.out('x');
};
@@ -727,6 +739,23 @@ var DefinitelyTyped;
this.out('-----------------------------------------------------------------------------\n');
};
+ Print.prototype.printBoldDiv = function () {
+ this.out('=============================================================================\n');
+ };
+
+ Print.prototype.printErrorsHeader = function () {
+ this.out('=============================================================================\n');
+ this.out(' \33[34m\33[1mErrors in files\33[0m \n');
+ this.out('=============================================================================\n');
+ };
+
+ Print.prototype.printErrorsForFile = function (file) {
+ this.out('----------------- For file:' + file.formatName());
+ this.printBreak();
+ this.out(file.execResult.stderr);
+ this.printBreak();
+ };
+
Print.prototype.printfilesWithSintaxErrorMessage = function () {
this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n');
};
@@ -751,7 +780,7 @@ var DefinitelyTyped;
this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
};
- Print.prototype.breack = function () {
+ Print.prototype.printBreak = function () {
this.out('\n');
};
@@ -781,22 +810,30 @@ var DefinitelyTyped;
return Print;
})();
+ /////////////////////////////
+ // Represents the results of a test file execution
+ /////////////////////////////
var File = (function () {
- function File(name, hasError) {
- this.name = name;
- this.hasError = hasError;
+ function File(baseDir, filePathWithName, execResult) {
+ this.baseDir = baseDir;
+ this.filePathWithName = filePathWithName;
+ this.execResult = execResult;
}
- File.prototype.formatName = function (baseDir) {
- var dirName = path.dirname(this.name.substr(baseDir.length + 1)).replace('\\', '/');
+ // From '/complete/path/to/file' to 'specfolder/specfile.d.ts'
+ File.prototype.formatName = function () {
+ var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/');
var dir = dirName.split('/')[0];
- var file = path.basename(this.name, '.ts');
- var ext = path.extname(this.name);
+ var file = path.basename(this.filePathWithName, '.ts');
+ var ext = path.extname(this.filePathWithName);
return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext;
};
return File;
})();
+ /////////////////////////////
+ // Determine syntax errors in typings
+ /////////////////////////////
var SyntaxChecking = (function () {
function SyntaxChecking(fileHandler, out) {
this.fileHandler = fileHandler;
@@ -808,7 +845,7 @@ var DefinitelyTyped;
var list = [];
for (var i = 0; i < this.files.length; i++) {
- if (this.files[i].hasError) {
+ if (this.files[i].execResult.exitCode) {
list.push(this.files[i]);
}
}
@@ -820,7 +857,7 @@ var DefinitelyTyped;
var list = [];
for (var i = 0; i < this.files.length; i++) {
- if (!this.files[i].hasError) {
+ if (!this.files[i].execResult.exitCode) {
list.push(this.files[i]);
}
}
@@ -845,7 +882,7 @@ var DefinitelyTyped;
for (var i = 0; i < this.getFailedFiles().length; i++) {
var errorFile = this.getFailedFiles()[i];
- this.out.printErrorFile(errorFile.formatName(this.fileHandler.path));
+ this.out.printErrorFile(errorFile.formatName());
}
}
};
@@ -853,29 +890,26 @@ var DefinitelyTyped;
SyntaxChecking.prototype.run = function (it, file, len, maxLen, callback) {
var _this = this;
if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) {
- new Test(file).run(function (o) {
- var failed = false;
-
- if (o.exitCode === 1) {
- _this.out.printFailure();
- failed = true;
+ new Test(file).run(function (execResult) {
+ if (execResult.exitCode === 1) {
+ _this.out.printFailureCharacter();
len++;
} else {
- _this.out.printSuccess();
+ _this.out.printSuccessCharacter();
len++;
}
- _this.files.push(new File(file, failed));
+ _this.files.push(new File(_this.fileHandler.path, file, execResult));
if (len > maxLen) {
len = 0;
- _this.out.breack();
+ _this.out.printBreak();
}
if (it.hasNext()) {
_this.run(it, it.next(), len, maxLen, callback);
} else {
- _this.out.breack();
+ _this.out.printBreak();
_this.timer.end();
_this.printFailedFiles();
_this.printStats();
@@ -886,7 +920,7 @@ var DefinitelyTyped;
} else if (it.hasNext()) {
this.run(it, it.next(), len, maxLen, callback);
} else {
- this.out.breack();
+ this.out.printBreak();
this.timer.end();
this.printStats();
this.printFailedFiles();
@@ -912,6 +946,9 @@ var DefinitelyTyped;
return SyntaxChecking;
})();
+ /////////////////////////////
+ // Determines errors in typing tests
+ /////////////////////////////
var TestEval = (function () {
function TestEval(fileHandler, out) {
this.fileHandler = fileHandler;
@@ -923,7 +960,7 @@ var DefinitelyTyped;
var list = [];
for (var i = 0; i < this.files.length; i++) {
- if (this.files[i].hasError) {
+ if (this.files[i].execResult.exitCode) {
list.push(this.files[i]);
}
}
@@ -935,7 +972,7 @@ var DefinitelyTyped;
var list = [];
for (var i = 0; i < this.files.length; i++) {
- if (!this.files[i].hasError) {
+ if (!this.files[i].execResult.exitCode) {
list.push(this.files[i]);
}
}
@@ -960,7 +997,7 @@ var DefinitelyTyped;
for (var i = 0; i < this.getFailedFiles().length; i++) {
var errorFile = this.getFailedFiles()[i];
- this.out.printErrorFile(errorFile.formatName(this.fileHandler.path));
+ this.out.printErrorFile(errorFile.formatName());
}
}
};
@@ -968,29 +1005,26 @@ var DefinitelyTyped;
TestEval.prototype.run = function (it, file, len, maxLen, callback) {
var _this = this;
if (endsWith(file.toUpperCase(), '-TESTS.TS')) {
- new Test(file).run(function (o) {
- var failed = false;
-
- if (o.exitCode === 1) {
- _this.out.printFailure();
- failed = true;
+ new Test(file).run(function (execResult) {
+ if (execResult.exitCode === 1) {
+ _this.out.printFailureCharacter();
len++;
} else {
- _this.out.printSuccess();
+ _this.out.printSuccessCharacter();
len++;
}
- _this.files.push(new File(file, failed));
+ _this.files.push(new File(_this.fileHandler.path, file, execResult));
if (len > maxLen) {
len = 0;
- _this.out.breack();
+ _this.out.printBreak();
}
if (it.hasNext()) {
_this.run(it, it.next(), len, maxLen, callback);
} else {
- _this.out.breack();
+ _this.out.printBreak();
_this.timer.end();
_this.printFailedFiles();
_this.printStats();
@@ -1001,7 +1035,7 @@ var DefinitelyTyped;
} else if (it.hasNext()) {
this.run(it, it.next(), len, maxLen, callback);
} else {
- this.out.breack();
+ this.out.printBreak();
this.timer.end();
this.printFailedFiles();
this.printStats();
@@ -1027,6 +1061,9 @@ var DefinitelyTyped;
return TestEval;
})();
+ /////////////////////////////////
+ // The main class to kick things off
+ /////////////////////////////////
var TestRunner = (function () {
function TestRunner(dtPath) {
this.dtPath = dtPath;
@@ -1065,19 +1102,41 @@ var DefinitelyTyped;
return count;
};
+ TestRunner.prototype.printErrorsDetected = function () {
+ var _this = this;
+ this.out.printErrorsHeader();
+
+ var printErrorsForFileIfFound = function (file) {
+ if (file.execResult.exitCode)
+ _this.out.printErrorsForFile(file);
+ };
+
+ // sc errors:
+ this.sc.files.forEach(printErrorsForFileIfFound);
+ this.out.printBoldDiv();
+
+ // te errors:
+ this.te.files.forEach(printErrorsForFileIfFound);
+ this.out.printBoldDiv();
+ };
+
TestRunner.prototype.run = function () {
var _this = this;
var timer = new Timer();
timer.start();
this.out.printHeader();
- this.out.printSyntaxChecking();
+ // Run syntax tests
+ this.out.printSyntaxCheckingHeader();
this.sc.start(function (syntaxFailedCount, syntaxTotal) {
- _this.out.printTypingTests();
+ // Now run typing tests
+ _this.out.printTypingTestsHeader();
_this.te.start(function (testFailedCount, testTotal) {
- var total = _this.printTypingsWithoutTest();
+ // Get the tests without any typing and simultaneously print their names
+ var totalTypingsWithoutTest = _this.printTypingsWithoutTest();
+ // End total timer and print final messages
timer.end();
_this.out.printDiv();
@@ -1087,11 +1146,12 @@ var DefinitelyTyped;
_this.out.printElapsedTime(timer.asString, timer.time);
_this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal);
_this.out.printTestErrorCount(testFailedCount, testTotal);
- _this.out.printWithoutTestCount(total, _this.fh.allTypings().length);
+ _this.out.printWithoutTestCount(totalTypingsWithoutTest, _this.fh.allTypings().length);
_this.out.printDiv();
if (syntaxFailedCount > 0 || testFailedCount > 0) {
+ _this.printErrorsDetected();
process.exit(1);
}
});
diff --git a/_infrastructure/tests/runner.ts b/_infrastructure/tests/runner.ts
index 68e5f36ba..68682f536 100644
--- a/_infrastructure/tests/runner.ts
+++ b/_infrastructure/tests/runner.ts
@@ -1,562 +1,626 @@
-///
+///
+
+///
///
-module DefinitelyTyped {
-
- export module TestManager {
-
- var path = require('path');
-
- function endsWith(str, suffix) {
- return str.indexOf(suffix, str.length - suffix.length) !== -1;
- }
-
- class Iterator {
- index: number = -1;
-
- constructor(public list: any[]){}
-
- public next() {
- this.index++;
- return this.list[this.index];
- }
-
- public hasNext() {
- return this.list[1 + this.index] != null;
- }
- }
-
- class Tsc {
- public static run(tsfile: string, callback: Function) {
- var command = 'node ./_infrastructure/tests/typescript/tsc.js --module commonjs ';
- if (IO.fileExists(tsfile + '.tscparams')) {
- command += '@' + tsfile + '.tscparams';
- } else {
- command += '--noImplicitAny';
- }
- Exec.exec(command, [tsfile], (ExecResult) => {
- callback(ExecResult);
- });
- }
- }
-
- class Test {
- constructor(public tsfile: string) {}
-
- public run(callback: Function) {
- Tsc.run(this.tsfile , callback);
- }
- }
-
- class Typing {
- public fileHandler: FileHandler;
-
- constructor(public name: string, baseDir: string) {
- this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g);
- }
- }
-
- class FileHandler {
- public files: string[] = [];
- public typings: Typing[] = [];
-
- constructor(public path: string, pattern: any) {
- this.files = IO.dir(path, pattern, { recursive: true }).sort();
- }
-
- public allTS(): string[] {
- return this.files;
- }
-
- public allTests(): string[] {
- var tests = [];
-
- for(var i = 0; i < this.files.length; i++) {
- if (endsWith(this.files[i].toUpperCase(), '-TESTS.TS')) {
- tests.push(this.files[i]);
- }
- }
-
- return tests;
- }
-
- public allTypings(): string[] {
- var typings = {};
-
- for(var i = 0; i < this.files.length; i++) {
- var file = this.files[i];
- var firName = path.dirname(file.substr(this.path.length + 1)).replace('\\', '/');
- var dir = firName.split('/')[0];
-
- if(!typings[dir]) typings[dir] = true;
- }
-
- var list = [];
- for(var attr in typings) {
- list.push(attr);
- }
-
- return list;
- }
- }
-
- class Timer {
- public startTime;
- public time = 0;
- public asString: string;
-
- private static prettyDate(date1, date2): string {
- var diff = ((date2 - date1) / 1000),
- day_diff = Math.floor(diff / 86400);
-
- if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
- return;
-
- return (day_diff == 0 && (
- diff < 60 && (diff + " seconds") ||
- diff < 120 && "1 minute" ||
- diff < 3600 && Math.floor( diff / 60 ) + " minutes" ||
- diff < 7200 && "1 hour" ||
- diff < 86400 && Math.floor( diff / 3600 ) + " hours") ||
- day_diff == 1 && "Yesterday" ||
- day_diff < 7 && day_diff + " days" ||
- day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks");
- }
-
- public start() {
- this.time = 0;
- this.startTime = this.now();
- }
-
- private now() {
- return Date.now();
- }
-
- public end() {
- this.time = (this.now() - this.startTime) / 1000;
- this.asString = Timer.prettyDate(this.startTime, this.now());
- }
- }
-
- class Print {
- constructor(public version: string, public typings: number, public tsFiles: number) { }
-
- public out(s) {
- process.stdout.write(s);
- }
-
- public printHeader() {
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.3.0\33[0m\n');
- this.out('=============================================================================\n');
- this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
- this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
- this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
- }
-
- public printSyntaxChecking() {
- this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n');
- }
-
- public printTypingTests() {
- this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n');
- }
-
- public printSuccess() {
- this.out('\33[36m\33[1m.\33[0m');
- }
-
- public printFailure() {
- this.out('x');
- }
-
- public printDiv() {
- this.out('-----------------------------------------------------------------------------\n');
- }
-
- public printfilesWithSintaxErrorMessage() {
- this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n');
- }
-
- public printFailedTestMessage() {
- this.out(' \33[36m\33[1mFailed tests\33[0m\n');
- }
-
- public printTypingsWithoutTestsMessage() {
- this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
- }
-
- public printTotalMessage() {
- this.out(' \33[36m\33[1mTotal\33[0m\n');
- }
-
- public printErrorFile(file) {
- this.out(' - ' + file + '\n');
- }
-
- public printTypingsWithoutTest(file) {
- this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
- }
-
- public breack() {
- this.out('\n');
- }
-
- public printSuccessCount(current: number, total: number) {
- this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printFailedCount(current: number, total: number) {
- this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printElapsedTime(time, s) {
- this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
- }
-
- public printSyntaxErrorCount(current: number, total: number) {
- this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printTestErrorCount(current: number, total: number) {
- this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
-
- public printWithoutTestCount(current: number, total: number) {
- this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
- }
- }
-
- class File {
-
- constructor(public name: string, public hasError: boolean) {}
-
- public formatName(baseDir: string): string {
- var dirName = path.dirname(this.name.substr(baseDir.length + 1)).replace('\\', '/');
- var dir = dirName.split('/')[0];
- var file = path.basename(this.name, '.ts');
- var ext = path.extname(this.name);
-
- return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext;
- }
- }
-
- class SyntaxChecking {
-
- private timer: Timer;
-
- public files: File[] = [];
-
- private getFailedFiles(): File[] {
- var list: File[] = [];
-
- for(var i = 0; i < this.files.length; i++) {
- if(this.files[i].hasError) {
- list.push(this.files[i]);
- }
- }
-
- return list;
- }
-
- private getSuccessFiles(): File[] {
- var list: File[] = [];
-
- for(var i = 0; i < this.files.length; i++) {
- if(!this.files[i].hasError) {
- list.push(this.files[i]);
- }
- }
-
- return list;
- }
-
- constructor(public fileHandler: FileHandler, public out: Print) {
- this.timer = new Timer();
- }
-
- private printStats() {
- this.out.printDiv();
- this.out.printElapsedTime(this.timer.asString, this.timer.time);
- this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
- this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
- }
-
- private printFailedFiles() {
- if (this.getFailedFiles().length > 0) {
- this.out.printDiv();
-
- this.out.printfilesWithSintaxErrorMessage();
-
- this.out.printDiv();
-
- for(var i = 0; i < this.getFailedFiles().length; i++) {
- var errorFile = this.getFailedFiles()[i];
- this.out.printErrorFile(errorFile.formatName(this.fileHandler.path));
- }
- }
- }
-
- private run(it, file, len, maxLen, callback: Function) {
- if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) {
- new Test(file).run((o) => {
- var failed = false;
-
- if(o.exitCode === 1) {
- this.out.printFailure();
- failed = true;
- len++;
- } else {
- this.out.printSuccess();
- len++;
- }
-
- this.files.push(new File(file, failed));
-
- if(len > maxLen) {
- len = 0;
- this.out.breack();
- }
-
- if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- } else {
- this.out.breack();
- this.timer.end();
- this.printFailedFiles();
- this.printStats();
-
- callback(this.getFailedFiles().length, this.files.length);
- }
- });
- } else if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- } else {
- this.out.breack();
- this.timer.end();
- this.printStats();
- this.printFailedFiles();
-
- callback(this.getFailedFiles().length, this.files.length);
- }
- }
-
- public start(callback: Function) {
- this.timer.start();
-
- var tsFiles = this.fileHandler.allTS();
-
- var it = new Iterator(tsFiles);
-
- var len = 0;
- var maxLen = 76;
-
- if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- }
- }
- }
-
- class TestEval {
-
- private timer: Timer;
-
- public files: File[] = [];
-
- private getFailedFiles(): File[] {
- var list: File[] = [];
-
- for(var i = 0; i < this.files.length; i++) {
- if(this.files[i].hasError) {
- list.push(this.files[i]);
- }
- }
-
- return list;
- }
-
- private getSuccessFiles(): File[] {
- var list: File[] = [];
-
- for(var i = 0; i < this.files.length; i++) {
- if(!this.files[i].hasError) {
- list.push(this.files[i]);
- }
- }
-
- return list;
- }
-
- constructor(public fileHandler: FileHandler, public out: Print) {
- this.timer = new Timer();
- }
-
- private printStats() {
- this.out.printDiv();
- this.out.printElapsedTime(this.timer.asString, this.timer.time);
- this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
- this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
- }
-
- private printFailedFiles() {
- if (this.getFailedFiles().length > 0) {
- this.out.printDiv();
-
- this.out.printFailedTestMessage();
-
- this.out.printDiv();
-
- for(var i = 0; i < this.getFailedFiles().length; i++) {
- var errorFile = this.getFailedFiles()[i];
- this.out.printErrorFile(errorFile.formatName(this.fileHandler.path));
- }
- }
- }
-
- private run(it, file, len, maxLen, callback: Function) {
- if (endsWith(file.toUpperCase(), '-TESTS.TS')) {
- new Test(file).run((o) => {
- var failed = false;
-
- if(o.exitCode === 1) {
- this.out.printFailure();
- failed = true;
- len++;
- } else {
- this.out.printSuccess();
- len++;
- }
-
- this.files.push(new File(file, failed));
-
- if(len > maxLen) {
- len = 0;
- this.out.breack();
- }
-
- if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- } else {
- this.out.breack();
- this.timer.end();
- this.printFailedFiles();
- this.printStats();
-
- callback(this.getFailedFiles().length, this.files.length);
- }
- });
- } else if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- } else {
- this.out.breack();
- this.timer.end();
- this.printFailedFiles();
- this.printStats();
-
- callback(this.getFailedFiles().length, this.files.length);
- }
- }
-
- public start(callback: Function) {
- this.timer.start();
-
- var tsFiles = this.fileHandler.allTS();
-
- var it = new Iterator(tsFiles);
-
- var len = 0;
- var maxLen = 76;
-
- if (it.hasNext()) {
- this.run(it, it.next(), len, maxLen, callback);
- }
- }
- }
-
- export class TestRunner {
- private fh: FileHandler;
- private out: Print;
- private sc: SyntaxChecking;
- private te: TestEval;
- private typings: Typing[] = [];
-
- private printTypingsWithoutTest() {
- var count = 0;
-
- if (this.typings.length > 0) {
- this.out.printDiv();
-
- this.out.printTypingsWithoutTestsMessage();
-
- this.out.printDiv();
-
- for(var i = 0; i < this.typings.length; i++) {
- var typing = this.typings[i];
- if(typing.fileHandler.allTests().length == 0) {
- if (typing.name != '_infrastructure'
- && typing.name != '_ReSharper.DefinitelyTyped'
- && typing.name != 'obj'
- && typing.name != 'bin'
- && typing.name != 'Properties') {
- this.out.printTypingsWithoutTest(typing.name);
- count++;
- }
- }
- }
- }
-
- return count;
- }
-
- constructor(public dtPath: string) {
- this.fh = new FileHandler(dtPath, /.\.ts/g);
- this.out = new Print('0.9.1.1', this.fh.allTypings().length, this.fh.allTS().length);
- this.sc = new SyntaxChecking(this.fh, this.out);
- this.te = new TestEval(this.fh, this.out);
-
- var tpgs = this.fh.allTypings();
- for(var i = 0; i < tpgs.length; i++) {
- this.typings.push(new Typing(tpgs[i], this.dtPath));
- }
- }
-
- public run() {
- var timer = new Timer();
- timer.start();
-
- this.out.printHeader();
- this.out.printSyntaxChecking();
-
- this.sc.start((syntaxFailedCount, syntaxTotal) => {
- this.out.printTypingTests();
- this.te.start((testFailedCount, testTotal) => {
- var total = this.printTypingsWithoutTest();
-
- timer.end();
-
- this.out.printDiv();
- this.out.printTotalMessage();
- this.out.printDiv();
-
- this.out.printElapsedTime(timer.asString, timer.time);
- this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal);
- this.out.printTestErrorCount(testFailedCount, testTotal);
- this.out.printWithoutTestCount(total, this.fh.allTypings().length);
-
- this.out.printDiv();
-
- if (syntaxFailedCount > 0 || testFailedCount > 0) {
- process.exit(1);
- }
- });
- });
- }
- }
- }
+module DefinitelyTyped.TestManager {
+
+ var path = require('path');
+
+ function endsWith(str, suffix) {
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
+ }
+
+ class Iterator {
+ index: number = -1;
+
+ constructor(public list: any[]) { }
+
+ public next() {
+ this.index++;
+ return this.list[this.index];
+ }
+
+ public hasNext() {
+ return this.list[1 + this.index] != null;
+ }
+ }
+
+ interface TscCallback {
+ (result: ExecResult): void;
+ }
+
+ class Tsc {
+ public static run(tsfile: string, callback: TscCallback) {
+ var command = 'node ./_infrastructure/tests/typescript/tsc.js --module commonjs ';
+ if (IO.fileExists(tsfile + '.tscparams')) {
+ command += '@' + tsfile + '.tscparams';
+ } else {
+ command += '--noImplicitAny';
+ }
+ Exec.exec(command, [tsfile], (ExecResult) => {
+ callback(ExecResult);
+ });
+ }
+ }
+
+ class Test {
+ constructor(public tsfile: string) { }
+
+ public run(callback: TscCallback) {
+ Tsc.run(this.tsfile, callback);
+ }
+ }
+
+ class Typing {
+ public fileHandler: FileHandler;
+
+ constructor(public name: string, baseDir: string) {
+ this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g);
+ }
+ }
+
+ /////////////////////////////////
+ // Given a document root + ts file pattern this class returns:
+ // all the TS files OR just tests OR just definition files
+ /////////////////////////////////
+ class FileHandler {
+ public files: string[] = [];
+ public typings: Typing[] = [];
+
+ constructor(public path: string, pattern: any) {
+ this.files = IO.dir(path, pattern, { recursive: true }).sort();
+ }
+
+ public allTS(): string[] {
+ return this.files;
+ }
+
+ public allTests(): string[] {
+ var tests = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (endsWith(this.files[i].toUpperCase(), '-TESTS.TS')) {
+ tests.push(this.files[i]);
+ }
+ }
+
+ return tests;
+ }
+
+ public allTypings(): string[] {
+ var typings = {};
+
+ for (var i = 0; i < this.files.length; i++) {
+ var file = this.files[i];
+ var firName = path.dirname(file.substr(this.path.length + 1)).replace('\\', '/');
+ var dir = firName.split('/')[0];
+
+ if (!typings[dir]) typings[dir] = true;
+ }
+
+ var list = [];
+ for (var attr in typings) {
+ list.push(attr);
+ }
+
+ return list;
+ }
+ }
+
+ /////////////////////////////////
+ // Timer.start starts a timer
+ // Timer.end stops the timer and sets asString to the pretty print value
+ /////////////////////////////////
+ class Timer {
+ public startTime;
+ public time = 0;
+ public asString: string;
+
+ private static prettyDate(date1, date2): string {
+ var diff = ((date2 - date1) / 1000),
+ day_diff = Math.floor(diff / 86400);
+
+ if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31)
+ return;
+
+ return (day_diff == 0 && (
+ diff < 60 && (diff + " seconds") ||
+ diff < 120 && "1 minute" ||
+ diff < 3600 && Math.floor(diff / 60) + " minutes" ||
+ diff < 7200 && "1 hour" ||
+ diff < 86400 && Math.floor(diff / 3600) + " hours") ||
+ day_diff == 1 && "Yesterday" ||
+ day_diff < 7 && day_diff + " days" ||
+ day_diff < 31 && Math.ceil(day_diff / 7) + " weeks");
+ }
+
+ public start() {
+ this.time = 0;
+ this.startTime = this.now();
+ }
+
+ private now() {
+ return Date.now();
+ }
+
+ public end() {
+ this.time = (this.now() - this.startTime) / 1000;
+ this.asString = Timer.prettyDate(this.startTime, this.now());
+ }
+ }
+
+ /////////////////////////////////
+ // All the common things that we pring are functions of this class
+ /////////////////////////////////
+ class Print {
+ constructor(public version: string, public typings: number, public tsFiles: number) { }
+
+ public out(s) {
+ process.stdout.write(s);
+ }
+
+ public printHeader() {
+ this.out('=============================================================================\n');
+ this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.3.0\33[0m\n');
+ this.out('=============================================================================\n');
+ this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
+ this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
+ this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
+ }
+
+ public printSyntaxCheckingHeader() {
+ this.out('============================ \33[34m\33[1mSyntax checking\33[0m ================================\n');
+ }
+
+ public printTypingTestsHeader() {
+ this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n');
+ }
+
+ public printSuccessCharacter() {
+ this.out('\33[36m\33[1m.\33[0m');
+ }
+
+ public printFailureCharacter() {
+ this.out('x');
+ }
+
+ public printDiv() {
+ this.out('-----------------------------------------------------------------------------\n');
+ }
+
+ public printBoldDiv() {
+ this.out('=============================================================================\n');
+ }
+
+ public printErrorsHeader() {
+ this.out('=============================================================================\n');
+ this.out(' \33[34m\33[1mErrors in files\33[0m \n');
+ this.out('=============================================================================\n');
+ }
+
+ public printErrorsForFile(file: File) {
+ this.out('----------------- For file:' + file.formatName() );
+ this.printBreak();
+ this.out(file.execResult.stderr);
+ this.printBreak();
+ }
+
+ public printfilesWithSintaxErrorMessage() {
+ this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n');
+ }
+
+ public printFailedTestMessage() {
+ this.out(' \33[36m\33[1mFailed tests\33[0m\n');
+ }
+
+ public printTypingsWithoutTestsMessage() {
+ this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
+ }
+
+ public printTotalMessage() {
+ this.out(' \33[36m\33[1mTotal\33[0m\n');
+ }
+
+ public printErrorFile(file: string) {
+ this.out(' - ' + file + '\n');
+ }
+
+ public printTypingsWithoutTest(file) {
+ this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
+ }
+
+ public printBreak() {
+ this.out('\n');
+ }
+
+ public printSuccessCount(current: number, total: number) {
+ this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ }
+
+ public printFailedCount(current: number, total: number) {
+ this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ }
+
+ public printElapsedTime(time, s) {
+ this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
+ }
+
+ public printSyntaxErrorCount(current: number, total: number) {
+ this.out(' \33[36m\33[1mSyntax error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ }
+
+ public printTestErrorCount(current: number, total: number) {
+ this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ }
+
+ public printWithoutTestCount(current: number, total: number) {
+ this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
+ }
+ }
+
+ /////////////////////////////
+ // Represents the results of a test file execution
+ /////////////////////////////
+ class File {
+ static baseDir: string;
+
+ constructor(public baseDir: string, public filePathWithName: string, public execResult: ExecResult) { }
+
+ // From '/complete/path/to/file' to 'specfolder/specfile.d.ts'
+ public formatName(): string {
+ var dirName = path.dirname(this.filePathWithName.substr(this.baseDir.length + 1)).replace('\\', '/');
+ var dir = dirName.split('/')[0];
+ var file = path.basename(this.filePathWithName, '.ts');
+ var ext = path.extname(this.filePathWithName);
+
+ return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext;
+ }
+ }
+
+
+ /////////////////////////////
+ // Determine syntax errors in typings
+ /////////////////////////////
+ class SyntaxChecking {
+
+ private timer: Timer;
+
+ public files: File[] = [];
+
+ private getFailedFiles(): File[] {
+ var list: File[] = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (this.files[i].execResult.exitCode) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ }
+
+ private getSuccessFiles(): File[] {
+ var list: File[] = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (!this.files[i].execResult.exitCode) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ }
+
+ constructor(public fileHandler: FileHandler, public out: Print) {
+ this.timer = new Timer();
+ }
+
+ private printStats() {
+ this.out.printDiv();
+ this.out.printElapsedTime(this.timer.asString, this.timer.time);
+ this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
+ this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
+ }
+
+ private printFailedFiles() {
+ if (this.getFailedFiles().length > 0) {
+ this.out.printDiv();
+
+ this.out.printfilesWithSintaxErrorMessage();
+
+ this.out.printDiv();
+
+ for (var i = 0; i < this.getFailedFiles().length; i++) {
+ var errorFile = this.getFailedFiles()[i];
+ this.out.printErrorFile(errorFile.formatName());
+ }
+ }
+ }
+
+ private run(it, file, len, maxLen, callback: Function) {
+ if (!endsWith(file.toUpperCase(), '-TESTS.TS') && endsWith(file.toUpperCase(), '.TS') && file.indexOf('../_infrastructure') < 0) {
+ new Test(file).run((execResult) => {
+
+ if (execResult.exitCode === 1) {
+ this.out.printFailureCharacter();
+ len++;
+ } else {
+ this.out.printSuccessCharacter();
+ len++;
+ }
+
+ this.files.push(new File(this.fileHandler.path, file, execResult));
+
+ if (len > maxLen) {
+ len = 0;
+ this.out.printBreak();
+ }
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ } else {
+ this.out.printBreak();
+ this.timer.end();
+ this.printFailedFiles();
+ this.printStats();
+
+ callback(this.getFailedFiles().length, this.files.length);
+ }
+ });
+ } else if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ } else {
+ this.out.printBreak();
+ this.timer.end();
+ this.printStats();
+ this.printFailedFiles();
+
+ callback(this.getFailedFiles().length, this.files.length);
+ }
+ }
+
+ public start(callback: Function) {
+ this.timer.start();
+
+ var tsFiles = this.fileHandler.allTS();
+
+ var it = new Iterator(tsFiles);
+
+ var len = 0;
+ var maxLen = 76;
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ }
+ }
+ }
+
+ /////////////////////////////
+ // Determines errors in typing tests
+ /////////////////////////////
+ class TestEval {
+
+ private timer: Timer;
+
+ public files: File[] = [];
+
+ private getFailedFiles(): File[] {
+ var list: File[] = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (this.files[i].execResult.exitCode) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ }
+
+ private getSuccessFiles(): File[] {
+ var list: File[] = [];
+
+ for (var i = 0; i < this.files.length; i++) {
+ if (!this.files[i].execResult.exitCode) {
+ list.push(this.files[i]);
+ }
+ }
+
+ return list;
+ }
+
+ constructor(public fileHandler: FileHandler, public out: Print) {
+ this.timer = new Timer();
+ }
+
+ private printStats() {
+ this.out.printDiv();
+ this.out.printElapsedTime(this.timer.asString, this.timer.time);
+ this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
+ this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
+ }
+
+ private printFailedFiles() {
+ if (this.getFailedFiles().length > 0) {
+ this.out.printDiv();
+
+ this.out.printFailedTestMessage();
+
+ this.out.printDiv();
+
+ for (var i = 0; i < this.getFailedFiles().length; i++) {
+ var errorFile = this.getFailedFiles()[i];
+ this.out.printErrorFile(errorFile.formatName());
+ }
+ }
+ }
+
+ private run(it, file, len, maxLen, callback: Function) {
+ if (endsWith(file.toUpperCase(), '-TESTS.TS')) {
+ new Test(file).run((execResult) => {
+
+ if (execResult.exitCode === 1) {
+ this.out.printFailureCharacter();
+ len++;
+ } else {
+ this.out.printSuccessCharacter();
+ len++;
+ }
+
+ this.files.push(new File(this.fileHandler.path, file, execResult));
+
+ if (len > maxLen) {
+ len = 0;
+ this.out.printBreak();
+ }
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ } else {
+ this.out.printBreak();
+ this.timer.end();
+ this.printFailedFiles();
+ this.printStats();
+
+ callback(this.getFailedFiles().length, this.files.length);
+ }
+ });
+ } else if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ } else {
+ this.out.printBreak();
+ this.timer.end();
+ this.printFailedFiles();
+ this.printStats();
+
+ callback(this.getFailedFiles().length, this.files.length);
+ }
+ }
+
+ public start(callback: Function) {
+ this.timer.start();
+
+ var tsFiles = this.fileHandler.allTS();
+
+ var it = new Iterator(tsFiles);
+
+ var len = 0;
+ var maxLen = 76;
+
+ if (it.hasNext()) {
+ this.run(it, it.next(), len, maxLen, callback);
+ }
+ }
+ }
+
+ /////////////////////////////////
+ // The main class to kick things off
+ /////////////////////////////////
+ export class TestRunner {
+ private fh: FileHandler;
+ private out: Print;
+ private sc: SyntaxChecking;
+ private te: TestEval;
+ private typings: Typing[] = [];
+
+ private printTypingsWithoutTest() {
+ var count = 0;
+
+ if (this.typings.length > 0) {
+ this.out.printDiv();
+
+ this.out.printTypingsWithoutTestsMessage();
+
+ this.out.printDiv();
+
+ for (var i = 0; i < this.typings.length; i++) {
+ var typing = this.typings[i];
+ if (typing.fileHandler.allTests().length == 0) {
+ if (typing.name != '_infrastructure'
+ && typing.name != '_ReSharper.DefinitelyTyped'
+ && typing.name != 'obj'
+ && typing.name != 'bin'
+ && typing.name != 'Properties') {
+ this.out.printTypingsWithoutTest(typing.name);
+ count++;
+ }
+ }
+ }
+ }
+
+ return count;
+ }
+
+ private printErrorsDetected() {
+ this.out.printErrorsHeader();
+
+ var printErrorsForFileIfFound = (file: File) => {
+ if (file.execResult.exitCode)
+ this.out.printErrorsForFile(file);
+ };
+
+ // sc errors:
+ this.sc.files.forEach(printErrorsForFileIfFound);
+ this.out.printBoldDiv();
+
+ // te errors:
+ this.te.files.forEach(printErrorsForFileIfFound);
+ this.out.printBoldDiv();
+ }
+
+ constructor(public dtPath: string) {
+ this.fh = new FileHandler(dtPath, /.\.ts/g);
+ this.out = new Print('0.9.1.1', this.fh.allTypings().length, this.fh.allTS().length);
+ this.sc = new SyntaxChecking(this.fh, this.out);
+ this.te = new TestEval(this.fh, this.out);
+
+ var tpgs = this.fh.allTypings();
+ for (var i = 0; i < tpgs.length; i++) {
+ this.typings.push(new Typing(tpgs[i], this.dtPath));
+ }
+ }
+
+ public run() {
+ var timer = new Timer();
+ timer.start();
+
+ this.out.printHeader();
+
+ // Run syntax tests
+ this.out.printSyntaxCheckingHeader();
+ this.sc.start((syntaxFailedCount, syntaxTotal) => {
+
+ // Now run typing tests
+ this.out.printTypingTestsHeader();
+ this.te.start((testFailedCount, testTotal) => {
+
+ // Get the tests without any typing and simultaneously print their names
+ var totalTypingsWithoutTest = this.printTypingsWithoutTest();
+
+ // End total timer and print final messages
+ timer.end();
+
+ this.out.printDiv();
+ this.out.printTotalMessage();
+ this.out.printDiv();
+
+ this.out.printElapsedTime(timer.asString, timer.time);
+ this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal);
+ this.out.printTestErrorCount(testFailedCount, testTotal);
+ this.out.printWithoutTestCount(totalTypingsWithoutTest, this.fh.allTypings().length);
+
+ this.out.printDiv();
+
+ if (syntaxFailedCount > 0 || testFailedCount > 0) {
+ this.printErrorsDetected();
+ process.exit(1);
+ }
+ });
+ });
+ }
+ }
}
-declare var __dirname: any;
-
var dtPath = __dirname + '/../..';
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
diff --git a/_infrastructure/tests/src/io.ts b/_infrastructure/tests/src/io.ts
index 6fce75489..2c7a81f4f 100644
--- a/_infrastructure/tests/src/io.ts
+++ b/_infrastructure/tests/src/io.ts
@@ -83,22 +83,12 @@ declare class Enumerator {
public item(): any;
constructor (o: any);
}
-declare function setTimeout(callback: () =>void , ms?: number);
-//declare var require: any;
-declare module process {
- export var argv: string[];
- export var platform: string;
- export function on(event: string, handler: (any) => void ): void;
- export module stdout {
- export function write(str: string);
+
+// Missing in node definitions, but called in code below.
+interface NodeProcess {
+ mainModule: {
+ filename: string;
}
- export module stderr {
- export function write(str: string);
- }
- export module mainModule {
- export var filename: string;
- }
- export function exit(exitCode?: number);
}
var IO = (function() {
diff --git a/angularjs/README.md b/angularjs/README.md
index 1692d947c..806a605d5 100644
--- a/angularjs/README.md
+++ b/angularjs/README.md
@@ -35,6 +35,7 @@ To avoid cluttering the list of suggestions as you type in your IDE, all interfa
* `ng.cookies` for **ngCookies**
* `ng.mock` for **ngMock**
* `ng.resource` for **ngResource**
+* `ng.route` for **ngRoute**
* `ng.sanitize` for **ngSanitize**
**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces.
diff --git a/angularjs/angular-1.0-tests.ts b/angularjs/angular-1.0-tests.ts
new file mode 100644
index 000000000..ff3c87f77
--- /dev/null
+++ b/angularjs/angular-1.0-tests.ts
@@ -0,0 +1,219 @@
+///
+
+// 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
+ */
+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 = [];
+
+ /**
+ * 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
+ });
+ }
+
+ this.$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 < buffer.length; ++i) {
+ retry(buffer[i].config, buffer[i].deferred);
+ }
+ buffer = [];
+ }
+
+ return {
+ loginConfirmed: function () {
+ $rootScope.$broadcast('event:auth-loginConfirmed');
+ retryAll();
+ }
+ }
+ }]
+ })
+
+/**
+ * $http interceptor.
+ * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
+ */
+ .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider) {
+
+ 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[];
+ }
+
+ 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;
+ });
+ }
+
+ // 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) => console.log(data));
+ }
+}
+
+// Test for AngularJS Syntax
+
+module My.Namespace {
+ export var x; // 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) { })
+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);
+
+// 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();
+});
+
+
+// angular.element() tests
+var element = angular.element("div.myApp");
+var scope: ng.IScope = element.scope();
+
+
diff --git a/angularjs/angular-1.0-tests.ts.tscparams b/angularjs/angular-1.0-tests.ts.tscparams
new file mode 100644
index 000000000..e16c76dff
--- /dev/null
+++ b/angularjs/angular-1.0-tests.ts.tscparams
@@ -0,0 +1 @@
+""
diff --git a/angularjs/angular-1.0.d.ts b/angularjs/angular-1.0.d.ts
new file mode 100755
index 000000000..ecb7bd2c9
--- /dev/null
+++ b/angularjs/angular-1.0.d.ts
@@ -0,0 +1,760 @@
+// Type definitions for Angular JS 1.0
+// 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 {
+
+ // 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;
+ 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;
+ /** construct your angular application
+ official docs: Interface for configuring angular modules.
+ see: http://docs.angularjs.org/api/angular.Module
+ */
+ module(
+ /** name of your module you want to create */
+ name: string,
+ /** name of modules yours depends on */
+ requires?: string[],
+ configFunction?: any): 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, inlineAnnotadedFunction: any[]): IModule;
+ animation(object: Object): IModule;
+ /** configure existing services.
+ Use this method to register work which needs to be performed on module loading
+ */
+ config(configFn: Function): IModule;
+ /** configure existing services.
+ Use this method to register work which needs to be performed on module loading
+ */
+ config(inlineAnnotadedFunction: any[]): IModule;
+ constant(name: string, value: any): IModule;
+ constant(object: Object): IModule;
+ controller(name: string, controllerConstructor: Function): IModule;
+ controller(name: string, inlineAnnotadedConstructor: any[]): IModule;
+ controller(object : Object): IModule;
+ directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule;
+ directive(name: string, inlineAnnotadedFunction: any[]): IModule;
+ directive(object: Object): IModule;
+ factory(name: string, serviceFactoryFunction: Function): IModule;
+ factory(name: string, inlineAnnotadedFunction: any[]): IModule;
+ factory(object: Object): IModule;
+ filter(name: string, filterFactoryFunction: Function): IModule;
+ filter(name: string, inlineAnnotadedFunction: any[]): IModule;
+ filter(object: Object): IModule;
+ provider(name: string, serviceProviderConstructor: Function): IModule;
+ provider(name: string, inlineAnnotadedConstructor: any[]): IModule;
+ provider(object: Object): IModule;
+ run(initializationFunction: Function): IModule;
+ run(inlineAnnotadedFunction: any[]): IModule;
+ service(name: string, serviceConstructor: Function): IModule;
+ service(name: string, inlineAnnotadedConstructor: any[]): IModule;
+ service(object: Object): IModule;
+ 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 {
+ $set(name: string, value: any): void;
+ $observe(name: string, fn:(value?:any)=>any):void;
+ $attr: any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // FormController
+ // see http://docs.angularjs.org/api/ng.directive:form.FormController
+ ///////////////////////////////////////////////////////////////////////////
+ interface IFormController {
+ $pristine: boolean;
+ $dirty: boolean;
+ $valid: boolean;
+ $invalid: boolean;
+ $error: any;
+ $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;
+ $setViewValue(value: string): void;
+
+ // XXX Not sure about the types here. Documentation states it's a string, but
+ // I've seen it receiving other types throughout the code.
+ // Falling back to any for now.
+ $viewValue: any;
+
+ // XXX Same as avove
+ $modelValue: any;
+
+ $parsers: IModelParser[];
+ $formatters: IModelFormatter[];
+ $error: any;
+ $pristine: boolean;
+ $dirty: boolean;
+ $valid: boolean;
+ $invalid: boolean;
+ }
+
+ interface IModelParser {
+ (value: any): any;
+ }
+
+ interface IModelFormatter {
+ (value: any): any;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Scope
+ // see http://docs.angularjs.org/api/ng.$rootScope.Scope
+ ///////////////////////////////////////////////////////////////////////////
+ interface IScope {
+ $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): any;
+ $eval(expression: (scope: IScope) => any): 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;
+
+ $parent: IScope;
+
+ $id: number;
+
+ // Hidden members
+ $$isolateBindings: any;
+ $$phase: 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 {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // BrowserService
+ // TODO undocumented, so we need to get it from the source code
+ ///////////////////////////////////////////////////////////////////////////
+ interface IBrowserService {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TimeoutService
+ // see http://docs.angularjs.org/api/ng.$timeout
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITimeoutService {
+ (func: Function, delay?: 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
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILogService {
+ debug: ILogCall;
+ error: ILogCall;
+ info: ILogCall;
+ log: ILogCall;
+ warn: ILogCall;
+ }
+
+ // 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
+ ///////////////////////////////////////////////////////////////////////////
+ interface IParseService {
+ (expression: string): ICompiledExpression;
+ }
+
+ 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 Document {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // 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 {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // QService
+ // see http://docs.angularjs.org/api/ng.$q
+ ///////////////////////////////////////////////////////////////////////////
+ interface IQService {
+ all(promises: IPromise[]): IPromise;
+ defer(): IDeferred;
+ reject(reason?: any): IPromise;
+ when(value: T): IPromise;
+ }
+
+ interface IPromise {
+ then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any): IPromise;
+ then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any): IPromise;
+ then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult): IPromise;
+ }
+
+ interface IDeferred {
+ resolve(value?: T): void;
+ reject(reason?: 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?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
+ (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
+ (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
+ }
+
+ interface ICompileProvider extends IServiceProvider {
+ directive(name: string, directiveFactory: Function): ICompileProvider;
+
+ // Undocumented, but it is there...
+ directive(directivesMap: any): ICompileProvider;
+ }
+
+ interface ITemplateLinkingFunction {
+ // Let's hint but not force cloneAttachFn's signature
+ (scope: IScope, cloneAttachFn?: (clonedElement?: JQuery, scope?: IScope) => any): JQuery;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // 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, dependencyAnnotadedConstructor: any[]): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // HttpService
+ // see http://docs.angularjs.org/api/ng.$http
+ ///////////////////////////////////////////////////////////////////////////
+ interface IHttpService {
+ // At least moethod and url must be provided...
+ (config: IRequestConfig): IHttpPromise;
+ get (url: string, RequestConfig?: any): IHttpPromise;
+ delete (url: string, RequestConfig?: any): IHttpPromise;
+ head(url: string, RequestConfig?: any): IHttpPromise;
+ jsonp(url: string, RequestConfig?: any): IHttpPromise;
+ post(url: string, data: any, RequestConfig?: any): IHttpPromise;
+ put(url: string, data: any, RequestConfig?: any): IHttpPromise;
+ defaults: IRequestConfig;
+
+ // For debugging, BUT it is documented as public, so...
+ pendingRequests: any[];
+ }
+
+ // This is just for hinting.
+ // Some opetions might not be available depending on the request.
+ // see http://docs.angularjs.org/api/ng.$http#Usage for options explanations
+ interface IRequestConfig {
+ method: string;
+ url: string;
+ params?: any;
+
+ // XXX it has it's own structure... perhaps we should define it in the future
+ headers?: any;
+
+ cache?: any;
+ timeout?: number;
+ withCredentials?: boolean;
+
+ // These accept multiple types, so let's defile them as any
+ data?: any;
+ transformRequest?: any;
+ transformResponse?: any;
+ }
+
+ 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;
+ }
+
+ interface IHttpPromise extends IPromise {
+ success(callback: IHttpPromiseCallback): IHttpPromise;
+ error(callback: IHttpPromiseCallback): IHttpPromise;
+ then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
+ then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, 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;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RouteParamsService
+ // see http://docs.angularjs.org/api/ng.$routeParams
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRouteParamsService {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TemplateCacheService
+ // see http://docs.angularjs.org/api/ng.$templateCache
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITemplateCacheService extends ICacheObject {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RootScopeService
+ // see http://docs.angularjs.org/api/ng.$rootScope
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRootScopeService extends IScope {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RouteService
+ // see http://docs.angularjs.org/api/ng.$route
+ // see http://docs.angularjs.org/api/ng.$routeProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRouteService {
+ reload(): void;
+ routes: any;
+
+ // May not always be available. For instance, current will not be available
+ // to a controller that was not initialized as a result of a route maching.
+ current?: ICurrentRoute;
+ }
+
+ // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations
+ interface IRoute {
+ controller?: any;
+ name?: string;
+ template?: string;
+ templateUrl?: any;
+ resolve?: any;
+ redirectTo?: any;
+ reloadOnSearch?: boolean;
+ }
+
+ // see http://docs.angularjs.org/api/ng.$route#current
+ interface ICurrentRoute extends IRoute {
+ locals: {
+ $scope: IScope;
+ $template: string;
+ };
+
+ params: any;
+ }
+
+ interface IRouteProvider extends IServiceProvider {
+ otherwise(params: any): IRouteProvider;
+ when(path: string, route: IRoute): IRouteProvider;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Directive
+ // see http://docs.angularjs.org/api/ng.$compileProvider#directive
+ // and http://docs.angularjs.org/guide/directive
+ ///////////////////////////////////////////////////////////////////////////
+
+ interface IDirective{
+ priority?: number;
+ template?: any;
+ templateUrl?: any;
+ replace?: boolean;
+ transclude?: any;
+ restrict?: string;
+ scope?: any;
+ link?: Function;
+ compile?: Function;
+ controller?: 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;
+
+ inheritedData(key: string, value: any): JQuery;
+ inheritedData(obj: { [key: string]: any; }): JQuery;
+ inheritedData(key?: string): any;
+
+
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AUTO module (angular.js)
+ ///////////////////////////////////////////////////////////////////////////
+ export module auto {
+
+ ///////////////////////////////////////////////////////////////////////
+ // InjectorService
+ // see http://docs.angularjs.org/api/AUTO.$injector
+ ///////////////////////////////////////////////////////////////////////
+ interface IInjectorService {
+ annotate(fn: Function): string[];
+ annotate(inlineAnnotadedFunction: any[]): string[];
+ get (name: string): any;
+ instantiate(typeConstructor: Function, locals?: 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;
+ constant(name: string, value: any): void;
+
+ decorator(name: string, decorator: Function): void;
+ decorator(name: string, decoratorInline: any[]): void;
+ factory(name: string, serviceFactoryFunction: Function): 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/angularjs/angular-cookies-1.0.d.ts b/angularjs/angular-cookies-1.0.d.ts
new file mode 100644
index 000000000..4dc2e038e
--- /dev/null
+++ b/angularjs/angular-cookies-1.0.d.ts
@@ -0,0 +1,30 @@
+/// Type definitions for Angular JS 1.0 (ngCookies module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+///////////////////////////////////////////////////////////////////////////////
+// ngCookies module (angular-cookies.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng.cookies {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // CookieService
+ // see http://docs.angularjs.org/api/ngCookies.$cookies
+ ///////////////////////////////////////////////////////////////////////////
+ interface ICookiesService {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // CookieStoreService
+ // see http://docs.angularjs.org/api/ngCookies.$cookieStore
+ ///////////////////////////////////////////////////////////////////////////
+ interface ICookieStoreService {
+ get(key: string): any;
+ put(key: string, value: any): void;
+ remove(key: string): void;
+ }
+
+}
diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts
index 4dc2e038e..60eebbacb 100644
--- a/angularjs/angular-cookies.d.ts
+++ b/angularjs/angular-cookies.d.ts
@@ -1,4 +1,4 @@
-/// Type definitions for Angular JS 1.0 (ngCookies module)
+/// Type definitions for Angular JS 1.2 (ngCookies module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
diff --git a/angularjs/angular-mocks-1.0.d.ts b/angularjs/angular-mocks-1.0.d.ts
new file mode 100644
index 000000000..4d8decbf8
--- /dev/null
+++ b/angularjs/angular-mocks-1.0.d.ts
@@ -0,0 +1,150 @@
+// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+///////////////////////////////////////////////////////////////////////////////
+// functions attached to global object (window)
+///////////////////////////////////////////////////////////////////////////////
+declare var module: (...modules: any[]) => any;
+declare var inject: (...fns: Function[]) => any;
+
+///////////////////////////////////////////////////////////////////////////////
+// ngMock module (angular-mocks.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AngularStatic
+ // We reopen it to add the MockStatic definition
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAngularStatic {
+ mock: IMockStatic;
+ }
+
+ interface IMockStatic {
+ // see http://docs.angularjs.org/api/angular.mock.debug
+ debug(obj: any): string;
+
+ // see http://docs.angularjs.org/api/angular.mock.inject
+ inject(...fns: Function[]): any;
+
+ // see http://docs.angularjs.org/api/angular.mock.module
+ module(...modules: any[]): any;
+
+ // see http://docs.angularjs.org/api/angular.mock.TzDate
+ TzDate(offset: number, timestamp: number): Date;
+ TzDate(offset: number, timestamp: string): Date;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ExceptionHandlerService
+ // see http://docs.angularjs.org/api/ngMock.$exceptionHandler
+ // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IExceptionHandlerProvider extends IServiceProvider {
+ mode(mode: string): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TimeoutService
+ // see http://docs.angularjs.org/api/ngMock.$timeout
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITimeoutService {
+ flush(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LogService
+ // see http://docs.angularjs.org/api/ngMock.$log
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILogService {
+ assertEmpty(): void;
+ reset(): void;
+ }
+
+ interface LogCall {
+ logs: string[];
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // HttpBackendService
+ // see http://docs.angularjs.org/api/ngMock.$httpBackend
+ ///////////////////////////////////////////////////////////////////////////
+ interface IHttpBackendService {
+ flush(count?: number): void;
+ resetExpectations(): void;
+ verifyNoOutstandingExpectation(): void;
+ verifyNoOutstandingRequest(): void;
+
+ expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
+ expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler;
+ expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
+
+ when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
+ when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
+ when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler;
+ when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
+ when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
+ when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
+
+ expectDELETE(url: string, headers?: any): mock.IRequestHandler;
+ expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
+ expectGET(url: string, headers?: any): mock.IRequestHandler;
+ expectGET(url: RegExp, headers?: any): mock.IRequestHandler;
+ expectHEAD(url: string, headers?: any): mock.IRequestHandler;
+ expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
+ expectJSONP(url: string): mock.IRequestHandler;
+ expectJSONP(url: RegExp): mock.IRequestHandler;
+ expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler;
+ expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
+ expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler;
+ expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
+ expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler;
+ expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
+
+ whenDELETE(url: string, headers?: any): mock.IRequestHandler;
+ whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
+ whenGET(url: string, headers?: any): mock.IRequestHandler;
+ whenGET(url: RegExp, headers?: any): mock.IRequestHandler;
+ whenHEAD(url: string, headers?: any): mock.IRequestHandler;
+ whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
+ whenJSONP(url: string): mock.IRequestHandler;
+ whenJSONP(url: RegExp): mock.IRequestHandler;
+ whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
+ whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
+ whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
+ whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
+ whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
+ whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
+ }
+
+ export module mock {
+
+ // returned interface by the the mocked HttpBackendService expect/when methods
+ interface IRequestHandler {
+ respond(func: Function): void;
+ respond(status: number, data?: any, headers?: any): void;
+ respond(data: any, headers?: any): void;
+
+ // Available wehn ngMockE2E is loaded
+ passThrough(): void;
+ }
+
+ }
+
+}
diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts
new file mode 100644
index 000000000..b43580f36
--- /dev/null
+++ b/angularjs/angular-mocks-tests.ts
@@ -0,0 +1,288 @@
+///
+
+///////////////////////////////////////
+// IAngularStatic
+///////////////////////////////////////
+var angular: ng.IAngularStatic;
+var mock: ng.IMockStatic;
+
+mock = angular.mock;
+
+
+///////////////////////////////////////
+// IMockStatic
+///////////////////////////////////////
+var date: Date;
+
+mock.dump({ key: 'value' });
+
+mock.inject(
+ function () { return 1; },
+ function () { return 2; }
+ );
+
+mock.module('module1', 'module2');
+mock.module(
+ function () { return 1; },
+ function () { return 2; }
+ );
+mock.module({ module1: function () { return 1; } });
+
+date = mock.TzDate(-7, '2013-1-1T15:00:00Z');
+date = mock.TzDate(-8, 12345678);
+
+
+///////////////////////////////////////
+// IExceptionHandlerProvider
+///////////////////////////////////////
+var exceptionHandlerProvider: ng.IExceptionHandlerProvider;
+
+exceptionHandlerProvider.mode('log');
+
+
+///////////////////////////////////////
+// IExceptionHandlerProvider
+///////////////////////////////////////
+var timeoutService: ng.ITimeoutService;
+
+timeoutService.flush();
+timeoutService.flush(1234);
+timeoutService.flushNext();
+timeoutService.flushNext(1234);
+timeoutService.verifyNoPendingTasks();
+
+
+///////////////////////////////////////
+// ILogService, ILogCall
+///////////////////////////////////////
+var logService: ng.ILogService;
+var logCall: ng.ILogCall;
+var logs: string[];
+
+logService.assertEmpty();
+logService.reset();
+
+logCall = logService.debug;
+logCall = logService.error;
+logCall = logService.info;
+logCall = logService.log;
+logCall = logService.warn;
+
+logs = logCall.logs;
+
+
+///////////////////////////////////////
+// IHttpBackendService
+///////////////////////////////////////
+var httpBackendService: ng.IHttpBackendService;
+var requestHandler: ng.mock.IRequestHandler;
+
+httpBackendService.flush();
+httpBackendService.flush(1234);
+httpBackendService.resetExpectations();
+httpBackendService.verifyNoOutstandingExpectation();
+httpBackendService.verifyNoOutstandingRequest();
+
+requestHandler = httpBackendService.expect('GET', 'http://test.local');
+requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data');
+requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/);
+requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', /test.local/);
+requestHandler = httpBackendService.expect('GET', /test.local/, 'response data');
+requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', /test.local/, /response data/);
+requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
+requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
+
+requestHandler = httpBackendService.expectDELETE('http://test.local');
+requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.expectGET('http://test.local');
+requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.expectHEAD('http://test.local');
+requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.expectJSONP('http://test.local');
+requestHandler = httpBackendService.expectJSONP(/test.local/);
+
+requestHandler = httpBackendService.expectPATCH('http://test.local');
+requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
+requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/);
+requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local/);
+requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data');
+requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/);
+requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
+
+requestHandler = httpBackendService.expectPOST('http://test.local');
+requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
+requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPOST('http://test.local', /response data/);
+requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local/);
+requestHandler = httpBackendService.expectPOST(/test.local/, 'response data');
+requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
+requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
+
+requestHandler = httpBackendService.expectPUT('http://test.local');
+requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
+requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPUT('http://test.local', /response data/);
+requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local/);
+requestHandler = httpBackendService.expectPUT(/test.local/, 'response data');
+requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
+requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
+
+requestHandler = httpBackendService.when('GET', 'http://test.local');
+requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
+requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/);
+requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' });
+requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local/);
+requestHandler = httpBackendService.when('GET', /test.local/, 'response data');
+requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
+requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
+
+requestHandler = httpBackendService.whenDELETE('http://test.local');
+requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.whenGET('http://test.local');
+requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.whenHEAD('http://test.local');
+requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
+requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
+requestHandler = httpBackendService.whenJSONP('http://test.local');
+requestHandler = httpBackendService.whenJSONP(/test.local/);
+
+requestHandler = httpBackendService.whenPATCH('http://test.local');
+requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
+requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/);
+requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local/);
+requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data');
+requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
+requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
+
+requestHandler = httpBackendService.whenPOST('http://test.local');
+requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
+requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPOST('http://test.local', /response data/);
+requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local/);
+requestHandler = httpBackendService.whenPOST(/test.local/, 'response data');
+requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
+requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
+
+requestHandler = httpBackendService.whenPUT('http://test.local');
+requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
+requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPUT('http://test.local', /response data/);
+requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' });
+requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local/);
+requestHandler = httpBackendService.whenPUT(/test.local/, 'response data');
+requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
+requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
+
+
+///////////////////////////////////////
+// IRequestHandler
+///////////////////////////////////////
+requestHandler.passThrough();
+requestHandler.respond(function () { });
+requestHandler.respond({ key: 'value' });
+requestHandler.respond({ key: 'value' }, { header: 'value' });
+requestHandler.respond(404);
+requestHandler.respond(404, { key: 'value' });
+requestHandler.respond(404, { key: 'value' }, { header: 'value' });
diff --git a/angularjs/angular-mocks-tests.ts.tscparams b/angularjs/angular-mocks-tests.ts.tscparams
new file mode 100644
index 000000000..e16c76dff
--- /dev/null
+++ b/angularjs/angular-mocks-tests.ts.tscparams
@@ -0,0 +1 @@
+""
diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts
index 4d8decbf8..a607422dd 100644
--- a/angularjs/angular-mocks.d.ts
+++ b/angularjs/angular-mocks.d.ts
@@ -1,9 +1,8 @@
-// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module)
+// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
///
///////////////////////////////////////////////////////////////////////////////
@@ -26,14 +25,16 @@ declare module ng {
}
interface IMockStatic {
- // see http://docs.angularjs.org/api/angular.mock.debug
- debug(obj: any): string;
-
+ // see http://docs.angularjs.org/api/angular.mock.dump
+ dump(obj: any): string;
+
// see http://docs.angularjs.org/api/angular.mock.inject
inject(...fns: Function[]): any;
-
+
// see http://docs.angularjs.org/api/angular.mock.module
- module(...modules: any[]): any;
+ module(...modules: string[]): any;
+ module(...modules: Function[]): any;
+ module(modules: Object): any;
// see http://docs.angularjs.org/api/angular.mock.TzDate
TzDate(offset: number, timestamp: number): Date;
@@ -55,7 +56,9 @@ declare module ng {
// Augments the original service
///////////////////////////////////////////////////////////////////////////
interface ITimeoutService {
- flush(): void;
+ flush(delay?: number): void;
+ flushNext(expectedDelay?: number): void;
+ verifyNoPendingTasks(): void;
}
///////////////////////////////////////////////////////////////////////////
@@ -68,7 +71,7 @@ declare module ng {
reset(): void;
}
- interface LogCall {
+ interface ILogCall {
logs: string[];
}
@@ -82,62 +85,127 @@ declare module ng {
verifyNoOutstandingExpectation(): void;
verifyNoOutstandingRequest(): void;
- expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler;
- expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
- expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler;
- expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
-
- when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler;
- when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
- when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
- when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
- when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler;
- when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
- when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
- when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
-
- expectDELETE(url: string, headers?: any): mock.IRequestHandler;
- expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
- expectGET(url: string, headers?: any): mock.IRequestHandler;
- expectGET(url: RegExp, headers?: any): mock.IRequestHandler;
- expectHEAD(url: string, headers?: any): mock.IRequestHandler;
- expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
+ expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+ expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
+
+ expectDELETE(url: string, headers?: Object): mock.IRequestHandler;
+ expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
+ expectGET(url: string, headers?: Object): mock.IRequestHandler;
+ expectGET(url: RegExp, headers?: Object): mock.IRequestHandler;
+ expectHEAD(url: string, headers?: Object): mock.IRequestHandler;
+ expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
expectJSONP(url: string): mock.IRequestHandler;
expectJSONP(url: RegExp): mock.IRequestHandler;
- expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler;
- expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
- expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler;
- expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
- expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler;
- expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
- whenDELETE(url: string, headers?: any): mock.IRequestHandler;
- whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
- whenGET(url: string, headers?: any): mock.IRequestHandler;
- whenGET(url: RegExp, headers?: any): mock.IRequestHandler;
- whenHEAD(url: string, headers?: any): mock.IRequestHandler;
- whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
+ expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+
+ expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+
+ expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+
+ when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+ when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
+
+ whenDELETE(url: string, headers?: Object): mock.IRequestHandler;
+ whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
+ whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+
+ whenGET(url: string, headers?: Object): mock.IRequestHandler;
+ whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ whenGET(url: RegExp, headers?: Object): mock.IRequestHandler;
+ whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+
+ whenHEAD(url: string, headers?: Object): mock.IRequestHandler;
+ whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
+ whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
+ whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
+
whenJSONP(url: string): mock.IRequestHandler;
whenJSONP(url: RegExp): mock.IRequestHandler;
- whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler;
- whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
- whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
- whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
- whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler;
- whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
- whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
- whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
- whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler;
- whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
- whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
- whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
- }
+
+ whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+
+ whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+
+ whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
+ whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
+ }
export module mock {
-
+
// returned interface by the the mocked HttpBackendService expect/when methods
interface IRequestHandler {
- respond(func: Function): void;
+ respond(func: Function): void;
respond(status: number, data?: any, headers?: any): void;
respond(data: any, headers?: any): void;
@@ -145,6 +213,6 @@ declare module ng {
passThrough(): void;
}
- }
+ }
}
diff --git a/angularjs/angular-mocks.d.ts.tscparams b/angularjs/angular-mocks.d.ts.tscparams
new file mode 100644
index 000000000..e16c76dff
--- /dev/null
+++ b/angularjs/angular-mocks.d.ts.tscparams
@@ -0,0 +1 @@
+""
diff --git a/angularjs/angular-resource-1.0.d.ts b/angularjs/angular-resource-1.0.d.ts
new file mode 100644
index 000000000..c66bb341d
--- /dev/null
+++ b/angularjs/angular-resource-1.0.d.ts
@@ -0,0 +1,82 @@
+// Type definitions for Angular JS 1.0 (ngResource module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+
+///////////////////////////////////////////////////////////////////////////////
+// ngResource module (angular-resource.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng.resource {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ResourceService
+ // see http://docs.angularjs.org/api/ngResource.$resource
+ // Most part of the following definitions were achieved by analyzing the
+ // actual implementation, since the documentation doesn't seem to cover
+ // that deeply.
+ ///////////////////////////////////////////////////////////////////////////
+ interface IResourceService {
+ (url: string, paramDefaults?: any,
+ /** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
+ where deleteDescriptor : IActionDescriptor */
+ actionDescriptors?: any): IResourceClass;
+ }
+
+ // Just a reference to facilitate describing new actions
+ interface IActionDescriptor {
+ method: string;
+ isArray?: boolean;
+ params?: any;
+ headers?: any;
+ }
+
+ // Baseclass for everyresource with default actions.
+ // If you define your new actions for the resource, you will need
+ // to extend this interface and typecast the ResourceClass to it.
+ interface IResourceClass {
+ get: IActionCall;
+ save: IActionCall;
+ query: IActionCall;
+ remove: IActionCall;
+ delete: IActionCall;
+ }
+
+ // In case of passing the first argument as anything but a function,
+ // it's gonna be considered data if the action method is POST, PUT or
+ // PATCH (in other words, methods with body). Otherwise, it's going
+ // to be considered as parameters to the request.
+ interface IActionCall {
+ (): IResource;
+ (dataOrParams: any): IResource;
+ (dataOrParams: any, success: Function): IResource;
+ (success: Function, error?: Function): IResource;
+ (params: any, data: any, success?: Function, error?: Function): IResource;
+ }
+
+ interface IResource {
+ $save: IActionCall;
+ $remove: IActionCall;
+ $delete: IActionCall;
+
+ // No documented, but they are there, just as any custom action will be
+ $query: IActionCall;
+ $get: IActionCall;
+ }
+
+ /** when creating a resource factory via IModule.factory */
+ interface IResourceServiceFactoryFunction {
+ ($resource: ng.resource.IResourceService): ng.resource.IResourceClass;
+ }
+}
+
+/** extensions to base ng based on using angular-resource */
+declare module ng {
+
+ interface IModule {
+ /** creating a resource service factory */
+ factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule;
+ }
+}
diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts
index 494288365..f74f3eb44 100644
--- a/angularjs/angular-resource.d.ts
+++ b/angularjs/angular-resource.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Angular JS 1.0 (ngResource module)
+// Type definitions for Angular JS 1.2 (ngResource module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -19,10 +19,10 @@ declare module ng.resource {
// that deeply.
///////////////////////////////////////////////////////////////////////////
interface IResourceService {
- (url: string, paramDefaults?: any,
- /** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
- where deleteDescriptor : IActionDescriptor */
- actionDescriptors?: any): IResourceClass;
+ (url: string, paramDefaults?: any,
+ /** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
+ where deleteDescriptor : IActionDescriptor */
+ actionDescriptors?: any): IResourceClass;
}
// Just a reference to facilitate describing new actions
diff --git a/angularjs/angular-route-tests.ts b/angularjs/angular-route-tests.ts
new file mode 100644
index 000000000..2ebe16a21
--- /dev/null
+++ b/angularjs/angular-route-tests.ts
@@ -0,0 +1,14 @@
+///
+
+/**
+ * @license HTTP Auth Interceptor Module for AngularJS
+ * (c) 2013 Jonathan Park @ Daptiv Solutions Inc
+ * License: MIT
+ */
+
+declare var $routeProvider: ng.route.IRouteProvider;
+$routeProvider
+ .when('/projects/:projectId/dashboard',{
+ controller: ''
+ })
+ .otherwise({redirectTo: '/'});
diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts
new file mode 100644
index 000000000..b8d1db50b
--- /dev/null
+++ b/angularjs/angular-route.d.ts
@@ -0,0 +1,64 @@
+// Type definitions for Angular JS 1.2 (ngRoute module)
+// Project: http://angularjs.org
+// Definitions by: Jonathan Park
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+
+///////////////////////////////////////////////////////////////////////////////
+// ngRoute module (angular-route.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng.route {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RouteParamsService
+ // see http://docs.angularjs.org/api/ngRoute.$routeParams
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRouteParamsService {}
+
+ ///////////////////////////////////////////////////////////////////////////
+ // RouteService
+ // see http://docs.angularjs.org/api/ngRoute.$route
+ // see http://docs.angularjs.org/api/ngRoute.$routeProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IRouteService {
+ reload(): void;
+ routes: any;
+
+ // May not always be available. For instance, current will not be available
+ // to a controller that was not initialized as a result of a route maching.
+ current?: ICurrentRoute;
+ }
+
+ // see http://docs.angularjs.org/api/ngRoute.$routeProvider#when for options explanations
+ interface IRoute {
+ controller?: any;
+ controllerAs?: any;
+ name?: string;
+ template?: string;
+ templateUrl?: any;
+ resolve?: any;
+ redirectTo?: any;
+ reloadOnSearch?: boolean;
+ }
+
+ // see http://docs.angularjs.org/api/ng.$route#current
+ interface ICurrentRoute extends IRoute {
+ locals: {
+ $scope: IScope;
+ $template: string;
+ };
+
+ params: any;
+ }
+
+ interface IRouteProvider extends IServiceProvider {
+ otherwise(params: any): IRouteProvider;
+ /**
+ * This is a description
+ *
+ */
+ when(path: string, route: IRoute): IRouteProvider;
+ }
+}
diff --git a/angularjs/angular-sanitize-1.0.d.ts b/angularjs/angular-sanitize-1.0.d.ts
new file mode 100644
index 000000000..56a3bc2ae
--- /dev/null
+++ b/angularjs/angular-sanitize-1.0.d.ts
@@ -0,0 +1,22 @@
+// Type definitions for Angular JS 1.0 (ngSanitize module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+///////////////////////////////////////////////////////////////////////////////
+// ngSanitize module (angular-sanitize.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module ng.sanitize {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SanitizeService
+ // see http://docs.angularjs.org/api/ngSanitize.$sanitize
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISanitizeService {
+ (html: string): string;
+ }
+
+}
diff --git a/angularjs/angular-sanitize.d.ts b/angularjs/angular-sanitize.d.ts
index 56a3bc2ae..43576ae3b 100644
--- a/angularjs/angular-sanitize.d.ts
+++ b/angularjs/angular-sanitize.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Angular JS 1.0 (ngSanitize module)
+// Type definitions for Angular JS 1.2 (ngSanitize module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
diff --git a/angularjs/angular-scenario-1.0.d.ts b/angularjs/angular-scenario-1.0.d.ts
new file mode 100644
index 000000000..8dd605f7d
--- /dev/null
+++ b/angularjs/angular-scenario-1.0.d.ts
@@ -0,0 +1,155 @@
+// Type definitions for Angular Scenario Testing
+// Project: [http://angularjs.org]
+// Definitions by: [RomanoLindano]
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module angularScenario {
+ export interface AngularModel {
+ scenario: any;
+ }
+
+ export interface RunFunction {
+ (functionToRun: any): any;
+ }
+ export interface RunFunctionWithDescription {
+ (description: string, functionToRun: any): any;
+ }
+
+ export interface PauseFunction {
+ (): any;
+ }
+
+ export interface SleepFunction {
+ (seconds: number): any;
+ }
+
+ export interface Future {
+ }
+
+ export interface testWindow {
+ href(): Future;
+ path(): Future;
+ search(): Future;
+ hash(): Future;
+ }
+
+ export interface testLocation {
+ url(): Future;
+ path(): Future;
+ search(): Future;
+ hash(): Future;
+ }
+
+ export interface Browser {
+ navigateTo(url: string): void;
+ navigateTo(urlDescription: string, urlFunction: () => string): void;
+ reload(): void;
+ window(): testWindow;
+ location(): testLocation;
+ }
+
+ export interface Matchers {
+ toEqual(value: any): void;
+ toBe(value: any): void;
+ toBeDefined(): void;
+ toBeTruthy(): void;
+ toBeFalsy(): void;
+ toMatch(regularExpression: any): void;
+ toBeNull(): void;
+ toContain(value: any): void;
+ toBeLessThan(value: any): void;
+ toBeGreaterThan(value: any): void;
+ }
+
+ export interface CustomMatchers extends Matchers{
+ }
+
+ export interface Expect extends CustomMatchers {
+ not(): angularScenario.CustomMatchers;
+ }
+
+ export interface UsingFunction {
+ (selector: string, selectorDescription?: string): void;
+ }
+
+ export interface BindingFunction {
+ (bracketBindingExpression: string): Future;
+ }
+
+ export interface Input {
+ enter(value: any);
+ check(): any;
+ select(radioButtonValue: any): any;
+ val(): Future;
+ }
+
+ export interface Repeater {
+ count(): Future;
+ row(index: number): Future;
+ column(ngBindingExpression: string): Future;
+ }
+
+ export interface Select {
+ option(value: any): any;
+ option(...listOfValues: any[]): any;
+ }
+
+ export interface Element {
+ count(): Future;
+ click(): any;
+ query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) =>any): any;
+ val(): Future;
+ text(): Future;
+ html(): Future;
+ height(): Future;
+ innerHeight(): Future;
+ outerHeight(): Future;
+ width(): Future;
+ innerWidth(): Future;
+ outerWidth(): Future;
+ position(): Future;
+ scrollLeft(): Future;
+ scrollTop(): Future;
+ offset(): Future;
+
+ val(value: any): void;
+ text(value: any): void;
+ html(value: any): void;
+ height(value: any): void;
+ innerHeight(value: any): void;
+ outerHeight(value: any): void;
+ width(value: any): void;
+ innerWidth(value: any): void;
+ outerWidth(value: any): void;
+ position(value: any): void;
+ scrollLeft(value: any): void;
+ scrollTop(value: any): void;
+ offset(value: any): void;
+
+ attr(key: any): Future;
+ prop(key: any): Future;
+ css(key: any): Future;
+
+ attr(key: any, value: any): void;
+ prop(key: any, value: any): void;
+ css(key: any, value: any): void;
+ }
+}
+
+declare var describe: angularScenario.RunFunctionWithDescription;
+declare var xdescribe: angularScenario.RunFunctionWithDescription;
+declare var beforeEach: angularScenario.RunFunction;
+declare var afterEach: angularScenario.RunFunction;
+declare var it: angularScenario.RunFunctionWithDescription;
+declare var xit: angularScenario.RunFunctionWithDescription;
+declare var pause: angularScenario.PauseFunction;
+declare var sleep: angularScenario.SleepFunction;
+declare function browser(): angularScenario.Browser;
+declare function expect(expectation: angularScenario.Future): angularScenario.Expect;
+declare var using: angularScenario.UsingFunction;
+declare var binding: angularScenario.BindingFunction;
+declare function input(ngModelBinding: string): angularScenario.Input;
+declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater;
+declare function select(ngModelBinding: string): angularScenario.Select;
+declare function element(selector: string, elementDescription?: string): angularScenario.Element;
+declare var angular: angularScenario.AngularModel;
diff --git a/angularjs/angular-scenario-1.0.d.ts.tscparams b/angularjs/angular-scenario-1.0.d.ts.tscparams
new file mode 100644
index 000000000..e16c76dff
--- /dev/null
+++ b/angularjs/angular-scenario-1.0.d.ts.tscparams
@@ -0,0 +1 @@
+""
diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts
index 6a6892f57..bcfe31d16 100644
--- a/angularjs/angular-tests.ts
+++ b/angularjs/angular-tests.ts
@@ -182,6 +182,7 @@ mod.value('name', 23);
mod.value('name', "23");
mod.value(My.Namespace);
+
// Promise signature tests
var foo: ng.IPromise;
foo.then((x) => {
@@ -217,3 +218,17 @@ var element = angular.element("div.myApp");
var scope: ng.IScope = element.scope();
+
+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: {}
+});
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 145696286..921cbafc9 100755
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -81,11 +81,11 @@ declare module ng {
animation(name: string, animationFactory: Function): IModule;
animation(name: string, inlineAnnotadedFunction: any[]): IModule;
animation(object: Object): IModule;
- /** configure existing services.
+ /** configure existing services.
Use this method to register work which needs to be performed on module loading
*/
config(configFn: Function): IModule;
- /** configure existing services.
+ /** configure existing services.
Use this method to register work which needs to be performed on module loading
*/
config(inlineAnnotadedFunction: any[]): IModule;
@@ -94,9 +94,9 @@ declare module ng {
controller(name: string, controllerConstructor: Function): IModule;
controller(name: string, inlineAnnotadedConstructor: any[]): IModule;
controller(object : Object): IModule;
- directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule;
+ directive(name: string, directiveFactory: Function): IModule;
directive(name: string, inlineAnnotadedFunction: any[]): IModule;
- directive(object: Object): IModule;
+ directive(object: Object): IModule;
factory(name: string, serviceFactoryFunction: Function): IModule;
factory(name: string, inlineAnnotadedFunction: any[]): IModule;
factory(object: Object): IModule;
@@ -124,9 +124,33 @@ declare module ng {
// see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
///////////////////////////////////////////////////////////////////////////
interface IAttributes {
- $set(name: string, value: any): void;
- $observe(name: string, fn:(value?:any)=>any):void;
- $attr: any;
+ // 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;
}
///////////////////////////////////////////////////////////////////////////
@@ -139,6 +163,8 @@ declare module ng {
$valid: boolean;
$invalid: boolean;
$error: any;
+ $addControl(control: ng.INgModelController): void;
+ $removeControl(control: ng.INgModelController): void;
$setDirty(): void;
$setPristine(): void;
}
@@ -189,8 +215,8 @@ declare module ng {
$emit(name: string, ...args: any[]): IAngularEvent;
// Documentation says exp is optional, but actual implementaton counts on it
- $eval(expression: string): any;
- $eval(expression: (scope: IScope) => any): any;
+ $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;
@@ -212,7 +238,7 @@ declare module ng {
$parent: IScope;
$id: number;
-
+
// Hidden members
$$isolateBindings: any;
$$phase: any;
@@ -250,6 +276,15 @@ declare module ng {
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
@@ -602,12 +637,6 @@ declare module ng {
endSymbol(value: string): IInterpolateProvider;
}
- ///////////////////////////////////////////////////////////////////////////
- // RouteParamsService
- // see http://docs.angularjs.org/api/ng.$routeParams
- ///////////////////////////////////////////////////////////////////////////
- interface IRouteParamsService {}
-
///////////////////////////////////////////////////////////////////////////
// TemplateCacheService
// see http://docs.angularjs.org/api/ng.$templateCache
@@ -621,45 +650,58 @@ declare module ng {
interface IRootScopeService extends IScope {}
///////////////////////////////////////////////////////////////////////////
- // RouteService
- // see http://docs.angularjs.org/api/ng.$route
- // see http://docs.angularjs.org/api/ng.$routeProvider
+ // SCEService
+ // see http://docs.angularjs.org/api/ng.$sce
///////////////////////////////////////////////////////////////////////////
- interface IRouteService {
- reload(): void;
- routes: any;
+ 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;
+ }
- // May not always be available. For instance, current will not be available
- // to a controller that was not initialized as a result of a route maching.
- current?: ICurrentRoute;
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEProvider
+ // see http://docs.angularjs.org/api/ng.$sceProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEProvider extends IServiceProvider {
+ enabled(value: boolean): void;
}
- // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations
- interface IRoute {
- controller?: any;
- name?: string;
- template?: string;
- templateUrl?: any;
- resolve?: any;
- redirectTo?: any;
- reloadOnSearch?: boolean;
+ ///////////////////////////////////////////////////////////////////////////
+ // 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;
}
- // see http://docs.angularjs.org/api/ng.$route#current
- interface ICurrentRoute extends IRoute {
- locals: {
- $scope: IScope;
- $template: string;
- };
-
- params: any;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SCEDelegateProvider
+ // see http://docs.angularjs.org/api/ng.$sceDelegateProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISCEDelegateProvider extends IServiceProvider {
+ resourceUrlBlacklist(blacklist: any[]): void;
+ resourceUrlWhitelist(whitelist: any[]): void;
}
-
- interface IRouteProvider extends IServiceProvider {
- otherwise(params: any): IRouteProvider;
- when(path: string, route: IRoute): IRouteProvider;
- }
-
+
///////////////////////////////////////////////////////////////////////////
// Directive
// see http://docs.angularjs.org/api/ng.$compileProvider#directive
@@ -667,16 +709,29 @@ declare module ng {
///////////////////////////////////////////////////////////////////////////
interface IDirective{
+ compile?:
+ (templateElement: any,
+ templateAttributes: IAttributes,
+ transclude: (scope: IScope, cloneLinkingFn: Function) => void
+ ) => any;
+ controller?: any;
+ controllerAs?: string;
+ link?:
+ (scope: IScope,
+ instanceElement: any,
+ instanceAttributes: IAttributes,
+ controller: any
+ ) => void;
+ name?: string;
priority?: number;
- template?: any;
- templateUrl?: any;
replace?: boolean;
- transclude?: any;
+ require?: any;
restrict?: string;
scope?: any;
- link?: Function;
- compile?: Function;
- controller?: any;
+ template?: any;
+ templateUrl?: any;
+ terminal?: boolean;
+ transclude?: any;
}
///////////////////////////////////////////////////////////////////////////
diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts
index e2579c407..3902d8ffd 100644
--- a/backbone/backbone.d.ts
+++ b/backbone/backbone.d.ts
@@ -67,16 +67,16 @@ declare module Backbone {
}
class Events {
- on(eventName: any, callback?: (...args: any[]) => void , context?: any): any;
- off(eventName?: string, callback?: (...args: any[]) => void , context?: any): any;
+ on(eventName: any, callback?: Function, context?: any): any;
+ off(eventName?: string, callback?: Function, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
- bind(eventName: string, callback: (...args: any[]) => void , context?: any): any;
- unbind(eventName?: string, callback?: (...args: any[]) => void , context?: any): any;
+ bind(eventName: string, callback: Function, context?: any): any;
+ unbind(eventName?: string, callback?: Function, context?: any): any;
- once(events: string, callback: (...args: any[]) => void , context?: any): any;
- listenTo(object: any, events: string, callback: (...args: any[]) => void ): any;
- listenToOnce(object: any, events: string, callback: (...args: any[]) => void ): any;
- stopListening(object?: any, events?: string, callback?: (...args: any[]) => void ): any;
+ once(events: string, callback: Function, context?: any): any;
+ listenTo(object: any, events: string, callback: Function): any;
+ listenToOnce(object: any, events: string, callback: Function): any;
+ stopListening(object?: any, events?: string, callback?: Function): any;
}
class ModelBase extends Events {
@@ -248,7 +248,7 @@ declare module Backbone {
constructor(options?: RouterOptions);
initialize(options?: RouterOptions);
- route(route: string, name: string, callback?: (...parameter: any[]) => void );
+ route(route: string, name: string, callback?: Function);
navigate(fragment: string, options?: NavigateOptions);
navigate(fragment: string, trigger?: boolean);
@@ -269,7 +269,7 @@ declare module Backbone {
getHash(window?: Window): string;
getFragment(fragment?: string, forcePushState?: boolean): string;
stop(): void;
- route(route: string, callback: (...args: any[]) => void );
+ route(route: string, callback: Function);
checkUrl(e?: any): void;
loadUrl(fragmentOverride: string): boolean;
navigate(fragment: string, options?: any);
@@ -339,4 +339,3 @@ declare module Backbone {
function setDomLibrary(jQueryNew);
}
-
diff --git a/bootstrap.datepicker/bootstrap.datepicker.d.ts b/bootstrap.datepicker/bootstrap.datepicker.d.ts
index 9be7bccc2..4cf27ef19 100644
--- a/bootstrap.datepicker/bootstrap.datepicker.d.ts
+++ b/bootstrap.datepicker/bootstrap.datepicker.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for bootstrap.datepicker
+// Type definitions for bootstrap.datepicker
// Project: https://github.com/eternicode/bootstrap-datepicker
// Definitions by: Boris Yankov
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -24,4 +24,10 @@ interface JQuery {
datepicker(methodName: string): JQuery;
datepicker(methodName: string, params: any): JQuery;
datepicker(options: DatepickerOptions): JQuery;
-}
\ No newline at end of file
+
+ off(events?: "changeDate", selector?: any, handler?: (eventObject: any) => any): JQuery;
+
+ on(events: "changeDate", selector?: string, data?: any, handler?: (eventObject: any) => any): JQuery;
+ on(events: "changeDate", selector?: string, handler?: (eventObject: any) => any): JQuery;
+ on(events: "changeDate", handler?: (eventObject: any) => any): JQuery;
+}
diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts
index 3b8cf08be..8c410b94a 100644
--- a/browser-harness/browser-harness.d.ts
+++ b/browser-harness/browser-harness.d.ts
@@ -9,25 +9,25 @@ declare module "browser-harness" {
import events = require("events");
interface HarnessEvents extends events.NodeEventEmitter {
- once(event: string, listener: (driver: Driver) => void);
- once(event: 'ready', listener: (driver: Driver) => void);
+ once(event: string, listener: (driver: Driver) => void): events.NodeEventEmitter;
+ once(event: 'ready', listener: (driver: Driver) => void): events.NodeEventEmitter;
- on(event: string, listener: (driver: Driver) => void);
- on(event: 'ready', listener: (driver: Driver) => void);
+ on(event: string, listener: (driver: Driver) => void): events.NodeEventEmitter;
+ on(event: 'ready', listener: (driver: Driver) => void): events.NodeEventEmitter;
}
interface DriverEvents extends events.NodeEventEmitter {
- once(event: string, listener: (text: string) => void);
- once(event: 'console.log', listener: (text: string) => void);
- once(event: 'console.warn', listener: (text: string) => void);
- once(event: 'console.error', listener: (text: string) => void);
- once(event: 'window.onerror', listener: (text: string) => void);
+ once(event: string, listener: (text: string) => void): events.NodeEventEmitter;
+ once(event: 'console.log', listener: (text: string) => void): events.NodeEventEmitter;
+ once(event: 'console.warn', listener: (text: string) => void): events.NodeEventEmitter;
+ once(event: 'console.error', listener: (text: string) => void): events.NodeEventEmitter;
+ once(event: 'window.onerror', listener: (text: string) => void): events.NodeEventEmitter;
- on(event: string, listener: (text: string) => void);
- on(event: 'console.log', listener: (text: string) => void);
- on(event: 'console.warn', listener: (text: string) => void);
- on(event: 'console.error', listener: (text: string) => void);
- on(event: 'window.onerror', listener: (text: string) => void);
+ on(event: string, listener: (text: string) => void): events.NodeEventEmitter;
+ on(event: 'console.log', listener: (text: string) => void): events.NodeEventEmitter;
+ on(event: 'console.warn', listener: (text: string) => void): events.NodeEventEmitter;
+ on(event: 'console.error', listener: (text: string) => void): events.NodeEventEmitter;
+ on(event: 'window.onerror', listener: (text: string) => void): events.NodeEventEmitter;
}
export interface Driver {
diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts
index 4be7b40c4..de43c548b 100644
--- a/casperjs/casperjs.d.ts
+++ b/casperjs/casperjs.d.ts
@@ -5,39 +5,50 @@
///
-interface Casper {
+interface CasperModule {
+ create(options: CasperOptions): Casper;
+ selectXPath(expression: string): Object
+}
- constructor (options: CasperOptions);
+interface EventEmitter {
+ removeAllFilters(filter: string): Casper;
+ setFilter(filter: string, cb: Function): boolean;
+}
+
+interface Casper extends EventEmitter {
+ test: Tester;
+
+ constructor (options: CasperOptions): Casper;
// Properties
__utils__: ClientUtils;
// Methods
- back();
- base64encode(url: string, method?: string, data?: any);
- click(selector: string);
- clickLabel(label: string, tag?: string);
- capture(targetFilePath: string, clipRect: ClipRect);
- captureBase64(format: string);
- captureBase64(format: string, area: string);
- captureBase64(format: string, area: ClipRect);
- captureBase64(format: string, area: any);
- captureSelector(targetFile: string, selector: string);
- clear();
- debugHTML(selector?: string, outer?: boolean);
- debugPage();
- die(message: string, status?: number);
- download(url: string, target?: string, method?: string, data?: any);
- each(array: Array, fn: (self, link) => void);
- echo(message: string, style?: string);
- evaluate(fn: Function, ...args: any[]);
- evaluateOrDie(fn: Function, message?: string);
- exit(status?: number);
- exists(selector: string);
- fetchText(selector: string);
- forward();
- log(message: string, level?: string, space?: string);
- fill(selector: string, values: any, submit?: boolean);
+ back(): Casper;
+ base64encode(url: string, method?: string, data?: any): string;
+ click(selector: string): boolean;
+ clickLabel(label: string, tag?: string): boolean;
+ capture(targetFilePath: string, clipRect: ClipRect): Casper;
+ captureBase64(format: string): string;
+ captureBase64(format: string, area: string): string;
+ captureBase64(format: string, area: ClipRect): string;
+ captureBase64(format: string, area: any): string;
+ captureSelector(targetFile: string, selector: string): Casper;
+ clear(): Casper;
+ debugHTML(selector?: string, outer?: boolean): Casper;
+ debugPage(): Casper;
+ die(message: string, status?: number): Casper;
+ download(url: string, target?: string, method?: string, data?: any): Casper;
+ each(array: T[], fn: (self: Casper, item: T, index: number) => void): Casper;
+ echo(message: string, style?: string): Casper;
+ evaluate(fn: () => T, ...args: any[]): T
+ evaluateOrDie(fn: () => any, message?: string, status?: number): Casper;
+ exit(status?: number): Casper;
+ exists(selector: string): boolean;
+ fetchText(selector: string): string;
+ forward(): Casper;
+ log(message: string, level?: string, space?: string): Casper;
+ fill(selector: string, values: any, submit?: boolean): void;
getCurrentUrl(): string;
getElementAttribute(selector: string, attribute: string): string;
getElementBounds(selector: string): ElementBounds;
@@ -48,44 +59,44 @@ interface Casper {
getHTML(selector?: string, outer?: boolean): string;
getPageContent(): string;
getTitle(): string;
- mouseEvent(type: string, selector: string);
+ mouseEvent(type: string, selector: string): boolean;
open(location: string, settings: OpenSettings): Casper;
- reload(then?: (response: HttpResponse) => void);
- repeat(times: number, then: Function);
- resourceExists(test: Function);
- resourceExists(test: string);
- run(onComplete: Function, time?: number);
- sendKeys(selector: string, keys: string, options?: any);
- setHttpAuth(username: string, password: string);
+ reload(then?: (response: HttpResponse) => void): Casper;
+ repeat(times: number, then: Function): Casper;
+ resourceExists(test: Function): boolean;
+ resourceExists(test: string): boolean;
+ run(onComplete: Function, time?: number): Casper;
+ sendKeys(selector: string, keys: string, options?: any): Casper;
+ setHttpAuth(username: string, password: string): Casper;
start(url?: string, then?: (response: HttpResponse) => void): Casper;
status(asString: boolean): any;
- then(fn: (self?: Casper) => void);
- thenClick(selector: string);
- thenEvaluate(fn: Function, ...args: any[]);
- thenOpen(location: string, then?: (response: HttpResponse) => void);
- thenOpen(location: string, options?: OpenSettings, then?: (response: HttpResponse) => void);
- thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]);
- toString();
- userAgent(agent: string);
- viewport(width: number, height: number);
- visible(selector: string);
- wait(timeout: number, then?: Function);
- waitFor(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number);
- waitForPopup(urlPattern: string, then?: Function, onTimeout?: Function, timeout?: number);
- waitForPopup(urlPattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number);
- waitForSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number);
- waitWhileSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number);
- waitForResource(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number);
- waitForText(pattern: string, then?: Function, onTimeout?: Function, timeout?: number);
- waitForText(pattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number);
- waitUntilVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number);
- waitWhileVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number);
- warn(message: string);
- withFrame(frameInfo: string, then: Function);
- withFrame(frameInfo: number, then: Function);
- withPopup(popupInfo: string, step: Function);
- withPopup(popupInfo: RegExp, step: Function);
- zoom(factor: number);
+ then(fn: (self?: Casper) => void): Casper;
+ thenClick(selector: string): Casper;
+ thenEvaluate(fn: () => any, ...args: any[]): Casper;
+ thenOpen(location: string, then?: (response: HttpResponse) => void): Casper;
+ thenOpen(location: string, options?: OpenSettings, then?: (response: HttpResponse) => void): Casper;
+ thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]): Casper;
+ toString(): string;
+ userAgent(agent: string): string;
+ viewport(width: number, height: number): Casper;
+ visible(selector: string): boolean;
+ wait(timeout: number, then?: Function): Casper;
+ waitFor(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForPopup(urlPattern: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForPopup(urlPattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitWhileSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForResource(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForText(pattern: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitForText(pattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitUntilVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ waitWhileVisible(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper;
+ warn(message: string): Casper;
+ withFrame(frameInfo: string, then: Function): Casper;
+ withFrame(frameInfo: number, then: Function): Casper;
+ withPopup(popupInfo: string, step: Function): Casper;
+ withPopup(popupInfo: RegExp, step: Function): Casper;
+ zoom(factor: number): Casper;
}
interface HttpResponse {
@@ -127,96 +138,105 @@ interface ElementInfo {
}
interface CasperOptions {
- clientScripts: Array;
- exitOnError: boolean;
- httpStatusHandlers: any;
- logLevel: string;
- onAlert: Function;
- onDie: Function;
- onError: Function;
- onLoadError: Function;
- onPageInitialized: Function;
- onResourceReceived: Function;
- onResourceRequested: Function;
- onStepComplete: Function;
- onStepTimeout: Function;
- onTimeout: Function;
- onWaitTimeout: Function;
- page: WebPage;
- pageSettings: any;
- remoteScripts: Array;
- safeLogs: boolean;
- stepTimeout: number;
- timeout: number;
- verbose: boolean;
- viewportSize: any;
- waitTimeout: number;
+ clientScripts?: Array;
+ exitOnError?: boolean;
+ httpStatusHandlers?: any;
+ logLevel?: string;
+ onAlert?: Function;
+ onDie?: Function;
+ onError?: Function;
+ onLoadError?: Function;
+ onPageInitialized?: Function;
+ onResourceReceived?: Function;
+ onResourceRequested?: Function;
+ onStepComplete?: Function;
+ onStepTimeout?: Function;
+ onTimeout?: Function;
+ onWaitTimeout?: Function;
+ page?: WebPage;
+ pageSettings?: any;
+ remoteScripts?: Array;
+ safeLogs?: boolean;
+ stepTimeout?: number;
+ timeout?: number;
+ verbose?: boolean;
+ viewportSize?: any;
+ waitTimeout?: number;
}
interface ClientUtils {
- echo(message: string);
- encode(contents: string);
- exists(selector: string);
- findAll(selector: string);
- findOne(selector: string);
- getBase64(url: string, method?: string, data?: any);
- getBinary(url: string, method?: string, data?: any);
- getDocumentHeight();
- getElementBounds(selector: string);
- getElementsBounds(selector: string);
- getElementByXPath(expression: string, scope?: HTMLElement);
- getElementsByXPath(expression: string, scope?: HTMLElement);
- getFieldValue(inputName: string);
- getFormValues(selector: string);
- mouseEvent(type: string, selector: string);
- removeElementsByXPath(expression: string);
- sendAJAX(url: string, method?: string, data?: any, async?: boolean);
- visible(selector: string);
+ echo(message: string): void;
+ encode(contents: string): void;
+ exists(selector: string): void;
+ findAll(selector: string): void;
+ findOne(selector: string): void;
+ getBase64(url: string, method?: string, data?: any): void;
+ getBinary(url: string, method?: string, data?: any): void;
+ getDocumentHeight(): void;
+ getElementBounds(selector: string): void;
+ getElementsBounds(selector: string): void;
+ getElementByXPath(expression: string, scope?: HTMLElement): void;
+ getElementsByXPath(expression: string, scope?: HTMLElement): void;
+ getFieldValue(inputName: string): void;
+ getFormValues(selector: string): void;
+ mouseEvent(type: string, selector: string): void;
+ removeElementsByXPath(expression: string): void;
+ sendAJAX(url: string, method?: string, data?: any, async?: boolean): void;
+ visible(selector: string): void;
}
interface Colorizer {
- colorize(text: string, styleName: string);
- format(text: string, style: any);
+ colorize(text: string, styleName: string): void;
+ format(text: string, style: any): void;
}
interface Tester {
- assert(condition: boolean, message?: string);
- assertDoesntExist(selector: string, message?: string);
- assertEquals(testValue: any, expected: any, message?: string);
- assertEval(fn: Function, message: string, arguments: any);
- assertEvalEquals(fn: Function, expected: any, message?: string, arguments?: any);
- assertExists(selector: string, message?: string);
- assertFalsy(subject: any, message?: string);
- assertField(inputName: string, expected: string, message?: string);
- assertHttpStatus(status: number, message?: string);
- assertMatch(subject: any, pattern: RegExp, message?: string);
- assertNot(subject: any, message?: string);
- assertNotEquals(testValue: any, expected: any, message?: string);
- assertNotVisible(selector: string, message?: string);
- assertRaises(fn: Function, args: Array, message?: string);
- assertSelectorDoesntHaveText(selector: string, text: string, message?: string);
- assertSelectorExists(selector: string, message?: string);
- assertSelectorHasText(selector: string, text: string, message?: string);
- assertResourceExists(testFx: Function, message?: string);
- assertTextExists(expected: string, message?: string);
- assertTextDoesntExist(unexpected: string, message: string);
- assertTitle(expected: string, message?: string);
- assertTitleMatch(pattern: RegExp, message?: string);
- assertTruthy(subject: any, message?: string);
- assertType(input: any, type: string, message?: string);
- assertUrlMatch(pattern: RegExp, message?: string);
- assertVisible(selector: string, message?: string);
- colorize(message: string, style: string);
- comment(message: string);
- done(expected?: number);
- error(message: string);
- fail(message: string);
- formatMessage(message: string, style: string);
+ assert(condition: boolean, message?: string): any;
+ assertDoesntExist(selector: string, message?: string): any;
+ assertElementCount(selctor: string, expected: number, message?: string): any;
+ assertEquals(testValue: any, expected: any, message?: string): any;
+ assertEval(fn: Function, message: string, arguments: any): any;
+ assertEvalEquals(fn: Function, expected: any, message?: string, arguments?: any): any;
+ assertExists(selector: string, message?: string): any;
+ assertFalsy(subject: any, message?: string): any;
+ assertField(inputName: string, expected: string, message?: string): any;
+ assertHttpStatus(status: number, message?: string): any;
+ assertMatch(subject: any, pattern: RegExp, message?: string): any;
+ assertNot(subject: any, message?: string): any;
+ assertNotEquals(testValue: any, expected: any, message?: string): any;
+ assertNotVisible(selector: string, message?: string): any;
+ assertRaises(fn: Function, args: Array, message?: string): any;
+ assertSelectorDoesntHaveText(selector: string, text: string, message?: string): any;
+ assertSelectorExists(selector: string, message?: string): any;
+ assertSelectorHasText(selector: string, text: string, message?: string): any;
+ assertResourceExists(testFx: Function, message?: string): any;
+ assertTextExists(expected: string, message?: string): any;
+ assertTextDoesntExist(unexpected: string, message: string): any;
+ assertTitle(expected: string, message?: string): any;
+ assertTitleMatch(pattern: RegExp, message?: string): any;
+ assertTruthy(subject: any, message?: string): any;
+ assertType(input: any, type: string, message?: string): any;
+ assertUrlMatch(pattern: string, message?: string): any;
+ assertUrlMatch(pattern: RegExp, message?: string): any;
+ assertVisible(selector: string, message?: string): any;
+
+ /* since 1.1 */
+ begin(description: string, planned: number, suite: Function): any;
+ begin(description: string, suite: Function): any;
+ begin(description: string, planned: number, config: Object): any;
+ begin(description: string, config: Object): any;
+
+ colorize(message: string, style: string): any;
+ comment(message: string): any;
+ done(expected?: number): any;
+ error(message: string): any;
+ fail(message: string): any;
+ formatMessage(message: string, style: string): any;
getFailures(): Cases;
getPasses(): Cases;
- info(message: string);
- pass(message: string);
- renderResults(exit: boolean, status: number, save: string);
+ info(message: string): any;
+ pass(message: string): any;
+ renderResults(exit: boolean, status: number, save: string): any;
}
interface Cases {
@@ -238,30 +258,30 @@ interface CaseValues {
}
interface Utils {
- betterTypeOf(input: any);
- dump(value: any);
- fileExt(file: string);
- fillBlanks(text: string, pad: number);
- format(f: string, ...args: any[]);
- getPropertyPath(obj: any, path: string);
- inherits(ctor: any, superCtor: any);
- isArray(value: any);
- isCasperObject(value: any);
- isClipRect(value: any);
- isFalsy(subject: any);
- isFunction(value: any);
- isJsFile(file: string);
- isNull(value: any);
- isNumber(value: any);
- isObject(value: any);
- isRegExp(value: any);
- isString(value: any);
- isTruthy(subject: any);
- isType(what: any, type: string);
- isUndefined(value: any);
- isWebPage(what: any);
- mergeObjects(origin: any, add: any);
- node(name: string, attributes: any);
- serialize(value: any);
- unique(array: Array);
+ betterTypeOf(input: any): any;
+ dump(value: any): any;
+ fileExt(file: string): any;
+ fillBlanks(text: string, pad: number): any;
+ format(f: string, ...args: any[]): any;
+ getPropertyPath(obj: any, path: string): any;
+ inherits(ctor: any, superCtor: any): any;
+ isArray(value: any): any;
+ isCasperObject(value: any): any;
+ isClipRect(value: any): any;
+ isFalsy(subject: any): any;
+ isFunction(value: any): any;
+ isJsFile(file: string): any;
+ isNull(value: any): any;
+ isNumber(value: any): any;
+ isObject(value: any): any;
+ isRegExp(value: any): any;
+ isString(value: any): any;
+ isTruthy(subject: any): any;
+ isType(what: any, type: string): any;
+ isUndefined(value: any): any;
+ isWebPage(what: any): any;
+ mergeObjects(origin: any, add: any): any;
+ node(name: string, attributes: any): any;
+ serialize(value: any): any;
+ unique(array: Array): any;
}
diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts
index 8a09c3f42..b559c515d 100644
--- a/chai/chai-tests.ts
+++ b/chai/chai-tests.ts
@@ -688,6 +688,12 @@ function _throw() {
}, "blah: expected [Function] to throw error including 'hello' but got 'testing'");
}
+function use(){
+ chai.use(function (_chai, utils) {
+ _chai.can.use.any();
+ });
+}
+
function respondTo() {
function Foo() {};
var bar = {};
diff --git a/chai/chai.d.ts b/chai/chai.d.ts
index 9d649a17c..9fc93a667 100644
--- a/chai/chai.d.ts
+++ b/chai/chai.d.ts
@@ -8,6 +8,9 @@ declare module chai {
function expect(target: any): Expect;
+ // Provides a way to extend the internals of Chai
+ function use(fn: (chai: any, utils: any) => void);
+
interface ExpectStatic {
(target: any): Expect;
}
diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts
index 8b77c9617..8c9ec22dd 100644
--- a/chrome/chrome.d.ts
+++ b/chrome/chrome.d.ts
@@ -830,44 +830,11 @@ declare module chrome.events {
// Extension
////////////////////
declare module chrome.extension {
- interface MessageSender {
- id: string;
- tab?: chrome.tabs.Tab;
- }
-
- interface Port {
- postMessage: Function;
- sender?: MessageSender;
- onDisconnect: chrome.events.Event;
- onMessage: chrome.events.Event;
- name: string;
- }
-
interface FetchProperties {
windowId?: number;
type?: string;
}
- interface ConnectInfo {
- name?: string;
- }
-
- interface ExtensionMessageEvent extends chrome.events.Event {
- addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
- }
-
- interface ExtensionMessageExternalEvent extends chrome.events.Event {
- addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
- }
-
- interface ExtensionConnectEvent extends chrome.events.Event {
- addListener(callback: (port: Port) => void): void;
- }
-
- interface ExtensionConnectExternalEvent extends chrome.events.Event {
- addListener(callback: (port: Port) => void): void;
- }
-
var inIncognitoContext: boolean;
var lastError: Object;
@@ -876,15 +843,7 @@ declare module chrome.extension {
export function setUpdateUrlData(data: string): void;
export function getViews(fetchProperties?: FetchProperties): Window[];
export function isAllowedFileSchemeAccess(callback: (isAllowedAccess: boolean) => void): void;
- export function sendMessage(message: any, responseCallback?: (response: any) => void): void;
- export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void;
- export function connect(extensionId?: string, connectInfo?: ConnectInfo): Port;
export function isAllowedIncognitoAccess(callback: (isAllowedAccess) => void): void;
-
- var onMessage: ExtensionMessageEvent;
- var onMessageExternal: ExtensionMessageExternalEvent;
- var onConnect: ExtensionConnectEvent;
- var onConnectExternal: ExtensionConnectExternalEvent;
}
////////////////////
@@ -1461,11 +1420,62 @@ declare module chrome.runtime {
var lastError: Object;
var id: string;
+ interface ConnectInfo {
+ name?: string;
+ }
+
interface InstalledDetails {
reason: string;
previousVersion?: string;
}
+ interface MessageOptions {
+ includeTlsChannelId?: boolean;
+ }
+
+ interface MessageSender {
+ id: string;
+ tab?: chrome.tabs.Tab;
+ }
+
+ interface PlatformInfo {
+ os: string;
+ arch: string;
+ nacl_arch: string;
+ }
+
+ interface Port {
+ postMessage: Function;
+ sender?: MessageSender;
+ onDisconnect: chrome.events.Event;
+ onMessage: chrome.events.Event;
+ name: string;
+ }
+
+ interface UpdateAvailableDetails {
+ version: string;
+ }
+
+ interface UpdateCheckDetails {
+ version: string;
+ }
+
+ interface ExtensionMessageEvent extends chrome.events.Event {
+ addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
+ }
+
+ interface ExtensionMessageExternalEvent extends chrome.events.Event {
+ addListener(callback: (message: any, sender: MessageSender, sendResponse: Function) => void): void;
+ }
+
+ interface ExtensionConnectEvent extends chrome.events.Event {
+ addListener(callback: (port: Port) => void): void;
+ }
+
+ interface ExtensionConnectExternalEvent extends chrome.events.Event {
+ addListener(callback: (port: Port) => void): void;
+ }
+
interface RuntimeSuspendEvent extends chrome.events.Event {
addListener(callback: Function): void;
}
@@ -1484,18 +1494,43 @@ declare module chrome.runtime {
interface RuntimeMessageEvent extends chrome.events.Event {
addListener(callback: Function): void;
}
+
+ interface RuntimeRestartRequiredEvent extends chrome.events.Event {
+ addListener(callback: (reason: string) => void): void;
+ }
+
+ interface RuntimeUpdateAvailableEvent extends chrome.events.Event {
+ addListener(callback: (details: UpdateAvailableDetails) => void): void;
+ }
+ export function connect(connectInfo?: ConnectInfo): Port;
+ export function connect(extensionId: string, connectInfo?: ConnectInfo): Port;
+ export function connectNative(application: string): Port;
export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void;
export function getManifest(): Object;
+ export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void;
+ export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
export function getURL(path: string): string;
-
+ export function reload(): void;
+ export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void;
+ export function restart(): void;
+ export function sendMessage(message: any, responseCallback?: (response: any) => void): void;
+ export function sendMessage(message: any, options: MessageOptions, responseCallback?: (response: any) => void): void;
+ export function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void;
+ export function sendMessage(extensionId: string, message: any, options: MessageOptions, responseCallback?: (response: any) => void): void;
+ export function sendNativeMessage(application: string, message: any, responseCallback?: (response: any) => void ): void;
+ export function setUninstallUrl(url: string): void;
+
+ var onConnect: ExtensionConnectEvent;
+ var onConnectExternal: ExtensionConnectExternalEvent;
var onSuspend: RuntimeSuspendEvent;
var onStartup: RuntimeStartupEvent;
var onInstalled: RuntimeInstalledEvent;
var onSuspendCanceled: RuntimeSuspendCanceledEvent;
var onMessage: RuntimeMessageEvent;
var onMessageExternal: RuntimeMessageEvent;
- var sendMessage:(req:any, cb:(resp:any)=>void)=>void;
+ var onRestartRequired: RuntimeRestartRequiredEvent;
+ var onUpdateAvailable: RuntimeUpdateAvailableEvent;
}
@@ -1718,6 +1753,7 @@ declare module chrome.tabs {
}
interface TabRemoveInfo {
+ windowId: number;
isWindowClosing: boolean;
}
diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts
index 89417e3e5..c2567f62c 100644
--- a/durandal/durandal.d.ts
+++ b/durandal/durandal.d.ts
@@ -1,5 +1,5 @@
/**
- * Durandal 2.0.0 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved.
+ * Durandal 2.0.1 Copyright (c) 2012 Blue Spire Consulting, Inc. All Rights Reserved.
* Available via the MIT license.
* see: http://durandaljs.com or https://github.com/BlueSpire/Durandal for details.
*/
@@ -116,7 +116,7 @@ declare module 'durandal/system' {
* @param {object} extension* Uses to extend the target object.
*/
export function extend(obj: any, ...extensions: any[]): any;
-
+
/**
* Uses a setTimeout to wait the specified milliseconds.
* @param {number} milliseconds The number of milliseconds to wait.
@@ -226,7 +226,7 @@ declare module 'durandal/viewEngine' {
* @returns {boolean} True if the url is a view url, false otherwise.
*/
export function isViewUrl(url: string):boolean;
-
+
/**
* Converts a view url into a view id.
* @param {string} url The url to convert.
@@ -285,62 +285,8 @@ declare module 'durandal/viewEngine' {
* @requires system
*/
declare module 'durandal/events' {
- import ts = require('durandal/typescript');
-
- /**
- * Creates an object with eventing capabilities.
- * @class Events
- */
- class Events {
- constructor();
-
- /**
- * Creates a subscription or registers a callback for the specified event.
- * @param {string} events One or more events, separated by white space.
- * @returns {Subscription} A subscription is returned.
- */
- on(events: string): ts.EventSubscription;
-
- /**
- * Creates a subscription or registers a callback for the specified event.
- * @param {string} events One or more events, separated by white space.
- * @param {function} [callback] The callback function to invoke when the event is triggered.
- * @param {object} [context] An object to use as `this` when invoking the `callback`.
- * @returns {Events} The events object is returned for chaining.
- */
- on(events: string, callback: Function, context?: any): Events;
-
- /**
- * Removes the callbacks for the specified events.
- * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed.
- * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed.
- * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed.
- * @chainable
- */
- off(events: string, callback: Function, context?: any): Events;
-
- /**
- * Triggers the specified events.
- * @param {string} [events] One or more events, separated by white space to trigger.
- * @chainable
- */
- trigger(events: string, ...eventArgs: any[]): Events;
-
- /**
- * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object.
- * @param {string} events One or more events, separated by white space to trigger by invoking the returned function.
- * @returns {function} Calling the function will invoke the previously specified events on the events object.
- */
- proxy(events: string): Function;
-
- /**
- * Adds eventing capabilities to the specified object.
- * @param {object} targetObject The object to add eventing capabilities to.
- */
- static includeIn(targetObject: any): void;
- }
-
- export = Events;
+ var theModule: DurandalEventModule;
+ export = theModule;
}
/**
@@ -389,7 +335,7 @@ declare module 'durandal/binder' {
* @param {object} [obj] The data to bind to, causing the creation of a child binding context if present.
*/
export function bindContext(bindingContext: KnockoutBindingContext, view: HTMLElement, obj?: any): BindingInstruction;
-
+
/**
* Binds the view, preserving the existing binding context. Optionally, a new context can be created, parented to the previous context.
* @param {object} obj The data to bind to.
@@ -407,136 +353,12 @@ declare module 'durandal/binder' {
* @requires knockout
*/
declare module 'durandal/activator' {
- interface ActivatorSettings {
- /**
- * The default value passed to an object's deactivate function as its close parameter.
- * @default true
- */
- closeOnDeactivate: boolean;
-
- /**
- * Lower-cased words which represent a truthy value.
- * @default ['yes', 'ok', 'true']
- */
- affirmations: string[];
-
- /**
- * Interprets the response of a `canActivate` or `canDeactivate` call using the known affirmative values in the `affirmations` array.
- * @param {object} value
- * @returns {boolean}
- */
- interpretResponse(value: any): boolean;
-
- /**
- * Determines whether or not the current item and the new item are the same.
- * @param {object} currentItem
- * @param {object} newItem
- * @param {object} currentActivationData
- * @param {object} newActivationData
- * @returns {boolean}
- */
- areSameItem(currentItem: any, newItem: any, currentActivationData: any, newActivationData: any): boolean;
-
- /**
- * Called immediately before the new item is activated.
- * @param {object} newItem
- */
- beforeActivate(newItem: any): any;
-
- /**
- * Called immediately after the old item is deactivated.
- * @param {object} oldItem The previous item.
- * @param {boolean} close Whether or not the previous item was closed.
- * @param {function} setter The activate item setter function.
- */
- afterDeactivate(oldItem: any, close: boolean, setter: Function): void;
- }
-
- interface Activator extends KnockoutComputed {
- /**
- * The settings for this activator.
- */
- settings: ActivatorSettings;
-
- /**
- * An observable which indicates whether or not the activator is currently in the process of activating an instance.
- * @returns {boolean}
- */
- isActivating: KnockoutObservable;
-
- /**
- * Determines whether or not the specified item can be deactivated.
- * @param {object} item The item to check.
- * @param {boolean} close Whether or not to check if close is possible.
- * @returns {promise}
- */
- canDeactivateItem(item: T, close: boolean): JQueryPromise;
-
- /**
- * Deactivates the specified item.
- * @param {object} item The item to deactivate.
- * @param {boolean} close Whether or not to close the item.
- * @returns {promise}
- */
- deactivateItem(item: T, close: boolean): JQueryPromise;
-
- /**
- * Determines whether or not the specified item can be activated.
- * @param {object} item The item to check.
- * @param {object} activationData Data associated with the activation.
- * @returns {promise}
- */
- canActivateItem(newItem: T, activationData?: any): JQueryPromise;
-
- /**
- * Activates the specified item.
- * @param {object} newItem The item to activate.
- * @param {object} newActivationData Data associated with the activation.
- * @returns {promise}
- */
- activateItem(newItem: T, activationData?: any): JQueryPromise;
-
- /**
- * Determines whether or not the activator, in its current state, can be activated.
- * @returns {promise}
- */
- canActivate(): JQueryPromise;
-
- /**
- * Activates the activator, in its current state.
- * @returns {promise}
- */
- activate(): JQueryPromise;
-
- /**
- * Determines whether or not the activator, in its current state, can be deactivated.
- * @returns {promise}
- */
- canDeactivate(close: boolean): JQueryPromise;
-
- /**
- * Deactivates the activator, in its current state.
- * @returns {promise}
- */
- deactivate(close: boolean): JQueryPromise;
-
- /**
- * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator.
- */
- includeIn(includeIn: any): void;
-
- /**
- * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them.
- */
- forItems(items): Activator;
- }
-
/**
* The default settings used by activators.
* @property {ActivatorSettings} defaults
*/
- export var defaults: ActivatorSettings;
-
+ export var defaults: DurandalActivatorSettings;
+
/**
* Creates a new activator.
* @method create
@@ -544,7 +366,7 @@ declare module 'durandal/activator' {
* @param {ActivatorSettings} [settings] Per activator overrides of the default activator settings.
* @returns {Activator} The created activator.
*/
- export function create(initialActiveItem?: T, settings?: ActivatorSettings): Activator;
+ export function create(initialActiveItem?: T, settings?: DurandalActivatorSettings): DurandalActivator;
/**
* Determines whether or not the provided object is an activator or not.
@@ -568,7 +390,7 @@ declare module 'durandal/viewLocator' {
* @param {string} [areasPath] Partial views are mapped to the "views" folder if not specified. Use this parameter to change their location.
*/
export function useConvention(modulesPath?: string, viewsPath?: string, areasPath?: string): void;
-
+
/**
* Maps an object instance to a view instance.
* @param {object} obj The object to locate the view for.
@@ -577,7 +399,7 @@ declare module 'durandal/viewLocator' {
* @returns {Promise} A promise of the view.
*/
export function locateViewForObject(obj: any, area:string, elementsToSearch?: HTMLElement[]): JQueryPromise;
-
+
/**
* Converts a module id into a view id. By default the ids are the same.
* @param {string} moduleId The module id.
@@ -599,7 +421,7 @@ declare module 'durandal/viewLocator' {
* @returns {string} The translated view id.
*/
export function translateViewIdToArea(viewId: string, area: string): string;
-
+
/**
* Locates the specified view.
* @param {string|DOMElement} view A view. It will be immediately returned.
@@ -608,7 +430,7 @@ declare module 'durandal/viewLocator' {
* @returns {Promise} A promise of the view.
*/
export function locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise;
-
+
/**
* Locates the specified view.
* @param {string|DOMElement} viewUrlOrId A view url or view id to locate.
@@ -725,100 +547,8 @@ declare module 'durandal/composition' {
* @requires jquery
*/
declare module 'durandal/app' {
- import Events = require('durandal/events');
- import ts = require('durandal/typescript');
-
- /**
- * The title of your application.
- */
- export var title: string;
-
- /**
- * Shows a dialog via the dialog plugin.
- * @param {object|string} obj The object (or moduleId) to display as a dialog.
- * @param {object} [activationData] The data that should be passed to the object upon activation.
- * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified.
- * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing.
- */
- export function showDialog(obj: any, activationData?: any, context?: string):JQueryPromise;
-
- /**
- * Shows a message box via the dialog plugin.
- * @param {string} message The message to display in the dialog.
- * @param {string} [title] The title message.
- * @param {string[]} [options] The options to provide to the user.
- * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option.
- */
- export function showMessage(message: string, title?: string, options?: string[]): JQueryPromise;
-
- /**
- * Configures one or more plugins to be loaded and installed into the application.
- * @method configurePlugins
- * @param {object} config Keys are plugin names. Values can be truthy, to simply install the plugin, or a configuration object to pass to the plugin.
- * @param {string} [baseUrl] The base url to load the plugins from.
- */
- export function configurePlugins(config: Object, baseUrl?: string): void;
-
- /**
- * Starts the application.
- * @returns {promise}
- */
- export function start(): JQueryPromise;
-
- /**
- * Sets the root module/view for the application.
- * @param {string} root The root view or module.
- * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root.
- * @param {string} [applicationHost] The application host element id. By default the id 'applicationHost' will be used.
- */
- export function setRoot(root: any, transition?: string, applicationHost?: string): void;
-
- /**
- * Sets the root module/view for the application.
- * @param {string} root The root view or module.
- * @param {string} [transition] The transition to use from the previous root (or splash screen) into the new root.
- * @param {string} [applicationHost] The application host element. By default the id 'applicationHost' will be used.
- */
- export function setRoot(root: any, transition?: string, applicationHost?: HTMLElement): void;
-
- /**
- * Creates a subscription or registers a callback for the specified event.
- * @param {string} events One or more events, separated by white space.
- * @returns {Subscription} A subscription is returned.
- */
- export function on(events: string): ts.EventSubscription;
-
- /**
- * Creates a subscription or registers a callback for the specified event.
- * @param {string} events One or more events, separated by white space.
- * @param {function} [callback] The callback function to invoke when the event is triggered.
- * @param {object} [context] An object to use as `this` when invoking the `callback`.
- * @returns {Events} The events object is returned for chaining.
- */
- export function on(events: string, callback: Function, context?: any): Events;
-
- /**
- * Removes the callbacks for the specified events.
- * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed.
- * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed.
- * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed.
- * @chainable
- */
- export function off(events: string, callback: Function, context?: any): Events;
-
- /**
- * Triggers the specified events.
- * @param {string} [events] One or more events, separated by white space to trigger.
- * @chainable
- */
- export function trigger(events: string, ...eventArgs:any[]): Events;
-
- /**
- * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object.
- * @param {string} events One or more events, separated by white space to trigger by invoking the returned function.
- * @returns {function} Calling the function will invoke the previously specified events on the events object.
- */
- export function proxy(events: string): Function;
+ var theModule: DurandalAppModule;
+ export = theModule;
}
/**
@@ -832,7 +562,6 @@ declare module 'durandal/app' {
* @requires knockout
*/
declare module 'plugins/dialog' {
- import activator = require('durandal/activator');
import composition = require('durandal/composition');
/**
@@ -907,7 +636,7 @@ declare module 'plugins/dialog' {
interface Dialog {
owner: any;
context: DialogContext;
- activator: activator.Activator;
+ activator: DurandalActivator;
close(): JQueryPromise;
settings: composition.CompositionContext;
}
@@ -947,7 +676,7 @@ declare module 'plugins/dialog' {
* @param {DialogContext} dialogContext The context to add.
*/
export function addContext(name: string, modalContext: DialogContext): void;
-
+
/**
* Gets the dialog model that is associated with the specified object.
* @param {object} obj The object for whom to retrieve the dialog.
@@ -958,9 +687,9 @@ declare module 'plugins/dialog' {
/**
* Closes the dialog associated with the specified object.
* @param {object} obj The object whose dialog should be closed.
- * @param {object} result* The results to return back to the dialog caller after closing.
+ * @param {object} results* The results to return back to the dialog caller after closing.
*/
- export function close(obj: any, ...result: any[]): void;
+ export function close(obj: any, ...results: any[]): void;
/**
* Shows a dialog.
@@ -993,41 +722,6 @@ declare module 'plugins/dialog' {
* @requires jquery
*/
declare module 'plugins/history' {
- interface HistoryOptions {
- /**
- * The function that will be called back when the fragment changes.
- */
- routeHandler: (fragment: string) => void;
-
- /**
- * The url root used to extract the fragment when using push state.
- */
- root?: string;
-
- /**
- * Use hash change when present.
- * @default true
- */
- hashChange?: boolean;
-
- /**
- * Use push state when present.
- * @default false
- */
- pushState?: boolean;
-
- /**
- * Prevents loading of the current url when activating history.
- * @default false
- */
- silent?: boolean;
- }
-
- interface NavigationOptions {
- trigger: boolean;
- replace: boolean;
- }
-
/**
* The setTimeout interval used when the browser does not support hash change events.
* @default 50
@@ -1059,7 +753,7 @@ declare module 'plugins/history' {
* @param {HistoryOptions} options.
* @returns {boolean|undefined} Returns true/false from loading the url unless the silent option was selected.
*/
- export function activate(options: HistoryOptions): boolean;
+ export function activate(options: DurandalHistoryOptions): boolean;
/**
* Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers.
@@ -1102,7 +796,7 @@ declare module 'plugins/history' {
* @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default.
* @return {boolean} Returns true/false from loading the url.
*/
- export function navigate(fragment: string, options: NavigationOptions): boolean;
+ export function navigate(fragment: string, options: DurandalNavigationOptions): boolean;
/**
* Navigates back in the browser history.
@@ -1121,7 +815,7 @@ declare module 'plugins/http' {
* @default callback
*/
export var callbackParam: string;
-
+
/**
* Makes an HTTP GET request.
* @param {string} url The url to send the get request to.
@@ -1138,7 +832,7 @@ declare module 'plugins/http' {
* @returns {Promise} A promise of the response data.
*/
export function jsonp(url: string, query?: Object, callbackParam?: string): JQueryPromise;
-
+
/**
* Makes an HTTP POST request.
* @param {string} url The url to send the post request to.
@@ -1395,324 +1089,571 @@ declare module 'plugins/widget' {
* @requires jquery
*/
declare module 'plugins/router' {
- import activator = require('durandal/activator');
- import Events = require('durandal/events');
- import ts = require('durandal/typescript');
-
- var RootRouter: ts.RootRouter;
-
- export = RootRouter;
+ var theModule: DurandalRootRouter;
+ export = theModule;
}
-/**
- * Interface definitions used by other modules which were not possible to define within those modules due to TypeScript limitations.
- */
-declare module 'durandal/typescript' {
- import activator = require('durandal/activator');
- import history = require('plugins/history');
+interface DurandalEventSubscription {
+ /**
+ * Attaches a callback to the event subscription.
+ * @param {function} callback The callback function to invoke when the event is triggered.
+ * @param {object} [context] An object to use as `this` when invoking the `callback`.
+ * @chainable
+ */
+ then(thenCallback: Function, context?: any): DurandalEventSubscription;
/**
- * Represents an event subscription.
- * @class
- */
- export interface EventSubscription {
- /**
- * Attaches a callback to the event subscription.
- * @param {function} callback The callback function to invoke when the event is triggered.
- * @param {object} [context] An object to use as `this` when invoking the `callback`.
- * @chainable
- */
- then(thenCallback: Function, context?: any): EventSubscription;
+ * Attaches a callback to the event subscription.
+ * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated.
+ * @param {object} [context] An object to use as `this` when invoking the `callback`.
+ * @chainable
+ */
+ on(thenCallback: Function, context?: any): DurandalEventSubscription;
- /**
- * Attaches a callback to the event subscription.
- * @param {function} [callback] The callback function to invoke when the event is triggered. If `callback` is not provided, the previous callback will be re-activated.
- * @param {object} [context] An object to use as `this` when invoking the `callback`.
- * @chainable
- */
- on(thenCallback: Function, context?: any): EventSubscription;
-
- /**
- * Cancels the subscription.
- * @chainable
- */
- off(): EventSubscription;
- }
-
- export interface RouteConfiguration {
- title?: string;
- moduleId?: string;
- hash?: string;
- routePattern?: RegExp;
- isActive?: KnockoutComputed;
- }
-
- export interface RouteInstruction {
- fragment: string;
- queryString: string;
- config: RouteConfiguration;
- params: any[];
- queryParams: Object;
- }
-
- export interface RelativeRouteSettings {
- moduleId?: string;
- route?: string;
- fromParent?: boolean;
- }
-
- export interface Router {
- /**
- * The route handlers that are registered. Each handler consists of a `routePattern` and a `callback`.
- */
- handlers: { routePattern: RegExp; callback: (fragment: string) => void; }[];
-
- /**
- * The route configs that are registered.
- */
- routes: RouteConfiguration[];
-
- /**
- * The active item/screen based on the current navigation state.
- */
- activeItem: activator.Activator;
-
- /**
- * The route configurations that have been designated as displayable in a nav ui (nav:true).
- */
- navigationModel: KnockoutObservableArray;
-
- /**
- * Indicates that the router (or a child router) is currently in the process of navigating.
- */
- isNavigating: KnockoutComputed;
-
- /**
- * An observable surfacing the active routing instruction that is currently being processed or has recently finished processing.
- * The instruction object has `config`, `fragment`, `queryString`, `params` and `queryParams` properties.
- */
- activeInstruction: KnockoutObservable;
-
- /**
- * Parses a query string into an object.
- * @param {string} queryString The query string to parse.
- * @returns {object} An object keyed according to the query string parameters.
- */
- parseQueryString(queryString: string): Object;
-
- /**
- * Add a route to be tested when the url fragment changes.
- * @param {RegEx} routePattern The route pattern to test against.
- * @param {function} callback The callback to execute when the route pattern is matched.
- */
- route(routePattern: RegExp, callback: (fragment: string) => void ): void;
-
- /**
- * Attempt to load the specified URL fragment. If a route succeeds with a match, returns `true`. If no defined routes matches the fragment, returns `false`.
- * @param {string} fragment The URL fragment to find a match for.
- * @returns {boolean} True if a match was found, false otherwise.
- */
- loadUrl(fragment: string): boolean;
-
- /**
- * Updates the document title based on the activated module instance, the routing instruction and the app.title.
- * @param {object} instance The activated module.
- * @param {object} instruction The routing instruction associated with the action. It has a `config` property that references the original route mapping config.
- */
- updateDocumentTitle(instance: Object, instruction: RouteInstruction): void;
-
- /**
- * Save a fragment into the hash history, or replace the URL state if the
- * 'replace' option is passed. You are responsible for properly URL-encoding
- * the fragment in advance.
- * The options object can contain `trigger: false` if you wish to not have the
- * route callback be fired, or `replace: true`, if
- * you wish to modify the current URL without adding an entry to the history.
- * @param {string} fragment The url fragment to navigate to.
- * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default.
- * @return {boolean} Returns true/false from loading the url.
- */
- navigate(fragment: string, trigger?: boolean): boolean;
-
- /**
- * Save a fragment into the hash history, or replace the URL state if the
- * 'replace' option is passed. You are responsible for properly URL-encoding
- * the fragment in advance.
- * The options object can contain `trigger: false` if you wish to not have the
- * route callback be fired, or `replace: true`, if
- * you wish to modify the current URL without adding an entry to the history.
- * @param {string} fragment The url fragment to navigate to.
- * @param {object|boolean} options An options object with optional trigger and replace flags. You can also pass a boolean directly to set the trigger option. Trigger is `true` by default.
- * @return {boolean} Returns true/false from loading the url.
- */
- navigate(fragment: string, options: history.NavigationOptions): boolean;
-
- /**
- * Navigates back in the browser history.
- */
- navigateBack(): void;
-
- /**
- * Converts a route to a hash suitable for binding to a link's href.
- * @param {string} route
- * @returns {string} The hash.
- */
- convertRouteToHash(route: string): string;
-
- /**
- * Converts a route to a module id. This is only called if no module id is supplied as part of the route mapping.
- * @param {string} route
- * @returns {string} The module id.
- */
- convertRouteToModuleId(route: string): string;
-
- /**
- * Converts a route to a displayable title. This is only called if no title is specified as part of the route mapping.
- * @method convertRouteToTitle
- * @param {string} route
- * @returns {string} The title.
- */
- convertRouteToTitle(route: string): string;
-
- /**
- * Maps route patterns to modules.
- * @param {string} route A route.
- * @chainable
- */
- map(route: string): Router;
-
- /**
- * Maps route patterns to modules.
- * @param {string} route A route pattern.
- * @param {string} moduleId The module id to map the route to.
- * @chainable
- */
- map(route: string, moduleId: string): Router;
-
- /**
- * Maps route patterns to modules.
- * @param {RegExp} route A route pattern.
- * @param {string} moduleId The module id to map the route to.
- * @chainable
- */
- map(route: RegExp, moduleId: string): Router;
-
- /**
- * Maps route patterns to modules.
- * @param {string} route A route pattern.
- * @param {RouteConfiguration} config The route's configuration.
- * @chainable
- */
- map(route: string, config: RouteConfiguration): Router;
-
- /**
- * Maps route patterns to modules.
- * @method map
- * @param {RegExp} route A route pattern.
- * @param {RouteConfiguration} config The route's configuration.
- * @chainable
- */
- map(route: RegExp, config: RouteConfiguration): Router;
-
- /**
- * Maps route patterns to modules.
- * @param {RouteConfiguration} config The route's configuration.
- * @chainable
- */
- map(config: RouteConfiguration): Router;
-
- /**
- * Maps route patterns to modules.
- * @param {RouteConfiguration[]} configs An array of route configurations.
- * @chainable
- */
- map(configs: RouteConfiguration[]): Router;
-
- /**
- * Builds an observable array designed to bind a navigation UI to. The model will exist in the `navigationModel` property.
- * @param {number} defaultOrder The default order to use for navigation visible routes that don't specify an order. The defualt is 100.
- * @chainable
- */
- buildNavigationModel(defaultOrder?: number): Router;
-
- /**
- * Configures the router to map unknown routes to modules at the same path.
- * @chainable
- */
- mapUnknownRoutes(): Router;
-
- /**
- * Configures the router use the specified module id for all unknown routes.
- * @param {string} notFoundModuleId Represents the module id to route all unknown routes to.
- * @param {string} [replaceRoute] Optionally provide a route to replace the url with.
- * @chainable
- */
- mapUnknownRoutes(notFoundModuleId: string, replaceRoute?: string): Router;
-
- /**
- * Configures how the router will handle unknown routes.
- * @param {function} callback Called back with the route instruction containing the route info. The function can then modify the instruction by adding a moduleId and the router will take over from there.
- * @chainable
- */
- mapUnknownRoutes(callback: (instruction: RouteInstruction) => void ): Router;
-
- /**
- * Configures how the router will handle unknown routes.
- * @param {RouteConfiguration} config The route configuration to use for unknown routes.
- * @chainable
- */
- mapUnknownRoutes(config: RouteConfiguration): Router;
-
- /**
- * Resets the router by removing handlers, routes, event handlers and previously configured options.
- * @chainable
- */
- reset(): Router;
-
- /**
- * Makes all configured routes and/or module ids relative to a certain base url.
- * @param {string} settings The value is used as the base for routes and module ids.
- * @chainable
- */
- makeRelative(settings: string): Router;
-
- /**
- * Makes all configured routes and/or module ids relative to a certain base url.
- * @param {RelativeRouteSettings} settings If an object, you can specify `route` and `moduleId` separately. In place of specifying route, you can set `fromParent:true` to make routes automatically relative to the parent router's active route.
- * @chainable
- */
- makeRelative(settings: RelativeRouteSettings): Router;
-
- /**
- * Creates a child router.
- * @returns {Router} The child router.
- */
- createChildRouter(): Router;
-
- /**
- * Inspects routes and modules before activation. Can be used to protect access by cancelling navigation or redirecting.
- * @param {object} instance The module instance that is about to be activated by the router.
- * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties.
- * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types.
- */
- guardRoute?:(instance:Object, instruction:RouteInstruction) => any;
- }
-
- export interface RootRouter extends Router {
- /**
- * Activates the router and the underlying history tracking mechanism.
- * @returns {Promise} A promise that resolves when the router is ready.
- */
- activate(options?: history.HistoryOptions): JQueryPromise;
-
- /**
- * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers.
- */
- deactivate(): void;
-
- /**
- * Installs the router's custom ko binding handler.
- */
- install(): void;
- }
+ /**
+ * Cancels the subscription.
+ * @chainable
+ */
+ off(): DurandalEventSubscription;
}
+
+interface DurandalEventSupport {
+ /**
+ * Creates a subscription or registers a callback for the specified event.
+ * @param {string} events One or more events, separated by white space.
+ * @returns {Subscription} A subscription is returned.
+ */
+ on(events: string): DurandalEventSubscription;
+
+ /**
+ * Creates a subscription or registers a callback for the specified event.
+ * @param {string} events One or more events, separated by white space.
+ * @param {function} [callback] The callback function to invoke when the event is triggered.
+ * @param {object} [context] An object to use as `this` when invoking the `callback`.
+ * @returns {Events} The events object is returned for chaining.
+ */
+ on(events: string, callback: Function, context?: any): T;
+
+ /**
+ * Removes the callbacks for the specified events.
+ * @param {string} [events] One or more events, separated by white space to turn off. If no events are specified, then the callbacks will be removed.
+ * @param {function} [callback] The callback function to remove. If `callback` is not provided, all callbacks for the specified events will be removed.
+ * @param {object} [context] The object that was used as `this`. Callbacks with this context will be removed.
+ * @chainable
+ */
+ off(events: string, callback: Function, context?: any): T;
+
+ /**
+ * Triggers the specified events.
+ * @param {string} [events] One or more events, separated by white space to trigger.
+ * @chainable
+ */
+ trigger(events: string, ...eventArgs: any[]): T;
+
+ /**
+ * Creates a function that will trigger the specified events when called. Simplifies proxying jQuery (or other) events through to the events object.
+ * @param {string} events One or more events, separated by white space to trigger by invoking the returned function.
+ * @returns {function} Calling the function will invoke the previously specified events on the events object.
+ */
+ proxy(events: string): Function;
+}
+
+interface DurandalEventModule {
+ new (): DurandalEventSupport