From 3c40310e9bbfaaf802175d22b6bb1f3b3b1e1a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 9 Sep 2015 09:57:06 +0200 Subject: [PATCH 01/12] tech(typescript): testing for how to migrate to typescript --- package.json | 1 + public/app/components/panelmeta.d.ts | 7 + public/app/components/panelmeta.js | 4 + public/app/controllers/grafanaCtrl.js | 5 +- public/app/controllers/testCtrl.d.ts | 6 + public/app/controllers/testCtrl.js | 14 + public/app/controllers/testCtrl.js.map | 1 + public/app/controllers/testCtrl.ts | 18 ++ public/app/headers/require.d.ts | 369 +++++++++++++++++++++++++ tasks/options/typescript.js | 19 ++ 10 files changed, 443 insertions(+), 1 deletion(-) create mode 100644 public/app/components/panelmeta.d.ts create mode 100644 public/app/controllers/testCtrl.d.ts create mode 100644 public/app/controllers/testCtrl.js create mode 100644 public/app/controllers/testCtrl.js.map create mode 100644 public/app/controllers/testCtrl.ts create mode 100644 public/app/headers/require.d.ts create mode 100644 tasks/options/typescript.js diff --git a/package.json b/package.json index 24e2eb18abb..78081c998b8 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "grunt-karma": "~0.8.3", "grunt-ng-annotate": "^0.9.2", "grunt-string-replace": "~0.2.4", + "grunt-typescript": "^0.7.0", "grunt-usemin": "3.0.0", "jshint-stylish": "~0.1.5", "karma": "~0.12.31", diff --git a/public/app/components/panelmeta.d.ts b/public/app/components/panelmeta.d.ts new file mode 100644 index 00000000000..42258894622 --- /dev/null +++ b/public/app/components/panelmeta.d.ts @@ -0,0 +1,7 @@ +/// +declare class Base { + constructor(); + testFunc(): number + getName(): string +} +export = Base; diff --git a/public/app/components/panelmeta.js b/public/app/components/panelmeta.js index 7eee8fa970f..9f0b2cfcdd5 100644 --- a/public/app/components/panelmeta.js +++ b/public/app/components/panelmeta.js @@ -33,6 +33,10 @@ function () { this.menu.push({text: text, icon: icon, click: click, role: role}); }; + PanelMeta.prototype.getName = function() { + return "javascript"; + }; + PanelMeta.prototype.addExtendedMenuItem = function(text, icon, click, role) { this.extendedMenu.push({text: text, icon: icon, click: click, role: role}); }; diff --git a/public/app/controllers/grafanaCtrl.js b/public/app/controllers/grafanaCtrl.js index 16e505a68dc..6576b57de87 100644 --- a/public/app/controllers/grafanaCtrl.js +++ b/public/app/controllers/grafanaCtrl.js @@ -4,10 +4,13 @@ define([ 'lodash', 'jquery', 'store', + './testCtrl', ], -function (angular, config, _, $, store) { +function (angular, config, _, $, store, TestCtrl) { "use strict"; + console.log(new TestCtrl().getName()); + var module = angular.module('grafana.controllers'); module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv) { diff --git a/public/app/controllers/testCtrl.d.ts b/public/app/controllers/testCtrl.d.ts new file mode 100644 index 00000000000..fd80685535d --- /dev/null +++ b/public/app/controllers/testCtrl.d.ts @@ -0,0 +1,6 @@ +/// +declare class Base { + constructor(); + getName(): string; +} +export = Base; diff --git a/public/app/controllers/testCtrl.js b/public/app/controllers/testCtrl.js new file mode 100644 index 00000000000..b8687f2732b --- /dev/null +++ b/public/app/controllers/testCtrl.js @@ -0,0 +1,14 @@ +/// +define(["require", "exports", "../components/panelmeta"], function (require, exports) { + var Base = (function () { + function Base() { + } + Base.prototype.getName = function () { + debugger; + return "asd"; + }; + return Base; + })(); + return Base; +}); +//# sourceMappingURL=testCtrl.js.map \ No newline at end of file diff --git a/public/app/controllers/testCtrl.js.map b/public/app/controllers/testCtrl.js.map new file mode 100644 index 00000000000..f99ddeff0ce --- /dev/null +++ b/public/app/controllers/testCtrl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAM/C;QAEIA;QACAC,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,QAAQA,CAACA;YACTA,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AATD,IASC;IAEa,AAAd,OAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/public/app/controllers/testCtrl.ts b/public/app/controllers/testCtrl.ts new file mode 100644 index 00000000000..cf7f91289fa --- /dev/null +++ b/public/app/controllers/testCtrl.ts @@ -0,0 +1,18 @@ +/// + +/// + +import PanelMeta = require('../components/panelmeta'); + +class Base { + + constructor() { + } + + public getName() : string { + debugger; + return "asd"; + } +} + +export = Base; diff --git a/public/app/headers/require.d.ts b/public/app/headers/require.d.ts new file mode 100644 index 00000000000..c42a1bda101 --- /dev/null +++ b/public/app/headers/require.d.ts @@ -0,0 +1,369 @@ +// Type definitions for RequireJS 2.1.8 +// Project: http://requirejs.org/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* +require-2.1.8.d.ts may be freely distributed under the MIT license. + +Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +*/ + +declare module 'module' { + var mod: { + config: () => any; + id: string; + uri: string; + } + export = mod; +} + +interface RequireError extends Error { + + /** + * The error ID that maps to an ID on a web page. + **/ + requireType: string; + + /** + * Required modules. + **/ + requireModules: string[]; + + /** + * The original error, if there is one (might be null). + **/ + originalError: Error; +} + +interface RequireShim { + + /** + * List of dependencies. + **/ + deps?: string[]; + + /** + * Name the module will be exported as. + **/ + exports?: string; + + /** + * Initialize function with all dependcies passed in, + * if the function returns a value then that value is used + * as the module export value instead of the object + * found via the 'exports' string. + * @param dependencies + * @return + **/ + init?: (...dependencies: any[]) => any; +} + +interface RequireConfig { + + // The root path to use for all module lookups. + baseUrl?: string; + + // Path mappings for module names not found directly under + // baseUrl. + paths?: { [key: string]: any; }; + + // Dictionary of Shim's. + // does not cover case of key->string[] + shim?: { [key: string]: RequireShim; }; + + /** + * For the given module prefix, instead of loading the + * module with the given ID, substitude a different + * module ID. + * + * @example + * requirejs.config({ + * map: { + * 'some/newmodule': { + * 'foo': 'foo1.2' + * }, + * 'some/oldmodule': { + * 'foo': 'foo1.0' + * } + * } + * }); + **/ + map?: { + [id: string]: { + [id: string]: string; + }; + }; + + /** + * AMD configurations, use module.config() to access in + * define() functions + **/ + config?: { [id: string]: {}; }; + + /** + * Configures loading modules from CommonJS packages. + **/ + packages?: {}; + + /** + * The number of seconds to wait before giving up on loading + * a script. The default is 7 seconds. + **/ + waitSeconds?: number; + + /** + * A name to give to a loading context. This allows require.js + * to load multiple versions of modules in a page, as long as + * each top-level require call specifies a unique context string. + **/ + context?: string; + + /** + * An array of dependencies to load. + **/ + deps?: string[]; + + /** + * A function to pass to require that should be require after + * deps have been loaded. + * @param modules + **/ + callback?: (...modules: any[]) => void; + + /** + * If set to true, an error will be thrown if a script loads + * that does not call define() or have shim exports string + * value that can be checked. + **/ + enforceDefine?: boolean; + + /** + * If set to true, document.createElementNS() will be used + * to create script elements. + **/ + xhtml?: boolean; + + /** + * Extra query string arguments appended to URLs that RequireJS + * uses to fetch resources. Most useful to cachce bust when + * the browser or server is not configured correcty. + * + * @example + * urlArgs: "bust= + (new Date()).getTime() + **/ + urlArgs?: string; + + /** + * Specify the value for the type="" attribute used for script + * tags inserted into the document by RequireJS. Default is + * "text/javascript". To use Firefox's JavasScript 1.8 + * features, use "text/javascript;version=1.8". + **/ + scriptType?: string; + +} + +// todo: not sure what to do with this guy +interface RequireModule { + + /** + * + **/ + config(): {}; + +} + +/** +* +**/ +interface RequireMap { + + /** + * + **/ + prefix: string; + + /** + * + **/ + name: string; + + /** + * + **/ + parentMap: RequireMap; + + /** + * + **/ + url: string; + + /** + * + **/ + originalName: string; + + /** + * + **/ + fullName: string; +} + +interface Require { + + /** + * Configure require.js + **/ + config(config: RequireConfig): Require; + + /** + * CommonJS require call + * @param module Module to load + * @return The loaded module + */ + (module: string): any; + + /** + * Start the main app logic. + * Callback is optional. + * Can alternatively use deps and callback. + * @param modules Required modules to load. + **/ + (modules: string[]): void; + + /** + * @see Require() + * @param ready Called when required modules are ready. + **/ + (modules: string[], ready: Function): void; + + /** + * @see http://requirejs.org/docs/api.html#errbacks + * @param ready Called when required modules are ready. + **/ + (modules: string[], ready: Function, errback: Function): void; + + /** + * Generate URLs from require module + * @param module Module to URL + * @return URL string + **/ + toUrl(module: string): string; + + /** + * Returns true if the module has already been loaded and defined. + * @param module Module to check + **/ + defined(module: string): boolean; + + /** + * Returns true if the module has already been requested or is in the process of loading and should be available at some point. + * @param module Module to check + **/ + specified(module: string): boolean; + + /** + * On Error override + * @param err + **/ + onError(err: RequireError, errback?: (err: RequireError) => void): void; + + /** + * Undefine a module + * @param module Module to undefine. + **/ + undef(module: string): void; + + /** + * Semi-private function, overload in special instance of undef() + **/ + onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void; +} + +interface RequireDefine { + + /** + * Define Simple Name/Value Pairs + * @param config Dictionary of Named/Value pairs for the config. + **/ + (config: { [key: string]: any; }): void; + + /** + * Define function. + * @param func: The function module. + **/ + (func: () => any): void; + + /** + * Define function with dependencies. + * @param deps List of dependencies module IDs. + * @param ready Callback function when the dependencies are loaded. + * callback param deps module dependencies + * callback return module definition + **/ + (deps: string[], ready: Function): void; + + /** + * Define module with simplified CommonJS wrapper. + * @param ready + * callback require requirejs instance + * callback exports exports object + * callback module module + * callback return module definition + **/ + (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void; + + /** + * Define a module with a name and dependencies. + * @param name The name of the module. + * @param deps List of dependencies module IDs. + * @param ready Callback function when the dependencies are loaded. + * callback deps module dependencies + * callback return module definition + **/ + (name: string, deps: string[], ready: Function): void; + + /** + * Define a module with a name. + * @param name The name of the module. + * @param ready Callback function when the dependencies are loaded. + * callback return module definition + **/ + (name: string, ready: Function): void; + + /** + * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms + * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object. + * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function + * that does not conform to the AMD API. + * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version + * of jQuery being loaded simultaneously. + */ + amd: Object; +} + +// Ambient declarations for 'require' and 'define' +declare var requirejs: Require; +declare var require: Require; +declare var define: RequireDefine; diff --git a/tasks/options/typescript.js b/tasks/options/typescript.js new file mode 100644 index 00000000000..79251c77eb6 --- /dev/null +++ b/tasks/options/typescript.js @@ -0,0 +1,19 @@ +module.exports = function() { + 'use strict'; + + return { + base: { + src: ['public/app/**/*.ts'], + dest: '', + options: { + module: 'amd', //or commonjs + target: 'es5', //or es3 + keepDirectoryHierarchy: true, + declaration: true, + watch: true, + sourceMap: true, + } + } + }; + +}; From 005e1e002b7aa476e51bb12cb641b50c05a60ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 9 Sep 2015 17:40:52 +0200 Subject: [PATCH 02/12] more playing around with typescript --- public/app/controllers/fileSearcher.d.ts | 6 ++++++ public/app/controllers/fileSearcher.js | 13 +++++++++++++ public/app/controllers/fileSearcher.js.map | 1 + public/app/controllers/fileSearcher.ts | 18 ++++++++++++++++++ public/app/controllers/testCtrl.js | 5 +++-- public/app/controllers/testCtrl.js.map | 2 +- public/app/controllers/testCtrl.ts | 4 +++- 7 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 public/app/controllers/fileSearcher.d.ts create mode 100644 public/app/controllers/fileSearcher.js create mode 100644 public/app/controllers/fileSearcher.js.map create mode 100644 public/app/controllers/fileSearcher.ts diff --git a/public/app/controllers/fileSearcher.d.ts b/public/app/controllers/fileSearcher.d.ts new file mode 100644 index 00000000000..dbac066880e --- /dev/null +++ b/public/app/controllers/fileSearcher.d.ts @@ -0,0 +1,6 @@ +/// +declare class FileSearcher { + constructor(); + getFiles(): string[]; +} +export = FileSearcher; diff --git a/public/app/controllers/fileSearcher.js b/public/app/controllers/fileSearcher.js new file mode 100644 index 00000000000..24842f571d2 --- /dev/null +++ b/public/app/controllers/fileSearcher.js @@ -0,0 +1,13 @@ +/// +define(["require", "exports"], function (require, exports) { + var FileSearcher = (function () { + function FileSearcher() { + } + FileSearcher.prototype.getFiles = function () { + return ["asd"]; + }; + return FileSearcher; + })(); + return FileSearcher; +}); +//# sourceMappingURL=fileSearcher.js.map \ No newline at end of file diff --git a/public/app/controllers/fileSearcher.js.map b/public/app/controllers/fileSearcher.js.map new file mode 100644 index 00000000000..8fee4ea258a --- /dev/null +++ b/public/app/controllers/fileSearcher.js.map @@ -0,0 +1 @@ +{"version":3,"file":"fileSearcher.js","sourceRoot":"","sources":["fileSearcher.ts"],"names":["FileSearcher","FileSearcher.constructor","FileSearcher.getFiles"],"mappings":"AAAA,+CAA+C;;IAE/C;QAEIA;QACAC,CAACA;QAEMD,+BAAQA,GAAfA;YACEE,MAAMA,CAACA,CAACA,KAAKA,CAACA,CAACA;QACjBA,CAACA;QACLF,mBAACA;IAADA,CAACA,AARD,IAQC;IAEqB,AAAtB,OAAS,YAAY,CAAC"} \ No newline at end of file diff --git a/public/app/controllers/fileSearcher.ts b/public/app/controllers/fileSearcher.ts new file mode 100644 index 00000000000..4515c374bd0 --- /dev/null +++ b/public/app/controllers/fileSearcher.ts @@ -0,0 +1,18 @@ +/// + +class FileSearcher { + + constructor() { + } + + public getFiles() : string[] { + return ["asd"]; + } + + public getBullshit() : any { + return "asd"; + } + +} + +export = FileSearcher; diff --git a/public/app/controllers/testCtrl.js b/public/app/controllers/testCtrl.js index b8687f2732b..878d3934e7b 100644 --- a/public/app/controllers/testCtrl.js +++ b/public/app/controllers/testCtrl.js @@ -1,10 +1,11 @@ /// -define(["require", "exports", "../components/panelmeta"], function (require, exports) { +define(["require", "exports", './fileSearcher', "../components/panelmeta"], function (require, exports, FileSearcher) { var Base = (function () { function Base() { + var test = new FileSearcher(); + test.getFiles(); } Base.prototype.getName = function () { - debugger; return "asd"; }; return Base; diff --git a/public/app/controllers/testCtrl.js.map b/public/app/controllers/testCtrl.js.map index f99ddeff0ce..22984a48a83 100644 --- a/public/app/controllers/testCtrl.js.map +++ b/public/app/controllers/testCtrl.js.map @@ -1 +1 @@ -{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAM/C;QAEIA;QACAC,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,QAAQA,CAACA;YACTA,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AATD,IASC;IAEa,AAAd,OAAS,IAAI,CAAC"} \ No newline at end of file +{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAO/C;QAEIA;YACEC,IAAIA,IAAIA,GAAGA,IAAIA,YAAYA,EAAEA,CAACA;YAC9BA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;QAClBA,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AAVD,IAUC;IAEa,AAAd,OAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/public/app/controllers/testCtrl.ts b/public/app/controllers/testCtrl.ts index cf7f91289fa..596d8f67a1d 100644 --- a/public/app/controllers/testCtrl.ts +++ b/public/app/controllers/testCtrl.ts @@ -3,14 +3,16 @@ /// import PanelMeta = require('../components/panelmeta'); +import FileSearcher = require('./fileSearcher'); class Base { constructor() { + var test = new FileSearcher(); + test.getFiles(); } public getName() : string { - debugger; return "asd"; } } From a8197df1c1089d4e888223d1adc5a919bacf1f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 9 Sep 2015 19:34:24 +0200 Subject: [PATCH 03/12] more experiments for mixing javascript and typescript --- .gitignore | 1 + public/app/components/panelmeta.d.ts | 7 ---- .../components/{panelmeta.js => panelmeta.ts} | 35 +++++++++---------- public/app/components/require.config.js | 2 +- public/app/controllers/fileSearcher.d.ts | 6 ---- public/app/controllers/fileSearcher.js | 13 ------- public/app/controllers/fileSearcher.js.map | 1 - public/app/controllers/testCtrl.d.ts | 6 ---- public/app/controllers/testCtrl.js | 15 -------- public/app/controllers/testCtrl.js.map | 1 - public/app/controllers/testCtrl.ts | 1 - public/views/index.html | 2 +- tasks/options/copy.js | 10 +++++- tasks/options/typescript.js | 21 ++++++++--- tasks/options/watch.js | 17 +++++++++ tsconfig.json | 17 +++++++++ 16 files changed, 80 insertions(+), 75 deletions(-) delete mode 100644 public/app/components/panelmeta.d.ts rename public/app/components/{panelmeta.js => panelmeta.ts} (72%) delete mode 100644 public/app/controllers/fileSearcher.d.ts delete mode 100644 public/app/controllers/fileSearcher.js delete mode 100644 public/app/controllers/fileSearcher.js.map delete mode 100644 public/app/controllers/testCtrl.d.ts delete mode 100644 public/app/controllers/testCtrl.js delete mode 100644 public/app/controllers/testCtrl.js.map create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 96824b93aa3..f25714d3759 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ coverage/ awsconfig /dist /emails/dist +/public/app_gen /tmp docs/AWS_S3_BUCKET diff --git a/public/app/components/panelmeta.d.ts b/public/app/components/panelmeta.d.ts deleted file mode 100644 index 42258894622..00000000000 --- a/public/app/components/panelmeta.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// -declare class Base { - constructor(); - testFunc(): number - getName(): string -} -export = Base; diff --git a/public/app/components/panelmeta.js b/public/app/components/panelmeta.ts similarity index 72% rename from public/app/components/panelmeta.js rename to public/app/components/panelmeta.ts index 9f0b2cfcdd5..801727481f0 100644 --- a/public/app/components/panelmeta.js +++ b/public/app/components/panelmeta.ts @@ -1,9 +1,13 @@ -define([ -], -function () { - "use strict"; +class PanelMeta { + description: any + fullscreen: any + editIcon: any + panelName: any + menu: any + editorTabs: any + extendedMenu: any - function PanelMeta(options) { + constructor(options : any) { this.description = options.description; this.fullscreen = options.fullscreen; this.editIcon = options.editIcon; @@ -29,22 +33,17 @@ function () { this.addExtendedMenuItem('Panel JSON', '', 'editPanelJson(); dismiss();'); } - PanelMeta.prototype.addMenuItem = function(text, icon, click, role) { + addMenuItem (text, icon, click, role?) { this.menu.push({text: text, icon: icon, click: click, role: role}); - }; + } - PanelMeta.prototype.getName = function() { - return "javascript"; - }; - - PanelMeta.prototype.addExtendedMenuItem = function(text, icon, click, role) { + addExtendedMenuItem (text, icon, click, role?) { this.extendedMenu.push({text: text, icon: icon, click: click, role: role}); - }; + } - PanelMeta.prototype.addEditorTab = function(title, src) { + addEditorTab (title, src) { this.editorTabs.push({title: title, src: src}); - }; + } +} - return PanelMeta; - -}); +export = PanelMeta; diff --git a/public/app/components/require.config.js b/public/app/components/require.config.js index f255418414e..7db59e2b59a 100644 --- a/public/app/components/require.config.js +++ b/public/app/components/require.config.js @@ -1,6 +1,6 @@ require.config({ urlArgs: 'bust=' + (new Date().getTime()), - baseUrl: 'public/app', + baseUrl: 'public/app_gen', paths: { config: 'components/config', diff --git a/public/app/controllers/fileSearcher.d.ts b/public/app/controllers/fileSearcher.d.ts deleted file mode 100644 index dbac066880e..00000000000 --- a/public/app/controllers/fileSearcher.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// -declare class FileSearcher { - constructor(); - getFiles(): string[]; -} -export = FileSearcher; diff --git a/public/app/controllers/fileSearcher.js b/public/app/controllers/fileSearcher.js deleted file mode 100644 index 24842f571d2..00000000000 --- a/public/app/controllers/fileSearcher.js +++ /dev/null @@ -1,13 +0,0 @@ -/// -define(["require", "exports"], function (require, exports) { - var FileSearcher = (function () { - function FileSearcher() { - } - FileSearcher.prototype.getFiles = function () { - return ["asd"]; - }; - return FileSearcher; - })(); - return FileSearcher; -}); -//# sourceMappingURL=fileSearcher.js.map \ No newline at end of file diff --git a/public/app/controllers/fileSearcher.js.map b/public/app/controllers/fileSearcher.js.map deleted file mode 100644 index 8fee4ea258a..00000000000 --- a/public/app/controllers/fileSearcher.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"fileSearcher.js","sourceRoot":"","sources":["fileSearcher.ts"],"names":["FileSearcher","FileSearcher.constructor","FileSearcher.getFiles"],"mappings":"AAAA,+CAA+C;;IAE/C;QAEIA;QACAC,CAACA;QAEMD,+BAAQA,GAAfA;YACEE,MAAMA,CAACA,CAACA,KAAKA,CAACA,CAACA;QACjBA,CAACA;QACLF,mBAACA;IAADA,CAACA,AARD,IAQC;IAEqB,AAAtB,OAAS,YAAY,CAAC"} \ No newline at end of file diff --git a/public/app/controllers/testCtrl.d.ts b/public/app/controllers/testCtrl.d.ts deleted file mode 100644 index fd80685535d..00000000000 --- a/public/app/controllers/testCtrl.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// -declare class Base { - constructor(); - getName(): string; -} -export = Base; diff --git a/public/app/controllers/testCtrl.js b/public/app/controllers/testCtrl.js deleted file mode 100644 index 878d3934e7b..00000000000 --- a/public/app/controllers/testCtrl.js +++ /dev/null @@ -1,15 +0,0 @@ -/// -define(["require", "exports", './fileSearcher', "../components/panelmeta"], function (require, exports, FileSearcher) { - var Base = (function () { - function Base() { - var test = new FileSearcher(); - test.getFiles(); - } - Base.prototype.getName = function () { - return "asd"; - }; - return Base; - })(); - return Base; -}); -//# sourceMappingURL=testCtrl.js.map \ No newline at end of file diff --git a/public/app/controllers/testCtrl.js.map b/public/app/controllers/testCtrl.js.map deleted file mode 100644 index 22984a48a83..00000000000 --- a/public/app/controllers/testCtrl.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"testCtrl.js","sourceRoot":"","sources":["testCtrl.ts"],"names":["Base","Base.constructor","Base.getName"],"mappings":"AAAA,+CAA+C;;IAO/C;QAEIA;YACEC,IAAIA,IAAIA,GAAGA,IAAIA,YAAYA,EAAEA,CAACA;YAC9BA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;QAClBA,CAACA;QAEMD,sBAAOA,GAAdA;YACEE,MAAMA,CAACA,KAAKA,CAACA;QACfA,CAACA;QACLF,WAACA;IAADA,CAACA,AAVD,IAUC;IAEa,AAAd,OAAS,IAAI,CAAC"} \ No newline at end of file diff --git a/public/app/controllers/testCtrl.ts b/public/app/controllers/testCtrl.ts index 596d8f67a1d..48e5f094375 100644 --- a/public/app/controllers/testCtrl.ts +++ b/public/app/controllers/testCtrl.ts @@ -2,7 +2,6 @@ /// -import PanelMeta = require('../components/panelmeta'); import FileSearcher = require('./fileSearcher'); class Base { diff --git a/public/views/index.html b/public/views/index.html index b3c1763ce51..69b3dd6a66b 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -19,7 +19,7 @@ - + diff --git a/tasks/options/copy.js b/tasks/options/copy.js index ae068eba3c0..48d4514e612 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -4,8 +4,16 @@ module.exports = function(config) { everything_but_less_to_temp: { cwd: '<%= srcDir %>', expand: true, - src: ['**/*', '!**/*.less', '!config.js'], + src: ['**/*', '!**/*.less'], dest: '<%= tempDir %>' + }, + + app_gen_build: { + cwd: '<%= srcDir %>/app', + expand: true, + src: ['**/*.js', '**/*.html'], + dest: '<%= srcDir %>/app_gen' } + }; }; diff --git a/tasks/options/typescript.js b/tasks/options/typescript.js index 79251c77eb6..752b8ab4eb7 100644 --- a/tasks/options/typescript.js +++ b/tasks/options/typescript.js @@ -2,16 +2,29 @@ module.exports = function() { 'use strict'; return { - base: { + build: { src: ['public/app/**/*.ts'], - dest: '', + dest: 'public/app_gen', options: { module: 'amd', //or commonjs target: 'es5', //or es3 - keepDirectoryHierarchy: true, + rootDir: 'public/app', declaration: true, - watch: true, sourceMap: true, + generateTsConfig: true, + } + }, + watch: { + src: ['public/app/**/*.ts'], + dest: 'public/app_gen', + options: { + module: 'amd', //or commonjs + target: 'es5', //or es3 + rootDir: 'public/app', + declaration: true, + sourceMap: true, + watch: true, + generateTsConfig: true, } } }; diff --git a/tasks/options/watch.js b/tasks/options/watch.js index c97609d9e53..692ec08e179 100644 --- a/tasks/options/watch.js +++ b/tasks/options/watch.js @@ -6,6 +6,23 @@ module.exports = function(config) { options: { spawn: false } + }, + + app_gen: { + files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'], + tasks: ['copy:app_gen_build'], + options: { + spawn: false + } + }, + + typescript: { + files: ['<%= srcDir %>/app/**/*.ts'], + tasks: ['typescript:build'], + options: { + spawn: false + } } + }; }; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000000..a89d0f30933 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "sourceMap": true, + "declaration": true, + "outDir": "public/app_gen", + "target": "ES5", + "rootDir": "public/app", + "module": "amd", + "noEmitOnError": true + }, + "files": [ + "public/app/components/panelmeta.ts", + "public/app/controllers/fileSearcher.ts", + "public/app/controllers/testCtrl.ts", + "public/app/headers/require.d.ts" + ] +} \ No newline at end of file From 82061c7c3b4fc2a4833110498edddc8e8b461fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 9 Sep 2015 20:37:27 +0200 Subject: [PATCH 04/12] experiments --- .gitignore | 2 +- public/app/components/require.config.js | 2 +- public/views/index.html | 2 +- tasks/options/copy.js | 2 +- tasks/options/typescript.js | 4 ++-- tsconfig.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index f25714d3759..7ba77672df2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ coverage/ awsconfig /dist /emails/dist -/public/app_gen +/public/.app_gen /tmp docs/AWS_S3_BUCKET diff --git a/public/app/components/require.config.js b/public/app/components/require.config.js index 7db59e2b59a..268d782114a 100644 --- a/public/app/components/require.config.js +++ b/public/app/components/require.config.js @@ -1,6 +1,6 @@ require.config({ urlArgs: 'bust=' + (new Date().getTime()), - baseUrl: 'public/app_gen', + baseUrl: 'public/.app_gen', paths: { config: 'components/config', diff --git a/public/views/index.html b/public/views/index.html index 69b3dd6a66b..bf7c5c969c3 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -19,7 +19,7 @@ - + diff --git a/tasks/options/copy.js b/tasks/options/copy.js index 48d4514e612..9bd4ad9571f 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -12,7 +12,7 @@ module.exports = function(config) { cwd: '<%= srcDir %>/app', expand: true, src: ['**/*.js', '**/*.html'], - dest: '<%= srcDir %>/app_gen' + dest: '<%= srcDir %>/.app_gen' } }; diff --git a/tasks/options/typescript.js b/tasks/options/typescript.js index 752b8ab4eb7..87c1cab5573 100644 --- a/tasks/options/typescript.js +++ b/tasks/options/typescript.js @@ -4,7 +4,7 @@ module.exports = function() { return { build: { src: ['public/app/**/*.ts'], - dest: 'public/app_gen', + dest: 'public/.app_gen', options: { module: 'amd', //or commonjs target: 'es5', //or es3 @@ -16,7 +16,7 @@ module.exports = function() { }, watch: { src: ['public/app/**/*.ts'], - dest: 'public/app_gen', + dest: 'public/.app_gen', options: { module: 'amd', //or commonjs target: 'es5', //or es3 diff --git a/tsconfig.json b/tsconfig.json index a89d0f30933..e8b34801c24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "sourceMap": true, "declaration": true, - "outDir": "public/app_gen", + "outDir": "public/.app_gen", "target": "ES5", "rootDir": "public/app", "module": "amd", From abac8bccc6d380f194aa2a629d02fe908b11fd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 11:26:40 +0200 Subject: [PATCH 05/12] tech(typescript): its looking good --- .gitignore | 2 +- Gruntfile.js | 1 + package.json | 1 + public/app/app.js | 2 +- public/app/components/require.config.js | 2 +- public/app/controllers/errorCtrl.js | 1 + public/app/controllers/grafanaCtrl.js | 5 +--- public/app/core/core.ts | 6 ++++ public/app/core/directives/cool_dir.ts | 7 +++++ public/app/core/routes/module_loader.ts | 19 +++++++++++++ public/app/core/time_series.ts | 6 ++++ public/app/features/all.js | 1 - public/app/routes/all.js | 10 ++++++- public/{css => }/less/admin.less | 0 .../{css => }/less/bootstrap-tagsinput.less | 0 public/{css => }/less/bootstrap.dark.less | 0 public/{css => }/less/bootstrap.light.less | 0 public/{css => }/less/bootswatch.dark.less | 0 public/{css => }/less/bootswatch.light.less | 0 public/{css => }/less/dashlist.less | 0 public/{css => }/less/fonts.less | 0 public/{css => }/less/forms.less | 0 public/{css => }/less/gfbox.less | 0 public/{css => }/less/grafana-responsive.less | 0 public/{css => }/less/grafana.less | 0 public/{css => }/less/graph.less | 0 public/{css => }/less/login.less | 0 public/{css => }/less/navbar.less | 0 public/{css => }/less/overrides.less | 0 public/{css => }/less/panel.less | 0 public/{css => }/less/search.less | 0 public/{css => }/less/sidemenu.less | 0 public/{css => }/less/singlestat.less | 0 public/{css => }/less/submenu.less | 0 public/{css => }/less/tables_lists.less | 0 public/{css => }/less/tabs.less | 0 public/{css => }/less/tightform.less | 0 public/{css => }/less/type.less | 0 public/{css => }/less/validation.less | 0 public/{css => }/less/variables.dark.less | 0 public/{css => }/less/variables.light.less | 0 public/test/karma.conf.js | 2 +- public/test/test-main.js | 2 +- public/views/index.html | 2 +- tasks/build_task.js | 9 +++--- tasks/default_task.js | 14 ++++++++-- tasks/options/clean.js | 5 +++- tasks/options/concat.js | 28 +++++++++---------- tasks/options/copy.js | 8 +++--- tasks/options/less.js | 23 +++++---------- tasks/options/requirejs.js | 14 ++++++---- tasks/options/typescript.js | 15 ++++++++-- tasks/options/watch.js | 8 +++--- tsconfig.json | 6 +++- 54 files changed, 133 insertions(+), 66 deletions(-) create mode 100644 public/app/core/core.ts create mode 100644 public/app/core/directives/cool_dir.ts create mode 100644 public/app/core/routes/module_loader.ts create mode 100644 public/app/core/time_series.ts rename public/{css => }/less/admin.less (100%) rename public/{css => }/less/bootstrap-tagsinput.less (100%) rename public/{css => }/less/bootstrap.dark.less (100%) rename public/{css => }/less/bootstrap.light.less (100%) rename public/{css => }/less/bootswatch.dark.less (100%) rename public/{css => }/less/bootswatch.light.less (100%) rename public/{css => }/less/dashlist.less (100%) rename public/{css => }/less/fonts.less (100%) rename public/{css => }/less/forms.less (100%) rename public/{css => }/less/gfbox.less (100%) rename public/{css => }/less/grafana-responsive.less (100%) rename public/{css => }/less/grafana.less (100%) rename public/{css => }/less/graph.less (100%) rename public/{css => }/less/login.less (100%) rename public/{css => }/less/navbar.less (100%) rename public/{css => }/less/overrides.less (100%) rename public/{css => }/less/panel.less (100%) rename public/{css => }/less/search.less (100%) rename public/{css => }/less/sidemenu.less (100%) rename public/{css => }/less/singlestat.less (100%) rename public/{css => }/less/submenu.less (100%) rename public/{css => }/less/tables_lists.less (100%) rename public/{css => }/less/tabs.less (100%) rename public/{css => }/less/tightform.less (100%) rename public/{css => }/less/type.less (100%) rename public/{css => }/less/validation.less (100%) rename public/{css => }/less/variables.dark.less (100%) rename public/{css => }/less/variables.light.less (100%) diff --git a/.gitignore b/.gitignore index 7ba77672df2..8abd0d17cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ coverage/ awsconfig /dist /emails/dist -/public/.app_gen +/public_gen /tmp docs/AWS_S3_BUCKET diff --git a/Gruntfile.js b/Gruntfile.js index 43cb1f09bd1..70defdeaf6d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,6 +6,7 @@ module.exports = function (grunt) { pkg: grunt.file.readJSON('package.json'), baseDir: '.', srcDir: 'public', + genDir: 'public_gen', destDir: 'dist', tempDir: 'tmp', arch: os.arch(), diff --git a/package.json b/package.json index 78081c998b8..01b9ae03cb1 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "license": "Apache-2.0", "dependencies": { "grunt-jscs": "~1.5.x", + "grunt-sync": "^0.4.1", "karma-sinon": "^1.0.3", "lodash": "^2.4.1", "sinon": "1.10.3" diff --git a/public/app/app.js b/public/app/app.js index 8adc04d1ef7..e91efa1169a 100644 --- a/public/app/app.js +++ b/public/app/app.js @@ -104,8 +104,8 @@ function (angular, $, _, appLevelRequire) { _.each(pre_boot_modules, function (module) { _.extend(module, register_fns); }); - pre_boot_modules = false; + pre_boot_modules = false; $rootScope.requireContext = appLevelRequire; $rootScope.require = function (deps, fn) { var $scope = this; diff --git a/public/app/components/require.config.js b/public/app/components/require.config.js index 268d782114a..f255418414e 100644 --- a/public/app/components/require.config.js +++ b/public/app/components/require.config.js @@ -1,6 +1,6 @@ require.config({ urlArgs: 'bust=' + (new Date().getTime()), - baseUrl: 'public/.app_gen', + baseUrl: 'public/app', paths: { config: 'components/config', diff --git a/public/app/controllers/errorCtrl.js b/public/app/controllers/errorCtrl.js index 9e70efb3ee4..b2dcbd1de50 100644 --- a/public/app/controllers/errorCtrl.js +++ b/public/app/controllers/errorCtrl.js @@ -8,6 +8,7 @@ function (angular) { var module = angular.module('grafana.controllers'); + module.controller('ErrorCtrl', function($scope, contextSrv) { var showSideMenu = contextSrv.sidemenu; diff --git a/public/app/controllers/grafanaCtrl.js b/public/app/controllers/grafanaCtrl.js index 6576b57de87..16e505a68dc 100644 --- a/public/app/controllers/grafanaCtrl.js +++ b/public/app/controllers/grafanaCtrl.js @@ -4,13 +4,10 @@ define([ 'lodash', 'jquery', 'store', - './testCtrl', ], -function (angular, config, _, $, store, TestCtrl) { +function (angular, config, _, $, store) { "use strict"; - console.log(new TestCtrl().getName()); - var module = angular.module('grafana.controllers'); module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv) { diff --git a/public/app/core/core.ts b/public/app/core/core.ts new file mode 100644 index 00000000000..f9a4b27c7ff --- /dev/null +++ b/public/app/core/core.ts @@ -0,0 +1,6 @@ + +export * from './time_series' +export * from './directives/cool_dir' +export * from './routes/module_loader' + + diff --git a/public/app/core/directives/cool_dir.ts b/public/app/core/directives/cool_dir.ts new file mode 100644 index 00000000000..78caa78bed8 --- /dev/null +++ b/public/app/core/directives/cool_dir.ts @@ -0,0 +1,7 @@ + +export class CoolDir { + getName() : string { + return "CoolDir"; + } +} + diff --git a/public/app/core/routes/module_loader.ts b/public/app/core/routes/module_loader.ts new file mode 100644 index 00000000000..9f309250d68 --- /dev/null +++ b/public/app/core/routes/module_loader.ts @@ -0,0 +1,19 @@ +/// + +export class ModuleLoader { + lazy: any + + constructor(moduleName) { + + this.lazy = ["$q", "$route", "$rootScope", function($q, $route, $rootScope) { + var defered = $q.defer(); + + require([moduleName], function () { + defered.resolve(); + }); + + return defered.promise; + }]; + + } +} diff --git a/public/app/core/time_series.ts b/public/app/core/time_series.ts new file mode 100644 index 00000000000..46d78e9fa7f --- /dev/null +++ b/public/app/core/time_series.ts @@ -0,0 +1,6 @@ +export class TimeSeries { + getName() : string { + return "TimeSeries"; + } +} + diff --git a/public/app/features/all.js b/public/app/features/all.js index 1a000a71782..6519d112b74 100644 --- a/public/app/features/all.js +++ b/public/app/features/all.js @@ -8,6 +8,5 @@ define([ './profile/profileCtrl', './profile/changePasswordCtrl', './profile/selectOrgCtrl', - './org/all', './admin/all', ], function () {}); diff --git a/public/app/routes/all.js b/public/app/routes/all.js index 74fb4997524..cdfdf0daf37 100644 --- a/public/app/routes/all.js +++ b/public/app/routes/all.js @@ -1,7 +1,8 @@ define([ 'angular', + '../core/core', './dashLoadControllers', -], function(angular) { +], function(angular, core) { "use strict"; var module = angular.module('grafana.routes'); @@ -41,30 +42,37 @@ define([ .when('/datasources', { templateUrl: 'app/features/org/partials/datasources.html', controller : 'DataSourcesCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/datasources/edit/:id', { templateUrl: 'app/features/org/partials/datasourceEdit.html', controller : 'DataSourceEditCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/datasources/new', { templateUrl: 'app/features/org/partials/datasourceEdit.html', controller : 'DataSourceEditCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/org', { templateUrl: 'app/features/org/partials/orgDetails.html', controller : 'OrgDetailsCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/org/new', { templateUrl: 'app/features/org/partials/newOrg.html', controller : 'NewOrgCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/org/users', { templateUrl: 'app/features/org/partials/orgUsers.html', controller : 'OrgUsersCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/org/apikeys', { templateUrl: 'app/features/org/partials/orgApiKeys.html', controller : 'OrgApiKeysCtrl', + resolve: new core.ModuleLoader("features/org/all"), }) .when('/profile', { templateUrl: 'app/features/profile/partials/profile.html', diff --git a/public/css/less/admin.less b/public/less/admin.less similarity index 100% rename from public/css/less/admin.less rename to public/less/admin.less diff --git a/public/css/less/bootstrap-tagsinput.less b/public/less/bootstrap-tagsinput.less similarity index 100% rename from public/css/less/bootstrap-tagsinput.less rename to public/less/bootstrap-tagsinput.less diff --git a/public/css/less/bootstrap.dark.less b/public/less/bootstrap.dark.less similarity index 100% rename from public/css/less/bootstrap.dark.less rename to public/less/bootstrap.dark.less diff --git a/public/css/less/bootstrap.light.less b/public/less/bootstrap.light.less similarity index 100% rename from public/css/less/bootstrap.light.less rename to public/less/bootstrap.light.less diff --git a/public/css/less/bootswatch.dark.less b/public/less/bootswatch.dark.less similarity index 100% rename from public/css/less/bootswatch.dark.less rename to public/less/bootswatch.dark.less diff --git a/public/css/less/bootswatch.light.less b/public/less/bootswatch.light.less similarity index 100% rename from public/css/less/bootswatch.light.less rename to public/less/bootswatch.light.less diff --git a/public/css/less/dashlist.less b/public/less/dashlist.less similarity index 100% rename from public/css/less/dashlist.less rename to public/less/dashlist.less diff --git a/public/css/less/fonts.less b/public/less/fonts.less similarity index 100% rename from public/css/less/fonts.less rename to public/less/fonts.less diff --git a/public/css/less/forms.less b/public/less/forms.less similarity index 100% rename from public/css/less/forms.less rename to public/less/forms.less diff --git a/public/css/less/gfbox.less b/public/less/gfbox.less similarity index 100% rename from public/css/less/gfbox.less rename to public/less/gfbox.less diff --git a/public/css/less/grafana-responsive.less b/public/less/grafana-responsive.less similarity index 100% rename from public/css/less/grafana-responsive.less rename to public/less/grafana-responsive.less diff --git a/public/css/less/grafana.less b/public/less/grafana.less similarity index 100% rename from public/css/less/grafana.less rename to public/less/grafana.less diff --git a/public/css/less/graph.less b/public/less/graph.less similarity index 100% rename from public/css/less/graph.less rename to public/less/graph.less diff --git a/public/css/less/login.less b/public/less/login.less similarity index 100% rename from public/css/less/login.less rename to public/less/login.less diff --git a/public/css/less/navbar.less b/public/less/navbar.less similarity index 100% rename from public/css/less/navbar.less rename to public/less/navbar.less diff --git a/public/css/less/overrides.less b/public/less/overrides.less similarity index 100% rename from public/css/less/overrides.less rename to public/less/overrides.less diff --git a/public/css/less/panel.less b/public/less/panel.less similarity index 100% rename from public/css/less/panel.less rename to public/less/panel.less diff --git a/public/css/less/search.less b/public/less/search.less similarity index 100% rename from public/css/less/search.less rename to public/less/search.less diff --git a/public/css/less/sidemenu.less b/public/less/sidemenu.less similarity index 100% rename from public/css/less/sidemenu.less rename to public/less/sidemenu.less diff --git a/public/css/less/singlestat.less b/public/less/singlestat.less similarity index 100% rename from public/css/less/singlestat.less rename to public/less/singlestat.less diff --git a/public/css/less/submenu.less b/public/less/submenu.less similarity index 100% rename from public/css/less/submenu.less rename to public/less/submenu.less diff --git a/public/css/less/tables_lists.less b/public/less/tables_lists.less similarity index 100% rename from public/css/less/tables_lists.less rename to public/less/tables_lists.less diff --git a/public/css/less/tabs.less b/public/less/tabs.less similarity index 100% rename from public/css/less/tabs.less rename to public/less/tabs.less diff --git a/public/css/less/tightform.less b/public/less/tightform.less similarity index 100% rename from public/css/less/tightform.less rename to public/less/tightform.less diff --git a/public/css/less/type.less b/public/less/type.less similarity index 100% rename from public/css/less/type.less rename to public/less/type.less diff --git a/public/css/less/validation.less b/public/less/validation.less similarity index 100% rename from public/css/less/validation.less rename to public/less/validation.less diff --git a/public/css/less/variables.dark.less b/public/less/variables.dark.less similarity index 100% rename from public/css/less/variables.dark.less rename to public/less/variables.dark.less diff --git a/public/css/less/variables.light.less b/public/less/variables.light.less similarity index 100% rename from public/css/less/variables.light.less rename to public/less/variables.light.less diff --git a/public/test/karma.conf.js b/public/test/karma.conf.js index d5d67d5218b..020c65a9e3c 100644 --- a/public/test/karma.conf.js +++ b/public/test/karma.conf.js @@ -9,7 +9,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ 'public/test/test-main.js', - {pattern: 'public/app/**/*.js', included: false}, + {pattern: 'public/.app_gen/**/*.js', included: false}, {pattern: 'public/vendor/**/*.js', included: false}, {pattern: 'public/test/**/*.js', included: false}, {pattern: 'public/**/*.js', included: false} diff --git a/public/test/test-main.js b/public/test/test-main.js index 6abf176b3e5..b9c0ba986aa 100644 --- a/public/test/test-main.js +++ b/public/test/test-main.js @@ -1,5 +1,5 @@ require.config({ - baseUrl: 'http://localhost:9876/base/public/app', + baseUrl: 'http://localhost:9876/base/public/app_gen', paths: { specs: '../test/specs', diff --git a/public/views/index.html b/public/views/index.html index bf7c5c969c3..b3c1763ce51 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -19,7 +19,7 @@ - + diff --git a/tasks/build_task.js b/tasks/build_task.js index b5c2e14a479..4d7209017b8 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -6,11 +6,11 @@ module.exports = function(grunt) { 'jshint:source', 'jshint:tests', 'jscs', - 'karma:test', 'clean:on_start', - 'less:src', - 'concat:cssDark', - 'concat:cssLight', + 'copy:app_gen_build', + 'typescript:build', + 'karma:test', + 'css', 'copy:everything_but_less_to_temp', 'htmlmin:build', 'ngtemplates', @@ -25,7 +25,6 @@ module.exports = function(grunt) { 'uglify:dest' ]); - // task to add [[.AppSubUrl]] to reved path grunt.registerTask('remapFilerev', function(){ var root = grunt.config().destDir; diff --git a/tasks/default_task.js b/tasks/default_task.js index 0bd46b9f5f9..edf2a38b35a 100644 --- a/tasks/default_task.js +++ b/tasks/default_task.js @@ -1,6 +1,16 @@ // Lint and build CSS module.exports = function(grunt) { - grunt.registerTask('css', ['less:src', 'concat:cssDark', 'concat:cssLight']); - grunt.registerTask('default', ['jscs', 'jshint', 'css']); + 'use strict'; + + grunt.registerTask('css', ['less', 'concat:cssDark', 'concat:cssLight']); + grunt.registerTask('default', [ + 'jscs', + 'jshint', + 'clean:gen', + 'copy:everything_but_ts_and_less', + 'css', + 'typescript:build' + ]); + grunt.registerTask('test', ['default', 'karma:test']); }; diff --git a/tasks/options/clean.js b/tasks/options/clean.js index 26bc01bc617..49f09f10e7c 100644 --- a/tasks/options/clean.js +++ b/tasks/options/clean.js @@ -1,6 +1,9 @@ module.exports = function(config) { + 'use strict'; + return { - on_start: ['<%= destDir %>', '<%= tempDir %>'], + release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'], + gen: ['<%= genDir %>'], temp: ['<%= tempDir %>'] }; }; diff --git a/tasks/options/concat.js b/tasks/options/concat.js index c325afd7f51..648d94fdbcc 100644 --- a/tasks/options/concat.js +++ b/tasks/options/concat.js @@ -4,25 +4,25 @@ module.exports = function(config) { return { cssDark: { src: [ - '<%= srcDir %>/vendor/css/normalize.min.css', - '<%= srcDir %>/vendor/css/timepicker.css', - '<%= srcDir %>/vendor/css/spectrum.css', - '<%= srcDir %>/css/bootstrap.dark.min.css', - '<%= srcDir %>/css/bootstrap-responsive.min.css', - '<%= srcDir %>/vendor/css/font-awesome.min.css' + '<%= genDir %>/vendor/css/normalize.min.css', + '<%= genDir %>/vendor/css/timepicker.css', + '<%= genDir %>/vendor/css/spectrum.css', + '<%= genDir %>/css/bootstrap.dark.min.css', + '<%= genDir %>/css/bootstrap-responsive.min.css', + '<%= genDir %>/vendor/css/font-awesome.min.css' ], - dest: '<%= srcDir %>/css/grafana.dark.min.css' + dest: '<%= genDir %>/css/grafana.dark.min.css' }, cssLight: { src: [ - '<%= srcDir %>/vendor/css/normalize.min.css', - '<%= srcDir %>/vendor/css/timepicker.css', - '<%= srcDir %>/vendor/css/spectrum.css', - '<%= srcDir %>/css/bootstrap.light.min.css', - '<%= srcDir %>/css/bootstrap-responsive.min.css', - '<%= srcDir %>/vendor/css/font-awesome.min.css' + '<%= genDir %>/vendor/css/normalize.min.css', + '<%= genDir %>/vendor/css/timepicker.css', + '<%= genDir %>/vendor/css/spectrum.css', + '<%= genDir %>/css/bootstrap.light.min.css', + '<%= genDir %>/css/bootstrap-responsive.min.css', + '<%= genDir %>/vendor/css/font-awesome.min.css' ], - dest: '<%= srcDir %>/css/grafana.light.min.css' + dest: '<%= genDir %>/css/grafana.light.min.css' }, js: { diff --git a/tasks/options/copy.js b/tasks/options/copy.js index 9bd4ad9571f..781042f9921 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -8,11 +8,11 @@ module.exports = function(config) { dest: '<%= tempDir %>' }, - app_gen_build: { - cwd: '<%= srcDir %>/app', + everything_but_less: { + cwd: '<%= srcDir %>', expand: true, - src: ['**/*.js', '**/*.html'], - dest: '<%= srcDir %>/.app_gen' + src: ['**/*', '!**/*.less'], + dest: '<%= genDir %>' } }; diff --git a/tasks/options/less.js b/tasks/options/less.js index 4d9fe764e03..b0a893e9a37 100644 --- a/tasks/options/less.js +++ b/tasks/options/less.js @@ -1,25 +1,16 @@ module.exports = function(config) { + return { - // this is the only task, other than copy, that runs on the src directory, since we don't really need - // the less files in the dist. Everything else runs from on temp, and require copys everything - // from temp -> dist - dist:{ - expand: true, - cwd:'<%= srcDir %>/vendor/bootstrap/less/', - src: ['bootstrap.dark.less', 'bootstrap.light.less'], - dest: '<%= tempDir %>/css/', - }, - // Compile in place when not building src:{ options: { - paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/css/less"], - yuicompress:true + paths: ["<%= srcDir %>/vendor/bootstrap/less", "<%= srcDir %>/less"], + yuicompress: true }, files: { - "<%= srcDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/css/less/bootstrap.dark.less", - "<%= srcDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/css/less/bootstrap.light.less", - "<%= srcDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/css/less/grafana-responsive.less" + "<%= genDir %>/css/bootstrap.dark.min.css": "<%= srcDir %>/less/bootstrap.dark.less", + "<%= genDir %>/css/bootstrap.light.min.css": "<%= srcDir %>/less/bootstrap.light.less", + "<%= genDir %>/css/bootstrap-responsive.min.css": "<%= srcDir %>/less/grafana-responsive.less" } } }; -}; \ No newline at end of file +}; diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index 41061158c66..21b22d51c26 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -7,7 +7,7 @@ module.exports = function(config,grunt) { appDir: '<%= tempDir %>', dir: '<%= destDir %>', mainConfigFile: '<%= tempDir %>/app/components/require.config.js', - baseUrl: './app', + baseUrl: 'app_gen', waitSeconds: 0, modules: [], // populated below, @@ -37,9 +37,9 @@ module.exports = function(config,grunt) { // setup the modules require will build var requireModules = options.modules = [ - { - // main/common module - name: 'app', + { + // main/common module + name: 'app', include: [ 'kbn', 'text', @@ -66,7 +66,11 @@ module.exports = function(config,grunt) { 'plugins/datasource/graphite/datasource', 'plugins/datasource/influxdb_08/datasource', ] - } + }, + // { + // name: 'features/org/all', + // exclude: ['app'], + // } ]; var fs = require('fs'); diff --git a/tasks/options/typescript.js b/tasks/options/typescript.js index 87c1cab5573..8b60604c6a0 100644 --- a/tasks/options/typescript.js +++ b/tasks/options/typescript.js @@ -4,7 +4,7 @@ module.exports = function() { return { build: { src: ['public/app/**/*.ts'], - dest: 'public/.app_gen', + dest: 'public_gen/app', options: { module: 'amd', //or commonjs target: 'es5', //or es3 @@ -14,9 +14,20 @@ module.exports = function() { generateTsConfig: true, } }, + + // build2: { + // src: ['public/app/alerting#<{(||)}>#*.ts'], + // dest: 'public/.app_gen/alerting/all.js', + // options: { + // target: 'es5', //or es3 + // declaration: true, + // sourceMap: true, + // } + // }, + watch: { src: ['public/app/**/*.ts'], - dest: 'public/.app_gen', + dest: 'public/app_gen', options: { module: 'amd', //or commonjs target: 'es5', //or es3 diff --git a/tasks/options/watch.js b/tasks/options/watch.js index 692ec08e179..21d3c6ad340 100644 --- a/tasks/options/watch.js +++ b/tasks/options/watch.js @@ -1,16 +1,16 @@ module.exports = function(config) { return { css: { - files: [ '<%= srcDir %>/css/**/*.less' ], + files: [ '<%= srcDir %>/less/**/*.less' ], tasks: ['css'], options: { spawn: false } }, - app_gen: { - files: ['<%= srcDir %>/app/**/*.js', '<%= srcDir %>/app/**/*.html'], - tasks: ['copy:app_gen_build'], + copy_to_gen: { + files: ['<%= srcDir %>/**/*', '!<%= srcDir %>/**/*.less'], + tasks: ['copy:everything_but_less'], options: { spawn: false } diff --git a/tsconfig.json b/tsconfig.json index e8b34801c24..dfc160e0e64 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "sourceMap": true, "declaration": true, - "outDir": "public/.app_gen", + "outDir": "public_gen/app", "target": "ES5", "rootDir": "public/app", "module": "amd", @@ -12,6 +12,10 @@ "public/app/components/panelmeta.ts", "public/app/controllers/fileSearcher.ts", "public/app/controllers/testCtrl.ts", + "public/app/core/core.ts", + "public/app/core/directives/cool_dir.ts", + "public/app/core/routes/module_loader.ts", + "public/app/core/time_series.ts", "public/app/headers/require.d.ts" ] } \ No newline at end of file From da832368f04cb04aa3c74a88b2a33dbcea59002c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 12:42:24 +0200 Subject: [PATCH 06/12] dev building and optimized builds work --- package.json | 2 +- public/app/controllers/errorCtrl.js | 1 - public/test/karma.conf.js | 8 ++++---- public/test/test-main.js | 2 +- tasks/build_task.js | 25 +++++++++++-------------- tasks/default_task.js | 2 +- tasks/options/compress.js | 2 +- tasks/options/concat.js | 8 ++++---- tasks/options/copy.js | 2 +- tasks/options/cssmin.js | 6 +++--- tasks/options/filerev.js | 12 ++++++------ tasks/options/htmlmin.js | 6 +++--- tasks/options/ngAnnotate.js | 4 ++-- tasks/options/ngtemplates.js | 4 ++-- tasks/options/requirejs.js | 10 +++++----- tasks/options/uglify.js | 6 +++--- tasks/options/usemin.js | 5 +++-- tasks/options/useminPrepare.js | 7 ------- tasks/options/watch.js | 2 +- 19 files changed, 52 insertions(+), 62 deletions(-) delete mode 100644 tasks/options/useminPrepare.js diff --git a/package.json b/package.json index 01b9ae03cb1..34754a312ed 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-jshint": "~0.10.0", "grunt-contrib-less": "~0.7.0", - "grunt-contrib-requirejs": "~0.4.1", + "grunt-contrib-requirejs": "~0.4.4", "grunt-contrib-uglify": "~0.8.0", "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^0.2.1", diff --git a/public/app/controllers/errorCtrl.js b/public/app/controllers/errorCtrl.js index b2dcbd1de50..9e70efb3ee4 100644 --- a/public/app/controllers/errorCtrl.js +++ b/public/app/controllers/errorCtrl.js @@ -8,7 +8,6 @@ function (angular) { var module = angular.module('grafana.controllers'); - module.controller('ErrorCtrl', function($scope, contextSrv) { var showSideMenu = contextSrv.sidemenu; diff --git a/public/test/karma.conf.js b/public/test/karma.conf.js index 020c65a9e3c..7c4881ee64a 100644 --- a/public/test/karma.conf.js +++ b/public/test/karma.conf.js @@ -9,10 +9,10 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ 'public/test/test-main.js', - {pattern: 'public/.app_gen/**/*.js', included: false}, - {pattern: 'public/vendor/**/*.js', included: false}, - {pattern: 'public/test/**/*.js', included: false}, - {pattern: 'public/**/*.js', included: false} + {pattern: 'public_gen/.app_gen/**/*.js', included: false}, + {pattern: 'public_gen/vendor/**/*.js', included: false}, + {pattern: 'public_gen/test/**/*.js', included: false}, + {pattern: 'public_gen/**/*.js', included: false} ], // list of files to exclude diff --git a/public/test/test-main.js b/public/test/test-main.js index b9c0ba986aa..8a254c241ae 100644 --- a/public/test/test-main.js +++ b/public/test/test-main.js @@ -1,5 +1,5 @@ require.config({ - baseUrl: 'http://localhost:9876/base/public/app_gen', + baseUrl: 'http://localhost:9876/base/public_gen/app', paths: { specs: '../test/specs', diff --git a/tasks/build_task.js b/tasks/build_task.js index 4d7209017b8..546b2fed6cf 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -6,18 +6,18 @@ module.exports = function(grunt) { 'jshint:source', 'jshint:tests', 'jscs', - 'clean:on_start', - 'copy:app_gen_build', + 'clean:release', + 'copy:public_to_gen', 'typescript:build', 'karma:test', 'css', - 'copy:everything_but_less_to_temp', 'htmlmin:build', 'ngtemplates', 'cssmin:build', 'ngAnnotate:build', 'requirejs:build', 'concat:js', + 'clean:temp', 'filerev', 'remapFilerev', 'usemin', @@ -26,14 +26,13 @@ module.exports = function(grunt) { ]); // task to add [[.AppSubUrl]] to reved path - grunt.registerTask('remapFilerev', function(){ - var root = grunt.config().destDir; + grunt.registerTask('remapFilerev', function() { + var root = grunt.config().genDir; var summary = grunt.filerev.summary; var fixed = {}; for(var key in summary){ if(summary.hasOwnProperty(key)){ - var orig = key.replace(root, root+'/[[.AppSubUrl]]'); var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]'); fixed[orig] = revved; @@ -44,29 +43,27 @@ module.exports = function(grunt) { }); grunt.registerTask('build-post-process', function() { - grunt.config('copy.dist_to_tmp', { + grunt.config('copy.public_gen_to_dest', { expand: true, - cwd: '<%= destDir %>', + cwd: '<%= genDir %>', src: '**/*', - dest: '<%= tempDir %>/public/', + dest: '<%= destDir %>/public/', }); - grunt.config('clean.dest_dir', ['<%= destDir %>']); grunt.config('copy.backend_bin', { cwd: 'bin', expand: true, src: ['*'], options: { mode: true}, - dest: '<%= tempDir %>/bin/' + dest: '<%= destDir %>/bin/' }); grunt.config('copy.backend_files', { expand: true, src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/**/*', 'scripts/*'], options: { mode: true}, - dest: '<%= tempDir %>' + dest: '<%= destDir %>' }); - grunt.task.run('copy:dist_to_tmp'); - grunt.task.run('clean:dest_dir'); + grunt.task.run('copy:public_gen_to_dest'); grunt.task.run('copy:backend_bin'); grunt.task.run('copy:backend_files'); }); diff --git a/tasks/default_task.js b/tasks/default_task.js index edf2a38b35a..87a2f711faa 100644 --- a/tasks/default_task.js +++ b/tasks/default_task.js @@ -7,7 +7,7 @@ module.exports = function(grunt) { 'jscs', 'jshint', 'clean:gen', - 'copy:everything_but_ts_and_less', + 'copy:public_to_gen', 'css', 'typescript:build' ]); diff --git a/tasks/options/compress.js b/tasks/options/compress.js index 4dc77ec82f8..99524dfd0cd 100644 --- a/tasks/options/compress.js +++ b/tasks/options/compress.js @@ -9,7 +9,7 @@ module.exports = function(config) { files : [ { expand: true, - cwd: '<%= tempDir %>', + cwd: '<%= destDir %>', src: ['**/*'], dest: '<%= pkg.name %>-<%= pkg.version %>/', }, diff --git a/tasks/options/concat.js b/tasks/options/concat.js index 648d94fdbcc..96ad9ae1341 100644 --- a/tasks/options/concat.js +++ b/tasks/options/concat.js @@ -27,11 +27,11 @@ module.exports = function(config) { js: { src: [ - '<%= destDir %>/vendor/requirejs/require.js', - '<%= destDir %>/app/components/require.config.js', - '<%= destDir %>/app/app.js', + '<%= tempDir %>/vendor/requirejs/require.js', + '<%= tempDir %>/app/components/require.config.js', + '<%= tempDir %>/app/app.js', ], - dest: '<%= destDir %>/app/app.js' + dest: '<%= genDir %>/app/app.js' }, }; }; diff --git a/tasks/options/copy.js b/tasks/options/copy.js index 781042f9921..afd705de92f 100644 --- a/tasks/options/copy.js +++ b/tasks/options/copy.js @@ -8,7 +8,7 @@ module.exports = function(config) { dest: '<%= tempDir %>' }, - everything_but_less: { + public_to_gen: { cwd: '<%= srcDir %>', expand: true, src: ['**/*', '!**/*.less'], diff --git a/tasks/options/cssmin.js b/tasks/options/cssmin.js index b049a383fca..97953af8bc7 100644 --- a/tasks/options/cssmin.js +++ b/tasks/options/cssmin.js @@ -2,9 +2,9 @@ module.exports = function(config) { return { build: { expand: true, - cwd: '<%= tempDir %>', + cwd: '<%= genDir %>', src: '**/*.css', - dest: '<%= tempDir %>' + dest: '<%= genDir %>' } }; -}; \ No newline at end of file +}; diff --git a/tasks/options/filerev.js b/tasks/options/filerev.js index 2571822f807..aa954146518 100644 --- a/tasks/options/filerev.js +++ b/tasks/options/filerev.js @@ -6,16 +6,16 @@ module.exports = function(config) { length: 8, }, cssDark: { - src: '<%= destDir %>/css/grafana.dark.min.css', - dest: '<%= destDir %>/css' + src: '<%= genDir %>/css/grafana.dark.min.css', + dest: '<%= genDir %>/css' }, cssLight: { - src: '<%= destDir %>/css/grafana.light.min.css', - dest: '<%= destDir %>/css' + src: '<%= genDir %>/css/grafana.light.min.css', + dest: '<%= genDir %>/css' }, js: { - src: '<%= destDir %>/app/app.js', - dest: '<%= destDir %>/app' + src: '<%= genDir %>/app/app.js', + dest: '<%= genDir %>/app' } }; }; diff --git a/tasks/options/htmlmin.js b/tasks/options/htmlmin.js index b5d36b89e77..2fa6a769a09 100644 --- a/tasks/options/htmlmin.js +++ b/tasks/options/htmlmin.js @@ -6,13 +6,13 @@ module.exports = function(config) { collapseWhitespace: true }, expand: true, - cwd: '<%= tempDir %>', + cwd: '<%= genDir %>', src: [ //'index.html', 'app/panels/**/*.html', 'app/partials/**/*.html' ], - dest: '<%= tempDir %>' + dest: '<%= genDir %>' } }; -}; \ No newline at end of file +}; diff --git a/tasks/options/ngAnnotate.js b/tasks/options/ngAnnotate.js index 816532096c2..293023c1b5f 100644 --- a/tasks/options/ngAnnotate.js +++ b/tasks/options/ngAnnotate.js @@ -2,7 +2,7 @@ module.exports = function(config) { return { build: { expand: true, - cwd:'<%= tempDir %>', + cwd:'<%= genDir %>', src: [ 'app/controllers/**/*.js', 'app/plugins/**/*.js', @@ -15,7 +15,7 @@ module.exports = function(config) { 'app/app.js', 'vendor/angular/**/*.js', ], - dest: '<%= tempDir %>' + dest: '<%= genDir %>' } }; }; diff --git a/tasks/options/ngtemplates.js b/tasks/options/ngtemplates.js index a20624a5ff9..2ccdf4ce5ef 100644 --- a/tasks/options/ngtemplates.js +++ b/tasks/options/ngtemplates.js @@ -1,9 +1,9 @@ module.exports = function(config) { return { grafana: { - cwd: '<%= tempDir %>', + cwd: '<%= genDir %>', src: ['app/**/*.html'], - dest: '<%= tempDir %>/app/components/partials.js', + dest: '<%= genDir %>/app/components/partials.js', options: { bootstrap: function(module, script) { return "define('components/partials', ['angular'], function(angular) { \n" + diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index 21b22d51c26..a7a9d5b8dda 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -4,10 +4,10 @@ module.exports = function(config,grunt) { function buildRequireJsOptions() { var options = { - appDir: '<%= tempDir %>', - dir: '<%= destDir %>', - mainConfigFile: '<%= tempDir %>/app/components/require.config.js', - baseUrl: 'app_gen', + appDir: '<%= genDir %>', + dir: '<%= tempDir %>', + mainConfigFile: '<%= genDir %>/app/components/require.config.js', + baseUrl: 'app', waitSeconds: 0, modules: [], // populated below, @@ -74,7 +74,7 @@ module.exports = function(config,grunt) { ]; var fs = require('fs'); - var panelPath = config.srcDir+'/app/panels'; + var panelPath = config.genDir+'/app/panels'; // create a module for each directory in public/app/panels/ fs.readdirSync(panelPath).forEach(function (panelName) { diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js index 2428331b021..04e892a308a 100644 --- a/tasks/options/uglify.js +++ b/tasks/options/uglify.js @@ -2,9 +2,9 @@ module.exports = function(config) { return { dest: { expand: true, - src: ['**/*.js', '!dashboards/*.js', '!vendor/jquery/**/*.js'], - dest: '<%= destDir %>', - cwd: '<%= destDir %>', + src: ['**/*.js', '!dashboards/*.js', '!vendor/**/*.js'], + dest: '<%= genDir %>', + cwd: '<%= genDir %>', options: { quite: true, compress: {}, diff --git a/tasks/options/usemin.js b/tasks/options/usemin.js index f87a70ea672..a6eefd623b5 100644 --- a/tasks/options/usemin.js +++ b/tasks/options/usemin.js @@ -3,10 +3,11 @@ module.exports = function() { return { html: [ - '<%= destDir %>/views/index.html', + '<%= genDir %>/views/index.html', + '<%= genDir %>/views/500.html', ], options: { - assetsDirs: ['<%= destDir %>'], + assetsDirs: ['<%= genDir %>'], patterns: { css: [ [/(\.css)/, 'Replacing reference to image.png'] diff --git a/tasks/options/useminPrepare.js b/tasks/options/useminPrepare.js deleted file mode 100644 index f4b948a846d..00000000000 --- a/tasks/options/useminPrepare.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = function(config) { - return { - html: [ - 'tmp/index.html', - ] - }; -}; diff --git a/tasks/options/watch.js b/tasks/options/watch.js index 21d3c6ad340..f91c0dc92fd 100644 --- a/tasks/options/watch.js +++ b/tasks/options/watch.js @@ -10,7 +10,7 @@ module.exports = function(config) { copy_to_gen: { files: ['<%= srcDir %>/**/*', '!<%= srcDir %>/**/*.less'], - tasks: ['copy:everything_but_less'], + tasks: ['copy:public_to_gen'], options: { spawn: false } From 0b5f40e66c6045c007c30e4362e19279e7fd6f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 13:34:32 +0200 Subject: [PATCH 07/12] tech(): made config system check for generated css or javascript files and panic if there are none, also if there is a public_gen directory it will use that, even if static root is set to public --- pkg/setting/setting.go | 19 ++++++++++++++++++- tasks/build_task.js | 10 +++++----- tasks/options/compress.js | 2 +- tasks/options/requirejs.js | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index cc74456971e..9254bada6d4 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -354,6 +354,23 @@ func setHomePath(args *CommandLineArgs) { } } +func getStaticRootPath(configValue string) string { + if configValue != "public" { + return configValue + } + + if _, err := os.Stat(path.Join(HomePath, configValue, "css")); err == nil { + return configValue + } + + if _, err := os.Stat(path.Join(HomePath, "public_gen", "css")); err == nil { + return "public_gen" + } + + log.Fatal(3, "Failed to detect generated css or javascript files in static root (%s), have you executed default grunt task?", configValue) + return "" +} + func NewConfigContext(args *CommandLineArgs) { setHomePath(args) loadConfiguration(args) @@ -373,7 +390,7 @@ func NewConfigContext(args *CommandLineArgs) { Domain = server.Key("domain").MustString("localhost") HttpAddr = server.Key("http_addr").MustString("0.0.0.0") HttpPort = server.Key("http_port").MustString("3000") - StaticRootPath = makeAbsolute(server.Key("static_root_path").String(), HomePath) + StaticRootPath = makeAbsolute(getStaticRootPath(server.Key("static_root_path").String()), HomePath) RouterLogging = server.Key("router_logging").MustBool(false) EnableGzip = server.Key("enable_gzip").MustBool(false) EnforceDomain = server.Key("enforce_domain").MustBool(false) diff --git a/tasks/build_task.js b/tasks/build_task.js index 546b2fed6cf..63334cbec5a 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -43,27 +43,27 @@ module.exports = function(grunt) { }); grunt.registerTask('build-post-process', function() { - grunt.config('copy.public_gen_to_dest', { + grunt.config('copy.public_gen_to_temp', { expand: true, cwd: '<%= genDir %>', src: '**/*', - dest: '<%= destDir %>/public/', + dest: '<%= tempDir %>/public/', }); grunt.config('copy.backend_bin', { cwd: 'bin', expand: true, src: ['*'], options: { mode: true}, - dest: '<%= destDir %>/bin/' + dest: '<%= tempDir %>/bin/' }); grunt.config('copy.backend_files', { expand: true, src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/**/*', 'scripts/*'], options: { mode: true}, - dest: '<%= destDir %>' + dest: '<%= tempDir %>' }); - grunt.task.run('copy:public_gen_to_dest'); + grunt.task.run('copy:public_gen_to_temp'); grunt.task.run('copy:backend_bin'); grunt.task.run('copy:backend_files'); }); diff --git a/tasks/options/compress.js b/tasks/options/compress.js index 99524dfd0cd..4dc77ec82f8 100644 --- a/tasks/options/compress.js +++ b/tasks/options/compress.js @@ -9,7 +9,7 @@ module.exports = function(config) { files : [ { expand: true, - cwd: '<%= destDir %>', + cwd: '<%= tempDir %>', src: ['**/*'], dest: '<%= pkg.name %>-<%= pkg.version %>/', }, diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index a7a9d5b8dda..f3a113048c9 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -74,7 +74,7 @@ module.exports = function(config,grunt) { ]; var fs = require('fs'); - var panelPath = config.genDir+'/app/panels'; + var panelPath = config.srcDir + '/app/panels'; // create a module for each directory in public/app/panels/ fs.readdirSync(panelPath).forEach(function (panelName) { From dceec44671f054e120643801af305f2253cf46e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 14:36:05 +0200 Subject: [PATCH 08/12] removed tsconfig --- package.json | 4 +- public/app/components/panelmeta.ts | 14 +- public/app/controllers/fileSearcher.ts | 18 -- public/app/controllers/testCtrl.ts | 19 -- public/app/core/routes/module_loader.ts | 4 +- public/app/core/time_series.ts | 4 + public/app/headers/require.d.ts | 369 ------------------------ tsconfig.json | 21 -- 8 files changed, 16 insertions(+), 437 deletions(-) delete mode 100644 public/app/controllers/fileSearcher.ts delete mode 100644 public/app/controllers/testCtrl.ts delete mode 100644 public/app/headers/require.d.ts delete mode 100644 tsconfig.json diff --git a/package.json b/package.json index 34754a312ed..656ccd5e989 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "grunt-karma": "~0.8.3", "grunt-ng-annotate": "^0.9.2", "grunt-string-replace": "~0.2.4", + "grunt-tslint": "^2.5.0", "grunt-typescript": "^0.7.0", "grunt-usemin": "3.0.0", "jshint-stylish": "~0.1.5", @@ -48,7 +49,8 @@ "load-grunt-tasks": "0.2.0", "mocha": "2.2.4", "requirejs": "2.1.17", - "rjs-build-analysis": "0.0.3" + "rjs-build-analysis": "0.0.3", + "tslint": "^2.5.0-beta" }, "engines": { "node": "0.10.x", diff --git a/public/app/components/panelmeta.ts b/public/app/components/panelmeta.ts index 801727481f0..17a19b20dfb 100644 --- a/public/app/components/panelmeta.ts +++ b/public/app/components/panelmeta.ts @@ -1,11 +1,11 @@ class PanelMeta { - description: any - fullscreen: any - editIcon: any - panelName: any - menu: any - editorTabs: any - extendedMenu: any + description: any; + fullscreen: any; + editIcon: any; + panelName: any; + menu: any; + editorTabs: any; + extendedMenu: any; constructor(options : any) { this.description = options.description; diff --git a/public/app/controllers/fileSearcher.ts b/public/app/controllers/fileSearcher.ts deleted file mode 100644 index 4515c374bd0..00000000000 --- a/public/app/controllers/fileSearcher.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -class FileSearcher { - - constructor() { - } - - public getFiles() : string[] { - return ["asd"]; - } - - public getBullshit() : any { - return "asd"; - } - -} - -export = FileSearcher; diff --git a/public/app/controllers/testCtrl.ts b/public/app/controllers/testCtrl.ts deleted file mode 100644 index 48e5f094375..00000000000 --- a/public/app/controllers/testCtrl.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -/// - -import FileSearcher = require('./fileSearcher'); - -class Base { - - constructor() { - var test = new FileSearcher(); - test.getFiles(); - } - - public getName() : string { - return "asd"; - } -} - -export = Base; diff --git a/public/app/core/routes/module_loader.ts b/public/app/core/routes/module_loader.ts index 9f309250d68..3142ecbb5cd 100644 --- a/public/app/core/routes/module_loader.ts +++ b/public/app/core/routes/module_loader.ts @@ -1,7 +1,7 @@ -/// +/// export class ModuleLoader { - lazy: any + lazy: any; constructor(moduleName) { diff --git a/public/app/core/time_series.ts b/public/app/core/time_series.ts index 46d78e9fa7f..7ab6f0ac3d1 100644 --- a/public/app/core/time_series.ts +++ b/public/app/core/time_series.ts @@ -1,5 +1,9 @@ export class TimeSeries { getName() : string { + if (true) { + return "asd"; + } + return "TimeSeries"; } } diff --git a/public/app/headers/require.d.ts b/public/app/headers/require.d.ts deleted file mode 100644 index c42a1bda101..00000000000 --- a/public/app/headers/require.d.ts +++ /dev/null @@ -1,369 +0,0 @@ -// Type definitions for RequireJS 2.1.8 -// Project: http://requirejs.org/ -// Definitions by: Josh Baldwin -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/* -require-2.1.8.d.ts may be freely distributed under the MIT license. - -Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. -*/ - -declare module 'module' { - var mod: { - config: () => any; - id: string; - uri: string; - } - export = mod; -} - -interface RequireError extends Error { - - /** - * The error ID that maps to an ID on a web page. - **/ - requireType: string; - - /** - * Required modules. - **/ - requireModules: string[]; - - /** - * The original error, if there is one (might be null). - **/ - originalError: Error; -} - -interface RequireShim { - - /** - * List of dependencies. - **/ - deps?: string[]; - - /** - * Name the module will be exported as. - **/ - exports?: string; - - /** - * Initialize function with all dependcies passed in, - * if the function returns a value then that value is used - * as the module export value instead of the object - * found via the 'exports' string. - * @param dependencies - * @return - **/ - init?: (...dependencies: any[]) => any; -} - -interface RequireConfig { - - // The root path to use for all module lookups. - baseUrl?: string; - - // Path mappings for module names not found directly under - // baseUrl. - paths?: { [key: string]: any; }; - - // Dictionary of Shim's. - // does not cover case of key->string[] - shim?: { [key: string]: RequireShim; }; - - /** - * For the given module prefix, instead of loading the - * module with the given ID, substitude a different - * module ID. - * - * @example - * requirejs.config({ - * map: { - * 'some/newmodule': { - * 'foo': 'foo1.2' - * }, - * 'some/oldmodule': { - * 'foo': 'foo1.0' - * } - * } - * }); - **/ - map?: { - [id: string]: { - [id: string]: string; - }; - }; - - /** - * AMD configurations, use module.config() to access in - * define() functions - **/ - config?: { [id: string]: {}; }; - - /** - * Configures loading modules from CommonJS packages. - **/ - packages?: {}; - - /** - * The number of seconds to wait before giving up on loading - * a script. The default is 7 seconds. - **/ - waitSeconds?: number; - - /** - * A name to give to a loading context. This allows require.js - * to load multiple versions of modules in a page, as long as - * each top-level require call specifies a unique context string. - **/ - context?: string; - - /** - * An array of dependencies to load. - **/ - deps?: string[]; - - /** - * A function to pass to require that should be require after - * deps have been loaded. - * @param modules - **/ - callback?: (...modules: any[]) => void; - - /** - * If set to true, an error will be thrown if a script loads - * that does not call define() or have shim exports string - * value that can be checked. - **/ - enforceDefine?: boolean; - - /** - * If set to true, document.createElementNS() will be used - * to create script elements. - **/ - xhtml?: boolean; - - /** - * Extra query string arguments appended to URLs that RequireJS - * uses to fetch resources. Most useful to cachce bust when - * the browser or server is not configured correcty. - * - * @example - * urlArgs: "bust= + (new Date()).getTime() - **/ - urlArgs?: string; - - /** - * Specify the value for the type="" attribute used for script - * tags inserted into the document by RequireJS. Default is - * "text/javascript". To use Firefox's JavasScript 1.8 - * features, use "text/javascript;version=1.8". - **/ - scriptType?: string; - -} - -// todo: not sure what to do with this guy -interface RequireModule { - - /** - * - **/ - config(): {}; - -} - -/** -* -**/ -interface RequireMap { - - /** - * - **/ - prefix: string; - - /** - * - **/ - name: string; - - /** - * - **/ - parentMap: RequireMap; - - /** - * - **/ - url: string; - - /** - * - **/ - originalName: string; - - /** - * - **/ - fullName: string; -} - -interface Require { - - /** - * Configure require.js - **/ - config(config: RequireConfig): Require; - - /** - * CommonJS require call - * @param module Module to load - * @return The loaded module - */ - (module: string): any; - - /** - * Start the main app logic. - * Callback is optional. - * Can alternatively use deps and callback. - * @param modules Required modules to load. - **/ - (modules: string[]): void; - - /** - * @see Require() - * @param ready Called when required modules are ready. - **/ - (modules: string[], ready: Function): void; - - /** - * @see http://requirejs.org/docs/api.html#errbacks - * @param ready Called when required modules are ready. - **/ - (modules: string[], ready: Function, errback: Function): void; - - /** - * Generate URLs from require module - * @param module Module to URL - * @return URL string - **/ - toUrl(module: string): string; - - /** - * Returns true if the module has already been loaded and defined. - * @param module Module to check - **/ - defined(module: string): boolean; - - /** - * Returns true if the module has already been requested or is in the process of loading and should be available at some point. - * @param module Module to check - **/ - specified(module: string): boolean; - - /** - * On Error override - * @param err - **/ - onError(err: RequireError, errback?: (err: RequireError) => void): void; - - /** - * Undefine a module - * @param module Module to undefine. - **/ - undef(module: string): void; - - /** - * Semi-private function, overload in special instance of undef() - **/ - onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void; -} - -interface RequireDefine { - - /** - * Define Simple Name/Value Pairs - * @param config Dictionary of Named/Value pairs for the config. - **/ - (config: { [key: string]: any; }): void; - - /** - * Define function. - * @param func: The function module. - **/ - (func: () => any): void; - - /** - * Define function with dependencies. - * @param deps List of dependencies module IDs. - * @param ready Callback function when the dependencies are loaded. - * callback param deps module dependencies - * callback return module definition - **/ - (deps: string[], ready: Function): void; - - /** - * Define module with simplified CommonJS wrapper. - * @param ready - * callback require requirejs instance - * callback exports exports object - * callback module module - * callback return module definition - **/ - (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void; - - /** - * Define a module with a name and dependencies. - * @param name The name of the module. - * @param deps List of dependencies module IDs. - * @param ready Callback function when the dependencies are loaded. - * callback deps module dependencies - * callback return module definition - **/ - (name: string, deps: string[], ready: Function): void; - - /** - * Define a module with a name. - * @param name The name of the module. - * @param ready Callback function when the dependencies are loaded. - * callback return module definition - **/ - (name: string, ready: Function): void; - - /** - * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms - * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object. - * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function - * that does not conform to the AMD API. - * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version - * of jQuery being loaded simultaneously. - */ - amd: Object; -} - -// Ambient declarations for 'require' and 'define' -declare var requirejs: Require; -declare var require: Require; -declare var define: RequireDefine; diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index dfc160e0e64..00000000000 --- a/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "sourceMap": true, - "declaration": true, - "outDir": "public_gen/app", - "target": "ES5", - "rootDir": "public/app", - "module": "amd", - "noEmitOnError": true - }, - "files": [ - "public/app/components/panelmeta.ts", - "public/app/controllers/fileSearcher.ts", - "public/app/controllers/testCtrl.ts", - "public/app/core/core.ts", - "public/app/core/directives/cool_dir.ts", - "public/app/core/routes/module_loader.ts", - "public/app/core/time_series.ts", - "public/app/headers/require.d.ts" - ] -} \ No newline at end of file From 20407bca8960460e5847ae905bfa506db7e254e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 16:21:57 +0200 Subject: [PATCH 09/12] tech(typescript): converted signup controller to typescript --- .gitignore | 1 + public/app/controllers/signupCtrl.js | 49 - public/app/controllers/signupCtrl.ts | 55 + public/app/core/core.ts | 1 - public/app/core/routes/module_loader.ts | 2 +- public/app/core/time_series.ts | 10 - public/app/headers/angularjs/angularjs.d.ts | 1746 ++++++++++ public/app/headers/jquery/jquery.d.ts | 3178 +++++++++++++++++++ public/app/headers/require/require.d.ts | 369 +++ public/app/partials/signup_step2.html | 2 +- tasks/build_task.js | 16 +- tasks/options/tslint.js | 23 + tasks/options/uglify.js | 2 +- 13 files changed, 5383 insertions(+), 71 deletions(-) delete mode 100644 public/app/controllers/signupCtrl.js create mode 100644 public/app/controllers/signupCtrl.ts delete mode 100644 public/app/core/time_series.ts create mode 100644 public/app/headers/angularjs/angularjs.d.ts create mode 100644 public/app/headers/jquery/jquery.d.ts create mode 100644 public/app/headers/require/require.d.ts create mode 100644 tasks/options/tslint.js diff --git a/.gitignore b/.gitignore index 8abd0d17cbd..b52ecff18b8 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ conf/custom.ini fig.yml profile.cov grafana +tsconfig.json diff --git a/public/app/controllers/signupCtrl.js b/public/app/controllers/signupCtrl.js deleted file mode 100644 index c23e7b151c6..00000000000 --- a/public/app/controllers/signupCtrl.js +++ /dev/null @@ -1,49 +0,0 @@ -define([ - 'angular', - 'config', -], -function (angular, config) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('SignUpCtrl', function($scope, $location, contextSrv, backendSrv) { - - contextSrv.sidemenu = false; - - $scope.formModel = {}; - - $scope.init = function() { - var params = $location.search(); - $scope.formModel.orgName = params.email; - $scope.formModel.email = params.email; - $scope.formModel.username = params.email; - $scope.formModel.code = params.code; - - $scope.verifyEmailEnabled = false; - $scope.autoAssignOrg = false; - - backendSrv.get('/api/user/signup/options').then(function(options) { - $scope.verifyEmailEnabled = options.verifyEmailEnabled; - $scope.autoAssignOrg = options.autoAssignOrg; - }); - }; - - $scope.submit = function() { - if (!$scope.signUpForm.$valid) { - return; - } - - backendSrv.post('/api/user/signup/step2', $scope.formModel).then(function(rsp) { - if (rsp.code === 'redirect-to-select-org') { - window.location.href = config.appSubUrl + '/profile/select-org?signup=1'; - } else { - window.location.href = config.appSubUrl + '/'; - } - }); - }; - - $scope.init(); - - }); -}); diff --git a/public/app/controllers/signupCtrl.ts b/public/app/controllers/signupCtrl.ts new file mode 100644 index 00000000000..20cd41c263e --- /dev/null +++ b/public/app/controllers/signupCtrl.ts @@ -0,0 +1,55 @@ +/// +/// +/// +/// + +var angular = require('angular'); +var config = require('config'); + +var module = angular.module('grafana.controllers'); + +export class SignUpCtrl { + + constructor( + private $scope : any, + private $location : any, + private contextSrv : any, + private backendSrv : any) { + + contextSrv.sidemenu = false; + $scope.ctrl = this; + + $scope.formModel = {}; + + var params = $location.search(); + $scope.formModel.orgName = params.email; + $scope.formModel.email = params.email; + $scope.formModel.username = params.email; + $scope.formModel.code = params.code; + + $scope.verifyEmailEnabled = false; + $scope.autoAssignOrg = false; + + backendSrv.get('/api/user/signup/options').then(options => { + $scope.verifyEmailEnabled = options.verifyEmailEnabled; + $scope.autoAssignOrg = options.autoAssignOrg; + }); + } + + submit () { + if (!this.$scope.signUpForm.$valid) { + return; + } + + this.backendSrv.post('/api/user/signup/step2', this.$scope.formModel).then(rsp => { + if (rsp.code === 'redirect-to-select-org') { + window.location.href = config.appSubUrl + '/profile/select-org?signup=1'; + } else { + window.location.href = config.appSubUrl + '/'; + } + }); + }; +} + +module.controller('SignUpCtrl', SignUpCtrl); + diff --git a/public/app/core/core.ts b/public/app/core/core.ts index f9a4b27c7ff..dc72df22e38 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -1,5 +1,4 @@ -export * from './time_series' export * from './directives/cool_dir' export * from './routes/module_loader' diff --git a/public/app/core/routes/module_loader.ts b/public/app/core/routes/module_loader.ts index 3142ecbb5cd..4cc4c39473d 100644 --- a/public/app/core/routes/module_loader.ts +++ b/public/app/core/routes/module_loader.ts @@ -1,4 +1,4 @@ -/// +/// export class ModuleLoader { lazy: any; diff --git a/public/app/core/time_series.ts b/public/app/core/time_series.ts deleted file mode 100644 index 7ab6f0ac3d1..00000000000 --- a/public/app/core/time_series.ts +++ /dev/null @@ -1,10 +0,0 @@ -export class TimeSeries { - getName() : string { - if (true) { - return "asd"; - } - - return "TimeSeries"; - } -} - diff --git a/public/app/headers/angularjs/angularjs.d.ts b/public/app/headers/angularjs/angularjs.d.ts new file mode 100644 index 00000000000..d183167b59f --- /dev/null +++ b/public/app/headers/angularjs/angularjs.d.ts @@ -0,0 +1,1746 @@ +// Type definitions for Angular JS 1.4+ +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: angular.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject?: string[]; +} + +// Collapse angular into ng +import ng = angular; +// Support AMD require +declare module 'angular' { + export = angular; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module angular { + + // not directly implemented, but ensures that constructed class implements $get + interface IServiceProviderClass { + new (...args: any[]): IServiceProvider; + } + + interface IServiceProviderFactory { + (...args: any[]): IServiceProvider; + } + + // All service providers extend this interface + interface IServiceProvider { + $get: any; + } + + interface IAngularBootstrapConfig { + strictDi?: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + + /** + * Creates a deep copy of source, which should be an object or an array. + * + * - If no destination is supplied, a copy of the object or array is created. + * - If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it. + * - If source is not an object or array (inc. null and undefined), source is returned. + * - If source is identical to 'destination' an exception will be thrown. + * + * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined. + * @param destination Destination into which the source is copied. If provided, must be of the same type as source. + */ + copy(source: T, destination?: T): T; + + /** + * Wraps a raw DOM element or HTML string as a jQuery element. + * + * If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite." + */ + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + + fromJson(json: string): any; + identity(arg?: T): T; + injector(modules?: any[], strictDi?: boolean): 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; + + /** + * Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2). + * + * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy. + * + * @param dst Destination object. + * @param src Source object(s). + */ + merge(dst: any, ...src: any[]): any; + + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ + module( + name: string, + requires?: string[], + configFn?: Function): IModule; + + noop(...args: any[]): void; + reloadWithDebugInfo(): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codeName: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; + animation(object: Object): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param configFn Execute this function on module load. Useful for service configuration. + */ + config(configFn: Function): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. + */ + config(inlineAnnotatedFunction: any[]): IModule; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, controllerConstructor: Function): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, inlineAnnotatedConstructor: any[]): IModule; + controller(object: Object): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, directiveFactory: IDirectiveFactory): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, inlineAnnotatedFunction: any[]): IModule; + directive(object: Object): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, $getFn: Function): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, inlineAnnotatedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotatedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; + provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; + provider(name: string, inlineAnnotatedConstructor: any[]): IModule; + provider(name: string, providerObject: IServiceProvider): IModule; + provider(object: Object): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(initializationFunction: Function): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(inlineAnnotatedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotatedConstructor: any[]): IModule; + service(object: Object): IModule; + /** + * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service. + + Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator. + * + * @param name The name of the instance. + * @param value The value. + */ + value(name: string, value: any): IModule; + value(object: Object): IModule; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * @param name The name of the service to decorate + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name:string, decoratorConstructor: Function): IModule; + decorator(name:string, inlineAnnotatedConstructor: any[]): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + /** + * this is necessary to be able to access the scoped attributes. it's not very elegant + * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way + * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 + */ + [name: string]: any; + + /** + * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form. + * + * Also there is special case for Moz prefix starting with upper case letter. + * + * For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives + */ + $normalize(name: string): void; + + /** + * 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?: T) => any): Function; + + /** + * A map of DOM element attribute names to the normalized name. This is needed + * to do reverse lookup from normalized name back to actual name. + */ + $attr: Object; + } + + /** + * form.FormController - type in module ng + * see https://docs.angularjs.org/api/ng/type/form.FormController + */ + interface IFormController { + + /** + * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272 + */ + [name: string]: any; + + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $submitted: boolean; + $error: any; + $addControl(control: INgModelController): void; + $removeControl(control: INgModelController): void; + $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void; + $setDirty(): void; + $setPristine(): void; + $commitViewValue(): void; + $rollbackViewValue(): void; + $setSubmitted(): void; + $setUntouched(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any, trigger?: string): void; + $setPristine(): void; + $setDirty(): void; + $validate(): void; + $setTouched(): void; + $setUntouched(): void; + $rollbackViewValue(): void; + $commitViewValue(): void; + $isEmpty(value: any): boolean; + + $viewValue: any; + + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $viewChangeListeners: IModelViewChangeListener[]; + $error: any; + $name: string; + + $touched: boolean; + $untouched: boolean; + + $validators: IModelValidators; + $asyncValidators: IAsyncModelValidators; + + $pending: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelValidators { + /** + * viewValue is any because it can be an object that is called in the view like $viewValue.name:$viewValue.subName + */ + [index: string]: (modelValue: any, viewValue: any) => boolean; + } + + interface IAsyncModelValidators { + [index: string]: (modelValue: any, viewValue: any) => IPromise; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + interface IModelViewChangeListener { + (): void; + } + + /** + * $rootScope - $rootScopeProvider - service in module ng + * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope + */ + interface IRootScopeService { + [index: string]: any; + + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $applyAsync(): any; + $applyAsync(exp: string): any; + $applyAsync(exp: (scope: IScope) => any): any; + + /** + * Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners. + * + * The event life cycle starts at the scope on which $broadcast was called. All listeners listening for name event on this scope get notified. Afterwards, the event propagates to all direct and indirect scopes of the current scope and calls all registered listeners along the way. The event cannot be canceled. + * + * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. + * + * @param name Event name to broadcast. + * @param args Optional one or more arguments which will be passed onto the event listeners. + */ + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + /** + * Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners. + * + * The event life cycle starts at the scope on which $emit was called. All listeners listening for name event on this scope get notified. Afterwards, the event traverses upwards toward the root scope and calls all registered listeners along the way. The event will stop propagating if one of the listeners cancels it. + * + * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. + * + * @param name Event name to emit. + * @param args Optional one or more arguments which will be passed onto the event listeners. + */ + $emit(name: string, ...args: any[]): IAngularEvent; + + $eval(): any; + $eval(expression: string, locals?: Object): any; + $eval(expression: (scope: IScope) => any, locals?: Object): any; + + $evalAsync(): void; + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean, parent?: IScope): IScope; + + /** + * Listens on events of a given type. See $emit for discussion of event life cycle. + * + * The event listener function format is: function(event, args...). + * + * @param name Event name to listen on. + * @param listener Function to call when the event is emitted. + */ + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => T, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => T, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; + + $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + $root: IRootScopeService; + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IScope extends IRootScopeService { } + + /** + * $scope for ngRepeat directive. + * see https://docs.angularjs.org/api/ng/directive/ngRepeat + */ + interface IRepeatScope extends IScope { + + /** + * iterator offset of the repeated element (0..length-1). + */ + $index: number; + + /** + * true if the repeated element is first in the iterator. + */ + $first: boolean; + + /** + * true if the repeated element is between the first and last in the iterator. + */ + $middle: boolean; + + /** + * true if the repeated element is last in the iterator. + */ + $last: boolean; + + /** + * true if the iterator position $index is even (otherwise false). + */ + $even: boolean; + + /** + * true if the iterator position $index is odd (otherwise false). + */ + $odd: boolean; + + } + + interface IAngularEvent { + /** + * the scope on which the event was $emit-ed or $broadcast-ed. + */ + targetScope: IScope; + /** + * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null. + */ + currentScope: IScope; + /** + * name of the event. + */ + name: string; + /** + * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed). + */ + stopPropagation?: Function; + /** + * calling preventDefault sets defaultPrevented flag to true. + */ + preventDefault: Function; + /** + * true if preventDefault was called. + */ + defaultPrevented: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService { + defer: angular.ITimeoutService; + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (delay?: number, invokeApply?: boolean): IPromise; + (fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise; + cancel(promise?: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see http://docs.angularjs.org/api/ng/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + + /** + * $filter - $filterProvider - service in module ng + * + * Filters are used for formatting data displayed to the user. + * + * see https://docs.angularjs.org/api/ng/service/$filter + */ + interface IFilterService { + /** + * Usage: + * $filter(name); + * + * @param name Name of the filter function to retrieve + */ + (name: string): Function; + } + + /** + * $filterProvider - $filter - provider in module ng + * + * Filters are just functions which transform input to an output. However filters need to be Dependency Injected. To achieve this a filter definition consists of a factory function which is annotated with dependencies and is responsible for creating a filter function. + * + * see https://docs.angularjs.org/api/ng/provider/$filterProvider + */ + interface IFilterProvider extends IServiceProvider { + /** + * register(name); + * + * @param name Name of the filter function, or an object map of filters where the keys are the filter names and the values are the filter factories. Note: Filter names must be valid angular Expressions identifiers, such as uppercase or orderBy. Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace your filters, then you can use capitalization (myappSubsectionFilterx) or underscores (myapp_subsection_filterx). + */ + register(name: string | {}): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + // see http://docs.angularjs.org/api/ng.$logProvider + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + interface ILogProvider extends IServiceProvider { + debugEnabled(): boolean; + debugEnabled(enabled: boolean): ILogProvider; + } + + // We define this as separate interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + // see http://docs.angularjs.org/api/ng.$parseProvider + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface IParseProvider { + logPromiseWarnings(): boolean; + logPromiseWarnings(value: boolean): IParseProvider; + + unwrapPromises(): boolean; + unwrapPromises(value: boolean): IParseProvider; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /** + * $location - $locationProvider - service in module ng + * see https://docs.angularjs.org/api/ng/service/$location + */ + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + + /** + * Return path of current url + */ + path(): string; + + /** + * Change path when called with parameter and return $location. + * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing. + * + * @param path New path + */ + path(path: string): ILocationService; + + port(): number; + protocol(): string; + replace(): ILocationService; + + /** + * Return search part (as object) of current url + */ + search(): any; + + /** + * Change search part when called with parameter and return $location. + * + * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value. + * + * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url. + */ + search(search: any): ILocationService; + + /** + * Change search part when called with parameter and return $location. + * + * @param search New search params + * @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign. + */ + search(search: string, paramValue: string|number|string[]|boolean): ILocationService; + + state(): any; + state(state: 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; + html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends IAugmentedJQuery {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + interface IQResolveReject { + (): void; + (value: T): void; + } + /** + * $q - service in module ng + * A promise/deferred implementation inspired by Kris Kowal's Q. + * See http://docs.angularjs.org/api/ng/service/$q + */ + interface IQService { + new (resolver: (resolve: IQResolveReject) => any): IPromise; + new (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + (resolver: (resolve: IQResolveReject) => any): IPromise; + (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with an array of values, each value corresponding to the promise at the same index in the promises array. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises An array of promises. + */ + all(promises: IPromise[]): IPromise; + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with a hash of values, each value corresponding to the promise at the same key in the promises hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises A hash of promises. + */ + all(promises: { [id: string]: IPromise; }): IPromise<{ [id: string]: any; }>; + all(promises: { [id: string]: IPromise; }): IPromise; + /** + * Creates a Deferred object which represents a task which will finish in the future. + */ + defer(): IDeferred; + /** + * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it. + * + * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject. + * + * @param reason Constant, message, exception or an object representing the rejection reason. + */ + reject(reason?: any): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(): IPromise; + } + + interface IPromise { + /** + * Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected. + * The successCallBack may return IPromise for when a $q.reject() needs to be returned + * This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method. + */ + then(successCallback: (promiseValue: T) => IHttpPromise|IPromise|TResult|IPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + + /** + * Shorthand for promise.then(null, errorCallback) + */ + catch(onRejected: (reason: any) => IHttpPromise|IPromise|TResult): IPromise; + + /** + * Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information. + * + * Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible. + */ + finally(finallyCallback: () => any): IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + notify(state?: any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + (hash: string): void; + yOffset: any; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /** + * $cacheFactory - service in module ng + * + * Factory that constructs Cache objects and gives access to them. + * + * see https://docs.angularjs.org/api/ng/service/$cacheFactory + */ + interface ICacheFactoryService { + /** + * Factory that constructs Cache objects and gives access to them. + * + * @param cacheId Name or id of the newly created cache. + * @param optionsMap Options object that specifies the cache behavior. Properties: + * + * capacity — turns the cache into LRU cache. + */ + (cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject; + + /** + * Get information about all the caches that have been created. + * @returns key-value map of cacheId to the result of calling cache#info + */ + info(): any; + + /** + * Get access to a cache object by the cacheId used when it was created. + * + * @param cacheId Name or id of a cache to access. + */ + get(cacheId: string): ICacheObject; + } + + /** + * $cacheFactory.Cache - type in module ng + * + * A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data. + * + * see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache + */ + interface ICacheObject { + /** + * Retrieve information regarding a particular Cache. + */ + info(): { + /** + * the id of the cache instance + */ + id: string; + + /** + * the number of entries kept in the cache instance + */ + size: number; + + //...: any additional properties from the options object when creating the cache. + }; + + /** + * Inserts a named entry into the Cache object to be retrieved later, and incrementing the size of the cache if the key was not already present in the cache. If behaving like an LRU cache, it will also remove stale entries from the set. + * + * It will not insert undefined values into the cache. + * + * @param key the key under which the cached data is stored. + * @param value the value to store alongside the key. If it is undefined, the key will not be stored. + */ + put(key: string, value?: T): T; + + /** + * Retrieves named data stored in the Cache object. + * + * @param key the key of the data to be retrieved + */ + get(key: string): T; + + /** + * Removes an entry from the Cache object. + * + * @param key the key of the entry to be removed + */ + remove(key: string): void; + + /** + * Clears the cache object of any entries. + */ + removeAll(): void; + + /** + * Destroys the Cache object entirely, removing it from the $cacheFactory set. + */ + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + + aHrefSanitizationWhitelist(): RegExp; + aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + imgSrcSanitizationWhitelist(): RegExp; + imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + debugInfoEnabled(enabled?: boolean): any; + } + + interface ICloneAttachFunction { + // Let's hint but not force cloneAttachFn's signature + (clonedElement?: JQuery, scope?: IScope): any; + } + + // This corresponds to the "publicLinkFn" returned by $compile. + interface ITemplateLinkingFunction { + (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + // This corresponds to $transclude (and also the transclude function passed to link). + interface ITranscludeFunction { + // If the scope is provided, then the cloneAttachFn must be as well. + (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; + // If one argument is provided, then it's assumed to be the cloneAttachFn. + (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any, bindToController?: any): any; + (controllerName: string, locals?: any, bindToController?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotatedConstructor: any[]): void; + allowGlobals(): void; + } + + /** + * HttpService + * see http://docs.angularjs.org/api/ng/service/$http + */ + interface IHttpService { + /** + * Object describing the request to be made and how it should be processed. + */ + (config: IRequestConfig): IHttpPromise; + + /** + * Shortcut method to perform GET request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + get(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform DELETE request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + delete(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform HEAD request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + head(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform JSONP request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform POST request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PUT request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PATCH request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + patch(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. + */ + defaults: IRequestConfig; + + /** + * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. + */ + pendingRequests: any[]; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestShortcutConfig { + /** + * {Object.} + * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified. + */ + params?: any; + + /** + * Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent. + */ + headers?: any; + + /** + * Name of HTTP header to populate with the XSRF token. + */ + xsrfHeaderName?: string; + + /** + * Name of cookie containing the XSRF token. + */ + xsrfCookieName?: string; + + /** + * {boolean|Cache} + * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching. + */ + cache?: any; + + /** + * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information. + */ + withCredentials?: boolean; + + /** + * {string|Object} + * Data to be sent as the request message data. + */ + data?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version. + */ + transformRequest?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version. + */ + transformResponse?: any; + + /** + * {number|Promise} + * Timeout in milliseconds, or promise that should abort the request when resolved. + */ + timeout?: any; + + /** + * See requestType. + */ + responseType?: string; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestConfig extends IRequestShortcutConfig { + /** + * HTTP method (e.g. 'GET', 'POST', etc) + */ + method: string; + /** + * Absolute or relative URL of the resource that is being requested. + */ + url: string; + } + + interface IHttpHeadersGetter { + (): { [name: string]: string; }; + (headerName: string): string; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: IHttpHeadersGetter; + config?: IRequestConfig; + statusText?: string; + } + + interface IHttpPromise extends IPromise> { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise|TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + /** + * Object that controls the defaults for $http provider + * https://docs.angularjs.org/api/ng/service/$http#defaults + */ + interface IHttpProviderDefaults { + cache?: boolean; + /** + * Transform function or an array of such functions. The transform function takes the http request body and + * headers and returns its transformed (typically serialized) version. + */ + transformRequest?: ((data: any, headersGetter?: any) => any)|((data: any, headersGetter?: any) => any)[]; + xsrfCookieName?: string; + xsrfHeaderName?: string; + withCredentials?: boolean; + headers?: { + common?: any; + post?: any; + put?: any; + patch?: any; + } + } + + interface IHttpProvider extends IServiceProvider { + defaults: IHttpProviderDefaults; + interceptors: any[]; + useApplyAsync(): boolean; + useApplyAsync(value: boolean): IHttpProvider; + + /** + * + * @param {boolean=} value If true, `$http` will return a normal promise without the `success` and `error` methods. + * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining. + * otherwise, returns the current configured value. + */ + useLegacyPromiseExtensions(value:boolean) : boolean | IHttpProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // 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, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; + } + + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; + resourceUrlBlacklist(): any[]; + resourceUrlWhitelist(): any[]; + } + + /** + * $templateRequest service + * see http://docs.angularjs.org/api/ng/service/$templateRequest + */ + interface ITemplateRequestService { + /** + * Downloads a template using $http and, upon success, stores the + * contents inside of $templateCache. + * + * If the HTTP request fails or the response data of the HTTP request is + * empty then a $compile error will be thrown (unless + * {ignoreRequestError} is set to true). + * + * @param tpl The template URL. + * @param ignoreRequestError Whether or not to ignore the exception + * when the request fails or the template is + * empty. + * + * @return A promise whose value is the template content. + */ + (tpl: string, ignoreRequestError?: boolean): IPromise; + /** + * total amount of pending template requests being downloaded. + * @type {number} + */ + totalPendingRequests: number; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirectiveFactory { + (...args: any[]): IDirective; + } + + interface IDirectiveLinkFn { + ( + scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: {}, + transclude: ITranscludeFunction + ): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement: IAugmentedJQuery, + templateAttributes: IAttributes, + transclude: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; + controller?: any; + controllerAs?: string; + bindToController?: boolean|Object; + link?: IDirectiveLinkFn | IDirectivePrePost; + name?: string; + priority?: number; + replace?: boolean; + require?: any; + restrict?: string; + scope?: any; + template?: any; + templateUrl?: any; + terminal?: boolean; + transclude?: any; + } + + /** + * angular.element + * when calling angular.element, angular returns a jQuery object, + * augmented with additional methods like e.g. scope. + * see: http://docs.angularjs.org/api/angular.element + */ + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + controller(): any; + controller(name: string): any; + injector(): any; + scope(): IScope; + isolateScope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + } + + /////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ng.$animate + /////////////////////////////////////////////////////////////////////// + interface IAnimateService { + addClass(element: JQuery, className: string, done?: Function): IPromise; + enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + leave(element: JQuery, done?: Function): void; + move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + removeClass(element: JQuery, className: string, done?: Function): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotatedFunction: any[]): string[]; + get(name: string): T; + has(name: string): boolean; + instantiate(typeConstructor: Function, locals?: any): T; + invoke(inlineAnnotatedFunction: any[]): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): void; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, decorator: Function): void; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, inlineAnnotatedFunction: any[]): void; + factory(name: string, serviceFactoryFunction: Function): IServiceProvider; + factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider; + provider(name: string, provider: IServiceProvider): IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): IServiceProvider; + service(name: string, constructor: Function): IServiceProvider; + value(name: string, value: any): IServiceProvider; + } + + } +} diff --git a/public/app/headers/jquery/jquery.d.ts b/public/app/headers/jquery/jquery.d.ts new file mode 100644 index 00000000000..70737253efd --- /dev/null +++ b/public/app/headers/jquery/jquery.d.ts @@ -0,0 +1,3178 @@ +// Type definitions for jQuery 1.10.x / 2.0.x +// Project: http://jquery.com/ +// Definitions by: Boris Yankov , Christian Hoffmeister , Steve Fenton , Diullei Gomes , Tass Iliopoulos , Jason Swearingen , Sean Hill , Guus Goossens , Kelly Summerlin , Basarat Ali Syed , Nicholas Wolverson , Derek Cicerone , Andrew Gaspar , James Harrison Fisher , Seikichi Kondo , Benjamin Jackman , Poul Sorensen , Josh Strobl , John Reilly , Dick van den Brink +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + + +/** + * Interface for the AJAX setting that will configure the AJAX request + */ +interface JQueryAjaxSettings { + /** + * The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. + */ + accepts?: any; + /** + * By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success(). + */ + async?: boolean; + /** + * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. + */ + beforeSend? (jqXHR: JQueryXHR, settings: JQueryAjaxSettings): any; + /** + * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET. + */ + cache?: boolean; + /** + * A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + complete? (jqXHR: JQueryXHR, textStatus: string): any; + /** + * An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. (version added: 1.5) + */ + contents?: { [key: string]: any; }; + //According to jQuery.ajax source code, ajax's option actually allows contentType to set to "false" + // https://github.com/borisyankov/DefinitelyTyped/issues/742 + /** + * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. + */ + contentType?: any; + /** + * This object will be made the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). + */ + context?: any; + /** + * An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. (version added: 1.5) + */ + converters?: { [key: string]: any; }; + /** + * If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5) + */ + crossDomain?: boolean; + /** + * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). + */ + data?: any; + /** + * A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. + */ + dataFilter? (data: any, ty: any): any; + /** + * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). + */ + dataType?: string; + /** + * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. + */ + error? (jqXHR: JQueryXHR, textStatus: string, errorThrown: string): any; + /** + * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. + */ + global?: boolean; + /** + * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5) + */ + headers?: { [key: string]: any; }; + /** + * Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data. + */ + ifModified?: boolean; + /** + * Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. (version added: 1.5.1) + */ + isLocal?: boolean; + /** + * Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" } + */ + jsonp?: any; + /** + * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. + */ + jsonpCallback?: any; + /** + * The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). (version added: 1.9.0) + */ + method?: string; + /** + * A mime type to override the XHR mime type. (version added: 1.5.1) + */ + mimeType?: string; + /** + * A password to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + password?: string; + /** + * By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. + */ + processData?: boolean; + /** + * Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. + */ + scriptCharset?: string; + /** + * An object of numeric HTTP codes and functions to be called when the response has the corresponding code. f the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. (version added: 1.5) + */ + statusCode?: { [key: string]: any; }; + /** + * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. + */ + success? (data: any, textStatus: string, jqXHR: JQueryXHR): any; + /** + * Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. + */ + timeout?: number; + /** + * Set this to true if you wish to use the traditional style of param serialization. + */ + traditional?: boolean; + /** + * The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers. + */ + type?: string; + /** + * A string containing the URL to which the request is sent. + */ + url?: string; + /** + * A username to be used with XMLHttpRequest in response to an HTTP access authentication request. + */ + username?: string; + /** + * Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory. + */ + xhr?: any; + /** + * An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. (version added: 1.5.1) + */ + xhrFields?: { [key: string]: any; }; +} + +/** + * Interface for the jqXHR object + */ +interface JQueryXHR extends XMLHttpRequest, JQueryPromise { + /** + * The .overrideMimeType() method may be used in the beforeSend() callback function, for example, to modify the response content-type header. As of jQuery 1.5.1, the jqXHR object also contains the overrideMimeType() method (it was available in jQuery 1.4.x, as well, but was temporarily removed in jQuery 1.5). + */ + overrideMimeType(mimeType: string): any; + /** + * Cancel the request. + * + * @param statusText A string passed as the textStatus parameter for the done callback. Default value: "canceled" + */ + abort(statusText?: string): void; + /** + * Incorporates the functionality of the .done() and .fail() methods, allowing (as of jQuery 1.8) the underlying Promise to be manipulated. Refer to deferred.then() for implementation details. + */ + then(doneCallback: (data: any, textStatus: string, jqXHR: JQueryXHR) => void, failCallback?: (jqXHR: JQueryXHR, textStatus: string, errorThrown: any) => void): JQueryPromise; + /** + * Property containing the parsed response if the response Content-Type is json + */ + responseJSON?: any; + /** + * A function to be called if the request fails. + */ + error(xhr: JQueryXHR, textStatus: string, errorThrown: string): void; +} + +/** + * Interface for the JQuery callback + */ +interface JQueryCallback { + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function): JQueryCallback; + /** + * Add a callback or a collection of callbacks to a callback list. + * + * @param callbacks A function, or array of functions, that are to be added to the callback list. + */ + add(callbacks: Function[]): JQueryCallback; + + /** + * Disable a callback list from doing anything more. + */ + disable(): JQueryCallback; + + /** + * Determine if the callbacks list has been disabled. + */ + disabled(): boolean; + + /** + * Remove all of the callbacks from a list. + */ + empty(): JQueryCallback; + + /** + * Call all of the callbacks with the given arguments + * + * @param arguments The argument or list of arguments to pass back to the callback list. + */ + fire(...arguments: any[]): JQueryCallback; + + /** + * Determine if the callbacks have already been called at least once. + */ + fired(): boolean; + + /** + * Call all callbacks in a list with the given context and arguments. + * + * @param context A reference to the context in which the callbacks in the list should be fired. + * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. + */ + fireWith(context?: any, ...args: any[]): JQueryCallback; + + /** + * Determine whether a supplied callback is in a list + * + * @param callback The callback to search for. + */ + has(callback: Function): boolean; + + /** + * Lock a callback list in its current state. + */ + lock(): JQueryCallback; + + /** + * Determine if the callbacks list has been locked. + */ + locked(): boolean; + + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function): JQueryCallback; + /** + * Remove a callback or a collection of callbacks from a callback list. + * + * @param callbacks A function, or array of functions, that are to be removed from the callback list. + */ + remove(callbacks: Function[]): JQueryCallback; +} + +/** + * Allows jQuery Promises to interop with non-jQuery promises + */ +interface JQueryGenericPromise { + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value?: T, ...values: any[]) => U|JQueryPromise, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise; + + /** + * Add handlers to be called when the Deferred object is resolved, rejected, or still in progress. + * + * @param doneFilter A function that is called when the Deferred is resolved. + * @param failFilter An optional function that is called when the Deferred is rejected. + */ + then(doneFilter: (value?: T, ...values: any[]) => void, failFilter?: (...reasons: any[]) => any, progressFilter?: (...progression: any[]) => any): JQueryPromise; +} + +/** + * Interface for the JQuery promise/deferred callbacks + */ +interface JQueryPromiseCallback { + (value?: T, ...args: any[]): void; +} + +interface JQueryPromiseOperator { + (callback1: JQueryPromiseCallback|JQueryPromiseCallback[], ...callbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; +} + +/** + * Interface for the JQuery promise, part of callbacks + */ +interface JQueryPromise extends JQueryGenericPromise { + /** + * Determine the current state of a Deferred object. + */ + state(): string; + /** + * Add handlers to be called when the Deferred object is either resolved or rejected. + * + * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + */ + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is resolved. + * + * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + */ + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + /** + * Add handlers to be called when the Deferred object is rejected. + * + * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + */ + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryPromise; + /** + * Add handlers to be called when the Deferred object generates progress notifications. + * + * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + */ + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryPromise; + + // Deprecated - given no typings + pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; +} + +/** + * Interface for the JQuery deferred, part of callbacks + */ +interface JQueryDeferred extends JQueryGenericPromise { + /** + * Determine the current state of a Deferred object. + */ + state(): string; + /** + * Add handlers to be called when the Deferred object is either resolved or rejected. + * + * @param alwaysCallbacks1 A function, or array of functions, that is called when the Deferred is resolved or rejected. + * @param alwaysCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved or rejected. + */ + always(alwaysCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...alwaysCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is resolved. + * + * @param doneCallbacks1 A function, or array of functions, that are called when the Deferred is resolved. + * @param doneCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is resolved. + */ + done(doneCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...doneCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object is rejected. + * + * @param failCallbacks1 A function, or array of functions, that are called when the Deferred is rejected. + * @param failCallbacks2 Optional additional functions, or arrays of functions, that are called when the Deferred is rejected. + */ + fail(failCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...failCallbacksN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + /** + * Add handlers to be called when the Deferred object generates progress notifications. + * + * @param progressCallbacks A function, or array of functions, to be called when the Deferred generates progress notifications. + */ + progress(progressCallback1?: JQueryPromiseCallback|JQueryPromiseCallback[], ...progressCallbackN: Array|JQueryPromiseCallback[]>): JQueryDeferred; + + /** + * Call the progressCallbacks on a Deferred object with the given args. + * + * @param args Optional arguments that are passed to the progressCallbacks. + */ + notify(value?: any, ...args: any[]): JQueryDeferred; + + /** + * Call the progressCallbacks on a Deferred object with the given context and args. + * + * @param context Context passed to the progressCallbacks as the this object. + * @param args Optional arguments that are passed to the progressCallbacks. + */ + notifyWith(context: any, value?: any, ...args: any[]): JQueryDeferred; + + /** + * Reject a Deferred object and call any failCallbacks with the given args. + * + * @param args Optional arguments that are passed to the failCallbacks. + */ + reject(value?: any, ...args: any[]): JQueryDeferred; + /** + * Reject a Deferred object and call any failCallbacks with the given context and args. + * + * @param context Context passed to the failCallbacks as the this object. + * @param args An optional array of arguments that are passed to the failCallbacks. + */ + rejectWith(context: any, value?: any, ...args: any[]): JQueryDeferred; + + /** + * Resolve a Deferred object and call any doneCallbacks with the given args. + * + * @param value First argument passed to doneCallbacks. + * @param args Optional subsequent arguments that are passed to the doneCallbacks. + */ + resolve(value?: T, ...args: any[]): JQueryDeferred; + + /** + * Resolve a Deferred object and call any doneCallbacks with the given context and args. + * + * @param context Context passed to the doneCallbacks as the this object. + * @param args An optional array of arguments that are passed to the doneCallbacks. + */ + resolveWith(context: any, value?: T, ...args: any[]): JQueryDeferred; + + /** + * Return a Deferred's Promise object. + * + * @param target Object onto which the promise methods have to be attached + */ + promise(target?: any): JQueryPromise; + + // Deprecated - given no typings + pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; +} + +/** + * Interface of the JQuery extension of the W3C event object + */ +interface BaseJQueryEventObject extends Event { + data: any; + delegateTarget: Element; + isDefaultPrevented(): boolean; + isImmediatePropagationStopped(): boolean; + isPropagationStopped(): boolean; + namespace: string; + originalEvent: Event; + preventDefault(): any; + relatedTarget: Element; + result: any; + stopImmediatePropagation(): void; + stopPropagation(): void; + target: Element; + pageX: number; + pageY: number; + which: number; + metaKey: boolean; +} + +interface JQueryInputEventObject extends BaseJQueryEventObject { + altKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + shiftKey: boolean; +} + +interface JQueryMouseEventObject extends JQueryInputEventObject { + button: number; + clientX: number; + clientY: number; + offsetX: number; + offsetY: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; +} + +interface JQueryKeyEventObject extends JQueryInputEventObject { + char: any; + charCode: number; + key: any; + keyCode: number; +} + +interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject{ +} + +/* + Collection of properties of the current browser +*/ + +interface JQuerySupport { + ajax?: boolean; + boxModel?: boolean; + changeBubbles?: boolean; + checkClone?: boolean; + checkOn?: boolean; + cors?: boolean; + cssFloat?: boolean; + hrefNormalized?: boolean; + htmlSerialize?: boolean; + leadingWhitespace?: boolean; + noCloneChecked?: boolean; + noCloneEvent?: boolean; + opacity?: boolean; + optDisabled?: boolean; + optSelected?: boolean; + scriptEval? (): boolean; + style?: boolean; + submitBubbles?: boolean; + tbody?: boolean; +} + +interface JQueryParam { + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + */ + (obj: any): string; + + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + * + * @param obj An array or object to serialize. + * @param traditional A Boolean indicating whether to perform a traditional "shallow" serialization. + */ + (obj: any, traditional: boolean): string; +} + +/** + * The interface used to construct jQuery events (with $.Event). It is + * defined separately instead of inline in JQueryStatic to allow + * overriding the construction function with specific strings + * returning specific event objects. + */ +interface JQueryEventConstructor { + (name: string, eventProperties?: any): JQueryEventObject; + new (name: string, eventProperties?: any): JQueryEventObject; +} + +/** + * The interface used to specify coordinates. + */ +interface JQueryCoordinates { + left: number; + top: number; +} + +/** + * Elements in the array returned by serializeArray() + */ +interface JQuerySerializeArrayElement { + name: string; + value: string; +} + +interface JQueryAnimationOptions { + /** + * A string or number determining how long the animation will run. + */ + duration?: any; + /** + * A string indicating which easing function to use for the transition. + */ + easing?: string; + /** + * A function to call once the animation is complete. + */ + complete?: Function; + /** + * A function to be called for each animated property of each animated element. This function provides an opportunity to modify the Tween object to change the value of the property before it is set. + */ + step?: (now: number, tween: any) => any; + /** + * A function to be called after each step of the animation, only once per animated element regardless of the number of animated properties. (version added: 1.8) + */ + progress?: (animation: JQueryPromise, progress: number, remainingMs: number) => any; + /** + * A function to call when the animation begins. (version added: 1.8) + */ + start?: (animation: JQueryPromise) => any; + /** + * A function to be called when the animation completes (its Promise object is resolved). (version added: 1.8) + */ + done?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A function to be called when the animation fails to complete (its Promise object is rejected). (version added: 1.8) + */ + fail?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A function to be called when the animation completes or stops without completing (its Promise object is either resolved or rejected). (version added: 1.8) + */ + always?: (animation: JQueryPromise, jumpedToEnd: boolean) => any; + /** + * A Boolean indicating whether to place the animation in the effects queue. If false, the animation will begin immediately. As of jQuery 1.7, the queue option can also accept a string, in which case the animation is added to the queue represented by that string. When a custom queue name is used the animation does not automatically start; you must call .dequeue("queuename") to start it. + */ + queue?: any; + /** + * A map of one or more of the CSS properties defined by the properties argument and their corresponding easing functions. (version added: 1.4) + */ + specialEasing?: Object; +} + +/** + * Static members of jQuery (those on $ and jQuery themselves) + */ +interface JQueryStatic { + + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(settings: JQueryAjaxSettings): JQueryXHR; + /** + * Perform an asynchronous HTTP (Ajax) request. + * + * @param url A string containing the URL to which the request is sent. + * @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). + */ + ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR; + + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param dataTypes An optional string containing one or more space-separated dataTypes + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + /** + * Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax(). + * + * @param handler A handler to set default values for future Ajax requests. + */ + ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void; + + ajaxSettings: JQueryAjaxSettings; + + /** + * Set default values for future Ajax requests. Its use is not recommended. + * + * @param options A set of key/value pairs that configure the default Ajax request. All options are optional. + */ + ajaxSetup(options: JQueryAjaxSettings): void; + + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP GET request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). + */ + get(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load JSON-encoded data from the server using a GET HTTP request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. + */ + getJSON(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + /** + * Load a JavaScript file from the server using a GET HTTP request, then execute it. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. + */ + getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR; + + /** + * Create a serialized representation of an array or object, suitable for use in a URL query string or Ajax request. + */ + param: JQueryParam; + + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + /** + * Load data from the server using a HTTP POST request. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case. + * @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html). + */ + post(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR; + + /** + * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. + * + * @param flags An optional list of space-separated flags that change how the callback list behaves. + */ + Callbacks(flags?: string): JQueryCallback; + + /** + * Holds or releases the execution of jQuery's ready event. + * + * @param hold Indicates whether the ready hold is being requested or released + */ + holdReady(hold: boolean): void; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param selector A string containing a selector expression + * @param context A DOM Element, Document, or jQuery to use as context + */ + (selector: string, context?: Element|JQuery): JQuery; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param element A DOM element to wrap in a jQuery object. + */ + (element: Element): JQuery; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + */ + (elementArray: Element[]): JQuery; + + /** + * Binds a function to be executed when the DOM has finished loading. + * + * @param callback A function to execute after the DOM is ready. + */ + (callback: (jQueryAlias?: JQueryStatic) => any): JQuery; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object A plain object to wrap in a jQuery object. + */ + (object: {}): JQuery; + + /** + * Accepts a string containing a CSS selector which is then used to match a set of elements. + * + * @param object An existing jQuery object to clone. + */ + (object: JQuery): JQuery; + + /** + * Specify a function to execute when the DOM is fully loaded. + */ + (): JQuery; + + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string of HTML to create on the fly. Note that this parses HTML, not XML. + * @param ownerDocument A document in which the new elements will be created. + */ + (html: string, ownerDocument?: Document): JQuery; + + /** + * Creates DOM elements on the fly from the provided string of raw HTML. + * + * @param html A string defining a single, standalone, HTML element (e.g.
or
). + * @param attributes An object of attributes, events, and methods to call on the newly-created element. + */ + (html: string, attributes: Object): JQuery; + + /** + * Relinquish jQuery's control of the $ variable. + * + * @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). + */ + noConflict(removeAll?: boolean): Object; + + /** + * Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. + * + * @param deferreds One or more Deferred objects, or plain JavaScript objects. + */ + when(...deferreds: Array/* as JQueryDeferred */>): JQueryPromise; + + /** + * Hook directly into jQuery to override how particular CSS properties are retrieved or set, normalize CSS property naming, or create custom properties. + */ + cssHooks: { [key: string]: any; }; + cssNumber: any; + + /** + * Store arbitrary data associated with the specified element. Returns the value that was set. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + * @param value The new data value. + */ + data(element: Element, key: string, value: T): T; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + * @param key A string naming the piece of data to set. + */ + data(element: Element, key: string): any; + /** + * Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element. + * + * @param element The DOM element to associate with the data. + */ + data(element: Element): any; + + /** + * Execute the next function on the queue for the matched element. + * + * @param element A DOM element from which to remove and execute a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + dequeue(element: Element, queueName?: string): void; + + /** + * Determine whether an element has any jQuery data associated with it. + * + * @param element A DOM element to be checked for data. + */ + hasData(element: Element): boolean; + + /** + * Show the queue of functions to be executed on the matched element. + * + * @param element A DOM element to inspect for an attached queue. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + queue(element: Element, queueName?: string): any[]; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element where the array of queued functions is attached. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(element: Element, queueName: string, newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed on the matched element. + * + * @param element A DOM element on which to add a queued function. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param callback The new function to add to the queue. + */ + queue(element: Element, queueName: string, callback: Function): JQuery; + + /** + * Remove a previously-stored piece of data. + * + * @param element A DOM element from which to remove data. + * @param name A string naming the piece of data to remove. + */ + removeData(element: Element, name?: string): JQuery; + + /** + * A constructor function that returns a chainable utility object with methods to register multiple callbacks into callback queues, invoke callback queues, and relay the success or failure state of any synchronous or asynchronous function. + * + * @param beforeStart A function that is called just before the constructor returns. + */ + Deferred(beforeStart?: (deferred: JQueryDeferred) => any): JQueryDeferred; + + /** + * Effects + */ + fx: { + tick: () => void; + /** + * The rate (in milliseconds) at which animations fire. + */ + interval: number; + stop: () => void; + speeds: { slow: number; fast: number; }; + /** + * Globally disable all animations. + */ + off: boolean; + step: any; + }; + + /** + * Takes a function and returns a new one that will always have a particular context. + * + * @param fnction The function whose context will be changed. + * @param context The object to which the context (this) of the function should be set. + * @param additionalArguments Any number of arguments to be passed to the function referenced in the function argument. + */ + proxy(fnction: (...args: any[]) => any, context: Object, ...additionalArguments: any[]): any; + /** + * Takes a function and returns a new one that will always have a particular context. + * + * @param context The object to which the context (this) of the function should be set. + * @param name The name of the function whose context will be changed (should be a property of the context object). + * @param additionalArguments Any number of arguments to be passed to the function named in the name argument. + */ + proxy(context: Object, name: string, ...additionalArguments: any[]): any; + + Event: JQueryEventConstructor; + + /** + * Takes a string and throws an exception containing it. + * + * @param message The message to send out. + */ + error(message: any): JQuery; + + expr: any; + fn: any; //TODO: Decide how we want to type this + + isReady: boolean; + + // Properties + support: JQuerySupport; + + /** + * Check to see if a DOM element is a descendant of another DOM element. + * + * @param container The DOM element that may contain the other element. + * @param contained The DOM element that may be contained by (a descendant of) the other element. + */ + contains(container: Element, contained: Element): boolean; + + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ + each( + collection: T[], + callback: (indexInArray: number, valueOfElement: T) => any + ): any; + + /** + * A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a function's arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties. + * + * @param collection The object or array to iterate over. + * @param callback The function that will be executed on every object. + */ + each( + collection: any, + callback: (indexInArray: any, valueOfElement: any) => any + ): any; + + /** + * Merge the contents of two or more objects together into the first object. + * + * @param target An object that will receive the new properties if additional objects are passed in or that will extend the jQuery namespace if it is the sole argument. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(target: any, object1?: any, ...objectN: any[]): any; + /** + * Merge the contents of two or more objects together into the first object. + * + * @param deep If true, the merge becomes recursive (aka. deep copy). + * @param target The object to extend. It will receive the new properties. + * @param object1 An object containing additional properties to merge in. + * @param objectN Additional objects containing properties to merge in. + */ + extend(deep: boolean, target: any, object1?: any, ...objectN: any[]): any; + + /** + * Execute some JavaScript code globally. + * + * @param code The JavaScript code to execute. + */ + globalEval(code: string): any; + + /** + * Finds the elements of an array which satisfy a filter function. The original array is not affected. + * + * @param array The array to search through. + * @param func The function to process each item against. The first argument to the function is the item, and the second argument is the index. The function should return a Boolean value. this will be the global window object. + * @param invert If "invert" is false, or not provided, then the function returns an array consisting of all elements for which "callback" returns true. If "invert" is true, then the function returns an array consisting of all elements for which "callback" returns false. + */ + grep(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[]; + + /** + * Search for a specified value within an array and return its index (or -1 if not found). + * + * @param value The value to search for. + * @param array An array through which to search. + * @param fromIndex he index of the array at which to begin the search. The default is 0, which will search the whole array. + */ + inArray(value: T, array: T[], fromIndex?: number): number; + + /** + * Determine whether the argument is an array. + * + * @param obj Object to test whether or not it is an array. + */ + isArray(obj: any): boolean; + /** + * Check to see if an object is empty (contains no enumerable properties). + * + * @param obj The object that will be checked to see if it's empty. + */ + isEmptyObject(obj: any): boolean; + /** + * Determine if the argument passed is a Javascript function object. + * + * @param obj Object to test whether or not it is a function. + */ + isFunction(obj: any): boolean; + /** + * Determines whether its argument is a number. + * + * @param obj The value to be tested. + */ + isNumeric(value: any): boolean; + /** + * Check to see if an object is a plain object (created using "{}" or "new Object"). + * + * @param obj The object that will be checked to see if it's a plain object. + */ + isPlainObject(obj: any): boolean; + /** + * Determine whether the argument is a window. + * + * @param obj Object to test whether or not it is a window. + */ + isWindow(obj: any): boolean; + /** + * Check to see if a DOM node is within an XML document (or is an XML document). + * + * @param node he DOM node that will be checked to see if it's in an XML document. + */ + isXMLDoc(node: Node): boolean; + + /** + * Convert an array-like object into a true JavaScript array. + * + * @param obj Any object to turn into a native Array. + */ + makeArray(obj: any): any[]; + + /** + * Translate all items in an array or object to new array of items. + * + * @param array The Array to translate. + * @param callback The function to process each item against. The first argument to the function is the array item, the second argument is the index in array The function can return any value. Within the function, this refers to the global (window) object. + */ + map(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[]; + /** + * Translate all items in an array or object to new array of items. + * + * @param arrayOrObject The Array or Object to translate. + * @param callback The function to process each item against. The first argument to the function is the value; the second argument is the index or key of the array or object property. The function can return any value to add to the array. A returned array will be flattened into the resulting array. Within the function, this refers to the global (window) object. + */ + map(arrayOrObject: any, callback: (value: any, indexOrKey: any) => any): any; + + /** + * Merge the contents of two arrays together into the first array. + * + * @param first The first array to merge, the elements of second added. + * @param second The second array to merge into the first, unaltered. + */ + merge(first: T[], second: T[]): T[]; + + /** + * An empty function. + */ + noop(): any; + + /** + * Return a number representing the current time. + */ + now(): number; + + /** + * Takes a well-formed JSON string and returns the resulting JavaScript object. + * + * @param json The JSON string to parse. + */ + parseJSON(json: string): any; + + /** + * Parses a string into an XML document. + * + * @param data a well-formed XML string to be parsed + */ + parseXML(data: string): XMLDocument; + + /** + * Remove the whitespace from the beginning and end of a string. + * + * @param str Remove the whitespace from the beginning and end of a string. + */ + trim(str: string): string; + + /** + * Determine the internal JavaScript [[Class]] of an object. + * + * @param obj Object to get the internal JavaScript [[Class]] of. + */ + type(obj: any): string; + + /** + * Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers. + * + * @param array The Array of DOM elements. + */ + unique(array: Element[]): Element[]; + + /** + * Parses a string into an array of DOM nodes. + * + * @param data HTML string to be parsed + * @param context DOM element to serve as the context in which the HTML fragment will be created + * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + */ + parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[]; + + /** + * Parses a string into an array of DOM nodes. + * + * @param data HTML string to be parsed + * @param context DOM element to serve as the context in which the HTML fragment will be created + * @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string + */ + parseHTML(data: string, context?: Document, keepScripts?: boolean): any[]; +} + +/** + * The jQuery instance members + */ +interface JQuery { + /** + * Register a handler to be called when Ajax requests complete. This is an AjaxEvent. + * + * @param handler The function to be invoked. + */ + ajaxComplete(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery; + /** + * Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxError(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxSettings: JQueryAjaxSettings, thrownError: any) => any): JQuery; + /** + * Attach a function to be executed before an Ajax request is sent. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxSend(handler: (event: JQueryEventObject, jqXHR: JQueryXHR, ajaxOptions: JQueryAjaxSettings) => any): JQuery; + /** + * Register a handler to be called when the first Ajax request begins. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxStart(handler: () => any): JQuery; + /** + * Register a handler to be called when all Ajax requests have completed. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxStop(handler: () => any): JQuery; + /** + * Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event. + * + * @param handler The function to be invoked. + */ + ajaxSuccess(handler: (event: JQueryEventObject, XMLHttpRequest: XMLHttpRequest, ajaxOptions: JQueryAjaxSettings) => any): JQuery; + + /** + * Load data from the server and place the returned HTML into the matched element. + * + * @param url A string containing the URL to which the request is sent. + * @param data A plain object or string that is sent to the server with the request. + * @param complete A callback function that is executed when the request completes. + */ + load(url: string, data?: string|Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery; + + /** + * Encode a set of form elements as a string for submission. + */ + serialize(): string; + /** + * Encode a set of form elements as an array of names and values. + */ + serializeArray(): JQuerySerializeArrayElement[]; + + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param className One or more space-separated classes to be added to the class attribute of each matched element. + */ + addClass(className: string): JQuery; + /** + * Adds the specified class(es) to each of the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set. + */ + addClass(func: (index: number, className: string) => string): JQuery; + + /** + * Add the previous set of elements on the stack to the current set, optionally filtered by a selector. + */ + addBack(selector?: string): JQuery; + + /** + * Get the value of an attribute for the first element in the set of matched elements. + * + * @param attributeName The name of the attribute to get. + */ + attr(attributeName: string): string; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param value A value to set for the attribute. + */ + attr(attributeName: string, value: string|number): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributeName The name of the attribute to set. + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. + */ + attr(attributeName: string, func: (index: number, attr: string) => string|number): JQuery; + /** + * Set one or more attributes for the set of matched elements. + * + * @param attributes An object of attribute-value pairs to set. + */ + attr(attributes: Object): JQuery; + + /** + * Determine whether any of the matched elements are assigned the given class. + * + * @param className The class name to search for. + */ + hasClass(className: string): boolean; + + /** + * Get the HTML contents of the first element in the set of matched elements. + */ + html(): string; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param htmlString A string of HTML to set as the content of each matched element. + */ + html(htmlString: string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + */ + html(func: (index: number, oldhtml: string) => string): JQuery; + /** + * Set the HTML contents of each element in the set of matched elements. + * + * @param func A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set. + */ + + /** + * Get the value of a property for the first element in the set of matched elements. + * + * @param propertyName The name of the property to get. + */ + prop(propertyName: string): any; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param value A value to set for the property. + */ + prop(propertyName: string, value: string|number|boolean): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + */ + prop(properties: Object): JQuery; + /** + * Set one or more properties for the set of matched elements. + * + * @param propertyName The name of the property to set. + * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element. + */ + prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): JQuery; + + /** + * Remove an attribute from each element in the set of matched elements. + * + * @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes. + */ + removeAttr(attributeName: string): JQuery; + + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param className One or more space-separated classes to be removed from the class attribute of each matched element. + */ + removeClass(className?: string): JQuery; + /** + * Remove a single class, multiple classes, or all classes from each element in the set of matched elements. + * + * @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + */ + removeClass(func: (index: number, className: string) => string): JQuery; + + /** + * Remove a property for the set of matched elements. + * + * @param propertyName The name of the property to remove. + */ + removeProp(propertyName: string): JQuery; + + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param className One or more class names (separated by spaces) to be toggled for each element in the matched set. + * @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. + */ + toggleClass(className: string, swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param swtch A boolean value to determine whether the class should be added or removed. + */ + toggleClass(swtch?: boolean): JQuery; + /** + * Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument. + * + * @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments. + * @param swtch A boolean value to determine whether the class should be added or removed. + */ + toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery; + + /** + * Get the current value of the first element in the set of matched elements. + */ + val(): any; + /** + * Set the value of each element in the set of matched elements. + * + * @param value A string of text or an array of strings corresponding to the value of each matched element to set as selected/checked. + */ + val(value: string|string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string) => string): JQuery; + + + /** + * Get the value of style properties for the first element in the set of matched elements. + * + * @param propertyName A CSS property. + */ + css(propertyName: string): string; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A value to set for the property. + */ + css(propertyName: string, value: string|number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param propertyName A CSS property name. + * @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + css(propertyName: string, value: (index: number, value: string) => string|number): JQuery; + /** + * Set one or more CSS properties for the set of matched elements. + * + * @param properties An object of property-value pairs to set. + */ + css(properties: Object): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements. + */ + height(): number; + /** + * Set the CSS height of every matched element. + * + * @param value An integer representing the number of pixels, or an integer with an optional unit of measure appended (as a string). + */ + height(value: number|string): JQuery; + /** + * Set the CSS height of every matched element. + * + * @param func A function returning the height to set. Receives the index position of the element in the set and the old height as arguments. Within the function, this refers to the current element in the set. + */ + height(func: (index: number, height: number) => number|string): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements, including padding but not border. + */ + innerHeight(): number; + + /** + * Sets the inner height on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerHeight(height: number|string): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements, including padding but not border. + */ + innerWidth(): number; + + /** + * Sets the inner width on elements in the set of matched elements, including padding but not border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + innerWidth(width: number|string): JQuery; + + /** + * Get the current coordinates of the first element in the set of matched elements, relative to the document. + */ + offset(): JQueryCoordinates; + /** + * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + * + * @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + */ + offset(coordinates: JQueryCoordinates): JQuery; + /** + * An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements. + * + * @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties. + */ + offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery; + + /** + * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ + outerHeight(includeMargin?: boolean): number; + + /** + * Sets the outer height on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerHeight(height: number|string): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements, including padding and border. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ + outerWidth(includeMargin?: boolean): number; + + /** + * Sets the outer width on elements in the set of matched elements, including padding and border. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + outerWidth(width: number|string): JQuery; + + /** + * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. + */ + position(): JQueryCoordinates; + + /** + * Get the current horizontal position of the scroll bar for the first element in the set of matched elements or set the horizontal position of the scroll bar for every matched element. + */ + scrollLeft(): number; + /** + * Set the current horizontal position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ + scrollLeft(value: number): JQuery; + + /** + * Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element. + */ + scrollTop(): number; + /** + * Set the current vertical position of the scroll bar for each of the set of matched elements. + * + * @param value An integer indicating the new position to set the scroll bar to. + */ + scrollTop(value: number): JQuery; + + /** + * Get the current computed width for the first element in the set of matched elements. + */ + width(): number; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param value An integer representing the number of pixels, or an integer along with an optional unit of measure appended (as a string). + */ + width(value: number|string): JQuery; + /** + * Set the CSS width of each element in the set of matched elements. + * + * @param func A function returning the width to set. Receives the index position of the element in the set and the old width as arguments. Within the function, this refers to the current element in the set. + */ + width(func: (index: number, width: number) => number|string): JQuery; + + /** + * Remove from the queue all items that have not yet been run. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + clearQueue(queueName?: string): JQuery; + + /** + * Store arbitrary data associated with the matched elements. + * + * @param key A string naming the piece of data to set. + * @param value The new data value; it can be any Javascript type including Array or Object. + */ + data(key: string, value: any): JQuery; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + * + * @param key Name of the data stored. + */ + data(key: string): any; + /** + * Store arbitrary data associated with the matched elements. + * + * @param obj An object of key-value pairs of data to update. + */ + data(obj: { [key: string]: any; }): JQuery; + /** + * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute. + */ + data(): any; + + /** + * Execute the next function on the queue for the matched elements. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + dequeue(queueName?: string): JQuery; + + /** + * Remove a previously-stored piece of data. + * + * @param name A string naming the piece of data to delete or space-separated string naming the pieces of data to delete. + */ + removeData(name: string): JQuery; + /** + * Remove a previously-stored piece of data. + * + * @param list An array of strings naming the pieces of data to delete. + */ + removeData(list: string[]): JQuery; + + /** + * Return a Promise object to observe when all actions of a certain type bound to the collection, queued or not, have finished. + * + * @param type The type of queue that needs to be observed. (default: fx) + * @param target Object onto which the promise methods have to be attached + */ + promise(type?: string, target?: Object): JQueryPromise; + + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: string|number, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. (default: swing) + * @param complete A function to call once the animation is complete. + */ + animate(properties: Object, duration?: string|number, easing?: string, complete?: Function): JQuery; + /** + * Perform a custom animation of a set of CSS properties. + * + * @param properties An object of CSS properties and values that the animation will move toward. + * @param options A map of additional options to pass to the method. + */ + animate(properties: Object, options: JQueryAnimationOptions): JQuery; + + /** + * Set a timer to delay execution of subsequent items in the queue. + * + * @param duration An integer indicating the number of milliseconds to delay execution of the next item in the queue. + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + delay(duration: number, queueName?: string): JQuery; + + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: number|string, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeIn(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements by fading them to opaque. + * + * @param options A map of additional options to pass to the method. + */ + fadeIn(options: JQueryAnimationOptions): JQuery; + + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: number|string, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeOut(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements by fading them to transparent. + * + * @param options A map of additional options to pass to the method. + */ + fadeOut(options: JQueryAnimationOptions): JQuery; + + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: string|number, opacity: number, complete?: Function): JQuery; + /** + * Adjust the opacity of the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param opacity A number between 0 and 1 denoting the target opacity. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeTo(duration: string|number, opacity: number, easing?: string, complete?: Function): JQuery; + + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: number|string, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + fadeToggle(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements by animating their opacity. + * + * @param options A map of additional options to pass to the method. + */ + fadeToggle(options: JQueryAnimationOptions): JQuery; + + /** + * Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements. + * + * @param queue The name of the queue in which to stop animations. + */ + finish(queue?: string): JQuery; + + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: number|string, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + hide(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + hide(options: JQueryAnimationOptions): JQuery; + + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + show(duration?: number|string, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + show(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + show(options: JQueryAnimationOptions): JQuery; + + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: number|string, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideDown(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideDown(options: JQueryAnimationOptions): JQuery; + + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: number|string, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideToggle(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideToggle(options: JQueryAnimationOptions): JQuery; + + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: number|string, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + slideUp(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Hide the matched elements with a sliding motion. + * + * @param options A map of additional options to pass to the method. + */ + slideUp(options: JQueryAnimationOptions): JQuery; + + /** + * Stop the currently-running animation on the matched elements. + * + * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. + * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + */ + stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + /** + * Stop the currently-running animation on the matched elements. + * + * @param queue The name of the queue in which to stop animations. + * @param clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false. + * @param jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false. + */ + stop(queue?: string, clearQueue?: boolean, jumpToEnd?: boolean): JQuery; + + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: number|string, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param duration A string or number determining how long the animation will run. + * @param easing A string indicating which easing function to use for the transition. + * @param complete A function to call once the animation is complete. + */ + toggle(duration?: number|string, easing?: string, complete?: Function): JQuery; + /** + * Display or hide the matched elements. + * + * @param options A map of additional options to pass to the method. + */ + toggle(options: JQueryAnimationOptions): JQuery; + /** + * Display or hide the matched elements. + * + * @param showOrHide A Boolean indicating whether to show or hide the elements. + */ + toggle(showOrHide: boolean): JQuery; + + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute each time the event is triggered. + */ + bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param eventData An object containing data that will be passed to the event handler. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ + bind(eventType: string, eventData: any, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names. + * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true. + */ + bind(eventType: string, preventBubble: boolean): JQuery; + /** + * Attach a handler to an event for the elements. + * + * @param events An object containing one or more DOM event types and functions to execute for them. + */ + bind(events: any): JQuery; + + /** + * Trigger the "blur" event on an element + */ + blur(): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + blur(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "blur" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "change" event on an element. + */ + change(): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + change(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "change" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "click" event on an element. + */ + click(): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + */ + click(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "click" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "dblclick" event on an element. + */ + dblclick(): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "dblclick" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + delegate(selector: any, eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "focus" event on an element. + */ + focus(): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focus(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focus" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusin(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusin" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + focusout(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "focusout" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + focusout(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements. + * + * @param handlerIn A function to execute when the mouse pointer enters the element. + * @param handlerOut A function to execute when the mouse pointer leaves the element. + */ + hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements. + * + * @param handlerInOut A function to execute when the mouse pointer enters or leaves the element. + */ + hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "keydown" event on an element. + */ + keydown(): JQuery; + /** + * Bind an event handler to the "keydown" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keydown(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keydown" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keydown(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keypress" event on an element. + */ + keypress(): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keypress(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keypress" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keypress(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Trigger the "keyup" event on an element. + */ + keyup(): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + keyup(handler: (eventObject: JQueryKeyEventObject) => any): JQuery; + /** + * Bind an event handler to the "keyup" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + keyup(eventData?: any, handler?: (eventObject: JQueryKeyEventObject) => any): JQuery; + + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + load(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "load" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "mousedown" event on an element. + */ + mousedown(): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousedown(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousedown" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousedown(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseenter" event on an element. + */ + mouseenter(): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseenter(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse enters an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseenter(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseleave" event on an element. + */ + mouseleave(): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param handler A function to execute when the event is triggered. + */ + mouseleave(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to be fired when the mouse leaves an element. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseleave(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mousemove" event on an element. + */ + mousemove(): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mousemove(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mousemove" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mousemove(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseout" event on an element. + */ + mouseout(): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseout(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseout" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseout(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseover" event on an element. + */ + mouseover(): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseover(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseover" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseover(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Trigger the "mouseup" event on an element. + */ + mouseup(): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param handler A function to execute when the event is triggered. + */ + mouseup(handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + /** + * Bind an event handler to the "mouseup" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + mouseup(eventData: Object, handler: (eventObject: JQueryMouseEventObject) => any): JQuery; + + /** + * Remove an event handler. + */ + off(): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events One or more space-separated event types and optional namespaces, or just namespaces, such as "click", "keydown.myPlugin", or ".myPlugin". + * @param handler A handler function previously attached for the event(s), or the special value false. + */ + off(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove an event handler. + * + * @param events An object where the string keys represent one or more space-separated event types and optional namespaces, and the values represent handler functions previously attached for the event(s). + * @param selector A selector which should match the one originally passed to .on() when attaching event handlers. + */ + off(events: { [key: string]: any; }, selector?: string): JQuery; + + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). + */ + on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + on(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + on(events: { [key: string]: any; }, data?: any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names. + * @param data An object containing data that will be passed to the event handler. + * @param handler A function to execute at the time the event is triggered. + */ + one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + one(events: { [key: string]: any; }, selector?: string, data?: any): JQuery; + + /** + * Attach a handler to an event for the elements. The handler is executed at most once per element per event type. + * + * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s). + * @param data Data to be passed to the handler in event.data when an event occurs. + */ + one(events: { [key: string]: any; }, data?: any): JQuery; + + + /** + * Specify a function to execute when the DOM is fully loaded. + * + * @param handler A function to execute after the DOM is ready. + */ + ready(handler: (jQueryAlias?: JQueryStatic) => any): JQuery; + + /** + * Trigger the "resize" event on an element. + */ + resize(): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + resize(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "resize" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + resize(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "scroll" event on an element. + */ + scroll(): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + scroll(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "scroll" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + scroll(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "select" event on an element. + */ + select(): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param handler A function to execute each time the event is triggered. + */ + select(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "select" JavaScript event. + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + select(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Trigger the "submit" event on an element. + */ + submit(): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param handler A function to execute each time the event is triggered. + */ + submit(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "submit" JavaScript event + * + * @param eventData An object containing data that will be passed to the event handler. + * @param handler A function to execute each time the event is triggered. + */ + submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(eventType: string, extraParameters?: any[]|Object): JQuery; + /** + * Execute all handlers and behaviors attached to the matched elements for the given event type. + * + * @param event A jQuery.Event object. + * @param extraParameters Additional parameters to pass along to the event handler. + */ + trigger(event: JQueryEventObject, extraParameters?: any[]|Object): JQuery; + + /** + * Execute all handlers attached to an element for an event. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param extraParameters An array of additional parameters to pass along to the event handler. + */ + triggerHandler(eventType: string, ...extraParameters: any[]): Object; + + /** + * Execute all handlers attached to an element for an event. + * + * @param event A jQuery.Event object. + * @param extraParameters An array of additional parameters to pass along to the event handler. + */ + triggerHandler(event: JQueryEventObject, ...extraParameters: any[]): Object; + + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param handler The function that is to be no longer executed. + */ + unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param eventType A string containing a JavaScript event type, such as click or submit. + * @param fls Unbinds the corresponding 'return false' function that was bound using .bind( eventType, false ). + */ + unbind(eventType: string, fls: boolean): JQuery; + /** + * Remove a previously-attached event handler from the elements. + * + * @param evt A JavaScript event object as passed to an event handler. + */ + unbind(evt: any): JQuery; + + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + */ + undelegate(): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param eventType A string containing a JavaScript event type, such as "click" or "keydown" + * @param handler A function to execute at the time the event is triggered. + */ + undelegate(selector: string, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param selector A selector which will be used to filter the event results. + * @param events An object of one or more event types and previously bound functions to unbind from them. + */ + undelegate(selector: string, events: Object): JQuery; + /** + * Remove a handler from the event for all elements which match the current selector, based upon a specific set of root elements. + * + * @param namespace A string containing a namespace to unbind all events from. + */ + undelegate(namespace: string): JQuery; + + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ + unload(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "unload" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * The DOM node context originally passed to jQuery(); if none was passed then context will likely be the document. (DEPRECATED from v1.10) + */ + context: Element; + + jquery: string; + + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param handler A function to execute when the event is triggered. + */ + error(handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Bind an event handler to the "error" JavaScript event. (DEPRECATED from v1.8) + * + * @param eventData A plain object of data that will be passed to the event handler. + * @param handler A function to execute when the event is triggered. + */ + error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery; + + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + */ + pushStack(elements: any[]): JQuery; + /** + * Add a collection of DOM elements onto the jQuery stack. + * + * @param elements An array of elements to push onto the stack and make into a new jQuery object. + * @param name The name of a jQuery method that generated the array of elements. + * @param arguments The arguments that were passed in to the jQuery method (for serialization). + */ + pushStack(elements: any[], name: string, arguments: any[]): JQuery; + + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. + */ + after(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, after each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert after each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + after(func: (index: number, html: string) => string|Element|JQuery): JQuery; + + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. + */ + append(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the end of each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the end of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + */ + append(func: (index: number, html: string) => string|Element|JQuery): JQuery; + + /** + * Insert every element in the set of matched elements to the end of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the end of the element(s) specified by this parameter. + */ + appendTo(target: JQuery|any[]|Element|string): JQuery; + + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. + */ + before(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, before each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert before each element in the set of matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + before(func: (index: number, html: string) => string|Element|JQuery): JQuery; + + /** + * Create a deep copy of the set of matched elements. + * + * param withDataAndEvents A Boolean indicating whether event handlers and data should be copied along with the elements. The default value is false. + * param deepWithDataAndEvents A Boolean indicating whether event handlers and data for all children of the cloned element should be copied. By default its value matches the first argument's value (which defaults to false). + */ + clone(withDataAndEvents?: boolean, deepWithDataAndEvents?: boolean): JQuery; + + /** + * Remove the set of matched elements from the DOM. + * + * param selector A selector expression that filters the set of matched elements to be removed. + */ + detach(selector?: string): JQuery; + + /** + * Remove all child nodes of the set of matched elements from the DOM. + */ + empty(): JQuery; + + /** + * Insert every element in the set of matched elements after the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted after the element(s) specified by this parameter. + */ + insertAfter(target: JQuery|any[]|Element|Text|string): JQuery; + + /** + * Insert every element in the set of matched elements before the target. + * + * param target A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element(s) specified by this parameter. + */ + insertBefore(target: JQuery|any[]|Element|Text|string): JQuery; + + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. + */ + prepend(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + /** + * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. + * + * param func A function that returns an HTML string, DOM element(s), or jQuery object to insert at the beginning of each element in the set of matched elements. Receives the index position of the element in the set and the old HTML value of the element as arguments. Within the function, this refers to the current element in the set. + */ + prepend(func: (index: number, html: string) => string|Element|JQuery): JQuery; + + /** + * Insert every element in the set of matched elements to the beginning of the target. + * + * @param target A selector, element, HTML string, array of elements, or jQuery object; the matched set of elements will be inserted at the beginning of the element(s) specified by this parameter. + */ + prependTo(target: JQuery|any[]|Element|string): JQuery; + + /** + * Remove the set of matched elements from the DOM. + * + * @param selector A selector expression that filters the set of matched elements to be removed. + */ + remove(selector?: string): JQuery; + + /** + * Replace each target element with the set of matched elements. + * + * @param target A selector string, jQuery object, DOM element, or array of elements indicating which element(s) to replace. + */ + replaceAll(target: JQuery|any[]|Element|string): JQuery; + + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param newContent The content to insert. May be an HTML string, DOM element, array of DOM elements, or jQuery object. + */ + replaceWith(newContent: JQuery|any[]|Element|Text|string): JQuery; + /** + * Replace each element in the set of matched elements with the provided new content and return the set of elements that was removed. + * + * param func A function that returns content with which to replace the set of matched elements. + */ + replaceWith(func: () => Element|JQuery): JQuery; + + /** + * Get the combined text contents of each element in the set of matched elements, including their descendants. + */ + text(): string; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param text The text to set as the content of each matched element. When Number or Boolean is supplied, it will be converted to a String representation. + */ + text(text: string|number|boolean): JQuery; + /** + * Set the content of each element in the set of matched elements to the specified text. + * + * @param func A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments. + */ + text(func: (index: number, text: string) => string): JQuery; + + /** + * Retrieve all the elements contained in the jQuery set, as an array. + */ + toArray(): any[]; + + /** + * Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place. + */ + unwrap(): JQuery; + + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrap(wrappingElement: JQuery|Element|string): JQuery; + /** + * Wrap an HTML structure around each element in the set of matched elements. + * + * @param func A callback function returning the HTML content or jQuery object to wrap around the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + wrap(func: (index: number) => string|JQuery): JQuery; + + /** + * Wrap an HTML structure around all elements in the set of matched elements. + * + * @param wrappingElement A selector, element, HTML string, or jQuery object specifying the structure to wrap around the matched elements. + */ + wrapAll(wrappingElement: JQuery|Element|string): JQuery; + wrapAll(func: (index: number) => string): JQuery; + + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param wrappingElement An HTML snippet, selector expression, jQuery object, or DOM element specifying the structure to wrap around the content of the matched elements. + */ + wrapInner(wrappingElement: JQuery|Element|string): JQuery; + /** + * Wrap an HTML structure around the content of each element in the set of matched elements. + * + * @param func A callback function which generates a structure to wrap around the content of the matched elements. Receives the index position of the element in the set as an argument. Within the function, this refers to the current element in the set. + */ + wrapInner(func: (index: number) => string): JQuery; + + /** + * Iterate over a jQuery object, executing a function for each matched element. + * + * @param func A function to execute for each matched element. + */ + each(func: (index: number, elem: Element) => any): JQuery; + + /** + * Retrieve one of the elements matched by the jQuery object. + * + * @param index A zero-based integer indicating which element to retrieve. + */ + get(index: number): HTMLElement; + /** + * Retrieve the elements matched by the jQuery object. + */ + get(): any[]; + + /** + * Search for a given element from among the matched elements. + */ + index(): number; + /** + * Search for a given element from among the matched elements. + * + * @param selector A selector representing a jQuery collection in which to look for an element. + */ + index(selector: string|JQuery|Element): number; + + /** + * The number of elements in the jQuery object. + */ + length: number; + /** + * A selector representing selector passed to jQuery(), if any, when creating the original set. + * version deprecated: 1.7, removed: 1.9 + */ + selector: string; + [index: string]: any; + [index: number]: HTMLElement; + + /** + * Add elements to the set of matched elements. + * + * @param selector A string representing a selector expression to find additional elements to add to the set of matched elements. + * @param context The point in the document at which the selector should begin matching; similar to the context argument of the $(selector, context) method. + */ + add(selector: string, context?: Element): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param elements One or more elements to add to the set of matched elements. + */ + add(...elements: Element[]): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param html An HTML fragment to add to the set of matched elements. + */ + add(html: string): JQuery; + /** + * Add elements to the set of matched elements. + * + * @param obj An existing jQuery object to add to the set of matched elements. + */ + add(obj: JQuery): JQuery; + + /** + * Get the children of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + children(selector?: string): JQuery; + + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param selector A string containing a selector expression to match elements against. + */ + closest(selector: string): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param selector A string containing a selector expression to match elements against. + * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + */ + closest(selector: string, context?: Element): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param obj A jQuery object to match elements against. + */ + closest(obj: JQuery): JQuery; + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * + * @param element An element to match elements against. + */ + closest(element: Element): JQuery; + + /** + * Get an array of all the elements and selectors matched against the current element up through the DOM tree. + * + * @param selectors An array or string containing a selector expression to match elements against (can also be a jQuery object). + * @param context A DOM element within which a matching element may be found. If no context is passed in then the context of the jQuery set will be used instead. + */ + closest(selectors: any, context?: Element): any[]; + + /** + * Get the children of each element in the set of matched elements, including text and comment nodes. + */ + contents(): JQuery; + + /** + * End the most recent filtering operation in the current chain and return the set of matched elements to its previous state. + */ + end(): JQuery; + + /** + * Reduce the set of matched elements to the one at the specified index. + * + * @param index An integer indicating the 0-based position of the element. OR An integer indicating the position of the element, counting backwards from the last element in the set. + * + */ + eq(index: number): JQuery; + + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param selector A string containing a selector expression to match the current set of elements against. + */ + filter(selector: string): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param func A function used as a test for each element in the set. this is the current DOM element. + */ + filter(func: (index: number, element: Element) => any): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param element An element to match the current set of elements against. + */ + filter(element: Element): JQuery; + /** + * Reduce the set of matched elements to those that match the selector or pass the function's test. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + filter(obj: JQuery): JQuery; + + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param selector A string containing a selector expression to match elements against. + */ + find(selector: string): JQuery; + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param element An element to match elements against. + */ + find(element: Element): JQuery; + /** + * Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element. + * + * @param obj A jQuery object to match elements against. + */ + find(obj: JQuery): JQuery; + + /** + * Reduce the set of matched elements to the first in the set. + */ + first(): JQuery; + + /** + * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + * + * @param selector A string containing a selector expression to match elements against. + */ + has(selector: string): JQuery; + /** + * Reduce the set of matched elements to those that have a descendant that matches the selector or DOM element. + * + * @param contained A DOM element to match elements against. + */ + has(contained: Element): JQuery; + + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param selector A string containing a selector expression to match elements against. + */ + is(selector: string): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param func A function used as a test for the set of elements. It accepts one argument, index, which is the element's index in the jQuery collection.Within the function, this refers to the current DOM element. + */ + is(func: (index: number, element: Element) => boolean): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + is(obj: JQuery): boolean; + /** + * Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments. + * + * @param elements One or more elements to match the current set of elements against. + */ + is(elements: any): boolean; + + /** + * Reduce the set of matched elements to the final one in the set. + */ + last(): JQuery; + + /** + * Pass each element in the current matched set through a function, producing a new jQuery object containing the return values. + * + * @param callback A function object that will be invoked for each element in the current set. + */ + map(callback: (index: number, domElement: Element) => any): JQuery; + + /** + * Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + next(selector?: string): JQuery; + + /** + * Get all following siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + nextAll(selector?: string): JQuery; + + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param selector A string containing a selector expression to indicate where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(selector?: string, filter?: string): JQuery; + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param element A DOM node or jQuery object indicating where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(element?: Element, filter?: string): JQuery; + /** + * Get all following siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object passed. + * + * @param obj A DOM node or jQuery object indicating where to stop matching following sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + nextUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Remove elements from the set of matched elements. + * + * @param selector A string containing a selector expression to match elements against. + */ + not(selector: string): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param func A function used as a test for each element in the set. this is the current DOM element. + */ + not(func: (index: number, element: Element) => boolean): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param elements One or more DOM elements to remove from the matched set. + */ + not(...elements: Element[]): JQuery; + /** + * Remove elements from the set of matched elements. + * + * @param obj An existing jQuery object to match the current set of elements against. + */ + not(obj: JQuery): JQuery; + + /** + * Get the closest ancestor element that is positioned. + */ + offsetParent(): JQuery; + + /** + * Get the parent of each element in the current set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + parent(selector?: string): JQuery; + + /** + * Get the ancestors of each element in the current set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + parents(selector?: string): JQuery; + + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param selector A string containing a selector expression to indicate where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(selector?: string, filter?: string): JQuery; + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param element A DOM node or jQuery object indicating where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(element?: Element, filter?: string): JQuery; + /** + * Get the ancestors of each element in the current set of matched elements, up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param obj A DOM node or jQuery object indicating where to stop matching ancestor elements. + * @param filter A string containing a selector expression to match elements against. + */ + parentsUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Get the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + prev(selector?: string): JQuery; + + /** + * Get all preceding siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + prevAll(selector?: string): JQuery; + + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param selector A string containing a selector expression to indicate where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(selector?: string, filter?: string): JQuery; + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param element A DOM node or jQuery object indicating where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(element?: Element, filter?: string): JQuery; + /** + * Get all preceding siblings of each element up to but not including the element matched by the selector, DOM node, or jQuery object. + * + * @param obj A DOM node or jQuery object indicating where to stop matching preceding sibling elements. + * @param filter A string containing a selector expression to match elements against. + */ + prevUntil(obj?: JQuery, filter?: string): JQuery; + + /** + * Get the siblings of each element in the set of matched elements, optionally filtered by a selector. + * + * @param selector A string containing a selector expression to match elements against. + */ + siblings(selector?: string): JQuery; + + /** + * Reduce the set of matched elements to a subset specified by a range of indices. + * + * @param start An integer indicating the 0-based position at which the elements begin to be selected. If negative, it indicates an offset from the end of the set. + * @param end An integer indicating the 0-based position at which the elements stop being selected. If negative, it indicates an offset from the end of the set. If omitted, the range continues until the end of the set. + */ + slice(start: number, end?: number): JQuery; + + /** + * Show the queue of functions to be executed on the matched elements. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + */ + queue(queueName?: string): any[]; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + */ + queue(callback: Function): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param newQueue An array of functions to replace the current queue contents. + */ + queue(queueName: string, newQueue: Function[]): JQuery; + /** + * Manipulate the queue of functions to be executed, once for each matched element. + * + * @param queueName A string containing the name of the queue. Defaults to fx, the standard effects queue. + * @param callback The new function to add to the queue, with a function to call that will dequeue the next item. + */ + queue(queueName: string, callback: Function): JQuery; +} +declare module "jquery" { + export = $; +} +declare var jQuery: JQueryStatic; +declare var $: JQueryStatic; diff --git a/public/app/headers/require/require.d.ts b/public/app/headers/require/require.d.ts new file mode 100644 index 00000000000..c42a1bda101 --- /dev/null +++ b/public/app/headers/require/require.d.ts @@ -0,0 +1,369 @@ +// Type definitions for RequireJS 2.1.8 +// Project: http://requirejs.org/ +// Definitions by: Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* +require-2.1.8.d.ts may be freely distributed under the MIT license. + +Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +*/ + +declare module 'module' { + var mod: { + config: () => any; + id: string; + uri: string; + } + export = mod; +} + +interface RequireError extends Error { + + /** + * The error ID that maps to an ID on a web page. + **/ + requireType: string; + + /** + * Required modules. + **/ + requireModules: string[]; + + /** + * The original error, if there is one (might be null). + **/ + originalError: Error; +} + +interface RequireShim { + + /** + * List of dependencies. + **/ + deps?: string[]; + + /** + * Name the module will be exported as. + **/ + exports?: string; + + /** + * Initialize function with all dependcies passed in, + * if the function returns a value then that value is used + * as the module export value instead of the object + * found via the 'exports' string. + * @param dependencies + * @return + **/ + init?: (...dependencies: any[]) => any; +} + +interface RequireConfig { + + // The root path to use for all module lookups. + baseUrl?: string; + + // Path mappings for module names not found directly under + // baseUrl. + paths?: { [key: string]: any; }; + + // Dictionary of Shim's. + // does not cover case of key->string[] + shim?: { [key: string]: RequireShim; }; + + /** + * For the given module prefix, instead of loading the + * module with the given ID, substitude a different + * module ID. + * + * @example + * requirejs.config({ + * map: { + * 'some/newmodule': { + * 'foo': 'foo1.2' + * }, + * 'some/oldmodule': { + * 'foo': 'foo1.0' + * } + * } + * }); + **/ + map?: { + [id: string]: { + [id: string]: string; + }; + }; + + /** + * AMD configurations, use module.config() to access in + * define() functions + **/ + config?: { [id: string]: {}; }; + + /** + * Configures loading modules from CommonJS packages. + **/ + packages?: {}; + + /** + * The number of seconds to wait before giving up on loading + * a script. The default is 7 seconds. + **/ + waitSeconds?: number; + + /** + * A name to give to a loading context. This allows require.js + * to load multiple versions of modules in a page, as long as + * each top-level require call specifies a unique context string. + **/ + context?: string; + + /** + * An array of dependencies to load. + **/ + deps?: string[]; + + /** + * A function to pass to require that should be require after + * deps have been loaded. + * @param modules + **/ + callback?: (...modules: any[]) => void; + + /** + * If set to true, an error will be thrown if a script loads + * that does not call define() or have shim exports string + * value that can be checked. + **/ + enforceDefine?: boolean; + + /** + * If set to true, document.createElementNS() will be used + * to create script elements. + **/ + xhtml?: boolean; + + /** + * Extra query string arguments appended to URLs that RequireJS + * uses to fetch resources. Most useful to cachce bust when + * the browser or server is not configured correcty. + * + * @example + * urlArgs: "bust= + (new Date()).getTime() + **/ + urlArgs?: string; + + /** + * Specify the value for the type="" attribute used for script + * tags inserted into the document by RequireJS. Default is + * "text/javascript". To use Firefox's JavasScript 1.8 + * features, use "text/javascript;version=1.8". + **/ + scriptType?: string; + +} + +// todo: not sure what to do with this guy +interface RequireModule { + + /** + * + **/ + config(): {}; + +} + +/** +* +**/ +interface RequireMap { + + /** + * + **/ + prefix: string; + + /** + * + **/ + name: string; + + /** + * + **/ + parentMap: RequireMap; + + /** + * + **/ + url: string; + + /** + * + **/ + originalName: string; + + /** + * + **/ + fullName: string; +} + +interface Require { + + /** + * Configure require.js + **/ + config(config: RequireConfig): Require; + + /** + * CommonJS require call + * @param module Module to load + * @return The loaded module + */ + (module: string): any; + + /** + * Start the main app logic. + * Callback is optional. + * Can alternatively use deps and callback. + * @param modules Required modules to load. + **/ + (modules: string[]): void; + + /** + * @see Require() + * @param ready Called when required modules are ready. + **/ + (modules: string[], ready: Function): void; + + /** + * @see http://requirejs.org/docs/api.html#errbacks + * @param ready Called when required modules are ready. + **/ + (modules: string[], ready: Function, errback: Function): void; + + /** + * Generate URLs from require module + * @param module Module to URL + * @return URL string + **/ + toUrl(module: string): string; + + /** + * Returns true if the module has already been loaded and defined. + * @param module Module to check + **/ + defined(module: string): boolean; + + /** + * Returns true if the module has already been requested or is in the process of loading and should be available at some point. + * @param module Module to check + **/ + specified(module: string): boolean; + + /** + * On Error override + * @param err + **/ + onError(err: RequireError, errback?: (err: RequireError) => void): void; + + /** + * Undefine a module + * @param module Module to undefine. + **/ + undef(module: string): void; + + /** + * Semi-private function, overload in special instance of undef() + **/ + onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void; +} + +interface RequireDefine { + + /** + * Define Simple Name/Value Pairs + * @param config Dictionary of Named/Value pairs for the config. + **/ + (config: { [key: string]: any; }): void; + + /** + * Define function. + * @param func: The function module. + **/ + (func: () => any): void; + + /** + * Define function with dependencies. + * @param deps List of dependencies module IDs. + * @param ready Callback function when the dependencies are loaded. + * callback param deps module dependencies + * callback return module definition + **/ + (deps: string[], ready: Function): void; + + /** + * Define module with simplified CommonJS wrapper. + * @param ready + * callback require requirejs instance + * callback exports exports object + * callback module module + * callback return module definition + **/ + (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void; + + /** + * Define a module with a name and dependencies. + * @param name The name of the module. + * @param deps List of dependencies module IDs. + * @param ready Callback function when the dependencies are loaded. + * callback deps module dependencies + * callback return module definition + **/ + (name: string, deps: string[], ready: Function): void; + + /** + * Define a module with a name. + * @param name The name of the module. + * @param ready Callback function when the dependencies are loaded. + * callback return module definition + **/ + (name: string, ready: Function): void; + + /** + * Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms + * to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object. + * This helps avoid conflict with any other existing JavaScript code that could have defined a define() function + * that does not conform to the AMD API. + * define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version + * of jQuery being loaded simultaneously. + */ + amd: Object; +} + +// Ambient declarations for 'require' and 'define' +declare var requirejs: Require; +declare var require: Require; +declare var define: RequireDefine; diff --git a/public/app/partials/signup_step2.html b/public/app/partials/signup_step2.html index a604d216372..4ecd3b67be0 100644 --- a/public/app/partials/signup_step2.html +++ b/public/app/partials/signup_step2.html @@ -90,7 +90,7 @@
diff --git a/tasks/build_task.js b/tasks/build_task.js index 63334cbec5a..ab6fe5c9fbc 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -15,14 +15,14 @@ module.exports = function(grunt) { 'ngtemplates', 'cssmin:build', 'ngAnnotate:build', - 'requirejs:build', - 'concat:js', - 'clean:temp', - 'filerev', - 'remapFilerev', - 'usemin', - 'clean:temp', - 'uglify:dest' + // 'requirejs:build', + // 'concat:js', + // 'clean:temp', + // 'filerev', + // 'remapFilerev', + // 'usemin', + // 'clean:temp', + // 'uglify:genDir' ]); // task to add [[.AppSubUrl]] to reved path diff --git a/tasks/options/tslint.js b/tasks/options/tslint.js new file mode 100644 index 00000000000..18609b33c93 --- /dev/null +++ b/tasks/options/tslint.js @@ -0,0 +1,23 @@ +module.exports = function(config) { + return { + source: { + files: { + src: ['<%= srcDir %>/app/**/*.ts', '!<%= srcDir %>/app/**/*.d.ts'], + } + }, + options: { + configuration: { + rules: { + curly: true, + align: [true, "parameters", "arguments", "statements"], + indent: [true, "spaces"], + "class-name": true, + "interface-name": true, + "semicolon": true, + "use-strict": [true, "check-module", "check-function" ], + "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"], + } + } + } + }; +}; diff --git a/tasks/options/uglify.js b/tasks/options/uglify.js index 04e892a308a..23fac003acb 100644 --- a/tasks/options/uglify.js +++ b/tasks/options/uglify.js @@ -1,6 +1,6 @@ module.exports = function(config) { return { - dest: { + genDir: { expand: true, src: ['**/*.js', '!dashboards/*.js', '!vendor/**/*.js'], dest: '<%= genDir %>', From 84371f03b5dacb700226974f0368f40a49813e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Sep 2015 16:47:38 +0200 Subject: [PATCH 10/12] tech(typescript): more testing and migration --- public/app/app.js | 2 +- public/app/core/core.ts | 1 + public/app/core/filters/filters.ts | 81 ++++++++++++++++++++++++++++++ public/app/filters/all.js | 72 -------------------------- tasks/build_task.js | 16 +++--- tasks/options/requirejs.js | 2 +- 6 files changed, 92 insertions(+), 82 deletions(-) create mode 100644 public/app/core/filters/filters.ts delete mode 100755 public/app/filters/all.js diff --git a/public/app/app.js b/public/app/app.js index e91efa1169a..e543b34a611 100644 --- a/public/app/app.js +++ b/public/app/app.js @@ -80,11 +80,11 @@ function (angular, $, _, appLevelRequire) { }); var preBootRequires = [ + 'core/core', 'services/all', 'features/all', 'controllers/all', 'directives/all', - 'filters/all', 'components/partials', 'routes/all', ]; diff --git a/public/app/core/core.ts b/public/app/core/core.ts index dc72df22e38..1dbd6511e53 100644 --- a/public/app/core/core.ts +++ b/public/app/core/core.ts @@ -1,5 +1,6 @@ export * from './directives/cool_dir' export * from './routes/module_loader' +export * from './filters/filters' diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts new file mode 100644 index 00000000000..5868dad5140 --- /dev/null +++ b/public/app/core/filters/filters.ts @@ -0,0 +1,81 @@ +/// +/// +/// +/// +/// +/// + +var angular = require('angular'); +var jquery = require('jquery'); +var moment = require('moment'); +var _ = require('lodash'); + +var module = angular.module('grafana.filters'); + +module.filter('stringSort', function() { + return function(input) { + return input.sort(); + }; +}); + +module.filter('slice', function() { + return function(arr, start, end) { + if(!_.isUndefined(arr)) { + return arr.slice(start, end); + } + }; +}); + +module.filter('stringify', function() { + return function(arr) { + if(_.isObject(arr) && !_.isArray(arr)) { + return angular.toJson(arr); + } else { + return _.isNull(arr) ? null : arr.toString(); + } + }; +}); + +module.filter('moment', function() { + return function(date,mode) { + switch(mode) { + case 'ago': + return moment(date).fromNow(); + } + return moment(date).fromNow(); + }; +}); + +module.filter('noXml', function() { + var noXml = function(text) { + return _.isString(text) + ? text + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/'/g, ''') + .replace(/"/g, '"') + : text; + }; + return function(text) { + return _.isArray(text) + ? _.map(text, noXml) + : noXml(text); + }; +}); + +module.filter('interpolateTemplateVars', function(templateSrv) { + var interpolateTemplateVars : any = function (text, scope) { + if (scope.panel) { + return templateSrv.replaceWithText(text, scope.panel.scopedVars); + } else { + return templateSrv.replaceWithText(text, scope.row.scopedVars); + } + } + + interpolateTemplateVars.$stateful = true; + + return interpolateTemplateVars; +}); + +export function filters() {} diff --git a/public/app/filters/all.js b/public/app/filters/all.js deleted file mode 100755 index c904c7c9449..00000000000 --- a/public/app/filters/all.js +++ /dev/null @@ -1,72 +0,0 @@ -define(['angular', 'jquery', 'lodash', 'moment'], function (angular, $, _, moment) { - 'use strict'; - - var module = angular.module('grafana.filters'); - - module.filter('stringSort', function() { - return function(input) { - return input.sort(); - }; - }); - - module.filter('slice', function() { - return function(arr, start, end) { - if(!_.isUndefined(arr)) { - return arr.slice(start, end); - } - }; - }); - - module.filter('stringify', function() { - return function(arr) { - if(_.isObject(arr) && !_.isArray(arr)) { - return angular.toJson(arr); - } else { - return _.isNull(arr) ? null : arr.toString(); - } - }; - }); - - module.filter('moment', function() { - return function(date,mode) { - switch(mode) { - case 'ago': - return moment(date).fromNow(); - } - return moment(date).fromNow(); - }; - }); - - module.filter('noXml', function() { - var noXml = function(text) { - return _.isString(text) - ? text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/'/g, ''') - .replace(/"/g, '"') - : text; - }; - return function(text) { - return _.isArray(text) - ? _.map(text, noXml) - : noXml(text); - }; - }); - - module.filter('interpolateTemplateVars', function(templateSrv) { - function interpolateTemplateVars(text, scope) { - if (scope.panel) { - return templateSrv.replaceWithText(text, scope.panel.scopedVars); - } else { - return templateSrv.replaceWithText(text, scope.row.scopedVars); - } - } - - interpolateTemplateVars.$stateful = true; - - return interpolateTemplateVars; - }); - -}); diff --git a/tasks/build_task.js b/tasks/build_task.js index ab6fe5c9fbc..ed6387e69ea 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -15,14 +15,14 @@ module.exports = function(grunt) { 'ngtemplates', 'cssmin:build', 'ngAnnotate:build', - // 'requirejs:build', - // 'concat:js', - // 'clean:temp', - // 'filerev', - // 'remapFilerev', - // 'usemin', - // 'clean:temp', - // 'uglify:genDir' + 'requirejs:build', + 'concat:js', + 'clean:temp', + 'filerev', + 'remapFilerev', + 'usemin', + 'clean:temp', + 'uglify:genDir' ]); // task to add [[.AppSubUrl]] to reved path diff --git a/tasks/options/requirejs.js b/tasks/options/requirejs.js index f3a113048c9..953e5552d3d 100644 --- a/tasks/options/requirejs.js +++ b/tasks/options/requirejs.js @@ -54,10 +54,10 @@ module.exports = function(config,grunt) { 'jquery.flot', 'angular-strap', 'angular-dragdrop', + 'core/core', 'services/all', 'features/all', 'directives/all', - 'filters/all', 'controllers/all', 'routes/all', 'components/partials', From d4a701aad04dea3f8de2083adf9cb61e60161e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 11 Sep 2015 07:47:00 +0200 Subject: [PATCH 11/12] tech(typescript): more work on typescript --- public/app/core/filters/filters.ts | 17 +- public/app/headers/common.d.ts | 4 + public/app/headers/lodash/lodash.d.ts | 8521 ++++++++++++++++++++ public/app/headers/moment/moment-node.d.ts | 479 ++ public/app/headers/moment/moment.d.ts | 8 + 5 files changed, 9018 insertions(+), 11 deletions(-) create mode 100644 public/app/headers/common.d.ts create mode 100644 public/app/headers/lodash/lodash.d.ts create mode 100644 public/app/headers/moment/moment-node.d.ts create mode 100644 public/app/headers/moment/moment.d.ts diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts index 5868dad5140..f6f0fd518fe 100644 --- a/public/app/core/filters/filters.ts +++ b/public/app/core/filters/filters.ts @@ -1,14 +1,9 @@ -/// -/// -/// -/// -/// -/// - -var angular = require('angular'); -var jquery = require('jquery'); -var moment = require('moment'); -var _ = require('lodash'); +/// +// +import angular = require('angular'); +import jquery = require('jquery'); +import moment = require('moment'); +import _ = require('lodash'); var module = angular.module('grafana.filters'); diff --git a/public/app/headers/common.d.ts b/public/app/headers/common.d.ts new file mode 100644 index 00000000000..c4d1812a075 --- /dev/null +++ b/public/app/headers/common.d.ts @@ -0,0 +1,4 @@ +/// +/// +/// +/// diff --git a/public/app/headers/lodash/lodash.d.ts b/public/app/headers/lodash/lodash.d.ts new file mode 100644 index 00000000000..b6c95710bd9 --- /dev/null +++ b/public/app/headers/lodash/lodash.d.ts @@ -0,0 +1,8521 @@ +// Type definitions for Lo-Dash +// Project: http://lodash.com/ +// Definitions by: Brian Zengel , Ilya Mochalov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var _: _.LoDashStatic; + +declare module _ { + interface LoDashStatic { + /** + * Creates a lodash object which wraps the given value to enable intuitive method chaining. + * + * In addition to Lo-Dash methods, wrappers also have the following Array methods: + * concat, join, pop, push, reverse, shift, slice, sort, splice, and unshift + * + * Chaining is supported in custom builds as long as the value method is implicitly or + * explicitly included in the build. + * + * The chainable wrapper functions are: + * after, assign, bind, bindAll, bindKey, chain, chunk, compact, compose, concat, countBy, + * createCallback, curry, debounce, defaults, defer, delay, difference, filter, flatten, + * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, + * indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, + * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, + * remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times, + * toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip + * + * The non-chainable wrapper functions are: + * clone, cloneDeep, contains, escape, every, find, findIndex, findKey, findLast, + * findLastIndex, findLastKey, has, identity, indexOf, isArguments, isArray, isBoolean, + * isDate, isElement, isEmpty, isEqual, isFinite, isFunction, isNaN, isNull, isNumber, + * isObject, isPlainObject, isRegExp, isString, isUndefined, join, lastIndexOf, mixin, + * noConflict, parseInt, pop, random, reduce, reduceRight, result, shift, size, some, + * sortedIndex, runInContext, template, unescape, uniqueId, and value + * + * The wrapper functions first and last return wrapped values when n is provided, otherwise + * they return unwrapped values. + * + * Explicit chaining can be enabled by using the _.chain method. + **/ + (value: number): LoDashWrapper; + (value: string): LoDashStringWrapper; + (value: boolean): LoDashWrapper; + (value: Array): LoDashNumberArrayWrapper; + (value: Array): LoDashArrayWrapper; + (value: T): LoDashObjectWrapper; + (value: any): LoDashWrapper; + + /** + * The semantic version number. + **/ + VERSION: string; + + /** + * An object used to flag environments features. + **/ + support: Support; + + /** + * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby + * (ERB). Change the following template settings to use alternative delimiters. + **/ + templateSettings: TemplateSettings; + } + + /** + * By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby + * (ERB). Change the following template settings to use alternative delimiters. + **/ + interface TemplateSettings { + /** + * The "escape" delimiter. + **/ + escape?: RegExp; + + /** + * The "evaluate" delimiter. + **/ + evaluate?: RegExp; + + /** + * An object to import into the template as local variables. + **/ + imports?: Dictionary; + + /** + * The "interpolate" delimiter. + **/ + interpolate?: RegExp; + + /** + * Used to reference the data object in the template text. + **/ + variable?: string; + } + + /** + * Creates a cache object to store key/value pairs. + */ + interface MapCache { + /** + * Removes `key` and its value from the cache. + * @param key The key of the value to remove. + * @return Returns `true` if the entry was removed successfully, else `false`. + */ + delete(key: string): boolean; + + /** + * Gets the cached value for `key`. + * @param key The key of the value to get. + * @return Returns the cached value. + */ + get(key: string): any; + + /** + * Checks if a cached value for `key` exists. + * @param key The key of the entry to check. + * @return Returns `true` if an entry for `key` exists, else `false`. + */ + has(key: string): boolean; + + /** + * Sets `value` to `key` of the cache. + * @param key The key of the value to cache. + * @param value The value to cache. + * @return Returns the cache object. + */ + set(key: string, value: any): _.Dictionary; + } + + /** + * An object used to flag environments features. + **/ + interface Support { + /** + * Detect if an arguments object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). + **/ + argsClass: boolean; + + /** + * Detect if arguments objects are Object objects (all but Narwhal and Opera < 10.5). + **/ + argsObject: boolean; + + /** + * Detect if name or message properties of Error.prototype are enumerable by default. + * (IE < 9, Safari < 5.1) + **/ + enumErrorProps: boolean; + + /** + * Detect if prototype properties are enumerable by default. + * + * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 (if the prototype or a property on the + * prototype has been set) incorrectly set the [[Enumerable]] value of a function’s prototype property to true. + **/ + enumPrototypes: boolean; + + /** + * Detect if Function#bind exists and is inferred to be fast (all but V8). + **/ + fastBind: boolean; + + /** + * Detect if functions can be decompiled by Function#toString (all but PS3 and older Opera + * mobile browsers & avoided in Windows 8 apps). + **/ + funcDecomp: boolean; + + /** + * Detect if Function#name is supported (all but IE). + **/ + funcNames: boolean; + + /** + * Detect if arguments object indexes are non-enumerable (Firefox < 4, IE < 9, PhantomJS, + * Safari < 5.1). + **/ + nonEnumArgs: boolean; + + /** + * Detect if properties shadowing those on Object.prototype are non-enumerable. + * + * In IE < 9 an objects own properties, shadowing non-enumerable ones, are made + * non-enumerable as well (a.k.a the JScript [[DontEnum]] bug). + **/ + nonEnumShadows: boolean; + + /** + * Detect if own properties are iterated after inherited properties (all but IE < 9). + **/ + ownLast: boolean; + + /** + * Detect if Array#shift and Array#splice augment array-like objects correctly. + * + * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array shift() and splice() + * functions that fail to remove the last element, value[0], of array-like objects even + * though the length property is set to 0. The shift() method is buggy in IE 8 compatibility + * mode, while splice() is buggy regardless of mode in IE < 9 and buggy in compatibility mode + * in IE 9. + **/ + spliceObjects: boolean; + + /** + * Detect lack of support for accessing string characters by index. + * + * IE < 8 can't access characters by index and IE 8 can only access characters by index on + * string literals. + **/ + unindexedChars: boolean; + } + + interface LoDashWrapperBase { + /** + * Produces the toString result of the wrapped value. + * @return Returns the string result. + **/ + toString(): string; + + /** + * Executes the chained sequence to extract the unwrapped value. + * @return Returns the resolved unwrapped value. + **/ + value(): T; + + /** + * @see _.value + **/ + run(): T; + + /** + * @see _.value + **/ + toJSON(): T; + + /** + * @see _.value + **/ + valueOf(): T; + + /** + * @see _.toPlainObject + */ + toPlainObject(): Object; + } + + interface LoDashWrapper extends LoDashWrapperBase> { } + + interface LoDashStringWrapper extends LoDashWrapper { } + + interface LoDashObjectWrapper extends LoDashWrapperBase> { } + + interface LoDashArrayWrapper extends LoDashWrapperBase> { + concat(...items: Array>): LoDashArrayWrapper; + join(seperator?: string): string; + pop(): T; + push(...items: T[]): LoDashArrayWrapper; + reverse(): LoDashArrayWrapper; + shift(): T; + slice(start: number, end?: number): LoDashArrayWrapper; + sort(compareFn?: (a: T, b: T) => number): LoDashArrayWrapper; + splice(start: number): LoDashArrayWrapper; + splice(start: number, deleteCount: number, ...items: any[]): LoDashArrayWrapper; + unshift(...items: T[]): LoDashArrayWrapper; + } + + interface LoDashNumberArrayWrapper extends LoDashArrayWrapper { } + + //_.chain + interface LoDashStatic { + /** + * Creates a lodash object that wraps the given value with explicit method chaining enabled. + * @param value The value to wrap. + * @return The wrapper object. + **/ + chain(value: number): LoDashWrapper; + chain(value: string): LoDashWrapper; + chain(value: boolean): LoDashWrapper; + chain(value: Array): LoDashArrayWrapper; + chain(value: T): LoDashObjectWrapper; + chain(value: any): LoDashWrapper; + } + + interface LoDashWrapperBase { + /** + * Enables explicit method chaining on the wrapper object. + * @see _.chain + * @return The wrapper object. + **/ + chain(): TWrapper; + } + + //_.tap + interface LoDashStatic { + /** + * Invokes interceptor with the value as the first argument and then returns value. The + * purpose of this method is to "tap into" a method chain in order to perform operations on + * intermediate results within the chain. + * @param value The value to provide to interceptor + * @param interceptor The function to invoke. + * @return value + **/ + tap( + value: T, + interceptor: (value: T) => void): T; + } + + interface LoDashWrapperBase { + /** + * @see _.tap + **/ + tap(interceptor: (value: T) => void): TWrapper; + } + + /********* + * Arrays * + **********/ + + //_.chunk + interface LoDashStatic { + /** + * Creates an array of elements split into groups the length of size. If collection can't be + * split evenly, the final chunk will be the remaining elements. + * @param array The array to process. + * @param size The length of each chunk. + * @return Returns the new array containing chunks. + **/ + chunk(array: Array, size?: number): T[][]; + + /** + * @see _.chunk + **/ + chunk(array: List, size?: number): T[][]; + } + + interface LoDashArrayWrapper { + /** + * @see _.chunk + **/ + chunk(size?: number): LoDashArrayWrapper; + } + + //_.compact + interface LoDashStatic { + /** + * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", + * undefined and NaN are all falsy. + * @param array Array to compact. + * @return (Array) Returns a new array of filtered values. + **/ + compact(array?: Array): T[]; + + /** + * @see _.compact + **/ + compact(array?: List): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.compact + **/ + compact(): LoDashArrayWrapper; + } + + //_.difference + interface LoDashStatic { + /** + * Creates an array excluding all values of the provided arrays using strict equality for comparisons + * , i.e. ===. + * @param array The array to process + * @param others The arrays of values to exclude. + * @return Returns a new array of filtered values. + **/ + difference( + array?: Array, + ...others: Array[]): T[]; + /** + * @see _.difference + **/ + difference( + array?: List, + ...others: List[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.difference + **/ + difference( + ...others: Array[]): LoDashArrayWrapper; + /** + * @see _.difference + **/ + difference( + ...others: List[]): LoDashArrayWrapper; + } + + //_.findIndex + interface LoDashStatic { + /** + * This method is like _.find except that it returns the index of the first element that passes + * the callback check, instead of the element itself. + * @param array The array to search. + * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be + * used to create a ".pluck" or ".where" style callback, respectively. + * @param thisArg The this binding of callback. + * @return Returns the index of the found element, else -1. + **/ + findIndex( + array: Array, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: List, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, + pluckValue: string): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: List, + pluckValue: string): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, + whereDictionary: W): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: List, + whereDictionary: W): number; + } + + //_.findLastIndex + interface LoDashStatic { + /** + * This method is like _.findIndex except that it iterates over elements of a collection from right to left. + * @param array The array to search. + * @param {(Function|Object|string)} callback The function called per iteration. If a property name or object is provided it will be + * used to create a ".pluck" or ".where" style callback, respectively. + * @param thisArg The this binding of callback. + * @return Returns the index of the found element, else -1. + **/ + findLastIndex( + array: Array, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: List, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + pluckValue: string): number; + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: List, + pluckValue: string): number; + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + whereDictionary: Dictionary): number; + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: List, + whereDictionary: Dictionary): number; + } + + //_.first + interface LoDashStatic { + /** + * Gets the first element or first n elements of an array. If a callback is provided + * elements at the beginning of the array are returned as long as the callback returns + * truey. The callback is bound to thisArg and invoked with three arguments; (value, + * index, array). + * + * If a property name is provided for callback the created "_.pluck" style callback + * will return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return ] + * true for elements that have the properties of the given object, else false. + * @param array Retrieves the first element of this array. + * @return Returns the first element of `array`. + **/ + first(array?: Array): T; + + /** + * @see _.first + **/ + first(array?: List): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + first( + array: Array, + n: number): T[]; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + first( + array: List, + n: number): T[]; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first( + array: Array, + whereValue: W): T[]; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first( + array: List, + whereValue: W): T[]; + + /** + * @see _.first + **/ + head(array: Array): T; + + /** + * @see _.first + **/ + head(array: List): T; + + /** + * @see _.first + **/ + head( + array: Array, + n: number): T[]; + + /** + * @see _.first + **/ + head( + array: List, + n: number): T[]; + + /** + * @see _.first + **/ + head( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + head( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + head( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + head( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + head( + array: Array, + whereValue: W): T[]; + + /** + * @see _.first + **/ + head( + array: List, + whereValue: W): T[]; + + /** + * @see _.first + **/ + take(array: Array): T[]; + + /** + * @see _.first + **/ + take(array: List): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + n: number): T[]; + + /** + * @see _.first + **/ + take( + array: List, + n: number): T[]; + + /** + * Takes the first items from an array or list based on a predicate + * @param array The array or list of items on which the result set will be based + * @param predicate A predicate function to determine whether a value will be taken. Optional; defaults to identity. + * @param [thisArg] The this binding of predicate. + */ + takeWhile( + array: (Array|List), + predicate?: ListIterator, + thisArg?: any + ): T[]; + + /** + * Takes the first items from an array or list based on a predicate + * @param array The array or list of items on which the result set will be based + * @param pluckValue Uses a _.property style callback to return the property value of the given element + */ + takeWhile( + array: (Array|List), + pluckValue: string + ): any[]; + + /** + * Takes the first items from an array or list based on a predicate + * @param array The array or list of items on which the result set will be based + * @param whereValue Uses a _.matches style callback to return the first elements that match the given value + */ + takeWhile( + array: (Array|List), + whereValue: W + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.first + **/ + first(): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + first(n: number): LoDashArrayWrapper; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first(whereValue: W): LoDashArrayWrapper; + + /** + * @see _.first + **/ + head(): T; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + head(n: number): LoDashArrayWrapper; + + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + head( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + head(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + head(whereValue: W): LoDashArrayWrapper; + + /** + * @see _.first + **/ + take(): LoDashArrayWrapper; + + /** + * @see _.first + * @param n The number of elements to return. + **/ + take(n: number): LoDashArrayWrapper; + + /** + * Takes the first items based on a predicate + * @param predicate The function called per element. + * @param [thisArg] The this binding of callback. + **/ + takeWhile( + predicate: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * Takes the first items based on a predicate + * @param pluckValue Uses a _.property style callback to return the property value of the given element + **/ + takeWhile( + pluckValue: string): LoDashArrayWrapper; + + /** + * Takes the first items based on a predicate + * @param whereValue Uses a _.matches style callback to return the first elements that match the given value + **/ + takeWhile( + whereValue: W): LoDashArrayWrapper; + + } + + interface MaybeNestedList extends List> { } + interface RecursiveList extends List> { } + + //_.flatten + interface LoDashStatic { + /** + * Flattens a nested array a single level. + * + * _.flatten(x) is equivalent to _.flatten(x, false); + * + * @param array The array to flatten. + * @return `array` flattened. + **/ + flatten(array: MaybeNestedList): T[]; + + /** + * Flattens a nested array. If isDeep is true the array is recursively flattened, otherwise it is only + * flattened a single level. + * + * If you know whether or not this should be recursively at compile time, you typically want to use a + * version without a boolean parameter (i.e. `_.flatten(x)` or `_.flattenDeep(x)`). + * + * @param array The array to flatten. + * @param deep Specify a deep flatten. + * @return `array` flattened. + **/ + flatten(array: RecursiveList, isDeep: boolean): List | RecursiveList; + + /** + * Recursively flattens a nested array. + * + * _.flattenDeep(x) is equivalent to _.flatten(x, true); + * + * @param array The array to flatten + * @return `array` recursively flattened + */ + flattenDeep(array: RecursiveList): List + } + + interface LoDashArrayWrapper { + /** + * @see _.flatten + **/ + flatten(): LoDashArrayWrapper; + + /** + * @see _.flatten + **/ + flatten(isShallow: boolean): LoDashArrayWrapper; + + /** + * @see _.flattenDeep + */ + flattenDeep(): LoDashArrayWrapper; + } + + //_.indexOf + interface LoDashStatic { + /** + * Gets the index at which the first occurrence of value is found using strict equality + * for comparisons, i.e. ===. If the array is already sorted providing true for fromIndex + * will run a faster binary search. + * @param array The array to search. + * @param value The value to search for. + * @param fromIndex The index to search from. + * @return The index of `value` within `array`. + **/ + indexOf( + array: Array, + value: T): number; + + /** + * @see _.indexOf + **/ + indexOf( + array: List, + value: T): number; + + /** + * @see _.indexOf + * @param fromIndex The index to search from + **/ + indexOf( + array: Array, + value: T, + fromIndex: number): number; + + /** + * @see _.indexOf + * @param fromIndex The index to search from + **/ + indexOf( + array: List, + value: T, + fromIndex: number): number; + + /** + * @see _.indexOf + * @param isSorted True to perform a binary search on a sorted array. + **/ + indexOf( + array: Array, + value: T, + isSorted: boolean): number; + + /** + * @see _.indexOf + * @param isSorted True to perform a binary search on a sorted array. + **/ + indexOf( + array: List, + value: T, + isSorted: boolean): number; + } + + //_.initial + interface LoDashStatic { + /** + * Gets all but the last element or last n elements of an array. If a callback is provided + * elements at the end of the array are excluded from the result as long as the callback + * returns truey. The callback is bound to thisArg and invoked with three arguments; + * (value, index, array). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param array The array to query. + * @param n Leaves this many elements behind, optional. + * @return Returns everything but the last `n` elements of `array`. + **/ + initial( + array: Array): T[]; + + /** + * @see _.initial + **/ + initial( + array: List): T[]; + + /** + * @see _.initial + * @param n The number of elements to exclude. + **/ + initial( + array: Array, + n: number): T[]; + + /** + * @see _.initial + * @param n The number of elements to exclude. + **/ + initial( + array: List, + n: number): T[]; + + /** + * @see _.initial + * @param callback The function called per element + **/ + initial( + array: Array, + callback: ListIterator): T[]; + + /** + * @see _.initial + * @param callback The function called per element + **/ + initial( + array: List, + callback: ListIterator): T[]; + + /** + * @see _.initial + * @param pluckValue _.pluck style callback + **/ + initial( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.initial + * @param pluckValue _.pluck style callback + **/ + initial( + array: List, + pluckValue: string): T[]; + + /** + * @see _.initial + * @param whereValue _.where style callback + **/ + initial( + array: Array, + whereValue: W): T[]; + + /** + * @see _.initial + * @param whereValue _.where style callback + **/ + initial( + array: List, + whereValue: W): T[]; + } + + //_.intersection + interface LoDashStatic { + /** + * Creates an array of unique values present in all provided arrays using strict + * equality for comparisons, i.e. ===. + * @param arrays The arrays to inspect. + * @return Returns an array of composite values. + **/ + intersection(...arrays: Array[]): T[]; + + /** + * @see _.intersection + **/ + intersection(...arrays: List[]): T[]; + } + + //_.last + interface LoDashStatic { + /** + * Gets the last element of an array. + * @param array The array to query. + * @return Returns the last element of array. + **/ + last(array: Array): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.last + **/ + last(): T; + } + + //_.lastIndexOf + interface LoDashStatic { + /** + * Gets the index at which the last occurrence of value is found using strict equality + * for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the + * end of the collection. + * @param array The array to search. + * @param value The value to search for. + * @param fromIndex The index to search from. + * @return The index of the matched value or -1. + **/ + lastIndexOf( + array: Array, + value: T, + fromIndex?: number): number; + + /** + * @see _.lastIndexOf + **/ + lastIndexOf( + array: List, + value: T, + fromIndex?: number): number; + } + + //_.pull + interface LoDashStatic { + /** + * Removes all provided values from the given array using strict equality for comparisons, + * i.e. ===. + * @param array The array to modify. + * @param values The values to remove. + * @return array. + **/ + pull( + array: Array, + ...values: T[]): T[]; + + /** + * @see _.pull + **/ + pull( + array: List, + ...values: T[]): T[]; + } + + interface LoDashStatic { + /** + * Removes all provided values from the given array using strict equality for comparisons, + * i.e. ===. + * @param array The array to modify. + * @param values The values to remove. + * @return array. + **/ + pullAt( + array: Array, + ...values: any[]): any[]; + + /** + * @see _.pull + **/ + pullAt( + array: List, + ...values: any[]): any[]; + } + + //_.remove + interface LoDashStatic { + /** + * Removes all elements from an array that the callback returns truey for and returns + * an array of removed elements. The callback is bound to thisArg and invoked with three + * arguments; (value, index, array). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param array The array to modify. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return A new array of removed elements. + **/ + remove( + array: Array, + callback?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.remove + **/ + remove( + array: List, + callback?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.remove + * @param pluckValue _.pluck style callback + **/ + remove( + array: Array, + pluckValue?: string): T[]; + + /** + * @see _.remove + * @param pluckValue _.pluck style callback + **/ + remove( + array: List, + pluckValue?: string): T[]; + + /** + * @see _.remove + * @param whereValue _.where style callback + **/ + remove( + array: Array, + wherealue?: Dictionary): T[]; + + /** + * @see _.remove + * @param whereValue _.where style callback + **/ + remove( + array: List, + wherealue?: Dictionary): T[]; + + /** + * @see _.remove + * @param item The item to remove + **/ + remove( + array:Array, + item:T): T[]; + } + + //_.rest + interface LoDashStatic { + /** + * The opposite of _.initial this method gets all but the first element or first n elements of + * an array. If a callback function is provided elements at the beginning of the array are excluded + * from the result as long as the callback returns truey. The callback is bound to thisArg and + * invoked with three arguments; (value, index, array). + * + * If a property name is provided for callback the created "_.pluck" style callback will return + * the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return true + * for elements that have the properties of the given object, else false. + * @param array The array to query. + * @param {(Function|Object|number|string)} [callback=1] The function called per element or the number + * of elements to exclude. If a property name or object is provided it will be used to create a + * ".pluck" or ".where" style callback, respectively. + * @param {*} [thisArg] The this binding of callback. + * @return Returns a slice of array. + **/ + rest(array: Array): T[]; + + /** + * @see _.rest + **/ + rest(array: List): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + rest( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + n: number): T[]; + + /** + * @see _.rest + **/ + rest( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + rest( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + rest( + array: List, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + drop(array: Array): T[]; + + /** + * @see _.rest + **/ + drop(array: List): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + n: number): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail(array: Array): T[]; + + /** + * @see _.rest + **/ + tail(array: List): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + whereValue: W): T[]; + } + + //_.sortedIndex + interface LoDashStatic { + /** + * Uses a binary search to determine the smallest index at which a value should be inserted + * into a given sorted array in order to maintain the sort order of the array. If a callback + * is provided it will be executed for value and each element of array to compute their sort + * ranking. The callback is bound to thisArg and invoked with one argument; (value). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param array The sorted list. + * @param value The value to determine its index within `list`. + * @param callback Iterator to compute the sort ranking of each value, optional. + * @return The index at which value should be inserted into array. + **/ + sortedIndex( + array: Array, + value: T, + callback?: (x: T) => TSort, + thisArg?: any): number; + + /** + * @see _.sortedIndex + **/ + sortedIndex( + array: List, + value: T, + callback?: (x: T) => TSort, + thisArg?: any): number; + + /** + * @see _.sortedIndex + * @param pluckValue the _.pluck style callback + **/ + sortedIndex( + array: Array, + value: T, + pluckValue: string): number; + + /** + * @see _.sortedIndex + * @param pluckValue the _.pluck style callback + **/ + sortedIndex( + array: List, + value: T, + pluckValue: string): number; + + /** + * @see _.sortedIndex + * @param pluckValue the _.where style callback + **/ + sortedIndex( + array: Array, + value: T, + whereValue: W): number; + + /** + * @see _.sortedIndex + * @param pluckValue the _.where style callback + **/ + sortedIndex( + array: List, + value: T, + whereValue: W): number; + } + + //_.union + interface LoDashStatic { + /** + * Creates an array of unique values, in order, of the provided arrays using strict + * equality for comparisons, i.e. ===. + * @param arrays The arrays to inspect. + * @return Returns an array of composite values. + **/ + union(...arrays: Array[]): T[]; + + /** + * @see _.union + **/ + union(...arrays: List[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.union + **/ + union(...arrays: (Array|List)[]): LoDashArrayWrapper; + } + + //_.uniq + interface LoDashStatic { + /** + * Creates a duplicate-value-free version of an array using strict equality for comparisons, + * i.e. ===. If the array is sorted, providing true for isSorted will use a faster algorithm. + * If a callback is provided each element of array is passed through the callback before + * uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; + * (value, index, array). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param array Array to remove duplicates from. + * @param isSorted True if `array` is already sorted, optiona, default = false. + * @param iterator Transform the elements of `array` before comparisons for uniqueness. + * @param context 'this' object in `iterator`, optional. + * @return Copy of `array` where all elements are unique. + **/ + uniq(array: Array, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ + uniq(array: List, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ + uniq( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + uniq( + array: List, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + uniq( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + uniq( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: List, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: List, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + isSorted: boolean, + whereValue: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: List, + isSorted: boolean, + whereValue: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + whereValue: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: List, + whereValue: W): T[]; + + /** + * @see _.uniq + **/ + unique(array: Array, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ + unique(array: List, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ + unique( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + unique( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + unique( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ + unique( + array: List, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + isSorted: boolean, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + isSorted: boolean, + whereValue?: W): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.uniq + **/ + uniq(isSorted?: boolean): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + uniq( + isSorted: boolean, + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + uniq( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + isSorted: boolean, + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + isSorted: boolean, + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique(isSorted?: boolean): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique( + isSorted: boolean, + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + **/ + unique( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + isSorted: boolean, + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + isSorted: boolean, + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + whereValue: W): LoDashArrayWrapper; + } + + //_.without + interface LoDashStatic { + /** + * Creates an array excluding all provided values using strict equality for comparisons, i.e. ===. + * @param array The array to filter. + * @param values The value(s) to exclude. + * @return A new array of filtered values. + **/ + without( + array: Array, + ...values: T[]): T[]; + + /** + * @see _.without + **/ + without( + array: List, + ...values: T[]): T[]; + } + + //_.xor + interface LoDashStatic { + /** + * Creates an array of unique values that is the symmetric difference of the provided arrays. + * @param arrays The arrays to inspect. + * @return Returns the new array of values. + */ + xor(...arrays: List[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.xor + */ + xor(...arrays: T[][]): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.xor + */ + xor(...arrays: T[]): LoDashObjectWrapper; + } + + //_.zip + interface LoDashStatic { + /** + * Creates an array of grouped elements, the first of which contains the first + * elements of the given arrays, the second of which contains the second elements + * of the given arrays, and so on. + * @param arrays Arrays to process. + * @return A new array of grouped elements. + **/ + zip(...arrays: any[][]): any[][]; + + /** + * @see _.zip + **/ + zip(...arrays: any[]): any[]; + + /** + * @see _.zip + **/ + unzip(...arrays: any[][]): any[][]; + + /** + * @see _.zip + **/ + unzip(...arrays: any[]): any[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.zip + **/ + zip(...arrays: any[][]): _.LoDashArrayWrapper; + + /** + * @see _.zip + **/ + unzip(...arrays: any[]): _.LoDashArrayWrapper; + } + + //_.zipObject + interface LoDashStatic { + /** + * The inverse of _.pairs; this method returns an object composed from arrays of property + * names and values. Provide either a single two dimensional array, e.g. [[key1, value1], + * [key2, value2]] or two arrays, one of property names and one of corresponding values. + * @param props The property names. + * @param values The property values. + * @return Returns the new object. + **/ + zipObject( + props: List, + values?: List): TResult; + + /** + * @see _.zipObject + **/ + zipObject(props: List>): Dictionary; + + /** + * @see _.zipObject + **/ + object( + props: List, + values?: List): TResult; + + /** + * @see _.zipObject + **/ + object(props: List>): Dictionary; + } + + interface LoDashArrayWrapper { + /** + * @see _.zipObject + **/ + zipObject(values?: List): _.LoDashObjectWrapper>; + + /** + * @see _.zipObject + **/ + object(values?: List): _.LoDashObjectWrapper>; + } + + //_.zipWith + interface LoDashStatic { + /** + * This method is like _.zip except that it accepts an iteratee to specify how grouped values should be + * combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index, + * group). + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee] The function to combine grouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @return Returns the new array of grouped elements. + */ + zipWith(...args: any[]): TResult[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.zipWith + */ + zipWith(...args: any[]): LoDashArrayWrapper; + } + + /********* + * Chain * + *********/ + + //_.thru + interface LoDashStatic { + /** + * This method is like _.tap except that it returns the result of interceptor. + * @param value The value to provide to interceptor. + * @param interceptor The function to invoke. + * @param thisArg The this binding of interceptor. + * @return Returns the result of interceptor. + */ + thru( + value: T, + interceptor: (value: T) => TResult, + thisArg?: any): TResult; + } + + interface LoDashWrapperBase { + /** + * @see _.thru + */ + thru( + interceptor: (value: T) => TResult, + thisArg?: any): LoDashWrapper; + + /** + * @see _.thru + */ + thru( + interceptor: (value: T) => TResult, + thisArg?: any): LoDashWrapper; + + /** + * @see _.thru + */ + thru( + interceptor: (value: T) => TResult, + thisArg?: any): LoDashWrapper; + + /** + * @see _.thru + */ + thru( + interceptor: (value: T) => TResult, + thisArg?: any): LoDashObjectWrapper; + + /** + * @see _.thru + */ + thru( + interceptor: (value: T) => TResult[], + thisArg?: any): LoDashArrayWrapper; + } + + /************** + * Collection * + **************/ + + //_.at + interface LoDashStatic { + /** + * Creates an array of elements corresponding to the given keys, or indexes, of collection. Keys may be + * specified as individual arguments or as arrays of keys. + * + * @param collection The collection to iterate over. + * @param props The property names or indexes of elements to pick, specified individually or in arrays. + * @return Returns the new array of picked elements. + */ + at( + collection: List|Dictionary, + ...props: Array> + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.at + */ + at(...props: Array>): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.at + */ + at(...props: Array>): LoDashArrayWrapper; + } + + //_.contains + interface LoDashStatic { + /** + * Checks if a given value is present in a collection using strict equality for comparisons, + * i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection. + * @param collection The collection to iterate over. + * @param target The value to check for. + * @param fromIndex The index to search from. + * @return True if the target element is found, else false. + **/ + contains( + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + contains( + collection: List, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + * @param dictionary The dictionary to iterate over. + * @param value The value in the dictionary to search for. + **/ + contains( + dictionary: Dictionary, + value: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + * @param searchString the string to search + * @param targetString the string to search for + **/ + contains( + searchString: string, + targetString: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + collection: List, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + dictionary: Dictionary, + value: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + searchString: string, + targetString: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + collection: List, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + dictionary: Dictionary, + value: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes( + searchString: string, + targetString: string, + fromIndex?: number): boolean; + } + + interface LoDashArrayWrapper { + /** + * @see _.contains + **/ + contains(target: T, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include(target: T, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes(target: T, fromIndex?: number): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.contains + **/ + contains(target: TValue, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include(target: TValue, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes(target: TValue, fromIndex?: number): boolean; + } + + interface LoDashStringWrapper { + /** + * @see _.contains + **/ + contains(target: string, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include(target: string, fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + includes(target: string, fromIndex?: number): boolean; + } + + //_.countBy + interface LoDashStatic { + /** + * Creates an object composed of keys generated from the results of running each element + * of collection through the callback. The corresponding value of each key is the number + * of times the key was returned by the callback. The callback is bound to thisArg and + * invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return Returns the composed aggregate object. + **/ + countBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: List, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Array, + callback: string, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: List, + callback: string, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback: string, + thisArg?: any): Dictionary; + } + + interface LoDashArrayWrapper { + /** + * @see _.countBy + **/ + countBy( + callback?: ListIterator, + thisArg?: any): LoDashObjectWrapper>; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + callback: string, + thisArg?: any): LoDashObjectWrapper>; + } + + //_.every + interface LoDashStatic { + /** + * Checks if the given callback returns truey value for all elements of a collection. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return True if all elements passed the callback check, else false. + **/ + every( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: List, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: Dictionary, + whereValue: W): boolean; + + /** + * @see _.every + **/ + all( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: List, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Dictionary, + whereValue: W): boolean; + } + + //_.fill + interface LoDashStatic { + /** + * Fills elements of array with value from start up to, but not including, end. + * + * Note: This method mutates array. + * + * @param array (Array): The array to fill. + * @param value (*): The value to fill array with. + * @param [start=0] (number): The start position. + * @param [end=array.length] (number): The end position. + * @return (Array): Returns array. + */ + fill( + array: any[], + value: any, + start?: number, + end?: number): TResult[]; + + /** + * @see _.fill + */ + fill( + array: List, + value: any, + start?: number, + end?: number): List; + } + + interface LoDashArrayWrapper { + /** + * @see _.fill + */ + fill( + value: TResult, + start?: number, + end?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.fill + */ + fill( + value: TResult, + start?: number, + end?: number): LoDashObjectWrapper>; + } + + //_.filter + interface LoDashStatic { + /** + * Iterates over elements of a collection, returning an array of all elements the + * identity function returns truey for. + * + * @param collection The collection to iterate over. + * @return Returns a new array of elements that passed the callback check. + **/ + filter( + collection: (Array|List)): T[]; + + /** + * Iterates over elements of a collection, returning an array of all elements the + * callback returns truey for. The callback is bound to thisArg and invoked with three + * arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param context The this binding of callback. + * @return Returns a new array of elements that passed the callback check. + **/ + filter( + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + whereValue: W): T[]; + + /** + * @see _.filter + **/ + select( + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + whereValue: W): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.filter + **/ + filter(): LoDashArrayWrapper; + + /** + * @see _.filter + **/ + filter( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.filter + **/ + select( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + whereValue: W): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.filter + **/ + filter( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; + } + + //_.find + interface LoDashStatic { + /** + * Iterates over elements of collection, returning the first element predicate returns + * truthy for. The predicate is bound to thisArg and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for predicate the created _.property style callback + * returns the property value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback + * returns true for elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns + * true for elements that have the properties of the given object, else false. + * + * @param collection Searches for a value in this list. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return The found element, else undefined. + **/ + find( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * Alias of _.find + * @see _.find + **/ + detect( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * Alias of _.find + * @see _.find + **/ + detect( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T; + + /** + * Alias of _.find + * @see _.find + **/ + detect( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T; + + /** + * @see _.find + * @param _.matches style callback + **/ + find( + collection: Array|List|Dictionary, + whereValue: W): T; + + /** + * Alias of _.find + * @see _.find + * @param _.matches style callback + **/ + detect( + collection: Array|List|Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.matchesProperty style callback + **/ + find( + collection: Array|List|Dictionary, + path: string, + srcValue: any): T; + + /** + * Alias of _.find + * @see _.find + * @param _.matchesProperty style callback + **/ + detect( + collection: Array|List|Dictionary, + path: string, + srcValue: any): T; + + /** + * @see _.find + * @param _.property style callback + **/ + find( + collection: Array|List|Dictionary, + pluckValue: string): T; + + /** + * Alias of _.find + * @see _.find + * @param _.property style callback + **/ + detect( + collection: Array|List|Dictionary, + pluckValue: string): T; + + /** + * @see _.find + **/ + findWhere( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T; + + /** + * @see _.find + * @param _.matches style callback + **/ + findWhere( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.matches style callback + **/ + findWhere( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.matches style callback + **/ + findWhere( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.property style callback + **/ + findWhere( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.property style callback + **/ + findWhere( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.property style callback + **/ + findWhere( + collection: Dictionary, + pluckValue: string): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.find + */ + find( + callback: ListIterator, + thisArg?: any): T; + /** + * @see _.find + * @param _.matches style callback + */ + find( + whereValue: W): T; + /** + * @see _.find + * @param _.matchesProperty style callback + */ + find( + path: string, + srcValue: any): T; + /** + * @see _.find + * @param _.property style callback + */ + find( + pluckValue: string): T; + } + + //_.findLast + interface LoDashStatic { + /** + * This method is like _.find except that it iterates over elements of a collection from + * right to left. + * @param collection Searches for a value in this list. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return The found element, else undefined. + **/ + findLast( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: Dictionary, + pluckValue: string): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.findLast + */ + findLast( + callback: ListIterator, + thisArg?: any): T; + /** + * @see _.findLast + * @param _.where style callback + */ + findLast( + whereValue: W): T; + + /** + * @see _.findLast + * @param _.where style callback + */ + findLast( + pluckValue: string): T; + } + + //_.forEach + interface LoDashStatic { + /** + * Iterates over elements of a collection, executing the callback for each element. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * collection). Callbacks may exit iteration early by explicitly returning false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + forEach( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEach + **/ + forEach( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEach + **/ + forEach( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.each + **/ + forEach( + object: T, + callback: ObjectIterator, + thisArg?: any): T + + /** + * @see _.forEach + **/ + each( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEach + **/ + each( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEach + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + each( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.each + **/ + each( + object: T, + callback: ObjectIterator, + thisArg?: any): T + } + + interface LoDashArrayWrapper { + /** + * @see _.forEach + **/ + forEach( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.forEach + **/ + each( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.forEach + **/ + forEach( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; + + /** + * @see _.forEach + **/ + each( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; + } + + //_.forEachRight + interface LoDashStatic { + /** + * This method is like _.forEach except that it iterates over elements of a + * collection from right to left. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + forEachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEachRight + **/ + forEachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEachRight + **/ + forEachRight( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.forEachRight + **/ + eachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEachRight + **/ + eachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): Dictionary; + } + + interface LoDashArrayWrapper { + /** + * @see _.forEachRight + **/ + forEachRight( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.forEachRight + **/ + eachRight( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.forEachRight + **/ + forEachRight( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper>; + + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper>; + } + + //_.groupBy + interface LoDashStatic { + /** + * Creates an object composed of keys generated from the results of running each element + * of a collection through the callback. The corresponding value of each key is an array + * of the elements responsible for generating the key. The callback is bound to thisArg + * and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return Returns the composed aggregate object. + **/ + groupBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + **/ + groupBy( + collection: List, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: Array, + pluckValue: string): Dictionary; + + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: List, + pluckValue: string): Dictionary; + + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: Array, + whereValue: W): Dictionary; + + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: List, + whereValue: W): Dictionary; + + /** + * @see _.groupBy + **/ + groupBy( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: Dictionary, + pluckValue: string): Dictionary; + + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: Dictionary, + whereValue: W): Dictionary; + } + + interface LoDashArrayWrapper { + /** + * @see _.groupBy + **/ + groupBy( + callback: ListIterator, + thisArg?: any): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + pluckValue: string): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + whereValue: W): _.LoDashObjectWrapper<_.Dictionary>; + } + + interface LoDashObjectWrapper { + /** + * @see _.groupBy + **/ + groupBy( + callback: ListIterator, + thisArg?: any): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + pluckValue: string): _.LoDashObjectWrapper<_.Dictionary>; + + /** + * @see _.groupBy + **/ + groupBy( + whereValue: W): _.LoDashObjectWrapper<_.Dictionary>; + } + + //_.indexBy + interface LoDashStatic { + /** + * Creates an object composed of keys generated from the results of running each element + * of the collection through the given callback. The corresponding value of each key is + * the last element responsible for generating the key. The callback is bound to thisArg + * and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return + * true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return Returns the composed aggregate object. + **/ + indexBy( + list: Array, + iterator: ListIterator, + context?: any): Dictionary; + + /** + * @see _.indexBy + **/ + indexBy( + list: List, + iterator: ListIterator, + context?: any): Dictionary; + + /** + * @see _.indexBy + * @param pluckValue _.pluck style callback + **/ + indexBy( + collection: Array, + pluckValue: string): Dictionary; + + /** + * @see _.indexBy + * @param pluckValue _.pluck style callback + **/ + indexBy( + collection: List, + pluckValue: string): Dictionary; + + /** + * @see _.indexBy + * @param whereValue _.where style callback + **/ + indexBy( + collection: Array, + whereValue: W): Dictionary; + + /** + * @see _.indexBy + * @param whereValue _.where style callback + **/ + indexBy( + collection: List, + whereValue: W): Dictionary; + } + + //_.invoke + interface LoDashStatic { + /** + * Invokes the method named by methodName on each element in the collection returning + * an array of the results of each invoked method. Additional arguments will be provided + * to each invoked method. If methodName is a function it will be invoked for, and this + * bound to, each element in the collection. + * @param collection The collection to iterate over. + * @param methodName The name of the method to invoke. + * @param args Arguments to invoke the method with. + **/ + invoke( + collection: Array, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: List, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Array, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: List, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, + method: Function, + ...args: any[]): any; + } + + //_.map + interface LoDashStatic { + /** + * Creates an array of values by running each element in the collection through the callback. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, + * collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will return + * the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return true + * for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param theArg The this binding of callback. + * @return The mapped array result. + **/ + map( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + map( + collection: List, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg `this` object in `iterator`, optional. + * @return The mapped object result. + **/ + map( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + * @param pluckValue _.pluck style callback + **/ + map( + collection: Array, + pluckValue: string): TResult[]; + + /** + * @see _.map + * @param pluckValue _.pluck style callback + **/ + map( + collection: List, + pluckValue: string): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: List, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + object: Dictionary, + callback: DictionaryIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: Array, + pluckValue: string): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: List, + pluckValue: string): TResult[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.map + **/ + map( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.map + * @param pluckValue _.pluck style callback + **/ + map( + pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.map + **/ + collect( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.map + **/ + collect( + pluckValue: string): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.map + **/ + map( + callback: ObjectIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.map + **/ + collect( + callback: ObjectIterator, + thisArg?: any): LoDashArrayWrapper; + } + + //_.ceil + interface LoDashStatic { + /** + * Calculates n rounded up to precision. + * @param n The number to round up. + * @param precision The precision to round up to. + * @return Returns the rounded up number. + */ + ceil(n: number, precision?: number): number; + } + + interface LoDashWrapper { + /** + * @see _.ceil + */ + ceil(precision?: number): number; + } + + //_.floor + interface LoDashStatic { + /** + * Calculates n rounded down to precision. + * @param n The number to round down. + * @param precision The precision to round down to. + * @return Returns the rounded down number. + */ + floor(n: number, precision?: number): number; + } + + interface LoDashWrapper { + /** + * @see _.floor + */ + floor(precision?: number): number; + } + + //_.max + interface LoDashStatic { + /** + * Retrieves the maximum value of a collection. If the collection is empty or falsey -Infinity is + * returned. If a callback is provided it will be executed for each value in the collection to + * generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked + * with three arguments; (value, index, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will return the + * property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return true for + * elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return Returns the maximum value. + **/ + max( + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: Array, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: List, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: Dictionary, + pluckValue: string): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: Array, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: List, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: Dictionary, + whereValue: W): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.max + **/ + max( + callback?: ListIterator, + thisArg?: any): LoDashWrapper; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + pluckValue: string): LoDashWrapper; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + whereValue: W): LoDashWrapper; + } + + //_.min + interface LoDashStatic { + /** + * Retrieves the minimum value of a collection. If the collection is empty or falsey + * Infinity is returned. If a callback is provided it will be executed for each value + * in the collection to generate the criterion by which the value is ranked. The callback + * is bound to thisArg and invoked with three arguments; (value, index, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback + * will return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will + * return true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return Returns the maximum value. + **/ + min( + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: Array, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: List, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: Dictionary, + pluckValue: string): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: Array, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: List, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: Dictionary, + whereValue: W): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.min + **/ + min( + callback?: ListIterator, + thisArg?: any): LoDashWrapper; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + pluckValue: string): LoDashWrapper; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + whereValue: W): LoDashWrapper; + } + + //_.round + interface LoDashStatic { + /** + * Calculates n rounded to precision. + * @param n The number to round. + * @param precision The precision to round to. + * @return Returns the rounded number. + */ + round(n: number, precision?: number): number; + } + + interface LoDashWrapper { + /** + * @see _.round + */ + round(precision?: number): number; + } + + //_.sum + interface LoDashStatic { + /** + * Gets the sum of the values in collection. + * + * @param collection The collection to iterate over. + * @param iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the sum. + **/ + sum( + collection: Array): number; + + /** + * @see _.sum + **/ + sum( + collection: List): number; + + /** + * @see _.sum + **/ + sum( + collection: Dictionary): number; + + /** + * @see _.sum + **/ + sum( + collection: Array, + iteratee: ListIterator, + thisArg?: any): number; + + /** + * @see _.sum + **/ + sum( + collection: List, + iteratee: ListIterator, + thisArg?: any): number; + + /** + * @see _.sum + **/ + sum( + collection: Dictionary, + iteratee: ObjectIterator, + thisArg?: any): number; + + /** + * @see _.sum + * @param property _.property callback shorthand. + **/ + sum( + collection: Array, + property: string): number; + + /** + * @see _.sum + * @param property _.property callback shorthand. + **/ + sum( + collection: List, + property: string): number; + + /** + * @see _.sum + * @param property _.property callback shorthand. + **/ + sum( + collection: Dictionary, + property: string): number; + } + + interface LoDashNumberArrayWrapper { + /** + * @see _.sum + **/ + sum(): number; + + /** + * @see _.sum + **/ + sum( + iteratee: ListIterator, + thisArg?: any): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.sum + **/ + sum(): number; + + /** + * @see _.sum + **/ + sum( + iteratee: ListIterator, + thisArg?: any): number; + + /** + * @see _.sum + * @param property _.property callback shorthand. + **/ + sum( + property: string): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.sum + **/ + sum(): number; + + /** + * @see _.sum + **/ + sum( + iteratee: ObjectIterator, + thisArg?: any): number; + + /** + * @see _.sum + * @param property _.property callback shorthand. + **/ + sum( + property: string): number; + } + + //_.pluck + interface LoDashStatic { + /** + * Retrieves the value of a specified property from all elements in the collection. + * @param collection The collection to iterate over. + * @param property The property to pluck. + * @return A new array of property values. + **/ + pluck( + collection: Array, + property: string|string[]): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: List, + property: string|string[]): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: Dictionary, + property: string|string[]): any[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.pluck + **/ + pluck( + property: string): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.pluck + **/ + pluck( + property: string): LoDashArrayWrapper; + } + + //_.partition + interface LoDashStatic { + /** + * Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, + * while the second of which contains elements predicate returns falsey for. + * The predicate is bound to thisArg and invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for predicate the created _.property style callback + * returns the property value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback + * returns true for elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns + * true for elements that have the properties of the given object, else false. + * + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the array of grouped elements. + **/ + partition( + collection: List, + callback: ListIterator, + thisArg?: any): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: List, + whereValue: W): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: Dictionary, + whereValue: W): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: List, + path: string, + srcValue: any): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: Dictionary, + path: string, + srcValue: any): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: List, + pluckValue: string): T[][]; + + /** + * @see _.partition + **/ + partition( + collection: Dictionary, + pluckValue: string): T[][]; + } + + interface LoDashStringWrapper { + /** + * @see _.partition + */ + partition( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + } + + interface LoDashArrayWrapper { + /** + * @see _.partition + */ + partition( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + /** + * @see _.partition + */ + partition( + whereValue: W): LoDashArrayWrapper; + /** + * @see _.partition + */ + partition( + path: string, + srcValue: any): LoDashArrayWrapper; + /** + * @see _.partition + */ + partition( + pluckValue: string): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.partition + */ + partition( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.partition + */ + partition( + callback: DictionaryIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.partition + */ + partition( + whereValue: W): LoDashArrayWrapper; + + /** + * @see _.partition + */ + partition( + path: string, + srcValue: any): LoDashArrayWrapper; + + /** + * @see _.partition + */ + partition( + pluckValue: string): LoDashArrayWrapper; + } + + //_.reduce + interface LoDashStatic { + /** + * Reduces a collection to a value which is the accumulated result of running each + * element in the collection through the callback, where each successive callback execution + * consumes the return value of the previous execution. If accumulator is not provided the + * first element of the collection will be used as the initial accumulator value. The callback + * is bound to thisArg and invoked with four arguments; (accumulator, value, index|key, collection). + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param accumulator Initial value of the accumulator. + * @param thisArg The this binding of callback. + * @return Returns the accumulated value. + **/ + reduce( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + } + + interface LoDashArrayWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + + //_.reduceRight + interface LoDashStatic { + /** + * This method is like _.reduce except that it iterates over elements of a collection from + * right to left. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param accumulator Initial value of the accumulator. + * @param thisArg The this binding of callback. + * @return The accumulated value. + **/ + reduceRight( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + } + + //_.reject + interface LoDashStatic { + /** + * The opposite of _.filter this method returns the elements of a collection that + * the callback does not return truey for. + * + * If a property name is provided for callback the created "_.pluck" style callback + * will return the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will + * return true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return A new array of elements that failed the callback check. + **/ + reject( + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: Dictionary, + callback: DictionaryIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: Dictionary, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: List, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: Dictionary, + whereValue: W): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.reject + **/ + reject( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject(whereValue: W): LoDashArrayWrapper; + } + + //_.sample + interface LoDashStatic { + /** + * Retrieves a random element or n random elements from a collection. + * @param collection The collection to sample. + * @return Returns the random sample(s) of collection. + **/ + sample(collection: Array): T; + + /** + * @see _.sample + **/ + sample(collection: List): T; + + /** + * @see _.sample + **/ + sample(collection: Dictionary): T; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: Array, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: List, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: Dictionary, n: number): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.sample + **/ + sample(n: number): LoDashArrayWrapper; + + /** + * @see _.sample + **/ + sample(): LoDashWrapper; + } + + //_.shuffle + interface LoDashStatic { + /** + * Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. + * See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. + * @param collection The collection to shuffle. + * @return Returns a new shuffled collection. + **/ + shuffle(collection: Array): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: List): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: Dictionary): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.shuffle + **/ + shuffle(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.shuffle + **/ + shuffle(): LoDashArrayWrapper; + } + + //_.size + interface LoDashStatic { + /** + * Gets the size of the collection by returning collection.length for arrays and array-like + * objects or the number of own enumerable properties for objects. + * @param collection The collection to inspect. + * @return collection.length + **/ + size(collection: Array): number; + + /** + * @see _.size + **/ + size(collection: List): number; + + /** + * @see _.size + * @param object The object to inspect + * @return The number of own enumerable properties. + **/ + size(object: T): number; + + /** + * @see _.size + * @param aString The string to inspect + * @return The length of aString + **/ + size(aString: string): number; + } + + interface LoDashArrayWrapper { + /** + * @see _.size + **/ + size(): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.size + **/ + size(): number; + } + + //_.some + interface LoDashStatic { + /** + * Checks if the callback returns a truey value for any element of a collection. The function + * returns as soon as it finds a passing value and does not iterate over the entire collection. + * The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will return + * the property value of the given element. + * + * If an object is provided for callback the created "_.where" style callback will return true for + * elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return True if any element passed the callback check, else false. + **/ + some( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: {}, + callback?: ListIterator<{}, boolean>, + thisArg?: any): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: List, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: Dictionary, + whereValue: W): boolean; + + /** + * @see _.some + **/ + any( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: {}, + callback?: ListIterator<{}, boolean>, + thisArg?: any): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: List, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Dictionary, + whereValue: W): boolean; + } + + //_.sortBy + interface LoDashStatic { + /** + * Creates an array of elements, sorted in ascending order by the results of running each + * element in a collection through the callback. This method performs a stable sort, that + * is, it will preserve the original sort order of equal elements. The callback is bound + * to thisArg and invoked with three arguments; (value, index|key, collection). + * + * If a property name is provided for callback the created "_.pluck" style callback will + * return the property value of the given element. + * + * If a value is also provided for thisArg the created "_.matchesProperty" style callback + * returns true for elements that have a matching property value, else false. + * + * If an object is provided for an iteratee the created "_.matches" style callback returns + * true for elements that have the properties of the given object, else false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return A new array of sorted elements. + **/ + sortBy( + collection: Array, + iteratee?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.sortBy + **/ + sortBy( + collection: List, + iteratee?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy( + collection: List, + whereValue: W): T[]; + + /** + * Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts + * @param args The rules by which to sort + */ + sortByAll( + collection: (Array|List), + ...args: (ListIterator|Object|string)[] + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.sortBy + **/ + sortBy( + iteratee?: ListIterator, + thisArg?: any): LoDashArrayWrapper; + + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy(pluckValue: string): LoDashArrayWrapper; + + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy(whereValue: W): LoDashArrayWrapper; + + /** + * Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts + * @param args The rules by which to sort + */ + sortByAll(...args: (ListIterator|Object|string)[]): LoDashArrayWrapper; + } + + //_.sortByAll + interface LoDashStatic { + /** + * This method is like "_.sortBy" except that it can sort by multiple iteratees or + * property names. + * + * If a property name is provided for an iteratee the created "_.property" style callback + * returns the property value of the given element. + * + * If a value is also provided for thisArg the created "_.matchesProperty" style callback + * returns true for elements that have a matching property value, else false. + * + * If an object is provided for an iteratee the created "_.matches" style callback returns + * true for elements that have the properties of the given object, else false. + * + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return A new array of sorted elements. + **/ + sortByAll( + collection: Array, + iteratees: (ListIterator|string|Object)[]): T[]; + + /** + * @see _.sortByAll + **/ + sortByAll( + collection: List, + iteratees: (ListIterator|string|Object)[]): T[]; + + /** + * @see _.sortByAll + **/ + sortByAll( + collection: Array, + ...iteratees: (ListIterator|string|Object)[]): T[]; + + /** + * @see _.sortByAll + **/ + sortByAll( + collection: List, + ...iteratees: (ListIterator|string|Object)[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.sortByAll + **/ + sortByAll( + iteratees: (ListIterator|string|Object)[]): LoDashArrayWrapper; + + /** + * @see _.sortByAll + **/ + sortByAll( + ...iteratees: (ListIterator|string|Object)[]): LoDashArrayWrapper; + } + + //_.sortByOrder + interface LoDashStatic { + /** + * This method is like "_.sortByAll" except that it allows specifying the sort orders of the + * iteratees to sort by. If orders is unspecified, all values are sorted in ascending order. + * Otherwise, a value is sorted in ascending order if its corresponding order is "asc", and + * descending if "desc". + * + * If a property name is provided for an iteratee the created "_.property" style callback + * returns the property value of the given element. + * + * If an object is provided for an iteratee the created "_.matches" style callback returns + * true for elements that have the properties of the given object, else false. + * + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return A new array of sorted elements. + **/ + sortByOrder( + collection: Array, + iteratees: (ListIterator|string|Object)[], + orders?: boolean[]): T[]; + + /** + * @see _.sortByOrder + **/ + sortByOrder( + collection: List, + iteratees: (ListIterator|string|Object)[], + orders?: boolean[]): T[]; + + /** + * @see _.sortByOrder + **/ + sortByOrder( + collection: Array, + iteratees: (ListIterator|string|Object)[], + orders?: string[]): T[]; + + /** + * @see _.sortByOrder + **/ + sortByOrder( + collection: List, + iteratees: (ListIterator|string|Object)[], + orders?: string[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.sortByOrder + **/ + sortByOrder( + iteratees: (ListIterator|string|Object)[], + orders?: boolean[]): LoDashArrayWrapper; + + /** + * @see _.sortByOrder + **/ + sortByOrder( + iteratees: (ListIterator|string|Object)[], + orders?: string[]): LoDashArrayWrapper; + } + + //_.toArray + interface LoDashStatic { + /** + * Converts the collection to an array. + * @param collection The collection to convert. + * @return The new converted array. + **/ + toArray(collection: Array): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: List): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: Dictionary): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.toArray + **/ + toArray(): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.toArray + **/ + toArray(): LoDashArrayWrapper; + } + + //_.where + interface LoDashStatic { + /** + * Performs a deep comparison of each element in a collection to the given properties + * object, returning an array of all elements that have equivalent property values. + * @param collection The collection to iterate over. + * @param properties The object of property values to filter by. + * @return A new array of elements that have the given properties. + **/ + where( + list: Array, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: List, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: Dictionary, + properties: U): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.where + **/ + where(properties: U): LoDashArrayWrapper; + } + + /******** + * Date * + ********/ + + //_.now + interface LoDashStatic { + /** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * @return The number of milliseconds. + **/ + now(): number; + } + + /************* + * Functions * + *************/ + + //_.after + interface LoDashStatic { + /** + * Creates a function that executes func, with the this binding and arguments of the + * created function, only after being called n times. + * @param n The number of times the function must be called before func is executed. + * @param func The function to restrict. + * @return The new restricted function. + **/ + after( + n: number, + func: Function): Function; + } + + interface LoDashWrapper { + /** + * @see _.after + **/ + after(func: Function): LoDashObjectWrapper; + } + + //_.ary + interface LoDashStatic { + /** + * Creates a function that accepts up to n arguments ignoring any additional arguments. + * @param func The function to cap arguments for. + * @param n The arity cap. + * @param guard Enables use as a callback for functions like `_.map`. + * @returns Returns the new function. + */ + ary(func: Function, n?: number, guard?: Object): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.ary + */ + ary(n?: number, guard?: Object): LoDashObjectWrapper; + } + + //_.backflow + interface LoDashStatic { + /** + * @see _.flowRight + */ + backflow(...funcs: Function[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.flowRight + **/ + backflow(...funcs: Function[]): LoDashObjectWrapper; + } + + //_.before + interface LoDashStatic { + /** + * Creates a function that invokes func, with the this binding and arguments of the created function, while + * it is called less than n times. Subsequent calls to the created function return the result of the last func + * invocation. + * @param n The number of calls at which func is no longer invoked. + * @param func The function to restrict. + * @return Returns the new restricted function. + */ + before(n: number, func: TFunc): TFunc; + } + + interface LoDashWrapper { + /** + * @sed _.before + */ + before(func: TFunc): TFunc; + } + + //_.bind + interface LoDashStatic { + /** + * Creates a function that, when called, invokes func with the this binding of thisArg + * and prepends any additional bind arguments to those provided to the bound function. + * @param func The function to bind. + * @param thisArg The this binding of func. + * @param args Arguments to be partially applied. + * @return The new bound function. + **/ + bind( + func: Function, + thisArg: any, + ...args: any[]): (...args: any[]) => any; + } + + interface LoDashObjectWrapper { + /** + * @see _.bind + **/ + bind( + thisArg: any, + ...args: any[]): LoDashObjectWrapper<(...args: any[]) => any>; + } + + //_.bindAll + interface LoDashStatic { + /** + * Binds methods of an object to the object itself, overwriting the existing method. Method + * names may be specified as individual arguments or as arrays of method names. If no method + * names are provided all the function properties of object will be bound. + * @param object The object to bind and assign the bound methods to. + * @param methodNames The object method names to bind, specified as individual method names + * or arrays of method names. + * @return object + **/ + bindAll( + object: T, + ...methodNames: string[]): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.bindAll + **/ + bindAll(...methodNames: string[]): LoDashWrapper; + } + + //_.bindKey + interface LoDashStatic { + /** + * Creates a function that, when called, invokes the method at object[key] and prepends any + * additional bindKey arguments to those provided to the bound function. This method differs + * from _.bind by allowing bound functions to reference methods that will be redefined or don't + * yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. + * @param object The object the method belongs to. + * @param key The key of the method. + * @param args Arguments to be partially applied. + * @return The new bound function. + **/ + bindKey( + object: T, + key: string, + ...args: any[]): Function; + } + + interface LoDashObjectWrapper { + /** + * @see _.bindKey + **/ + bindKey( + key: string, + ...args: any[]): LoDashObjectWrapper; + } + + //_.compose + interface LoDashStatic { + /** + * @see _.flowRight + */ + compose(...funcs: Function[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.flowRight + */ + compose(...funcs: Function[]): LoDashObjectWrapper; + } + + //_.createCallback + interface LoDashStatic { + /** + * Produces a callback bound to an optional thisArg. If func is a property name the created + * callback will return the property value for a given element. If func is an object the created + * callback will return true for elements that contain the equivalent object properties, + * otherwise it will return false. + * @param func The value to convert to a callback. + * @param thisArg The this binding of the created callback. + * @param argCount The number of arguments the callback accepts. + * @return A callback function. + **/ + createCallback( + func: string, + thisArg?: any, + argCount?: number): () => any; + + /** + * @see _.createCallback + **/ + createCallback( + func: Dictionary, + thisArg?: any, + argCount?: number): () => boolean; + } + + interface LoDashWrapper { + /** + * @see _.createCallback + **/ + createCallback( + thisArg?: any, + argCount?: number): LoDashObjectWrapper<() => any>; + } + + interface LoDashObjectWrapper { + /** + * @see _.createCallback + **/ + createCallback( + thisArg?: any, + argCount?: number): LoDashObjectWrapper<() => any>; + } + + //_.curry + interface LoDashStatic { + /** + * Creates a function that accepts one or more arguments of func that when called either invokes func returning + * its result, if all func arguments have been provided, or returns a function that accepts one or more of the + * remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient. + * @param func The function to curry. + * @param arity The arity of func. + * @return Returns the new curried function. + */ + curry( + func: Function, + arity?: number): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.curry + **/ + curry(arity?: number): LoDashObjectWrapper; + } + + //_.curryRight + interface LoDashStatic { + /** + * This method is like _.curry except that arguments are applied to func in the manner of _.partialRight + * instead of _.partial. + * @param func The function to curry. + * @param arity The arity of func. + * @return Returns the new curried function. + */ + curryRight( + func: Function, + arity?: number): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.curryRight + **/ + curryRight(arity?: number): LoDashObjectWrapper; + } + + //_.debounce + interface LoDashStatic { + /** + * Creates a function that will delay the execution of func until after wait milliseconds have + * elapsed since the last time it was invoked. Provide an options object to indicate that func + * should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls + * to the debounced function will return the result of the last func call. + * + * Note: If leading and trailing options are true func will be called on the trailing edge of + * the timeout only if the the debounced function is invoked more than once during the wait + * timeout. + * @param func The function to debounce. + * @param wait The number of milliseconds to delay. + * @param options The options object. + * @param options.leading Specify execution on the leading edge of the timeout. + * @param options.maxWait The maximum time func is allowed to be delayed before it's called. + * @param options.trailing Specify execution on the trailing edge of the timeout. + * @return The new debounced function. + **/ + debounce( + func: T, + wait: number, + options?: DebounceSettings): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.debounce + **/ + debounce( + wait: number, + options?: DebounceSettings): LoDashObjectWrapper; + } + + interface DebounceSettings { + /** + * Specify execution on the leading edge of the timeout. + **/ + leading?: boolean; + + /** + * The maximum time func is allowed to be delayed before it's called. + **/ + maxWait?: number; + + /** + * Specify execution on the trailing edge of the timeout. + **/ + trailing?: boolean; + } + + //_.defer + interface LoDashStatic { + /** + * Defers executing the func function until the current call stack has cleared. Additional + * arguments will be provided to func when it is invoked. + * @param func The function to defer. + * @param args Arguments to invoke the function with. + * @return The timer id. + **/ + defer( + func: Function, + ...args: any[]): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.defer + **/ + defer(...args: any[]): LoDashWrapper; + } + + //_.delay + interface LoDashStatic { + /** + * Executes the func function after wait milliseconds. Additional arguments will be provided + * to func when it is invoked. + * @param func The function to delay. + * @param wait The number of milliseconds to delay execution. + * @param args Arguments to invoke the function with. + * @return The timer id. + **/ + delay( + func: Function, + wait: number, + ...args: any[]): number; + } + + interface LoDashObjectWrapper { + /** + * @see _.delay + **/ + delay( + wait: number, + ...args: any[]): LoDashWrapper; + } + + //_.flow + interface LoDashStatic { + /** + * Creates a function that returns the result of invoking the provided functions with the this binding of the + * created function, where each successive invocation is supplied the return value of the previous. + * @param funcs Functions to invoke. + * @return Returns the new function. + */ + flow(...funcs: Function[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.flow + **/ + flow(...funcs: Function[]): LoDashObjectWrapper; + } + + //_.flowRight + interface LoDashStatic { + /** + * This method is like _.flow except that it creates a function that invokes the provided functions from right + * to left. + * @param funcs Functions to invoke. + * @return Returns the new function. + */ + flowRight(...funcs: Function[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.flowRight + **/ + flowRight(...funcs: Function[]): LoDashObjectWrapper; + } + + //_.memoize + interface MemoizedFunction extends Function { + cache: MapCache; + } + + interface LoDashStatic { + /** + * Creates a function that memoizes the result of func. If resolver is provided it determines the cache key for + * storing the result based on the arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with + * the this binding of the memoized function. + * @param func The function to have its output memoized. + * @param resolver The function to resolve the cache key. + * @return Returns the new memoizing function. + */ + memoize( + func: Function, + resolver?: Function): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.memoize + */ + memoize(resolver?: Function): LoDashObjectWrapper; + } + + //_.modArgs + interface LoDashStatic { + /** + * Creates a function that runs each argument through a corresponding transform function. + * @param func The function to wrap. + * @param transforms The functions to transform arguments, specified as individual functions or arrays + * of functions. + * @return Returns the new function. + */ + modArgs( + func: T, + ...transforms: Function[] + ): TResult; + + /** + * @see _.modArgs + */ + modArgs( + func: T, + transforms: Function[] + ): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.modArgs + */ + modArgs(...transforms: Function[]): LoDashObjectWrapper; + + /** + * @see _.modArgs + */ + modArgs(transforms: Function[]): LoDashObjectWrapper; + } + + //_.negate + interface LoDashStatic { + /** + * Creates a function that negates the result of the predicate func. The func predicate is invoked with + * the this binding and arguments of the created function. + * @param predicate The predicate to negate. + * @return Returns the new function. + */ + negate(predicate: T): (...args: any[]) => boolean; + + /** + * @see _.negate + */ + negate(predicate: T): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.negate + */ + negate(): LoDashObjectWrapper<(...args: any[]) => boolean>; + + /** + * @see _.negate + */ + negate(): LoDashObjectWrapper; + } + + //_.once + interface LoDashStatic { + /** + * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value + * of the first call. The func is invoked with the this binding and arguments of the created function. + * @param func The function to restrict. + * @return Returns the new restricted function. + */ + + once(func: T): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.once + */ + once(): LoDashObjectWrapper; + } + + //_.partial + interface LoDashStatic { + /** + * Creates a function that, when called, invokes func with any additional partial arguments + * prepended to those provided to the new function. This method is similar to _.bind except + * it does not alter the this binding. + * @param func The function to partially apply arguments to. + * @param args Arguments to be partially applied. + * @return The new partially applied function. + **/ + partial( + func: Function, + ...args: any[]): Function; + } + + //_.partialRight + interface LoDashStatic { + /** + * This method is like _.partial except that partial arguments are appended to those provided + * to the new function. + * @param func The function to partially apply arguments to. + * @param args Arguments to be partially applied. + * @return The new partially applied function. + **/ + partialRight( + func: Function, + ...args: any[]): Function; + } + + //_.rearg + interface LoDashStatic { + /** + * Creates a function that invokes func with arguments arranged according to the specified indexes where the + * argument value at the first index is provided as the first argument, the argument value at the second index + * is provided as the second argument, and so on. + * @param func The function to rearrange arguments for. + * @param indexes The arranged argument indexes, specified as individual indexes or arrays of indexes. + * @return Returns the new function. + */ + rearg(func: Function, indexes: number[]): TResult; + + /** + * @see _.rearg + */ + rearg(func: Function, ...indexes: number[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.rearg + */ + rearg(indexes: number[]): LoDashObjectWrapper; + + /** + * @see _.rearg + */ + rearg(...indexes: number[]): LoDashObjectWrapper; + } + + //_.restParam + interface LoDashStatic { + /** + * Creates a function that invokes func with the this binding of the created function and arguments from start + * and beyond provided as an array. + * @param func The function to apply a rest parameter to. + * @param start The start position of the rest parameter. + * @return Returns the new function. + */ + restParam(func: Function, start?: number): TResult; + + /** + * @see _.restParam + */ + restParam(func: TFunc, start?: number): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.restParam + */ + restParam(start?: number): LoDashObjectWrapper; + } + + //_.spread + interface LoDashStatic { + /** + * Creates a function that invokes func with the this binding of the created function and an array of arguments + * much like Function#apply. + * @param func The function to spread arguments over. + * @return Returns the new function. + */ + spread(func: Function): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.spread + */ + spread(): LoDashObjectWrapper; + } + + + //_.throttle + interface LoDashStatic { + /** + * Creates a function that, when executed, will only call the func function at most once per + * every wait milliseconds. Provide an options object to indicate that func should be invoked + * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled + * function will return the result of the last func call. + * + * Note: If leading and trailing options are true func will be called on the trailing edge of + * the timeout only if the the throttled function is invoked more than once during the wait timeout. + * @param func The function to throttle. + * @param wait The number of milliseconds to throttle executions to. + * @param options The options object. + * @param options.leading Specify execution on the leading edge of the timeout. + * @param options.trailing Specify execution on the trailing edge of the timeout. + * @return The new throttled function. + **/ + throttle( + func: T, + wait: number, + options?: ThrottleSettings): T; + } + + interface ThrottleSettings { + + /** + * If you'd like to disable the leading-edge call, pass this as false. + **/ + leading?: boolean; + + /** + * If you'd like to disable the execution on the trailing-edge, pass false. + **/ + trailing?: boolean; + } + + //_.wrap + interface LoDashStatic { + /** + * Creates a function that provides value to the wrapper function as its first argument. + * Additional arguments provided to the function are appended to those provided to the + * wrapper function. The wrapper is executed with the this binding of the created function. + * @param value The value to wrap. + * @param wrapper The wrapper function. + * @return The new function. + **/ + wrap( + value: any, + wrapper: (func: Function, ...args: any[]) => any): Function; + } + + /******** + * Lang * + ********/ + + //_.clone + interface LoDashStatic { + /** + * Creates a clone of value. If isDeep is true nested objects are cloned, otherwise they are assigned by + * reference. If customizer is provided it’s invoked to produce the cloned values. If customizer returns + * undefined cloning is handled by the method instead. The customizer is bound to thisArg and invoked with up + * to three argument; (value [, index|key, object]). + * Note: This method is loosely based on the structured clone algorithm. The enumerable properties of arguments + * objects and objects created by constructors other than Object are cloned to plain Object objects. An empty + * object is returned for uncloneable values such as functions, DOM nodes, Maps, Sets, and WeakMaps. + * @param value The value to clone. + * @param isDeep Specify a deep clone. + * @param customizer The function to customize cloning values. + * @param thisArg The this binding of customizer. + * @return Returns the cloned value. + */ + clone( + value: T, + isDeep?: boolean, + customizer?: (value: any) => any, + thisArg?: any): T; + + /** + * @see _.clone + */ + clone( + value: T, + customizer?: (value: any) => any, + thisArg?: any): T; + } + + interface LoDashWrapper { + /** + * @see _.clone + */ + clone( + isDeep?: boolean, + customizer?: (value: any) => any, + thisArg?: any): T; + + /** + * @see _.clone + */ + clone( + customizer?: (value: any) => any, + thisArg?: any): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.clone + */ + clone( + isDeep?: boolean, + customizer?: (value: any) => any, + thisArg?: any): T[]; + + /** + * @see _.clone + */ + clone( + customizer?: (value: any) => any, + thisArg?: any): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.clone + */ + clone( + isDeep?: boolean, + customizer?: (value: any) => any, + thisArg?: any): T; + + /** + * @see _.clone + */ + clone( + customizer?: (value: any) => any, + thisArg?: any): T; + } + + //_.cloneDeep + interface LoDashStatic { + /** + * Creates a deep clone of value. If customizer is provided it’s invoked to produce the cloned values. If + * customizer returns undefined cloning is handled by the method instead. The customizer is bound to thisArg + * and invoked with up to three argument; (value [, index|key, object]). + * Note: This method is loosely based on the structured clone algorithm. The enumerable properties of arguments + * objects and objects created by constructors other than Object are cloned to plain Object objects. An empty + * object is returned for uncloneable values such as functions, DOM nodes, Maps, Sets, and WeakMaps. + * @param value The value to deep clone. + * @param customizer The function to customize cloning values. + * @param thisArg The this binding of customizer. + * @return Returns the deep cloned value. + */ + cloneDeep( + value: T, + customizer?: (value: any) => any, + thisArg?: any): T; + } + + interface LoDashWrapper { + /** + * @see _.cloneDeep + */ + cloneDeep( + customizer?: (value: any) => any, + thisArg?: any): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.cloneDeep + */ + cloneDeep( + customizer?: (value: any) => any, + thisArg?: any): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.cloneDeep + */ + cloneDeep( + customizer?: (value: any) => any, + thisArg?: any): T; + } + + //_.gt + interface LoDashStatic { + /** + * Checks if value is greater than other. + * @param value The value to compare. + * @param other The other value to compare. + * @return Returns true if value is greater than other, else false. + */ + gt(value: any, other: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.gt + */ + gt(other: any): boolean; + } + + //_.gte + interface LoDashStatic { + /** + * Checks if value is greater than or equal to other. + * @param value The value to compare. + * @param other The other value to compare. + * @return Returns true if value is greater than or equal to other, else false. + */ + gte(value: any, other: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.gte + */ + gte(other: any): boolean; + } + + //_.isArguments + interface LoDashStatic { + /** + * Checks if value is classified as an arguments object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + */ + isArguments(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isArguments + */ + isArguments(): boolean; + } + + //_.isArray + interface LoDashStatic { + /** + * Checks if value is classified as an Array object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isArray(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isArray + */ + isArray(): boolean; + } + + //_.isBoolean + interface LoDashStatic { + /** + * Checks if value is classified as a boolean primitive or object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isBoolean(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isBoolean + */ + isBoolean(): boolean; + } + + //_.isDate + interface LoDashStatic { + /** + * Checks if value is classified as a Date object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isDate(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isDate + */ + isDate(): boolean; + } + + //_.isElement + interface LoDashStatic { + /** + * Checks if value is a DOM element. + * @param value The value to check. + * @return Returns true if value is a DOM element, else false. + */ + isElement(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isElement + */ + isElement(): boolean; + } + + //_.isEmpty + interface LoDashStatic { + /** + * Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string, or + * jQuery-like collection with a length greater than 0 or an object with own enumerable properties. + * @param value The value to inspect. + * @return Returns true if value is empty, else false. + **/ + isEmpty(value?: any[]|Dictionary|string|any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isEmpty + */ + isEmpty(): boolean; + } + + //_.isError + interface LoDashStatic { + /** + * Checks if value is an Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, or URIError + * object. + * @param value The value to check. + * @return Returns true if value is an error object, else false. + */ + isError(value: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isError + */ + isError(): boolean; + } + + //_.isFinite + interface LoDashStatic { + /** + * Checks if value is a finite primitive number. + * Note: This method is based on Number.isFinite. + * @param value The value to check. + * @return Returns true if value is a finite number, else false. + **/ + isFinite(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isFinite + */ + isFinite(): boolean; + } + + //_.isFunction + interface LoDashStatic { + /** + * Checks if value is classified as a Function object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isFunction(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isFunction + */ + isFunction(): boolean; + } + + //_.isMatch + interface isMatchCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between object and source to determine if object contains equivalent property + * values. If customizer is provided it’s invoked to compare values. If customizer returns undefined + * comparisons are handled by the method instead. The customizer is bound to thisArg and invoked with three + * arguments: (value, other, index|key). + * @param object The object to inspect. + * @param source The object of property values to match. + * @param customizer The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return Returns true if object is a match, else false. + */ + isMatch(object: Object, source: Object, customizer?: isMatchCustomizer, thisArg?: any): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.isMatch + */ + isMatch(source: Object, customizer?: isMatchCustomizer, thisArg?: any): boolean; + } + + //_.isNaN + interface LoDashStatic { + /** + * Checks if value is NaN. + * Note: This method is not the same as isNaN which returns true for undefined and other non-numeric values. + * @param value The value to check. + * @return Returns true if value is NaN, else false. + */ + isNaN(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.isNaN + */ + isNaN(): boolean; + } + + //_.isNative + interface LoDashStatic { + /** + * Checks if value is a native function. + * @param value The value to check. + * @retrun Returns true if value is a native function, else false. + */ + isNative(value: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isNative + */ + isNative(): boolean; + } + + //_.isNull + interface LoDashStatic { + /** + * Checks if value is null. + * @param value The value to check. + * @return Returns true if value is null, else false. + **/ + isNull(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isNull + */ + isNull(): boolean; + } + + //_.isNumber + interface LoDashStatic { + /** + * Checks if value is classified as a Number primitive or object. + * Note: To exclude Infinity, -Infinity, and NaN, which are classified as numbers, use the _.isFinite method. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + */ + isNumber(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isNumber + */ + isNumber(): boolean; + } + + //_.isObject + interface LoDashStatic { + /** + * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), + * and new String('')) + * @param value The value to check. + * @return Returns true if value is an object, else false. + **/ + isObject(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isObject + */ + isObject(): boolean; + } + + //_.isPlainObject + interface LoDashStatic { + /** + * Checks if value is a plain object, that is, an object created by the Object constructor or one with a + * [[Prototype]] of null. + * + * Note: This method assumes objects created by the Object constructor have no inherited enumerable properties. + * + * @param value The value to check. + * @return Returns true if value is a plain object, else false. + */ + isPlainObject(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isPlainObject + */ + isPlainObject(): boolean; + } + + //_.isRegExp + interface LoDashStatic { + /** + * Checks if value is classified as a RegExp object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + */ + isRegExp(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isRegExp + */ + isRegExp(): boolean; + } + + //_.isString + interface LoDashStatic { + /** + * Checks if value is classified as a String primitive or object. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + **/ + isString(value?: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isString + */ + isString(): boolean; + } + + //_.isTypedArray + interface LoDashStatic { + /** + * Checks if value is classified as a typed array. + * @param value The value to check. + * @return Returns true if value is correctly classified, else false. + */ + isTypedArray(value: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isTypedArray + */ + isTypedArray(): boolean; + } + + //_.isUndefined + interface LoDashStatic { + /** + * Checks if value is undefined. + * @param value The value to check. + * @return Returns true if value is undefined, else false. + **/ + isUndefined(value: any): boolean; + } + + interface LoDashWrapperBase { + /** + * see _.isUndefined + */ + isUndefined(): boolean; + } + + //_.lt + interface LoDashStatic { + /** + * Checks if value is less than other. + * @param value The value to compare. + * @param other The other value to compare. + * @return Returns true if value is less than other, else false. + */ + lt(value: any, other: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.lt + */ + lt(other: any): boolean; + } + + //_.lte + interface LoDashStatic { + /** + * Checks if value is less than or equal to other. + * @param value The value to compare. + * @param other The other value to compare. + * @return Returns true if value is less than or equal to other, else false. + */ + lte(value: any, other: any): boolean; + } + + interface LoDashWrapperBase { + /** + * @see _.lte + */ + lte(other: any): boolean; + } + + //_.toPlainObject + interface LoDashStatic { + /** + * Converts value to a plain object flattening inherited enumerable properties of value to own properties + * of the plain object. + * @param value The value to convert. + * @return Returns the converted plain object. + */ + toPlainObject(value?: any): Object; + } + + /******** + * Math * + ********/ + + //_.add + interface LoDashStatic { + /** + * Adds two numbers. + * @param augend The first number to add. + * @param addend The second number to add. + * @return Returns the sum. + */ + add(augend: number, addend: number): number; + } + + interface LoDashWrapper { + /** + * @see _.add + */ + add(addend: number): number; + } + + /********** + * Number * + **********/ + + //_.inRange + interface LoDashStatic { + /** + * Checks if n is between start and up to but not including, end. If end is not specified it’s set to start + * with start then set to 0. + * @param n The number to check. + * @param start The start of the range. + * @param end The end of the range. + * @return Returns true if n is in the range, else false. + */ + inRange(n: number, start: number, end: number): boolean; + + + /** + * @see _.inRange + */ + inRange(n: number, end: number): boolean; + } + + interface LoDashWrapper { + /** + * @see _.inRange + */ + inRange(start: number, end: number): boolean; + + /** + * @see _.inRange + */ + inRange(end: number): boolean; + } + + /********** + * Object * + **********/ + + //_.assign + interface LoDashStatic { + /** + * Assigns own enumerable properties of source object(s) to the destination object. Subsequent + * sources will overwrite property assignments of previous sources. If a callback is provided + * it will be executed to produce the assigned values. The callback is bound to thisArg and + * invoked with two arguments; (objectValue, sourceValue). + * @param object The destination object. + * @param s1-8 The source object(s) + * @param callback The function to customize merging properties. + * @param thisArg The this binding of callback. + * @return The destination object. + **/ + assign( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + assign( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + extend( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + extend( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.assign + **/ + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + } + + interface LoDashObjectWrapper { + /** + * @see _.assign + **/ + assign( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + + /** + * @see _.assign + **/ + assign( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + assign( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + assign( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + assign( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + + /** + * @see _.assign + **/ + extend( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + + } + + //_.create + interface LoDashStatic { + /** + * Creates an object that inherits from the given prototype object. If a properties object is provided its own + * enumerable properties are assigned to the created object. + * @param prototype The object to inherit from. + * @param properties The properties to assign to the object. + * @return Returns the new object. + */ + create(prototype: Object, properties?: Object): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.create + */ + create(properties?: Object): LoDashObjectWrapper; + } + + //_.defaults + interface LoDashStatic { + /** + * Assigns own enumerable properties of source object(s) to the destination object for all + * destination properties that resolve to undefined. Once a property is set, additional defaults + * of the same property will be ignored. + * @param object The destination object. + * @param sources The source objects. + * @return The destination object. + **/ + defaults( + object: T, + ...sources: any[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.defaults + **/ + defaults(...sources: any[]): LoDashObjectWrapper + } + + //_.defaultsDeep + interface LoDashStatic { + /** + * This method is like _.defaults except that it recursively assigns default properties. + * @param object The destination object. + * @param sources The source objects. + * @return Returns object. + **/ + defaultsDeep( + object: T, + ...sources: any[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.defaultsDeep + **/ + defaultsDeep(...sources: any[]): LoDashObjectWrapper + } + + //_.findKey + interface LoDashStatic { + /** + * This method is like _.findIndex except that it returns the key of the first element that + * passes the callback check, instead of the element itself. + * @param object The object to search. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return The key of the found element, else undefined. + **/ + findKey( + object: any, + callback: (value: any) => boolean, + thisArg?: any): string; + + /** + * @see _.findKey + * @param pluckValue _.pluck style callback + **/ + findKey( + object: any, + pluckValue: string): string; + + /** + * @see _.findKey + * @param whereValue _.where style callback + **/ + findKey, T>( + object: T, + whereValue: W): string; + } + + //_.findLastKey + interface LoDashStatic { + /** + * This method is like _.findKey except that it iterates over elements of a collection in the opposite order. + * @param object The object to search. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return The key of the found element, else undefined. + **/ + findLastKey( + object: any, + callback: (value: any) => boolean, + thisArg?: any): string; + + /** + * @see _.findLastKey + * @param pluckValue _.pluck style callback + **/ + findLastKey( + object: any, + pluckValue: string): string; + + /** + * @see _.findLastKey + * @param whereValue _.where style callback + **/ + findLastKey, T>( + object: T, + whereValue: W): string; + } + + //_.forIn + interface LoDashStatic { + /** + * Iterates over own and inherited enumerable properties of an object, executing the callback for + * each property. The callback is bound to thisArg and invoked with three arguments; (value, key, + * object). Callbacks may exit iteration early by explicitly returning false. + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return object + **/ + forIn( + object: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.forIn + **/ + forIn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.forIn + **/ + forIn( + callback: ObjectIterator, + thisArg?: any): _.LoDashObjectWrapper; + } + + //_.forInRight + interface LoDashStatic { + /** + * This method is like _.forIn except that it iterates over elements of a collection in the + * opposite order. + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return object + **/ + forInRight( + object: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.forInRight + **/ + forInRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.forInRight + **/ + forInRight( + callback: ObjectIterator, + thisArg?: any): _.LoDashObjectWrapper; + } + + //_.forOwn + interface LoDashStatic { + /** + * Iterates over own enumerable properties of an object, executing the callback for each + * property. The callback is bound to thisArg and invoked with three arguments; (value, key, + * object). Callbacks may exit iteration early by explicitly returning false. + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return object + **/ + forOwn( + object: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + + /** + * @see _.forOwn + **/ + forOwn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.forOwn + **/ + forOwn( + callback: ObjectIterator, + thisArg?: any): _.LoDashObjectWrapper; + } + + //_.forOwnRight + interface LoDashStatic { + /** + * This method is like _.forOwn except that it iterates over elements of a collection in the + * opposite order. + * @param object The object to iterate over. + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + * @return object + **/ + forOwnRight( + object: Dictionary, + callback?: DictionaryIterator, + thisArg?: any): Dictionary; + /** + * @see _.forOwnRight + **/ + forOwnRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.forOwnRight + **/ + forOwnRight( + callback: ObjectIterator, + thisArg?: any): _.LoDashObjectWrapper; + } + + //_.functions + interface LoDashStatic { + /** + * Creates a sorted array of property names of all enumerable properties, own and inherited, of + * object that have function values. + * @param object The object to inspect. + * @return An array of property names that have function values. + **/ + functions(object: any): string[]; + + /** + * @see _functions + **/ + methods(object: any): string[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.functions + **/ + functions(): _.LoDashArrayWrapper; + + /** + * @see _.functions + **/ + methods(): _.LoDashArrayWrapper; + } + + //_.get + interface LoDashStatic { + /** + * Gets the property value at path of object. If the resolved + * value is undefined the defaultValue is used in its place. + * @param object The object to query. + * @param path The path of the property to get. + * @param defaultValue The value returned if the resolved value is undefined. + * @return Returns the resolved value. + **/ + get(object: Object, + path: string|number|boolean|Array, + defaultValue?:TResult + ): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.get + **/ + get(path: string|number|boolean|Array, + defaultValue?: TResult + ): TResult; + } + + //_.has + interface LoDashStatic { + /** + * Checks if path is a direct property. + * + * @param object The object to query. + * @param path The path to check. + * @return Returns true if path is a direct property, else false. + */ + has(object: any, path: string|number|boolean|Array): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.has + */ + has(path: string|number|boolean|Array): boolean; + } + + //_.invert + interface LoDashStatic { + /** + * Creates an object composed of the inverted keys and values of the given object. + * @param object The object to invert. + * @return The created inverted object. + **/ + invert(object: any): any; + } + + //_.isEqual + interface EqCustomizer { + (value: any, other: any, indexOrKey?: number|string): boolean; + } + + interface LoDashStatic { + /** + * Performs a deep comparison between two values to determine if they are equivalent. If customizer is + * provided it is invoked to compare values. If customizer returns undefined comparisons are handled + * by the method instead. The customizer is bound to thisArg and invoked with three + * arguments: (value, other [, index|key]). + * @param value The value to compare. + * @param other The other value to compare. + * @param callback The function to customize value comparisons. + * @param thisArg The this binding of customizer. + * @return True if the values are equivalent, else false. + */ + isEqual(value?: any, + other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + + /** + * @see _.isEqual + */ + eq(value?: any, + other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + } + + interface LoDashWrapper { + /** + * @see _.isEqual + */ + isEqual(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + + /** + * @see _.isEqual + */ + eq(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + + } + + interface LoDashArrayWrapper { + /** + * @see _.isEqual + */ + isEqual(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + + /** + * @see _.isEqual + */ + eq(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.isEqual + */ + isEqual(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + + /** + * @see _.isEqual + */ + eq(other?: any, + callback?: EqCustomizer, + thisArg?: any): boolean; + } + + //_.keys + interface LoDashStatic { + /** + * Creates an array composed of the own enumerable property names of an object. + * @param object The object to inspect. + * @return An array of property names. + **/ + keys(object?: any): string[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.keys + **/ + keys(): LoDashArrayWrapper + } + + //_.keysIn + interface LoDashStatic { + /** + * Creates an array of the own and inherited enumerable property names of object. + * @param object The object to query. + * @return An array of property names. + **/ + keysIn(object?: any): string[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.keysIn + **/ + keysIn(): LoDashArrayWrapper + } + + //_.mapValues + interface LoDashStatic { + /** + * Creates an object with the same keys as object and values generated by running each own + * enumerable property of object through iteratee. The iteratee function is bound to thisArg + * and invoked with three arguments: (value, key, object). + * + * If a property name is provided iteratee the created "_.property" style callback returns + * the property value of the given element. + * + * If a value is also provided for thisArg the creted "_.matchesProperty" style callback returns + * true for elements that have a matching property value, else false;. + * + * If an object is provided for iteratee the created "_.matches" style callback returns true + * for elements that have the properties of the given object, else false. + * + * @param {Object} object The object to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. + * @param {Object} [thisArg] The `this` binding of `iteratee`. + * @return {Object} Returns the new mapped object. + */ + mapValues(obj: Dictionary, callback: ObjectIterator, thisArg?: any): Dictionary; + mapValues(obj: Dictionary, where: Dictionary): Dictionary; + mapValues(obj: T, pluck: string): TMapped; + mapValues(obj: T, callback: ObjectIterator, thisArg?: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.mapValues + * TValue is the type of the property values of T. + * TResult is the type output by the ObjectIterator function + */ + mapValues(callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the property specified by pluck. + * T should be a Dictionary> + */ + mapValues(pluck: string): LoDashObjectWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the properties on the object specified by pluck. + * T should be a Dictionary>> + */ + mapValues(pluck: string, where: Dictionary): LoDashArrayWrapper>; + + /** + * @see _.mapValues + * TResult is the type of the properties of each object in the values of T + * T should be a Dictionary> + */ + mapValues(where: Dictionary): LoDashArrayWrapper; + } + + //_.merge + interface LoDashStatic { + /** + * Recursively merges own enumerable properties of the source object(s), that don't resolve + * to undefined into the destination object. Subsequent sources will overwrite property + * assignments of previous sources. If a callback is provided it will be executed to produce + * the merged values of the destination and source properties. If the callback returns undefined + * merging will be handled by the method instead. The callback is bound to thisArg and invoked + * with two arguments; (objectValue, sourceValue). + * @param object The destination object. + * @param s1-8 The source object(s) + * @param callback The function to customize merging properties. + * @param thisArg The this binding of callback. + * @return The destination object. + **/ + merge( + object: T, + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.merge + **/ + merge( + object: T, + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.merge + **/ + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + + /** + * @see _.merge + **/ + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): Result; + } + + //_.omit + interface LoDashStatic { + /** + * Creates a shallow clone of object excluding the specified properties. Property names may be + * specified as individual arguments or as arrays of property names. If a callback is provided + * it will be executed for each property of object omitting the properties the callback returns + * truey for. The callback is bound to thisArg and invoked with three arguments; (value, key, + * object). + * @param object The source object. + * @param keys The properties to omit. + * @return An object without the omitted properties. + **/ + omit( + object: T, + ...keys: string[]): Omitted; + + /** + * @see _.omit + **/ + omit( + object: T, + keys: string[]): Omitted; + + /** + * @see _.omit + **/ + omit( + object: T, + callback: ObjectIterator, + thisArg?: any): Omitted; + } + + interface LoDashObjectWrapper { + /** + * @see _.omit + **/ + omit( + ...keys: string[]): LoDashObjectWrapper; + + /** + * @see _.omit + **/ + omit( + keys: string[]): LoDashObjectWrapper; + + /** + * @see _.omit + **/ + omit( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; + } + + //_.pairs + interface LoDashStatic { + /** + * Creates a two dimensional array of an object's key-value pairs, + * i.e. [[key1, value1], [key2, value2]]. + * @param object The object to inspect. + * @return Aew array of key-value pairs. + **/ + pairs(object?: any): any[][]; + } + + interface LoDashObjectWrapper { + /** + * @see _.pairs + **/ + pairs(): LoDashArrayWrapper; + } + + //_.pick + interface LoDashStatic { + /** + * Creates an object composed of the picked object properties. Property names may be specified as individual + * arguments or as arrays of property names. If predicate is provided it’s invoked for each property of object + * picking the properties predicate returns truthy for. The predicate is bound to thisArg and invoked with + * three arguments: (value, key, object). + * + * @param object The source object. + * @param predicate The function invoked per iteration or property names to pick, specified as individual + * property names or arrays of property names. + * @param thisArg The this binding of predicate. + * @return An object composed of the picked properties. + */ + pick( + object: T, + predicate: ObjectIterator, + thisArg?: any + ): TResult; + + /** + * @see _.pick + */ + pick( + object: T, + ...predicate: Array> + ): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.pick + */ + pick( + predicate: ObjectIterator, + thisArg?: any + ): LoDashObjectWrapper; + + /** + * @see _.pick + */ + pick( + ...predicate: Array> + ): LoDashObjectWrapper; + } + + //_.set + interface LoDashStatic { + /** + * Sets the property value of path on object. If a portion of path does not exist it is created. + * @param object The object to augment. + * @param path The path of the property to set. + * @param value The value to set. + * @return Returns object. + **/ + set(object: T, + path: string|string[], + value: any): T; + } + + interface LoDashObjectWrapper { + /** + * @see _.set + **/ + set(path: string|string[], + value: any): LoDashObjectWrapper; + } + + //_.transform + interface LoDashStatic { + /** + * An alternative to _.reduce this method transforms object to a new accumulator object which is + * the result of running each of its elements through a callback, with each callback execution + * potentially mutating the accumulator object. The callback is bound to thisArg and invoked with + * four arguments; (accumulator, value, key, object). Callbacks may exit iteration early by + * explicitly returning false. + * @param collection The collection to iterate over. + * @param callback The function called per iteration. + * @param accumulator The custom accumulator value. + * @param thisArg The this binding of callback. + * @return The accumulated value. + **/ + transform( + collection: Array, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: List, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Array, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: List, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + } + + //_.values + interface LoDashStatic { + /** + * Creates an array of the own enumerable property values of object. + * @param object The object to query. + * @return Returns an array of property values. + **/ + values(object?: any): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.values + **/ + values(): LoDashObjectWrapper; + } + + //_.valuesIn + interface LoDashStatic { + /** + * Creates an array of the own and inherited enumerable property values of object. + * @param object The object to query. + * @return Returns the array of property values. + **/ + valuesIn(object?: any): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.valuesIn + **/ + valuesIn(): LoDashObjectWrapper; + } + + /********** + * String * + **********/ + + //_.camelCase + interface LoDashStatic { + /** + * Converts string to camel case. + * @param string The string to convert. + * @return Returns the camel cased string. + */ + camelCase(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.camelCase + */ + camelCase(): string; + } + + //_.capitalize + interface LoDashStatic { + capitalize(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.capitalize + */ + capitalize(): string; + } + + //_.deburr + interface LoDashStatic { + /** + * Deburrs string by converting latin-1 supplementary letters to basic latin letters and removing combining + * diacritical marks. + * @param string The string to deburr. + * @return Returns the deburred string. + */ + deburr(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.deburr + */ + deburr(): string; + } + + //_.endsWith + interface LoDashStatic { + /** + * Checks if string ends with the given target string. + * @param string The string to search. + * @param target The string to search for. + * @param position The position to search from. + * @return Returns true if string ends with target, else false. + */ + endsWith(string?: string, target?: string, position?: number): boolean; + } + + interface LoDashWrapper { + /** + * @see _.endsWith + */ + endsWith(target?: string, position?: number): boolean; + } + + // _.escape + interface LoDashStatic { + /** + * Converts the characters "&", "<", ">", '"', "'", and "`", in string to their corresponding HTML entities. + * @param string The string to escape. + * @return Returns the escaped string. + */ + escape(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.escape + */ + escape(): string; + } + + // _.escapeRegExp + interface LoDashStatic { + /** + * Escapes the RegExp special characters "\", "/", "^", "$", ".", "|", "?", "*", "+", "(", ")", "[", "]", + * "{" and "}" in string. + * @param string The string to escape. + * @return Returns the escaped string. + */ + escapeRegExp(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.escapeRegExp + */ + escapeRegExp(): string; + } + + //_.kebabCase + interface LoDashStatic { + /** + * Converts string to kebab case. + * @param string The string to convert. + * @return Returns the kebab cased string. + */ + kebabCase(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.kebabCase + */ + kebabCase(): string; + } + + interface LoDashStatic { + /** + * + * @param string The string to pad. + * @param length The padding length. + * @param chars The string used as padding. + * @return Returns the padded string. + */ + pad(string?: string, length?: number, chars?: string): string; + } + + //_.pad + interface LoDashWrapper { + /** + * @see _.pad + */ + pad(length?: number, chars?: string): string; + } + + //_.padLeft + interface LoDashStatic { + /** + * Pads string on the left side if it’s shorter than length. Padding characters are truncated if they exceed + * length. + * @param string The string to pad. + * @param length The padding length. + * @param chars The string used as padding. + * @return Returns the padded string. + */ + padLeft(string?: string, length?: number, chars?: string): string; + } + + //_.padLeft + interface LoDashWrapper { + /** + * @see _.padLeft + */ + padLeft(length?: number, chars?: string): string; + } + + //_.padRight + interface LoDashStatic { + /** + * Pads string on the right side if it’s shorter than length. Padding characters are truncated if they exceed + * length. + * @param string The string to pad. + * @param length The padding length. + * @param chars The string used as padding. + * @return Returns the padded string. + */ + padRight(string?: string, length?: number, chars?: string): string; + } + + //_.padRight + interface LoDashWrapper { + /** + * @see _.padRight + */ + padRight(length?: number, chars?: string): string; + } + + //_.parseInt + interface LoDashStatic { + /** + * Converts string to an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used + * unless value is a hexadecimal, in which case a radix of 16 is used. + * Note: This method aligns with the ES5 implementation of parseInt. + * @param string The string to convert. + * @param radix The radix to interpret value by. + * @return Returns the converted integer. + */ + parseInt(string: string, radix?: number): number; + } + + interface LoDashWrapper { + /** + * @see _.parseInt + */ + parseInt(radix?: number): number; + } + + //_.repeat + interface LoDashStatic { + /** + * Repeats the given string n times. + * @param string The string to repeat. + * @param n The number of times to repeat the string. + * @return Returns the repeated string. + */ + repeat(string?: string, n?: number): string; + } + + interface LoDashWrapper { + /** + * @see _.repeat + */ + repeat(n?: number): string; + } + + //_.snakeCase + interface LoDashStatic { + /** + * Converts string to snake case. + * @param string The string to convert. + * @return Returns the snake cased string. + */ + snakeCase(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.snakeCase + */ + snakeCase(): string; + } + + //_.startCase + interface LoDashStatic { + /** + * Converts string to start case. + * @param string The string to convert. + * @return Returns the start cased string. + */ + startCase(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.startCase + */ + startCase(): string; + } + + //_.startsWith + interface LoDashStatic { + /** + * Checks if string starts with the given target string. + * @param string The string to search. + * @param target The string to search for. + * @param position The position to search from. + * @return Returns true if string starts with target, else false. + */ + startsWith(string?: string, target?: string, position?: number): boolean; + } + + interface LoDashWrapper { + /** + * @see _.startsWith + */ + startsWith(target?: string, position?: number): boolean; + } + + //_.template + interface TemplateExecutor { + (data?: Object): string; + source: string; + } + + interface LoDashStatic { + /** + * Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, + * HTML-escape interpolated data properties in "escape" delimiters, and execute JavaScript in "evaluate" + * delimiters. Data properties may be accessed as free variables in the template. If a setting object is + * provided it takes precedence over _.templateSettings values. + * + * Note: In the development build _.template utilizes + * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier + * debugging. + * + * For more information on precompiling templates see + * [lodash's custom builds documentation](https://lodash.com/custom-builds). + * + * For more information on Chrome extension sandboxes see + * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). + * + * @param string The template string. + * @param options The options object. + * @param options.escape The HTML "escape" delimiter. + * @param options.evaluate The "evaluate" delimiter. + * @param options.imports An object to import into the template as free variables. + * @param options.interpolate The "interpolate" delimiter. + * @param options.variable The data object variable name. + * @return Returns the compiled template function. + */ + template( + string: string, + options?: TemplateSettings): TemplateExecutor; + } + + interface LoDashWrapper { + /** + * @see _.template + */ + template(options?: TemplateSettings): TemplateExecutor; + } + + //_.trim + interface LoDashStatic { + /** + * Removes leading and trailing whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trim(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trim + */ + trim(chars?: string): string; + } + + //_.trimLeft + interface LoDashStatic { + /** + * Removes leading whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trimLeft(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trimLeft + */ + trimLeft(chars?: string): string; + } + + //_.trimRight + interface LoDashStatic { + /** + * Removes trailing whitespace or specified characters from string. + * @param string The string to trim. + * @param chars The characters to trim. + * @return Returns the trimmed string. + */ + trimRight(string?: string, chars?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.trimRight + */ + trimRight(chars?: string): string; + } + + //_.trunc + interface TruncOptions { + /** The maximum string length. */ + length?: number; + /** The string to indicate text is omitted. */ + omission?: string; + /** The separator pattern to truncate to. */ + separator?: string|RegExp; + } + + interface LoDashStatic { + /** + * Truncates string if it’s longer than the given maximum string length. The last characters of the truncated + * string are replaced with the omission string which defaults to "…". + * @param string The string to truncate. + * @param options The options object or maximum string length. + * @return Returns the truncated string. + */ + trunc(string?: string, options?: TruncOptions|number): string; + } + + interface LoDashWrapper { + /** + * @see _.trunc + */ + trunc(options?: TruncOptions|number): string; + } + + //_.unescape + interface LoDashStatic { + /** + * The inverse of _.escape; this method converts the HTML entities &, <, >, ", ', and ` + * in string to their corresponding characters. + * @param string The string to unescape. + * @return Returns the unescaped string. + */ + unescape(string?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.unescape + */ + unescape(): string; + } + + //_.words + interface LoDashStatic { + /** + * Splits string into an array of its words. + * @param string The string to inspect. + * @param pattern The pattern to match words. + * @return Returns the words of string. + */ + words(string?: string, pattern?: string|RegExp): string[]; + } + + interface LoDashWrapper { + /** + * @see _.words + */ + words(pattern?: string|RegExp): string[]; + } + + /*********** + * Utility * + ***********/ + + //_.attempt + interface LoDashStatic { + /** + * Attempts to invoke func, returning either the result or the caught error object. Any additional arguments + * are provided to func when it’s invoked. + * @param func The function to attempt. + * @return Returns the func result or error object. + */ + attempt(func: (...args: any[]) => TResult): TResult|Error; + } + + interface LoDashObjectWrapper { + /** + * @see _.attempt + */ + attempt(): TResult|Error; + } + + //_.identity + interface LoDashStatic { + /** + * This method returns the first argument provided to it. + * @param value Any value. + * @return Returns value. + */ + identity(value?: T): T; + } + + interface LoDashWrapper { + /** + * @see _.identity + */ + identity(): T; + } + + interface LoDashArrayWrapper { + /** + * @see _.identity + */ + identity(): T[]; + } + + interface LoDashObjectWrapper { + /** + * @see _.identity + */ + identity(): T; + } + + //_.method + interface LoDashStatic { + /** + * Creates a function that invokes the method at path on a given object. Any additional arguments are provided + * to the invoked method. + * @param path The path of the method to invoke. + * @param args The arguments to invoke the method with. + * @return Returns the new function. + */ + method(path: string, ...args: any[]): (object: any) => TResult; + + /** + * @see _.method + */ + method(path: any[], ...args: any[]): (object: any) => TResult; + } + + interface LoDashWrapper { + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + } + + interface LoDashArrayWrapper { + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + + /** + * @see _.method + */ + method(...args: any[]): LoDashWrapper<(object: any) => TResult>; + } + + //_.methodOf + interface LoDashStatic { + /** + * The opposite of _.method; this method creates a function that invokes the method at a given path on object. + * Any additional arguments are provided to the invoked method. + * @param object The object to query. + * @param args The arguments to invoke the method with. + * @return Returns the new function. + */ + methodOf(object: Object, ...args: any[]): (path: string | any[]) => TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.methodOf + */ + methodOf(...args: any[]): LoDashObjectWrapper<(path: string | any[]) => TResult>; + } + + //_.mixin + interface MixinOptions { + chain?: boolean; + } + + interface LoDashStatic { + /** + * Adds all own enumerable function properties of a source object to the destination object. If object is a + * function then methods are added to its prototype as well. + * + * Note: Use _.runInContext to create a pristine lodash function to avoid conflicts caused by modifying + * the original. + * + * @param object The destination object. + * @param source The object of functions to add. + * @param options The options object. + * @param options.chain Specify whether the functions added are chainable. + * @return Returns object. + */ + mixin( + object: TObject, + source: Dictionary, + options?: MixinOptions + ): TResult; + + /** + * @see _.mixin + */ + mixin( + source: Dictionary, + options?: MixinOptions + ): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.mixin + */ + mixin( + source: Dictionary, + options?: MixinOptions + ): LoDashObjectWrapper; + + /** + * @see _.mixin + */ + mixin( + options?: MixinOptions + ): LoDashObjectWrapper; + } + + //_.noConflict + interface LoDashStatic { + /** + * Reverts the '_' variable to its previous value and returns a reference to the lodash function. + * @return The lodash function. + **/ + noConflict(): typeof _; + } + + //_.noop + interface LoDashStatic { + /** + * A no-operation function that returns undefined regardless of the arguments it receives. + * @return undefined + */ + noop(...args: any[]): void; + } + + interface LoDashWrapperBase { + /** + * @see _.noop + */ + noop(...args: any[]): void; + } + + //_.property + interface LoDashStatic { + /** + * Creates a function that returns the property value at path on a given object. + * @param path The path of the property to get. + * @return Returns the new function. + */ + property(path: string|string[]): (obj: TObj) => TResult; + } + + interface LoDashStringWrapper { + /** + * @see _.property + */ + property(): LoDashObjectWrapper<(obj: TObj) => TResult>; + } + + interface LoDashArrayWrapper { + /** + * @see _.property + */ + property(): LoDashObjectWrapper<(obj: TObj) => TResult>; + } + + //_.propertyOf + interface LoDashStatic { + /** + * The opposite of _.property; this method creates a function that returns the property value at a given path + * on object. + * @param object The object to query. + * @return Returns the new function. + */ + propertyOf(object: T): (path: string|string[]) => any; + } + + interface LoDashObjectWrapper { + /** + * @see _.propertyOf + */ + propertyOf(): LoDashObjectWrapper<(path: string|string[]) => any>; + } + + //_.range + interface LoDashStatic { + /** + * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. + * If end is not specified it’s set to start with start then set to 0. If end is less than start a zero-length + * range is created unless a negative step is specified. + * @param start The start of the range. + * @param end The end of the range. + * @param step The value to increment or decrement by. + * @return Returns a new range array. + */ + range( + start: number, + end: number, + step?: number): number[]; + + /** + * @see _.range + */ + range( + end: number, + step?: number): number[]; + } + + interface LoDashWrapper { + /** + * @see _.range + */ + range( + end?: number, + step?: number): LoDashArrayWrapper; + } + + //_.random + interface LoDashStatic { + /** + * Produces a random number between min and max (inclusive). If only one argument is provided a + * number between 0 and the given number will be returned. If floating is truey or either min or + * max are floats a floating-point number will be returned instead of an integer. + * @param max The maximum possible value. + * @param floating Specify returning a floating-point number. + * @return A random number. + **/ + random(max: number, floating?: boolean): number; + + /** + * @see _.random + * @param min The minimum possible value. + * @return A random number between `min` and `max`. + **/ + random(min: number, max: number, floating?: boolean): number; + } + + //_.result + interface LoDashStatic { + /** + * Resolves the value of property on object. If property is a function it will be invoked with + * the this binding of object and its result returned, else the property value is returned. If + * object is false then undefined is returned. + * @param object The object to query. + * @param path The path of the property to resolve. + * @param defaultValue The value returned if the resolved value is undefined. + * @return The resolved value. + **/ + + result(object: any, path: string|string[], defaultValue?: T): T; + } + + //_.runInContext + interface LoDashStatic { + /** + * Create a new lodash function using the given context object. + * @param context The context object + * @returns The lodash function. + **/ + runInContext(context: any): typeof _; + } + + //_.times + interface LoDashStatic { + /** + * Invokes the iteratee function n times, returning an array of the results of each invocation. The iteratee is + * bound to thisArg and invoked with one argument; (index). + * + * @param n The number of times to invoke iteratee. + * @param iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the array of results. + */ + times( + n: number, + iteratee: (num: number) => TResult, + thisArg?: any + ): TResult[]; + + /** + * @see _.times + */ + times(n: number): number[]; + } + + interface LoDashWrapper { + /** + * @see _.times + */ + times( + iteratee: (num: number) => TResult, + thisArgs?: any + ): LoDashArrayWrapper; + + /** + * @see _.times + */ + times(): LoDashArrayWrapper; + } + + //_.uniqueId + interface LoDashStatic { + /** + * Generates a unique ID. If prefix is provided the ID is appended to it. + * @param prefix The value to prefix the ID with. + * @return Returns the unique ID. + */ + uniqueId(prefix?: string): string; + } + + interface LoDashWrapper { + /** + * @see _.uniqueId + */ + uniqueId(): string; + } + + //_.constant + interface LoDashStatic { + /** + * Creates a function that returns value. + * @param value The value to return from the new function. + * @return Returns the new function. + */ + constant(value: T): () => T; + } + + interface LoDashWrapperBase { + /** + * @see _.constant + */ + constant(): () => TResult; + } + + interface ListIterator { + (value: T, index: number, collection: T[]): TResult; + } + + interface DictionaryIterator { + (value: T, key: string, collection: Dictionary): TResult; + } + + interface ObjectIterator { + (element: T, key: string, collection: any): TResult; + } + + interface MemoVoidIterator { + (prev: TResult, curr: T, indexOrKey: any, list?: T[]): void; + } + interface MemoIterator { + (prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult; + } + /* + interface MemoListIterator { + (prev: TResult, curr: T, index: number, list?: T[]): TResult; + } + interface MemoObjectIterator { + (prev: TResult, curr: T, index: string, object?: Dictionary): TResult; + } + */ + + //interface Collection {} + + // Common interface between Arrays and jQuery objects + interface List { + [index: number]: T; + length: number; + } + + interface Dictionary { + [index: string]: T; + } +} + +declare module "lodash" { + export = _; +} diff --git a/public/app/headers/moment/moment-node.d.ts b/public/app/headers/moment/moment-node.d.ts new file mode 100644 index 00000000000..b109893a3cf --- /dev/null +++ b/public/app/headers/moment/moment-node.d.ts @@ -0,0 +1,479 @@ +// Type definitions for Moment.js 2.8.0 +// Project: https://github.com/timrwood/moment +// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module moment { + + interface MomentInput { + + /** Year */ + years?: number; + /** Year */ + year?: number; + /** Year */ + y?: number; + + /** Month */ + months?: number; + /** Month */ + month?: number; + /** Month */ + M?: number; + + /** Day/Date */ + days?: number; + /** Day/Date */ + day?: number; + /** Day/Date */ + date?: number; + /** Day/Date */ + d?: number; + + /** Hour */ + hours?: number; + /** Hour */ + hour?: number; + /** Hour */ + h?: number; + + /** Minute */ + minutes?: number; + /** Minute */ + minute?: number; + /** Minute */ + m?: number; + + /** Second */ + seconds?: number; + /** Second */ + second?: number; + /** Second */ + s?: number; + + /** Millisecond */ + milliseconds?: number; + /** Millisecond */ + millisecond?: number; + /** Millisecond */ + ms?: number; + + } + + interface Duration { + + humanize(withSuffix?: boolean): string; + + as(units: string): number; + + milliseconds(): number; + asMilliseconds(): number; + + seconds(): number; + asSeconds(): number; + + minutes(): number; + asMinutes(): number; + + hours(): number; + asHours(): number; + + days(): number; + asDays(): number; + + months(): number; + asMonths(): number; + + years(): number; + asYears(): number; + + add(n: number, p: string): Duration; + add(n: number): Duration; + add(d: Duration): Duration; + + subtract(n: number, p: string): Duration; + subtract(n: number): Duration; + subtract(d: Duration): Duration; + + toISOString(): string; + toJSON(): string; + + } + + interface Moment { + + format(format: string): string; + format(): string; + + fromNow(withoutSuffix?: boolean): string; + + startOf(unitOfTime: string): Moment; + endOf(unitOfTime: string): Moment; + + /** + * Mutates the original moment by adding time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + * @param amount the amount you want to add + */ + add(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by adding time. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + add(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by adding time. + * + * @param duration a length of time + */ + add(duration: Duration): Moment; + + /** + * Mutates the original moment by subtracting time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + */ + subtract(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + subtract(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param duration a length of time + */ + subtract(duration: Duration): Moment; + + calendar(): string; + calendar(start: Moment): string; + + clone(): Moment; + + /** + * @return Unix timestamp, or milliseconds since the epoch. + */ + valueOf(): number; + + local(): Moment; // current date/time in local mode + + utc(): Moment; // current date/time in UTC mode + + isValid(): boolean; + invalidAt(): number; + + year(y: number): Moment; + year(): number; + quarter(): number; + quarter(q: number): Moment; + month(M: number): Moment; + month(M: string): Moment; + month(): number; + day(d: number): Moment; + day(d: string): Moment; + day(): number; + date(d: number): Moment; + date(): number; + hour(h: number): Moment; + hour(): number; + hours(h: number): Moment; + hours(): number; + minute(m: number): Moment; + minute(): number; + minutes(m: number): Moment; + minutes(): number; + second(s: number): Moment; + second(): number; + seconds(s: number): Moment; + seconds(): number; + millisecond(ms: number): Moment; + millisecond(): number; + milliseconds(ms: number): Moment; + milliseconds(): number; + weekday(): number; + weekday(d: number): Moment; + isoWeekday(): number; + isoWeekday(d: number): Moment; + weekYear(): number; + weekYear(d: number): Moment; + isoWeekYear(): number; + isoWeekYear(d: number): Moment; + week(): number; + week(d: number): Moment; + weeks(): number; + weeks(d: number): Moment; + isoWeek(): number; + isoWeek(d: number): Moment; + isoWeeks(): number; + isoWeeks(d: number): Moment; + weeksInYear(): number; + isoWeeksInYear(): number; + dayOfYear(): number; + dayOfYear(d: number): Moment; + + from(f: Moment|string|number|Date|number[], suffix?: boolean): string; + to(f: Moment|string|number|Date|number[], suffix?: boolean): string; + + diff(b: Moment): number; + diff(b: Moment, unitOfTime: string): number; + diff(b: Moment, unitOfTime: string, round: boolean): number; + + toArray(): number[]; + toDate(): Date; + toISOString(): string; + toJSON(): string; + unix(): number; + + isLeapYear(): boolean; + zone(): number; + zone(b: number): Moment; + zone(b: string): Moment; + utcOffset(): number; + utcOffset(b: number): Moment; + utcOffset(b: string): Moment; + daysInMonth(): number; + isDST(): boolean; + + isBefore(): boolean; + isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean; + + isAfter(): boolean; + isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean; + + isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean; + isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean; + + // Deprecated as of 2.8.0. + lang(language: string): Moment; + lang(reset: boolean): Moment; + lang(): MomentLanguage; + + locale(language: string): Moment; + locale(reset: boolean): Moment; + locale(): string; + + localeData(language: string): Moment; + localeData(reset: boolean): Moment; + localeData(): MomentLanguage; + + // Deprecated as of 2.7.0. + max(date: Moment|string|number|Date|any[]): Moment; + max(date: string, format: string): Moment; + + // Deprecated as of 2.7.0. + min(date: Moment|string|number|Date|any[]): Moment; + min(date: string, format: string): Moment; + + get(unit: string): number; + set(unit: string, value: number): Moment; + + } + + interface MomentCalendar { + + lastDay: any; + sameDay: any; + nextDay: any; + lastWeek: any; + nextWeek: any; + sameElse: any; + + } + + interface BaseMomentLanguage { + months ?: any; + monthsShort ?: any; + weekdays ?: any; + weekdaysShort ?: any; + weekdaysMin ?: any; + relativeTime ?: MomentRelativeTime; + meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; + calendar ?: MomentCalendar; + ordinal ?: (num: number) => string; + } + + interface MomentLanguage extends BaseMomentLanguage { + longDateFormat?: MomentLongDateFormat; + } + + interface MomentLanguageData extends BaseMomentLanguage { + /** + * @param formatType should be L, LL, LLL, LLLL. + */ + longDateFormat(formatType: string): string; + } + + interface MomentLongDateFormat { + + L: string; + LL: string; + LLL: string; + LLLL: string; + LT: string; + l?: string; + ll?: string; + lll?: string; + llll?: string; + lt?: string; + + } + + interface MomentRelativeTime { + + future: any; + past: any; + s: any; + m: any; + mm: any; + h: any; + hh: any; + d: any; + dd: any; + M: any; + MM: any; + y: any; + yy: any; + + } + + interface MomentStatic { + + version: string; + fn: Moment; + + (): Moment; + (date: number): Moment; + (date: number[]): Moment; + (date: string, format?: string, strict?: boolean): Moment; + (date: string, format?: string, language?: string, strict?: boolean): Moment; + (date: string, formats: string[], strict?: boolean): Moment; + (date: string, formats: string[], language?: string, strict?: boolean): Moment; + (date: string, specialFormat: () => void, strict?: boolean): Moment; + (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; + (date: Date): Moment; + (date: Moment): Moment; + (date: Object): Moment; + + utc(): Moment; + utc(date: number): Moment; + utc(date: number[]): Moment; + utc(date: string, format?: string, strict?: boolean): Moment; + utc(date: string, format?: string, language?: string, strict?: boolean): Moment; + utc(date: string, formats: string[], strict?: boolean): Moment; + utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; + utc(date: Date): Moment; + utc(date: Moment): Moment; + utc(date: Object): Moment; + + unix(timestamp: number): Moment; + + invalid(parsingFlags?: Object): Moment; + isMoment(): boolean; + isMoment(m: any): boolean; + isDate(m: any): boolean; + isDuration(): boolean; + isDuration(d: any): boolean; + + // Deprecated in 2.8.0. + lang(language?: string): string; + lang(language?: string, definition?: MomentLanguage): string; + + locale(language?: string): string; + locale(language?: string[]): string; + locale(language?: string, definition?: MomentLanguage): string; + + localeData(language?: string): MomentLanguageData; + + longDateFormat: any; + relativeTime: any; + meridiem: (hour: number, minute: number, isLowercase: boolean) => string; + calendar: any; + ordinal: (num: number) => string; + + duration(milliseconds: Number): Duration; + duration(num: Number, unitOfTime: string): Duration; + duration(input: MomentInput): Duration; + duration(object: any): Duration; + duration(): Duration; + + parseZone(date: string): Moment; + + months(): string[]; + months(index: number): string; + months(format: string): string[]; + months(format: string, index: number): string; + monthsShort(): string[]; + monthsShort(index: number): string; + monthsShort(format: string): string[]; + monthsShort(format: string, index: number): string; + + weekdays(): string[]; + weekdays(index: number): string; + weekdays(format: string): string[]; + weekdays(format: string, index: number): string; + weekdaysShort(): string[]; + weekdaysShort(index: number): string; + weekdaysShort(format: string): string[]; + weekdaysShort(format: string, index: number): string; + weekdaysMin(): string[]; + weekdaysMin(index: number): string; + weekdaysMin(format: string): string[]; + weekdaysMin(format: string, index: number): string; + + min(moments: Moment[]): Moment; + max(moments: Moment[]): Moment; + + normalizeUnits(unit: string): string; + relativeTimeThreshold(threshold: string): number|boolean; + relativeTimeThreshold(threshold: string, limit:number): boolean; + + /** + * Constant used to enable explicit ISO_8601 format parsing. + */ + ISO_8601(): void; + + defaultFormat: string; + + } + +} + +declare module 'moment' { + var moment: moment.MomentStatic; + export = moment; +} diff --git a/public/app/headers/moment/moment.d.ts b/public/app/headers/moment/moment.d.ts new file mode 100644 index 00000000000..78b09016cb6 --- /dev/null +++ b/public/app/headers/moment/moment.d.ts @@ -0,0 +1,8 @@ +// Type definitions for Moment.js 2.8.0 +// Project: https://github.com/timrwood/moment +// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare var moment: moment.MomentStatic; From 166a3c4d642c44d261f18dd6d369e745f19e0260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 11 Sep 2015 08:00:13 +0200 Subject: [PATCH 12/12] tech(typescript): added tslint to default task --- public/app/core/filters/filters.ts | 13 +++++++------ public/test/karma.conf.js | 4 +--- tasks/default_task.js | 1 + 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/public/app/core/filters/filters.ts b/public/app/core/filters/filters.ts index f6f0fd518fe..be9c3742866 100644 --- a/public/app/core/filters/filters.ts +++ b/public/app/core/filters/filters.ts @@ -15,7 +15,7 @@ module.filter('stringSort', function() { module.filter('slice', function() { return function(arr, start, end) { - if(!_.isUndefined(arr)) { + if (!_.isUndefined(arr)) { return arr.slice(start, end); } }; @@ -23,7 +23,7 @@ module.filter('slice', function() { module.filter('stringify', function() { return function(arr) { - if(_.isObject(arr) && !_.isArray(arr)) { + if (_.isObject(arr) && !_.isArray(arr)) { return angular.toJson(arr); } else { return _.isNull(arr) ? null : arr.toString(); @@ -32,8 +32,8 @@ module.filter('stringify', function() { }); module.filter('moment', function() { - return function(date,mode) { - switch(mode) { + return function(date, mode) { + switch (mode) { case 'ago': return moment(date).fromNow(); } @@ -66,11 +66,12 @@ module.filter('interpolateTemplateVars', function(templateSrv) { } else { return templateSrv.replaceWithText(text, scope.row.scopedVars); } - } + }; interpolateTemplateVars.$stateful = true; return interpolateTemplateVars; }); -export function filters() {} +// dummy export +export {}; diff --git a/public/test/karma.conf.js b/public/test/karma.conf.js index 7c4881ee64a..6b51d1a5a1e 100644 --- a/public/test/karma.conf.js +++ b/public/test/karma.conf.js @@ -9,9 +9,6 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ 'public/test/test-main.js', - {pattern: 'public_gen/.app_gen/**/*.js', included: false}, - {pattern: 'public_gen/vendor/**/*.js', included: false}, - {pattern: 'public_gen/test/**/*.js', included: false}, {pattern: 'public_gen/**/*.js', included: false} ], @@ -28,4 +25,5 @@ module.exports = function(config) { singleRun: true, }); + }; diff --git a/tasks/default_task.js b/tasks/default_task.js index 87a2f711faa..03f1b667941 100644 --- a/tasks/default_task.js +++ b/tasks/default_task.js @@ -6,6 +6,7 @@ module.exports = function(grunt) { grunt.registerTask('default', [ 'jscs', 'jshint', + 'tslint', 'clean:gen', 'copy:public_to_gen', 'css',