From ee35457a50c7d47aa540597d7fdf850b57f79420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Castre?= Date: Fri, 16 Oct 2015 15:55:22 +0200 Subject: [PATCH 01/24] Improve durandal.d.ts if you use Q instead of jQuery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Durandal supports injection/configuration to use a different library for Deferred/Promises (ref http://durandaljs.com/documentation/Q.html) When using a different Deferred/Promise implementation, you might want to use a different Promise interface in the durandal.d.ts file. Added some type annotations to ensure that durandal.d.ts won’t make compilation fail when the compiling with the noImplicitAny option set to true. Note that I'm not the author of these changes but was asked to review it, and then publish it for the benefits of the community. --- durandal/durandal.d.ts | 132 ++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 60 deletions(-) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index 86f988cbe..612e85c64 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Durandal 2.1.0 +// Type definitions for Durandal 2.1.0 // Project: http://durandaljs.com // Definitions by: Blue Spire // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -12,6 +12,18 @@ /// /// +// By default, Durandal uses JQuery's Defer/Promise implementation, but durandal supports injecting/configuring +// usage of different JavaScript Defer/Promise libraries (f.ex. Q or ES6 Promise polyfills). +// You might therefore want to use a different interface from a community typings file or your custom unified interface. +// When using f.ex. Q as Defer/Promise library replace the lines below with: + +// +// interface DurandalPromise extends Q.Promise +// interface DurandalDeferred extends Q.Deferred + +interface DurandalPromise extends JQueryPromise { } +interface DurandalDeferred extends JQueryDeferred { } + /** * The system module encapsulates the most basic features used by other modules. * @requires require @@ -45,7 +57,7 @@ interface DurandalSystemModule { * @param {object} obj The object whose module id you wish to set. * @param {string} id The id to set for the specified object. */ - setModuleId(obj, id: string): void; + setModuleId(obj: any, id: string): void; /** * Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with `new` and it's result is returned. @@ -89,9 +101,9 @@ interface DurandalSystemModule { /** * Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise. * @param {function} [action] The action to defer. You will be passed the deferred object as a paramter. - * @returns {JQueryDeferred} The deferred object. + * @returns {Deferred} The deferred object. */ - defer(action?: (dfd: JQueryDeferred) => void): JQueryDeferred; + defer(action?: (dfd: DurandalDeferred) => void): DurandalDeferred; /** * Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see [node-uuid](https://github.com/broofa/node-uuid). @@ -102,23 +114,23 @@ interface DurandalSystemModule { /** * Uses require.js to obtain a module. This function returns a promise which resolves with the module instance. * @param {string} moduleId The id of the module to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(moduleId: string): JQueryPromise; + acquire(moduleId: string): DurandalPromise; /** * Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array. * @param {string[]} moduleIds The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(modules: string[]): JQueryPromise; + acquire(modules: string[]): DurandalPromise; /** * Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array. * @param {string} moduleIds* The ids of the modules to load. - * @returns {JQueryPromise} A promise for the loaded module. + * @returns {Promise} A promise for the loaded module. */ - acquire(...moduleIds: string[]): JQueryPromise; + acquire(...moduleIds: string[]): DurandalPromise; /** * Extends the first object with the properties of the following objects. @@ -130,9 +142,9 @@ interface DurandalSystemModule { /** * Uses a setTimeout to wait the specified milliseconds. * @param {number} milliseconds The number of milliseconds to wait. - * @returns {JQueryPromise} + * @returns {Promise} */ - wait(milliseconds: number): JQueryPromise; + wait(milliseconds: number): DurandalPromise; /** * Gets all the owned keys of the specified object. @@ -295,14 +307,14 @@ interface DurandalViewEngineModule { * @param {string} id The view id whose view should be cached. * @param {DOMElement} view The view to cache. */ - putViewInCache(id: string, view: HTMLElement); + putViewInCache(id: string, view: HTMLElement): void; /** * Creates the view associated with the view id. * @param {string} viewId The view id whose view should be created. - * @returns {JQueryPromise} A promise of the view. + * @returns {DurandalPromise} A promise of the view. */ - createView(viewId: string): JQueryPromise; + createView(viewId: string): DurandalPromise; /** * Called when a view cannot be found to provide the opportunity to locate or generate a fallback view. Mainly used to ease development. @@ -311,7 +323,7 @@ interface DurandalViewEngineModule { * @param {Error} requirePath The error that was returned from the attempt to locate the default view. * @returns {Promise} A promise for the fallback view. */ - createFallbackView(viewId: string, requirePath: string, err: Error): JQueryPromise; + createFallbackView(viewId: string, requirePath: string, err: Error): DurandalPromise; } /** @@ -439,7 +451,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateViewForObject(obj: any, area: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Converts a module id into a view id. By default the ids are the same. @@ -470,7 +482,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(view: HTMLElement, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; /** * Locates the specified view. @@ -479,7 +491,7 @@ interface DurandalViewLocatorModule { * @param {DOMElement[]} [elementsToSearch] An existing set of elements to search first. * @returns {Promise} A promise of the view. */ - locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): JQueryPromise; + locateView(viewUrlOrId: string, area?: string, elementsToSearch?: HTMLElement[]): DurandalPromise; } /** @@ -514,7 +526,7 @@ declare module 'durandal/composition' { area?: string; preserveContext?: boolean; activate?: boolean; - strategy?: (context: CompositionContext) => JQueryPromise; + strategy?: (context: CompositionContext) => DurandalPromise; composingNewView: boolean; child: HTMLElement; binding?: (child: HTMLElement, parent: HTMLElement, context: CompositionContext) => void; @@ -547,7 +559,7 @@ declare module 'durandal/composition' { * @param {object} [config] The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler. * @param {function} [initOptionsFactory] If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does. */ - export function addBindingHandler(name, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any); + export function addBindingHandler(name: string, config?: KnockoutBindingHandler, initOptionsFactory?: (element?: HTMLElement, valueAccessor?: any, allBindingsAccessor?: any, viewModel?: any, bindingContext?: KnockoutBindingContext) => any): void; /** * Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself. @@ -568,7 +580,7 @@ declare module 'durandal/composition' { * @param {object} context The composition context containing the model and possibly existing viewElements. * @returns {promise} A promise for the view. */ - export var defaultStrategy: (context: CompositionContext) => JQueryPromise; + export var defaultStrategy: (context: CompositionContext) => DurandalPromise; /** * Initiates a composition. @@ -663,13 +675,13 @@ declare module 'plugins/dialog' { * In this function, you are expected to add a DOM element to the tree which will serve as the "host" for the modal's composed view. You must add a property called host to the modalWindow object which references the dom element. It is this host which is passed to the composition module. * @param {Dialog} theDialog The dialog model. */ - addHost(theDialog: Dialog); + addHost(theDialog: Dialog): void; /** * This function is expected to remove any DOM machinery associated with the specified dialog and do any other necessary cleanup. * @param {Dialog} theDialog The dialog model. */ - removeHost(theDialog: Dialog); + removeHost(theDialog: Dialog): void; /** * This function is called after the modal is fully composed into the DOM, allowing your implementation to do any final modifications, such as positioning or animation. You can obtain the original dialog object by using `getDialog` on context.model. @@ -677,14 +689,14 @@ declare module 'plugins/dialog' { * @param {DOMElement} parent The parent view. * @param {object} context The composition context. */ - compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext); + compositionComplete(child: HTMLElement, parent: HTMLElement, context: composition.CompositionContext): void; } interface Dialog { owner: any; context: DialogContext; activator: DurandalActivator; - close(): JQueryPromise; + close(): DurandalPromise; settings: composition.CompositionContext; } @@ -745,7 +757,7 @@ declare module 'plugins/dialog' { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - export function show(obj: any, activationData?: any, context?: string): JQueryPromise; + export function show(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Shows a message box. @@ -756,7 +768,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -767,7 +779,7 @@ declare module 'plugins/dialog' { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + export function showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Installs this module into Durandal; called by the framework. Adds `app.showDialog` and `app.showMessage` convenience methods. @@ -890,7 +902,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the get response data. */ - export function get(url: string, query?: Object, headers?: Object): JQueryPromise; + export function get(url: string, query?: Object, headers?: Object): DurandalPromise; /** * Makes an JSONP request. @@ -900,7 +912,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): JQueryPromise; + export function jsonp(url: string, query?: Object, callbackParam?: string, headers?: Object): DurandalPromise; /** * Makes an HTTP POST request. @@ -909,7 +921,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @returns {Promise} A promise of the response data. */ - export function post(url: string, data: Object, headers?: Object): JQueryPromise; + export function post(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP PUT request. @@ -919,7 +931,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the response data. */ - export function put(url: string, data: Object, headers?: Object): JQueryPromise; + export function put(url: string, data: Object, headers?: Object): DurandalPromise; /** * Makes an HTTP DELETE request. @@ -929,7 +941,7 @@ declare module 'plugins/http' { * @param {object} [headers] The data to add to the request header. It will be converted to JSON. If the data contains Knockout observables, they will be converted into normal properties before serialization. * @return {Promise} A promise of the get response data. */ - export function remove(url: string, query?: Object, headers?: Object): JQueryPromise; + export function remove(url: string, query?: Object, headers?: Object): DurandalPromise; } /** @@ -964,7 +976,7 @@ declare module 'plugins/observable' { * @param {function|object} evaluatorOrOptions The Knockout computed function or computed options object. * @returns {KnockoutComputed} The underlying computed observable. */ - export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine); + export function defineProperty(obj: any, propertyName: string, evaluatorOrOptions?: KnockoutComputedDefine): KnockoutComputed; /** * Installs the plugin into the view model binder's `beforeBind` hook so that objects are automatically converted before being bound. @@ -1046,7 +1058,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: string); + export function serialize(object: any, settings?: string): string; /** * Serializes the object. @@ -1054,7 +1066,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: number); + export function serialize(object: any, settings?: number): string; /** * Serializes the object. @@ -1062,7 +1074,7 @@ declare module 'plugins/serializer' { * @param {object} [settings] Settings can specify a replacer or space to override the serializer defaults. * @returns {string} The JSON string. */ - export function serialize(object: any, settings?: SerializerOptions); + export function serialize(object: any, settings?: SerializerOptions): string; /** * Gets the type id for an object instance, using the configured `typeAttribute`. @@ -1081,7 +1093,7 @@ declare module 'plugins/serializer' { * @param {string} typeId The type id. * @param {function} constructor The constructor. */ - export function registerType(typeId: string, constructor: () => any); + export function registerType(typeId: string, constructor: () => any): void; /** * The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping. @@ -1091,7 +1103,7 @@ declare module 'plugins/serializer' { * @param {object} getConstructor A custom function used to get the constructor function associated with a type id. * @returns {object} The value. */ - export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (string) => () => any): any; + export function reviver(key: string, value: any, getTypeId: (value: any) => string, getConstructor: (id: string) => () => any): any; /** * Deserialize the JSON. @@ -1128,7 +1140,7 @@ declare module 'plugins/widget' { * Creates a ko binding handler for the specified kind. * @param {string} kind The kind to create a custom binding handler for. */ - export function registerKind(kind: string); + export function registerKind(kind: string): void; /** * Maps views and module to the kind identifier if a non-standard pattern is desired. @@ -1136,7 +1148,7 @@ declare module 'plugins/widget' { * @param {string} [viewId] The unconventional view id to map the kind to. * @param {string} [moduleId] The unconventional module id to map the kind to. */ - export function mapKind(kind: string, viewId?: string, moduleId?: string); + export function mapKind(kind: string, viewId?: string, moduleId?: string): void; /** * Maps a kind name to it's module id. First it looks up a custom mapped kind, then falls back to `convertKindToModulePath`. @@ -1172,7 +1184,7 @@ declare module 'plugins/widget' { * @param {object} settings The widget settings. * @param {object} [bindingContext] The current binding context. */ - export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext); + export function create(element: HTMLElement, settings: WidgetSettings, bindingContext?: KnockoutBindingContext): void; } /** @@ -1279,14 +1291,14 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {string} [context] The name of the dialog context to use. Uses the default context if none is specified. * @returns {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing. */ - showDialog(obj: any, activationData?: any, context?: string): JQueryPromise; + showDialog(obj: any, activationData?: any, context?: string): DurandalPromise; /** * Closes the dialog associated with the specified object. via the dialog plugin. * @param {object} obj The object whose dialog should be closed. * @param {object} results* The results to return back to the dialog caller after closing. */ - closeDialog(obj: any, ...results); + closeDialog(obj: any, ...results: any[]): void; /** * Shows a message box via the dialog plugin. @@ -1297,7 +1309,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: string[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Shows a message box. @@ -1308,7 +1320,7 @@ interface DurandalAppModule extends DurandalEventSupport { * @param {Object} [settings] Custom settings for this instance of the messsage box, used to change classes and styles. * @returns {Promise} A promise that resolves when the message box is closed and returns the selected option. */ - showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): JQueryPromise; + showMessage(message: string, title?: string, options?: DialogButton[], autoclose?: boolean, settings?: Object): DurandalPromise; /** * Configures one or more plugins to be loaded and installed into the application. @@ -1322,7 +1334,7 @@ interface DurandalAppModule extends DurandalEventSupport { * Starts the application. * @returns {promise} */ - start(): JQueryPromise; + start(): DurandalPromise; /** * Sets the root module/view for the application. @@ -1404,7 +1416,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to check if close is possible. * @returns {promise} */ - canDeactivateItem(item: T, close: boolean): JQueryPromise; + canDeactivateItem(item: T, close: boolean): DurandalPromise; /** * Deactivates the specified item. @@ -1412,7 +1424,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {boolean} close Whether or not to close the item. * @returns {promise} */ - deactivateItem(item: T, close: boolean): JQueryPromise; + deactivateItem(item: T, close: boolean): DurandalPromise; /** * Determines whether or not the specified item can be activated. @@ -1420,7 +1432,7 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} activationData Data associated with the activation. * @returns {promise} */ - canActivateItem(newItem: T, activationData?: any): JQueryPromise; + canActivateItem(newItem: T, activationData?: any): DurandalPromise; /** * Activates the specified item. @@ -1428,31 +1440,31 @@ interface DurandalActivator extends KnockoutComputed { * @param {object} newActivationData Data associated with the activation. * @returns {promise} */ - activateItem(newItem: T, activationData?: any): JQueryPromise; + activateItem(newItem: T, activationData?: any): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be activated. * @returns {promise} */ - canActivate(): JQueryPromise; + canActivate(): DurandalPromise; /** * Activates the activator, in its current state. * @returns {promise} */ - activate(): JQueryPromise; + activate(): DurandalPromise; /** * Determines whether or not the activator, in its current state, can be deactivated. * @returns {promise} */ - canDeactivate(close: boolean): JQueryPromise; + canDeactivate(close: boolean): DurandalPromise; /** * Deactivates the activator, in its current state. * @returns {promise} */ - deactivate(close: boolean): JQueryPromise; + deactivate(close: boolean): DurandalPromise; /** * Adds canActivate, activate, canDeactivate and deactivate functions to the provided model which pass through to the corresponding functions on the activator. @@ -1462,7 +1474,7 @@ interface DurandalActivator extends KnockoutComputed { /** * Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them. */ - forItems(items): DurandalActivator; + forItems(items: any[]): DurandalActivator; } interface DurandalHistoryOptions { @@ -1509,7 +1521,7 @@ interface DurandalRouteConfiguration { title?: any; moduleId?: string; hash?: string; - route?: string|string[]; + route?: string | string[]; routePattern?: RegExp; isActive?: KnockoutComputed; nav?: any; @@ -1765,7 +1777,7 @@ interface DurandalRouterBase extends DurandalEventSupport { * @param {object} instruction The route instruction. The instruction object has config, fragment, queryString, params and queryParams properties. * @returns {Promise|Boolean|String} If a boolean, determines whether or not the route should activate or be cancelled. If a string, causes a redirect to the specified route. Can also be a promise for either of these value types. */ - guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => JQueryPromise|boolean|string; + guardRoute?: (instance: Object, instruction: DurandalRouteInstruction) => DurandalPromise | boolean | string; /** * Parent router of the current child router. @@ -1785,7 +1797,7 @@ interface DurandalRootRouter extends DurandalRouterBase { * Activates the router and the underlying history tracking mechanism. * @returns {Promise} A promise that resolves when the router is ready. */ - activate(options?: DurandalHistoryOptions): JQueryPromise; + activate(options?: DurandalHistoryOptions): DurandalPromise; /** * Disable history, perhaps temporarily. Not useful in a real app, but possibly useful for unit testing Routers. From 1f7bcc9133a3d82e3f980eabed5a7e640e010d11 Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Mon, 19 Oct 2015 15:58:34 +0200 Subject: [PATCH 02/24] New definitions for jquery.highlight.js --- jquery.highlight/jquery.highlight-tests.ts | 26 ++++++++++++++++++++++ jquery.highlight/jquery.highlight.d.ts | 20 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 jquery.highlight/jquery.highlight-tests.ts create mode 100644 jquery.highlight/jquery.highlight.d.ts diff --git a/jquery.highlight/jquery.highlight-tests.ts b/jquery.highlight/jquery.highlight-tests.ts new file mode 100644 index 000000000..84ef701f1 --- /dev/null +++ b/jquery.highlight/jquery.highlight-tests.ts @@ -0,0 +1,26 @@ +/// + + + +$('#content').highlight('lorem'); + +// search for and highlight more terms at once +// so you can save some time on traversing DOM +$('#content').highlight(['lorem', 'ipsum']); +$('#content').highlight('lorem ipsum'); + +// search only for entire word 'lorem' +$('#content').highlight('lorem', { wordsOnly: true }); + +// don't ignore case during search of term 'lorem' +$('#content').highlight('lorem', { caseSensitive: true }); + +// wrap every occurrance of term 'ipsum' in content +// with +$('#content').highlight('ipsum', { element: 'em', className: 'important' }); + +// remove default highlight +$('#content').unhighlight(); + +// remove custom highlight +$('#content').unhighlight({ element: 'em', className: 'important' }); \ No newline at end of file diff --git a/jquery.highlight/jquery.highlight.d.ts b/jquery.highlight/jquery.highlight.d.ts new file mode 100644 index 000000000..d48d1f7d8 --- /dev/null +++ b/jquery.highlight/jquery.highlight.d.ts @@ -0,0 +1,20 @@ +// Type definitions for jquery.highlight.js +// Project: https://github.com/bartaz/sandbox.js/blob/master/jquery.highlight.js +// Definitions by: Stefan Profanter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface JQuery { + unhighlight(options?: { + element?: string, + className?: string + }): JQuery; + highlight(words: string | string[], options?: { + element?: string, + className?: string + caseSensitive?: boolean, + wordsOnly?: boolean + }): JQuery; +} \ No newline at end of file From 2e1db438fbf9a34225e0130d983e048808b77645 Mon Sep 17 00:00:00 2001 From: "Krueger, Brandon" Date: Tue, 20 Oct 2015 20:18:27 -0500 Subject: [PATCH 03/24] server.select() returns either a single server or a list of servers, not void --- hapi/hapi.d.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 3fc5dca03..7f2fab90e 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -2104,12 +2104,14 @@ declare module "hapi" { Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. var Hapi = require('hapi'); var server = new Hapi.Server(); - server.connection({ port: 80, labels: ['a', 'b'] }); - server.connection({ port: 8080, labels: ['a', 'c'] }); - server.connection({ port: 8081, labels: ['b', 'c'] }); - var a = server.select('a'); // 80, 8080 - var ac = a.select('c'); // 8080*/ - select(labels: string|string[]): void; + server.connection({ port: 80, labels: ['a'] }); + server.connection({ port: 8080, labels: ['b'] }); + server.connection({ port: 8081, labels: ['c'] }); + server.connection({ port: 8082, labels: ['c','d'] }); + var a = server.select('a'); // The server with port 80 + var ab = server.select(['a','b']); // A list of servers containing the server with port 80 and the server with port 8080 + var c = server.select('c'); // A list of servers containing the server with port 8081 and the server with port 8082 */ + select(labels: string|string[]): Server|Server[]; /** server.start([callback]) Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false), where: callback - optional callback when server startup is completed or failed with the signature function(err) where: From cdaaf0e19be766fa55dfa4d5161724792926569a Mon Sep 17 00:00:00 2001 From: "Krueger, Brandon" Date: Tue, 20 Oct 2015 20:26:50 -0500 Subject: [PATCH 04/24] Updating the 8.2 version as well --- hapi/hapi-8.2.0.d.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hapi/hapi-8.2.0.d.ts b/hapi/hapi-8.2.0.d.ts index 80fcc4357..c652ad435 100644 --- a/hapi/hapi-8.2.0.d.ts +++ b/hapi/hapi-8.2.0.d.ts @@ -2101,12 +2101,14 @@ declare module "hapi" { Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. var Hapi = require('hapi'); var server = new Hapi.Server(); - server.connection({ port: 80, labels: ['a', 'b'] }); - server.connection({ port: 8080, labels: ['a', 'c'] }); - server.connection({ port: 8081, labels: ['b', 'c'] }); - var a = server.select('a'); // 80, 8080 - var ac = a.select('c'); // 8080*/ - select(labels: string|string[]): void; + server.connection({ port: 80, labels: ['a'] }); + server.connection({ port: 8080, labels: ['b'] }); + server.connection({ port: 8081, labels: ['c'] }); + server.connection({ port: 8082, labels: ['c','d'] }); + var a = server.select('a'); // The server with port 80 + var ab = server.select(['a','b']); // A list of servers containing the server with port 80 and the server with port 8080 + var c = server.select('c'); // A list of servers containing the server with port 8081 and the server with port 8082 */ + select(labels: string|string[]): Server|Server[]; /** server.start([callback]) Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false), where: callback - optional callback when server startup is completed or failed with the signature function(err) where: From 6568ce0b6faf5da2ff60c33643e1d33cc1513b62 Mon Sep 17 00:00:00 2001 From: Eyal Solnik Date: Fri, 23 Oct 2015 19:36:40 +0300 Subject: [PATCH 05/24] Fix issue #6065 * Update the Runner.run function. * Update the Server.new function. * Add new Config interface. * Add new ConfigFile interface. * Rename ClientConfig to ClientOptions. --- karma/karma.d.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/karma/karma.d.ts b/karma/karma.d.ts index cad9eb6ba..f12d5df20 100644 --- a/karma/karma.d.ts +++ b/karma/karma.d.ts @@ -53,11 +53,11 @@ declare module 'karma' { } interface Runner { - run(options?: Config, callback?: ServerCallback): void; + run(options?: ConfigOptions|ConfigFile, callback?: ServerCallback): void; } interface Server extends NodeJS.EventEmitter { - new(options?: Config, callback?: ServerCallback): Server; + new(options?: ConfigOptions|ConfigFile, callback?: ServerCallback): Server; /** * Start the server */ @@ -82,8 +82,21 @@ declare module 'karma' { interface ServerCallback { (exitCode: number): void; } + + interface Config { + set: (config: ConfigOptions) => void; + LOG_DISABLE: string; + LOG_ERROR: string; + LOG_WARN: string; + LOG_INFO: string; + LOG_DEBUG: string; + } + + interface ConfigFile { + configFile: string; + } - interface Config { + interface ConfigOptions { /** * @description Enable or disable watching files and executing the tests whenever one of these files changes. * @default true @@ -163,7 +176,7 @@ declare module 'karma' { *

*/ captureTimeout?: number; - client?: ClientConfig; + client?: ClientOptions; /** * @default true * @description Enable or disable colors in the output (reporters and logs). @@ -308,7 +321,7 @@ declare module 'karma' { urlRoot?: string; } - interface ClientConfig { + interface ClientOptions { /** * @default undefined * @description When karma run is passed additional arguments on the command-line, they From d47706e0a6fbb695b8cb731181660faac01d0345 Mon Sep 17 00:00:00 2001 From: Dan Manastireanu Date: Sat, 24 Oct 2015 16:27:55 +0300 Subject: [PATCH 06/24] Added definitions for jQuery.qrcode. Closes #6292 --- jquery.qrcode/jquery.qrcode-tests.ts | 73 +++++++++++++++ jquery.qrcode/jquery.qrcode.d.ts | 127 +++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 jquery.qrcode/jquery.qrcode-tests.ts create mode 100644 jquery.qrcode/jquery.qrcode.d.ts diff --git a/jquery.qrcode/jquery.qrcode-tests.ts b/jquery.qrcode/jquery.qrcode-tests.ts new file mode 100644 index 000000000..716010c51 --- /dev/null +++ b/jquery.qrcode/jquery.qrcode-tests.ts @@ -0,0 +1,73 @@ +/// +/// + +// Examples from website (note: the examples use color instead of fill, which is not supported) +$('.container').qrcode(); + +$('.container').qrcode({ + "size": 100, + "fill": "#3a3", + "text": "http://larsjung.de/qrcode" +}); + +$('.container').qrcode({ + "render": "div", + "size": 100, + "fill": "#3a3", + "text": "http://larsjung.de/qrcode" +}); + +// defaults +$('.container').qrcode({ + + // render method: `'canvas'`, `'image'` or `'div'` + render: 'canvas', + + // version range somewhere in 1 .. 40 + minVersion: 1, + maxVersion: 40, + + // error correction level: `'L'`, `'M'`, `'Q'` or `'H'` + ecLevel: 'L', + + // offset in pixel if drawn onto existing canvas + left: 0, + top: 0, + + // size in pixel + size: 200, + + // code color or image element + fill: '#000', + + // background color or image element, `null` for transparent background + background: null, + + // content + text: 'no text', + + // corner radius relative to module width: 0.0 .. 0.5 + radius: 0, + + // quiet zone in modules + quiet: 0, + + // modes + // 0: normal + // 1: label strip + // 2: label box + // 3: image strip + // 4: image box + mode: JQueryQRCode.Mode.NORMAL, + + mSize: 0.1, + mPosX: 0.5, + mPosY: 0.5, + + label: 'no label', + fontname: 'sans', + fontcolor: '#000', + + image: null +}); + diff --git a/jquery.qrcode/jquery.qrcode.d.ts b/jquery.qrcode/jquery.qrcode.d.ts new file mode 100644 index 000000000..c10582af2 --- /dev/null +++ b/jquery.qrcode/jquery.qrcode.d.ts @@ -0,0 +1,127 @@ +// Type definitions for jQuery.qrcode v0.12.0 +// Project: https://github.com/lrsjng/jquery-qrcode +// Definitions by: Dan Manastireanu +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JQueryQRCode { + /** + * One of the possible mode types. + */ + export const enum Mode { + NORMAL, + LABEL_STRIP, + LABEL_BOX, + IMAGE_STRIP, + IMAGE_BOX + } + + interface Options { + /** + * Render method: 'canvas', 'image' or 'div' + * @default 'canvas' + */ + render?: string, + + /** + * Start of version range, somewhere in 1 .. 40 + * @default 1 + */ + minVersion?: number, + /** + * End of version range, somewhere in 1 .. 40 + * @default 40 + */ + maxVersion?: number, + + /** + * Error correction level: 'L', 'M', 'Q' or 'H' + * @default 'L' + */ + ecLevel?: string, + + /** + * Left offset in pixels, if drawn onto existing canvas + * @default 0 + */ + left?: number, + /** + * Top offset in pixels, if drawn onto existing canvas + * @default 0 + */ + top?: number, + + /** + * Size in pixel + * @default 200 + */ + size?: number, + + /** + * Code color or image element + * @default '#000' + */ + fill?: string, + + /** + * Background color or image element, null for transparent background + * @default null + */ + background?: string, + + /** + * The text content of the QR code. + * @default 'no text' + */ + text?: string, + + /** + * Corner radius relative to module width: 0.0 .. 0.5 + * @default 0 + */ + radius?: number, + + /** + * Quiet zone in modules + * @default 0 + */ + quiet?: number, + + /** + * Mode + * @default Mode.NORMAL + */ + mode?: Mode, + + + /** @default 0.1 */ + mSize?: number, + /** @default 0.5 */ + mPosX?: number, + /** @default 0.5 */ + mPosY?: number, + + /** @default 'no label' */ + label?: string, + /** @default 'sans' */ + fontname?: string, + /** @default '#000' */ + fontcolor?: string, + + /** @default null */ + image?: string + } + + +} + + + +interface JQuery { + /** + * Create a QR Code inside the selected container. + * @param options + */ + qrcode(options?: JQueryQRCode.Options): JQuery; +} From e3f20e9a77c67a5658b3c483df1bce9dee83353e Mon Sep 17 00:00:00 2001 From: Dekel Barzilay Date: Sun, 25 Oct 2015 16:32:26 +0200 Subject: [PATCH 07/24] Added missing flag 'v8debug' to Global interface 'v8debug' is an optional flag that will be set in NodeJS globals upon using the 'debug-brk' command parameter. We're using it to dynamically detect when app is running in debug-mode. (When not on debug-mode, the 'v8debug' flag is undefined) --- node/node.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/node/node.d.ts b/node/node.d.ts index 9448b413b..1cab19a6d 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -334,6 +334,7 @@ declare module NodeJS { undefined: typeof undefined; unescape: (str: string) => string; gc: () => void; + v8debug?: any; } export interface Timer { From 707296e9f3aaf8c34383f5f1e539fdff6ef06c46 Mon Sep 17 00:00:00 2001 From: DanilF Date: Sun, 25 Oct 2015 22:39:52 -0400 Subject: [PATCH 08/24] DanilF - Added typings for decorum library. --- decorum/decorum-tests.ts | 102 ++++++++++ decorum/decorum-tests.ts.tscparams | 2 + decorum/decorum.d.ts | 292 +++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 decorum/decorum-tests.ts create mode 100644 decorum/decorum-tests.ts.tscparams create mode 100644 decorum/decorum.d.ts diff --git a/decorum/decorum-tests.ts b/decorum/decorum-tests.ts new file mode 100644 index 000000000..dd1743b5e --- /dev/null +++ b/decorum/decorum-tests.ts @@ -0,0 +1,102 @@ +/// + +import {Required} from 'decorum'; +import {Email} from 'decorum'; +import {MinLength} from 'decorum'; +import {MaxLength} from 'decorum'; +import {Length} from 'decorum'; +import {FieldName} from 'decorum'; +import {Validation} from 'decorum'; +import {Pattern} from 'decorum'; +import {Validator} from 'decorum'; +import {BaseValidator} from 'decorum'; + +class MyModel { + @FieldName('User name') + @Required() + @MaxLength(50) + username = ''; + + @FieldName('Email address') + @Email() + @Required('Your email address will be used to send you a confirmation email. You must fill it out') + emailAddress = ''; + + @Required() + @MinLength(10) + @MaxLength(30) + password = ''; + + @FieldName('Confirm password') + @Validation( + 'The passwords do not match.', + (pwd, model) => model.password === pwd + ) + confirmPassword = ''; + + @Pattern(/^[a-z0-9-]+$/i, 'Must be a valid slug tag') + slug = 'foo'; + + @Length(6, 'Alias must be 6 characters long') + alias: string; +} + +// ES6-style +class MyController { + model = new MyModel(); + validator = Validator.new(this.model); + + doStuff(): void { + var opts = this.validator.getValidationOptions('alias'); + var fieldName = opts.getFieldName(); + var errs = opts.validateValue('foo', this.model); + opts.setFieldName('Foo'); + opts.addValidator(null); + var validators = opts.getValidators(); + } + + validate(): void { + var result = this.validator.validate(); + if (!result.isValid) { + for(var i = 0; i < result.errors.length; i++) { + var current = result.errors[i]; + console.error(current.fieldName, current.errors); + } + } + } +} + +// ES5-style +function MyOtherModel() { + this.foo = ''; + this.bar = ''; +} + +Validator.decorate(MyOtherModel, { + foo: [ + Required() + ], + bar: [ + Pattern(/^[a-z][0-9]$/i) + ] +}); + +var otherValidator = Validator.new(new MyOtherModel()); +otherValidator.validateField('foo', ''); + +// Custom validator +class MyValidator extends BaseValidator { + + validatesEmptyValue(): boolean { + return false; + } + + getMessage(fieldName: string, fieldValue: any): string { + return 'No!'; + } + + isValid(value: any, model: any): boolean { + return false; + } + +} diff --git a/decorum/decorum-tests.ts.tscparams b/decorum/decorum-tests.ts.tscparams new file mode 100644 index 000000000..5300ee722 --- /dev/null +++ b/decorum/decorum-tests.ts.tscparams @@ -0,0 +1,2 @@ +--experimentalDecorators +--target ES5 diff --git a/decorum/decorum.d.ts b/decorum/decorum.d.ts new file mode 100644 index 000000000..858b1e2dd --- /dev/null +++ b/decorum/decorum.d.ts @@ -0,0 +1,292 @@ +// Type definitions for Decorum JS v0.1.2 +// Project: https://github.com/dflor003/decorum +// Definitions by: Danil Flores +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'decorum' { + /** + * A generic custom validation. Takes a predicate that will receive the proposed value as the first parameter and the + * current model state as the second. + * @param message The message to display when the predicate fails. + * @param predicate A lambda expression/function that determines if the value is valid. If it returns a falsy value, the + * field will be considered invalid and will return the passed error message upon validation. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function Validation(message: string, predicate: (value: any, model: TModel) => boolean): PropertyDecorator; + + /** + * Validate's that the field is a valid email address. The format used is the same as the webkit browser's internal + * email validation format. For looser or stricter formats, use your own validation based on the @Pattern decorator. + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function Email(message?: string): PropertyDecorator; + + /** + * Sets the field's "friendly" name in validation error messages. + * @param name The field's friendly name + * @returns {function(Object, string): void} A field validation decorator. + */ + export function FieldName(name: string): PropertyDecorator; + + /** + * Validate's a field's EXACT length. Validation fails if the field is not EXACTLY the length passed. + * @param length The exact length the field must be. + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function Length(length: number, message?: string): PropertyDecorator; + + /** + * Validates a field's maximum length. + * @param maxLength The field's maximum length. Must be a positive integer greater than 1. + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function MaxLength(maxLength: number, message?: string): PropertyDecorator; + + /** + * Validates the field's minimum length. + * @param minLength The field's minimum length. Must be a positive integer greater than 0 + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function MinLength(minLength: number, message?: string): PropertyDecorator; + + /** + * Validates the field against a regular expression pattern. + * @param regex The regex to validate against. Should be a valid JavaScript {RegExp} instance. + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function Pattern(regex: RegExp, message?: string): PropertyDecorator; + + /** + * Marks the field as required. + * @param message [Optional] Overrides the default validation error message. + * @returns {function(Object, string): void} A field validation decorator. + */ + export function Required(message?: string): PropertyDecorator; + + /** + * A map from field name to array of field validation decorators. + */ + export type ValidationDefinitions = { + [field: string]: PropertyDecorator[]; + }; + + /** + * Static container for convenience methods related to field validation. + */ + export class Validator { + /** + * Creates a new model validator for the given model. Model should be a valid class that has a valid constructor + * and a prototype. + * @param model The model to create the validator for. + * @returns {ModelValidator} An instance of {ModelValidator} + */ + static new(model: any): ModelValidator; + + /** + * Decorates the passed class with model validations. Use this when you do not have access to ES7 decorators. + * The object passed should be a valid class (ES6 class or ES5 function constructor). + * @param objectType The class to decorate. + * @param definitions One or more field validation definitions of the form { "fieldName": [ decorators ] }. + */ + static decorate(objectType: any, definitions: ValidationDefinitions): void; + + /** + * Creates an anonymous validator, immediately validates the model, and returns any validation errors on the model + * as a result. + * @param model The model to validate. + */ + static validate(model: any): IValidationResult; + } + + /** + * Details about validation errors on a field. + */ + export interface IFieldValidationError { + /** + * The property name of the field on the model. + */ + field: string; + + /** + * The "friendly" name of the field. If not set on the model via @FieldName(...), it will default to "Field". + */ + fieldName: string; + + /** + * One or more field validation errors. Empty if no errors. + */ + errors: string[]; + } + + /** + * Result returned when a model is validated. + */ + export interface IValidationResult { + /** + * Whether or not the model is valid. + */ + isValid: boolean; + + /** + * A map of field name to validation errors. + */ + errors: IFieldValidationError[]; + } + + /** + * Wraps a model to allow the consuming class to call validation methods. + */ + export class ModelValidator { + /** + * Creates a new model validator. + * @param model The model to validate. Should be a class that has a valid constructor function and prototype. + */ + constructor(model: any); + + /** + * Gets the validation options for the given field name. + * @param fieldKey The name of the field to get options for. + * @returns {FieldOptions} The field options associated with that field or null if no validations defined + * for the field. + */ + getValidationOptions(fieldKey: string): FieldOptions; + + /** + * Validates the given field on this {ModelValidator}'s model. If a proposed value is passed, validate + * against that passed value; otherwise, use the field's current value on the model. + * @param fieldKey The name of the field to validate. + * @param proposedValue [Optional] The proposed value to set on the field. + * @returns {string[]} An array of field validation error messages if the field is invalid; otherwise, + * an empty array. + */ + validateField(fieldKey: string, proposedValue?: any): string[]; + + /** + * Validate the entire model and return a result that indicates whether the model is valid or not and any errors + * that have occurred in an object indexed by field name on the model. + * @returns {IValidationResult} An object that contains whether the model is valid or not and errors by field name. + */ + validate(): IValidationResult; + } + + /** + * Callback invoked when a validation needs to return an error. Parameters include field name, + * field value, and any other properties relating to the field validation itself. + */ + export type MessageHandler = (fieldName: string, fieldValue: any, ...args: any[]) => string; + + /** + * A map of validation "key" (unique name for a given type of validation) to message handler callback. + */ + export interface IMessageHandlerMap { + [key: string]: MessageHandler; + } + + /** + * Mechanism for overriding validation errors to provide for custom or localized error messages. + * @type {{IMessageHandlerMap}} + */ + let MessageHandlers: IMessageHandlerMap; + + /** + * Validation options for a given field including actual validators and meta data such as the field name. + */ + export class FieldOptions { + /** + * Gets the "friendly" name of the field for use in validation error messages. Defaults to just "Field". + * @returns {string} + */ + getFieldName(): string; + + /** + * Sets the "friendly" name of the field for use in validation error messages. This name will be used in the text + * of validation errors. + * @param name The new name to set. + */ + setFieldName(name: string): void; + + /** + * Add a validator to the list of validators for this field. + * @param validator The validator to add. Should be a class that extends from {BaseValidator}. + */ + addValidator(validator: BaseValidator): void; + + /** + * Gets the validators assigned to this field. + * @returns {BaseValidator[]} The validators for this field. + */ + getValidators(): BaseValidator[]; + + /** + * Runs through all of the validators for the field given a particular value and returns any validation errors that + * may have occurred. + * @param value The value to validate. + * @param model The rest of the model. Used in custom cross-field validations. + * @returns {string[]} Any validation errors that may have occurred or an empty array if the value passed is valid + * for the field. + */ + validateValue(value: any, model: any): string[]; + } + + /** + * Base abstract class for all validators. Methods that must be overridden: + * getMessage(...) - Get error message to return when field is invalid. + * isValid(...) - Check validity of field given proposed value and the rest of the model. + */ + abstract class BaseValidator { + /** + * Initializes the {BaseValidator} + * @param validatorKey A unique "key" by which to identify this field validator i.e. length, maxlength, required. + * Should be a valid JS property name. + * @param message A custom error message to return. Should be passed down from concrete class' constructors to enable + * customizing error messages. + */ + constructor(validatorKey: string, message: string); + + /** + * Returns true if the validator instance was passed a custom error message. + */ + hasCustomMessage: boolean; + + /** + * Check whether this validator should process an "empty" value (i.e. null, undefined, empty string). Override + * this in derived classes to skip validators if the field value hasn't been set. Things like email, min/max length, + * and pattern should return false for this to ensure they don't get fired when the model is initially empty + * before a user has had a chance to input a value. Things like required should override this to true so that + * they are fired for empty values. Base implementation defaults to false + * @returns {boolean} + */ + validatesEmptyValue(): boolean; + + /** + * Gets the custom error message set on this validator. + * @returns {string} The custom error message or null if none has been set. + */ + getCustomMessage(): string; + + /** + * Gets the unique name for this validator. + * @returns {string} The unique name for this validator. + */ + getKey(): string; + + /** + * [Abstract] Gets the error message to display when a field fails validation by this validator. + * @param fieldName The "friendly" name set for the field. + * @param fieldValue The field's current value. + */ + abstract getMessage(fieldName: string, fieldValue: any): string; + + /** + * [Abstract] Checks the passed value for validity. + * @param value The field's proposed value. + * @param model The rest of the model if cross-field validity checks are necessary. + */ + abstract isValid(value: any, model: any): boolean; + } +} From bb1c2b4ebc39858ae46c2b277a369790b9c3192e Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Mon, 26 Oct 2015 16:01:41 +0100 Subject: [PATCH 09/24] Renamed jquery.highlight to jquery.highlight-bartaz --- .../jquery.highlight-bartaz-tests.ts | 4 ++-- .../jquery.highlight-bartaz.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename jquery.highlight/jquery.highlight-tests.ts => jquery.highlight-bartaz/jquery.highlight-bartaz-tests.ts (92%) rename jquery.highlight/jquery.highlight.d.ts => jquery.highlight-bartaz/jquery.highlight-bartaz.d.ts (99%) diff --git a/jquery.highlight/jquery.highlight-tests.ts b/jquery.highlight-bartaz/jquery.highlight-bartaz-tests.ts similarity index 92% rename from jquery.highlight/jquery.highlight-tests.ts rename to jquery.highlight-bartaz/jquery.highlight-bartaz-tests.ts index 84ef701f1..90d60e83f 100644 --- a/jquery.highlight/jquery.highlight-tests.ts +++ b/jquery.highlight-bartaz/jquery.highlight-bartaz-tests.ts @@ -1,4 +1,4 @@ -/// +/// @@ -23,4 +23,4 @@ $('#content').highlight('ipsum', { element: 'em', className: 'important' }); $('#content').unhighlight(); // remove custom highlight -$('#content').unhighlight({ element: 'em', className: 'important' }); \ No newline at end of file +$('#content').unhighlight({ element: 'em', className: 'important' }); diff --git a/jquery.highlight/jquery.highlight.d.ts b/jquery.highlight-bartaz/jquery.highlight-bartaz.d.ts similarity index 99% rename from jquery.highlight/jquery.highlight.d.ts rename to jquery.highlight-bartaz/jquery.highlight-bartaz.d.ts index d48d1f7d8..2f5b8043b 100644 --- a/jquery.highlight/jquery.highlight.d.ts +++ b/jquery.highlight-bartaz/jquery.highlight-bartaz.d.ts @@ -17,4 +17,4 @@ interface JQuery { caseSensitive?: boolean, wordsOnly?: boolean }): JQuery; -} \ No newline at end of file +} From fc6f8c630d8cf42cca62b5d6995b93017faa878b Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 26 Oct 2015 22:40:43 +0500 Subject: [PATCH 10/24] lodash: signatures of the method _.add changed --- lodash/lodash-tests.ts | 16 ++++++++++++++-- lodash/lodash.d.ts | 13 ++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a47a41f1..8c04cd8f8 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2992,8 +2992,20 @@ module TestToPlainObject { ********/ // _.add -result = _.add(1, 1); -result = _(1).add(1); +module TestAdd { + { + let result: number; + + result = _.add(1, 1); + result = _(1).add(1); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().add(1); + } +} // _.ceil module TestCeil { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 528356ff2..5c1bf088f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7447,11 +7447,15 @@ declare module _ { 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; + add( + augend: number, + addend: number + ): number; } interface LoDashImplicitWrapper { @@ -7461,6 +7465,13 @@ declare module _ { add(addend: number): number; } + interface LoDashExplicitWrapper { + /** + * @see _.add + */ + add(addend: number): LoDashExplicitWrapper; + } + //_.ceil interface LoDashStatic { /** From 6ff51c98c76f748cd3535ba1a8778276bb74cc53 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 26 Oct 2015 22:48:58 +0500 Subject: [PATCH 11/24] lodash: signatures of the method _.floor changed --- lodash/lodash-tests.ts | 37 ++++++++++++++++++++------------- lodash/lodash.d.ts | 47 ++++++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 32 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a47a41f1..ea9dbf391 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2102,20 +2102,6 @@ module TestMap { } } -// _.floor -result = _.floor(4.006); -// → 4 -result = _.floor(0.046, 2); -// → 0.04 -result = _.floor(4060, -2); -// → 4000 -result = _(4.006).floor(); -// → 4 -result = _(0.046).floor(2); -// → 0.04 -result = _(4060).floor(-2); -// → 4000 - result = _.sum([4, 2, 8, 6]); result = _.sum([4, 2, 8, 6], function(v) { return v; }); result = _.sum({a: 2, b: 4}); @@ -3015,6 +3001,29 @@ module TestCeil { } } +// _.floor +module TestFloor { + { + let result: number; + + result = _.floor(4.006); + result = _.floor(0.046, 2); + result = _.floor(4060, -2); + + result = _(4.006).floor(); + result = _(0.046).floor(2); + result = _(4060).floor(-2); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(4.006).chain().floor(); + result = _(0.046).chain().floor(2); + result = _(4060).chain().floor(-2); + } +} + // _.max module TestMax { let array: number[]; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 528356ff2..04368101e 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4538,24 +4538,6 @@ declare module _ { ): LoDashImplicitArrayWrapper; } - //_.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 LoDashImplicitWrapper { - /** - * @see _.floor - */ - floor(precision?: number): number; - } - //_.sum interface LoDashStatic { /** @@ -7490,6 +7472,35 @@ declare module _ { ceil(precision?: number): LoDashExplicitWrapper; } + //_.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 LoDashImplicitWrapper { + /** + * @see _.floor + */ + floor(precision?: number): number; + } + + interface LoDashExplicitWrapper { + /** + * @see _.floor + */ + floor(precision?: number): LoDashExplicitWrapper; + } + //_.max interface LoDashStatic { /** From 5e48b490143cc32be5d6498b120f21980baf950e Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 26 Oct 2015 23:06:36 +0500 Subject: [PATCH 12/24] lodash: signatures of the method _.words changed --- lodash/lodash-tests.ts | 22 ++++++++++++++++++---- lodash/lodash.d.ts | 13 ++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a47a41f1..b613146c4 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3988,10 +3988,24 @@ result = _.unescape('fred, barney, & pebbles'); result = _('fred, barney, & pebbles').unescape(); // _.words -result = _.words('fred, barney, & pebbles'); -result = _.words('fred, barney, & pebbles', /[^, ]+/g); -result = _('fred, barney, & pebbles').words(); -result = _('fred, barney, & pebbles').words(/[^, ]+/g); +module TestWords { + { + let result: string[]; + + result = _.words('fred, barney, & pebbles'); + result = _.words('fred, barney, & pebbles', /[^, ]+/g); + + result = _('fred, barney, & pebbles').words(); + result = _('fred, barney, & pebbles').words(/[^, ]+/g); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('fred, barney, & pebbles').chain().words(); + result = _('fred, barney, & pebbles').chain().words(/[^, ]+/g); + } +} /*********** * Utility * diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 528356ff2..e57e4c5c2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9638,11 +9638,15 @@ declare module _ { 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[]; + words( + string?: string, + pattern?: string|RegExp + ): string[]; } interface LoDashImplicitWrapper { @@ -9652,6 +9656,13 @@ declare module _ { words(pattern?: string|RegExp): string[]; } + interface LoDashExplicitWrapper { + /** + * @see _.words + */ + words(pattern?: string|RegExp): LoDashExplicitArrayWrapper; + } + /*********** * Utility * ***********/ From 0bfa6372dc551a2018a53676a266430f655b008a Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 26 Oct 2015 23:10:30 +0500 Subject: [PATCH 13/24] lodash: signatures of the method _.camelCase changed --- lodash/lodash-tests.ts | 16 ++++++++++++++-- lodash/lodash.d.ts | 8 ++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a47a41f1..97c2b3522 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3711,8 +3711,20 @@ class Mage { *********/ // _.camelCase -result = _.camelCase('Foo Bar'); -result = _('Foo Bar').camelCase(); +module TestCamelCase { + { + let result: string; + + result = _.camelCase('Foo Bar'); + result = _('Foo Bar').camelCase(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('Foo Bar').chain().camelCase(); + } +} // _.capitalize module TestCapitalize { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 528356ff2..d0cb3120e 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9098,6 +9098,7 @@ declare module _ { interface LoDashStatic { /** * Converts string to camel case. + * * @param string The string to convert. * @return Returns the camel cased string. */ @@ -9111,6 +9112,13 @@ declare module _ { camelCase(): string; } + interface LoDashExplicitWrapper { + /** + * @see _.camelCase + */ + camelCase(): LoDashExplicitWrapper; + } + //_.capitalize interface LoDashStatic { capitalize(string?: string): string; From 734e2bb76c05e73f58f3aea296877c65ed8e40d0 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 26 Oct 2015 23:15:36 +0500 Subject: [PATCH 14/24] lodash: signatures of the method _.random changed --- lodash/lodash-tests.ts | 36 ++++++++++++++++++++++++------------ lodash/lodash.d.ts | 15 +++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a47a41f1..c34c088e1 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3157,20 +3157,32 @@ module TestInRange { // _.random module TestRandom { - let result: number; + { + let result: number; - result = _.random(); - result = _.random(1); - result = _.random(1, 2); - result = _.random(1, 2, true); - result = _.random(1, true); - result = _.random(true); + result = _.random(); + result = _.random(1); + result = _.random(1, 2); + result = _.random(1, 2, true); + result = _.random(1, true); + result = _.random(true); - result = _(1).random(); - result = _(1).random(2); - result = _(1).random(2, true); - result = _(1).random(true); - result = _(true).random(); + result = _(1).random(); + result = _(1).random(2); + result = _(1).random(2, true); + result = _(1).random(true); + result = _(true).random(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().random(); + result = _(1).chain().random(2); + result = _(1).chain().random(2, true); + result = _(1).chain().random(true); + result = _(true).chain().random(); + } } /********* diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 528356ff2..2cdb4820c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7835,6 +7835,21 @@ declare module _ { random(floating?: boolean): number; } + interface LoDashExplicitWrapper { + /** + * @see _.random + */ + random( + max?: number, + floating?: boolean + ): LoDashExplicitWrapper; + + /** + * @see _.random + */ + random(floating?: boolean): LoDashExplicitWrapper; + } + /********** * Object * **********/ From b54c43921823efd5fa410b4e4c436e95fe3a6fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 02:19:49 +0100 Subject: [PATCH 15/24] made option config argument optional --- yeoman-generator/yeoman-generator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index f6d0dd981..b6ebc2f47 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -29,7 +29,7 @@ declare module yo { determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; - option(name: string, config: IYeomanGeneratorOption): void; + option(name: string, config?: IYeomanGeneratorOption): void; rootGeneratorName(): string; run(args?: any): void; run(args: any, callback?: Function): void; From 6a7c067667b8389d1e92da9ff05b434a341a4701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 02:24:28 +0100 Subject: [PATCH 16/24] the configs for option is all optional --- yeoman-generator/yeoman-generator.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index b6ebc2f47..0586c2ee2 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -65,11 +65,11 @@ declare module yo { } export interface IYeomanGeneratorOption { - alias: string; - defaults: any; - desc: string; - hide: boolean; - type: any; + alias?: string; + defaults?: any; + desc?: string; + hide?: boolean; + type?: any; } export interface IQueueProps { From a81c1166f12bb41103accfb3a3da1164a7d337ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 02:40:15 +0100 Subject: [PATCH 17/24] added async,prompt and appname --- yeoman-generator/yeoman-generator.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 0586c2ee2..2f7c58185 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -43,6 +43,11 @@ declare module yo { setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + + async(): any; + prompt(opt?, callback?); + + appname:string; } export interface IArgumentConfig { From 76666791b18fe703b6cf786af10acbddef0655ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 03:07:05 +0100 Subject: [PATCH 18/24] added gruntfile property and interface --- yeoman-generator/yeoman-generator.d.ts | 291 +++++++++++++------------ 1 file changed, 152 insertions(+), 139 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 2f7c58185..5de23f725 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -5,168 +5,181 @@ /// declare module yo { - export interface IYeomanGenerator { - argument(name: string, config: IArgumentConfig): void; - composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; - defaultFor(name: string): void; - destinationRoot(rootPath: string): string; - determineAppname(): void; - getCollisionFilter(): (output: any) => void; - hookFor(name: string, config: IHookConfig): void; - option(name: string, config: IYeomanGeneratorOption): void; - rootGeneratorName(): string; - run(args?: any): void; - run(args: any, callback?: Function): void; - runHooks(callback?: Function): void; - sourceRoot(rootPath: string): string; - } + export interface IYeomanGenerator { + argument(name: string, config: IArgumentConfig): void; + composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; + defaultFor(name: string): void; + destinationRoot(rootPath: string): string; + determineAppname(): void; + getCollisionFilter(): (output: any) => void; + hookFor(name: string, config: IHookConfig): void; + option(name: string, config: IYeomanGeneratorOption): void; + rootGeneratorName(): string; + run(args?: any): void; + run(args: any, callback?: Function): void; + runHooks(callback?: Function): void; + sourceRoot(rootPath: string): string; - export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { - argument(name: string, config: IArgumentConfig): void; - composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; - defaultFor(name: string): void; - destinationRoot(rootPath: string): string; - determineAppname(): void; - getCollisionFilter(): (output: any) => void; - hookFor(name: string, config: IHookConfig): void; - option(name: string, config?: IYeomanGeneratorOption): void; - rootGeneratorName(): string; - run(args?: any): void; - run(args: any, callback?: Function): void; - runHooks(callback?: Function): void; - sourceRoot(rootPath: string): string; - addListener(event: string, listener: Function): NodeJS.EventEmitter; - on(event: string, listener: Function): NodeJS.EventEmitter; - once(event: string, listener: Function): NodeJS.EventEmitter; - removeListener(event: string, listener: Function): NodeJS.EventEmitter; - removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - - async(): any; - prompt(opt?, callback?); - - appname:string; - } - export interface IArgumentConfig { - desc: string; - required: boolean; - optional: boolean; - type: any; - defaults: any; - } + } - export interface IComposeSetting { - local?: string; - link?: string; - } + export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { + argument(name: string, config: IArgumentConfig): void; + composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; + defaultFor(name: string): void; + destinationRoot(rootPath: string): string; + determineAppname(): void; + getCollisionFilter(): (output: any) => void; + hookFor(name: string, config: IHookConfig): void; + option(name: string, config?: IYeomanGeneratorOption): void; + rootGeneratorName(): string; + run(args?: any): void; + run(args: any, callback?: Function): void; + runHooks(callback?: Function): void; + sourceRoot(rootPath: string): string; + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; - export interface IHookConfig { - as: string; - args: any; - options: any; - } + async(): any; + prompt(opt?, callback?); + log(message: string); + npmInstall(packages: string[], options?); - export interface IYeomanGeneratorOption { - alias?: string; - defaults?: any; - desc?: string; - hide?: boolean; - type?: any; - } + appname: string; + gruntfile: IGruntFileStatic; + } - export interface IQueueProps { - initializing: () => void; - prompting?: () => void; - configuring?: () => void; - default?: () => void; - writing: { - [target: string]: () => void; - }; - conflicts?: () => void; - install?: () => void; - end: () => void; - } + export interface IGruntFileStatic { + loadNpmTasks(pluginName: string): void; + insertConfig(name, config); + registerTask(name, tasks); + insertVariable(name, value); + prependJavaScript(code); + } - export interface INamedBase extends IYeomanGenerator { - } + export interface IArgumentConfig { + desc: string; + required: boolean; + optional: boolean; + type: any; + defaults: any; + } - export interface IBase extends INamedBase { - } + export interface IComposeSetting { + local?: string; + link?: string; + } - export interface IAssert { - file(path: string): void; - file(paths: string[]): void; - fileContent(file: string, reg: RegExp): void; + export interface IHookConfig { + as: string; + args: any; + options: any; + } - /** @param {[String, RegExp][]} pairs */ - fileContent(pairs: any[][]): void; + export interface IYeomanGeneratorOption { + alias?: string; + defaults?: any; + desc?: string; + hide?: boolean; + type?: any; + } - /** @param {[String, RegExp][]|String[]} pairs */ - files(pairs: any[]): void; + export interface IQueueProps { + initializing: () => void; + prompting?: () => void; + configuring?: () => void; + default?: () => void; + writing: { + [target: string]: () => void; + }; + conflicts?: () => void; + install?: () => void; + end: () => void; + } - /** - * @param {Object} subject - * @param {Object|Array} methods - */ - implement(subject: any, methods: any): void; - noFile(file: string): void; - noFileContent(file: string, reg: RegExp): void; + export interface INamedBase extends IYeomanGenerator { + } - /** @param {[String, RegExp][]} pairs */ - noFileContent(pairs: any[][]): void; + export interface IBase extends INamedBase { + } - /** - * @param {Object} subject - * @param {Object|Array} methods - */ - noImplement(subject: any, methods: any): void; + export interface IAssert { + file(path: string): void; + file(paths: string[]): void; + fileContent(file: string, reg: RegExp): void; - textEqual(value: string, expected: string): void; - } + /** @param {[String, RegExp][]} pairs */ + fileContent(pairs: any[][]): void; - export interface ITestHelper { - createDummyGenerator(): IYeomanGenerator; - createGenerator(name: string, dependencies: any[], args: any, options: any): IYeomanGenerator; - decorate(context: any, method: string, replacement: Function, options: any): void; - gruntfile(options: any, done: Function): void; - mockPrompt(generator: IYeomanGenerator, answers: any): void; - registerDependencies(dependencies: string[]): void; - restore(): void; + /** @param {[String, RegExp][]|String[]} pairs */ + files(pairs: any[]): void; - /** @param {String|Function} generator */ - run(generator: any): IRunContext; - } + /** + * @param {Object} subject + * @param {Object|Array} methods + */ + implement(subject: any, methods: any): void; + noFile(file: string): void; + noFileContent(file: string, reg: RegExp): void; - export interface IRunContext { - async(): Function; - inDir(dirPath: string): IRunContext; + /** @param {[String, RegExp][]} pairs */ + noFileContent(pairs: any[][]): void; - /** @param {String|String[]} args */ - withArguments(args: any): IRunContext; - withGenerators(dependencies: string[]): IRunContext; - withOptions(options: any): IRunContext; - withPrompts(answers: any): IRunContext; - } + /** + * @param {Object} subject + * @param {Object|Array} methods + */ + noImplement(subject: any, methods: any): void; - /** @type file file-utils */ - var file: any; - var assert: IAssert; - var test: ITestHelper; - module generators { + textEqual(value: string, expected: string): void; + } - export class NamedBase extends YeomanGeneratorBase implements INamedBase { - constructor(args: string | string[], options: any); - } + export interface ITestHelper { + createDummyGenerator(): IYeomanGenerator; + createGenerator(name: string, dependencies: any[], args: any, options: any): IYeomanGenerator; + decorate(context: any, method: string, replacement: Function, options: any): void; + gruntfile(options: any, done: Function): void; + mockPrompt(generator: IYeomanGenerator, answers: any): void; + registerDependencies(dependencies: string[]): void; + restore(): void; - export class Base extends NamedBase implements IBase { - static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; - } - } + /** @param {String|Function} generator */ + run(generator: any): IRunContext; + } + + export interface IRunContext { + async(): Function; + inDir(dirPath: string): IRunContext; + + /** @param {String|String[]} args */ + withArguments(args: any): IRunContext; + withGenerators(dependencies: string[]): IRunContext; + withOptions(options: any): IRunContext; + withPrompts(answers: any): IRunContext; + } + + /** @type file file-utils */ + var file: any; + var assert: IAssert; + var test: ITestHelper; + module generators { + + export class NamedBase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends NamedBase implements IBase { + static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } + } } declare module "yeoman-generator" { - export = yo; + export = yo; } From 9ce874b71252058000c8180f8523c8680be36f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 03:11:14 +0100 Subject: [PATCH 19/24] added types for making build happy --- yeoman-generator/yeoman-generator.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 5de23f725..992b611bd 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -47,14 +47,20 @@ declare module yo { emit(event: string, ...args: any[]): boolean; async(): any; - prompt(opt?, callback?); + prompt(opt?:IPromptOptions, callback?:(answers:any)=>void); log(message: string); npmInstall(packages: string[], options?); appname: string; gruntfile: IGruntFileStatic; } - + export interface IPromptOptions{ + type:stirng; + name:string; + message:string; + default:string; + } + export interface IGruntFileStatic { loadNpmTasks(pluginName: string): void; insertConfig(name, config); From 13a9213fe54efe27d87e098a0714ff24171626ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 03:14:03 +0100 Subject: [PATCH 20/24] added return types on methods --- yeoman-generator/yeoman-generator.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 992b611bd..3e456cb73 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -47,9 +47,9 @@ declare module yo { emit(event: string, ...args: any[]): boolean; async(): any; - prompt(opt?:IPromptOptions, callback?:(answers:any)=>void); - log(message: string); - npmInstall(packages: string[], options?); + prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; + log(message: string) : void; + npmInstall(packages: string[], options?) :void; appname: string; gruntfile: IGruntFileStatic; From 6c4ef6671d3aa63e06cdae3e20f208fefc906e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 03:17:42 +0100 Subject: [PATCH 21/24] A few more type errors --- yeoman-generator/yeoman-generator.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 3e456cb73..ee12efac6 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -55,7 +55,7 @@ declare module yo { gruntfile: IGruntFileStatic; } export interface IPromptOptions{ - type:stirng; + type:string; name:string; message:string; default:string; @@ -63,10 +63,10 @@ declare module yo { export interface IGruntFileStatic { loadNpmTasks(pluginName: string): void; - insertConfig(name, config); - registerTask(name, tasks); - insertVariable(name, value); - prependJavaScript(code); + insertConfig(name:string, config:any):void; + registerTask(name:string, tasks:any):void; + insertVariable(name:string, value:any):void; + prependJavaScript(code:string):void; } export interface IArgumentConfig { From 5d4709adb84659624f023c0af76d653d250d22c7 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Mon, 26 Oct 2015 19:19:09 -0700 Subject: [PATCH 22/24] added strong typed options --- OpenJsCad/openjscad.d.ts | 43 +++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/OpenJsCad/openjscad.d.ts b/OpenJsCad/openjscad.d.ts index af4d0b047..072fa10b5 100644 --- a/OpenJsCad/openjscad.d.ts +++ b/OpenJsCad/openjscad.d.ts @@ -772,13 +772,42 @@ declare module CSG { followWith(cagish: any): CSG; verify(): void; } + interface IRadiusOptions { + radius?: number; + resolution?: number; + } + interface ICircleOptions extends IRadiusOptions { + center?: Vector2D | number[]; + } + interface IArcOptions extends ICircleOptions { + startangle?: number; + endangle?: number; + maketangent?: boolean; + } + interface IEllpiticalArcOptions extends IRadiusOptions { + clockwise?: boolean; + large?: boolean; + xaxisrotation?: number; + xradius?: number; + yradius?: number; + } + interface IRectangleOptions { + center?: Vector2D; + corner1?: Vector2D; + corner2?: Vector2D; + radius?: Vector2D; + } + interface IRoundRectangleOptions { + roundradius: number; + resolution?: number; + } class Path2D extends CxG { closed: boolean; points: Vector2D[]; lastBezierControlPoint: Vector2D; constructor(points: number[], closed?: boolean); constructor(points: Vector2D[], closed?: boolean); - static arc(options: any): Path2D; + static arc(options: IArcOptions): Path2D; concat(otherpath: Path2D): Path2D; appendPoint(point: Vector2D): Path2D; appendPoints(points: Vector2D[]): Path2D; @@ -788,7 +817,7 @@ declare module CSG { innerToCAG(): CAG; transform(matrix4x4: Matrix4x4): Path2D; appendBezier(controlpoints: any, options: any): Path2D; - appendArc(endpoint: Vector2D, options: any): Path2D; + appendArc(endpoint: Vector2D, options: IEllpiticalArcOptions): Path2D; } } declare class CAG extends CxG implements ICenter { @@ -799,9 +828,9 @@ declare class CAG extends CxG implements ICenter { static fromPoints(points: CSG.Vector2D[]): CAG; static fromPointsNoCheck(points: CSG.Vector2D[]): CAG; static fromFakeCSG(csg: CSG): CAG; - static linesIntersect(p0start: any, p0end: any, p1start: any, p1end: any): boolean; - static circle(options: any): CAG; - static rectangle(options: any): CAG; + static linesIntersect(p0start: CSG.Vector2D, p0end: CSG.Vector2D, p1start: CSG.Vector2D, p1end: CSG.Vector2D): boolean; + static circle(options: CSG.ICircleOptions): CAG; + static rectangle(options: CSG.IRectangleOptions): CAG; static roundedRectangle(options: any): CAG; static fromCompactBinary(bin: any): CAG; toString(): string; @@ -834,11 +863,11 @@ declare class CAG extends CxG implements ICenter { sideVertexIndices: Uint32Array; vertexData: Float64Array; }; - getOutlinePaths(): any[]; + getOutlinePaths(): CSG.Path2D[]; overCutInsideCorners(cutterradius: any): CAG; center(cAxes: string[]): CxG; toDxf(): Blob; - static PathsToDxf(paths: any): Blob; + static PathsToDxf(paths: CSG.Path2D[]): Blob; } declare module CAG { class Vertex { From 64d834e93e0e5367e5b985107c41c7a9d97d3841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Tue, 27 Oct 2015 03:23:17 +0100 Subject: [PATCH 23/24] last type error --- yeoman-generator/yeoman-generator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index ee12efac6..4ccd98e44 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -49,7 +49,7 @@ declare module yo { async(): any; prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; log(message: string) : void; - npmInstall(packages: string[], options?) :void; + npmInstall(packages: string[], options?:any) :void; appname: string; gruntfile: IGruntFileStatic; From 2192b79337d07e44580987d6dec1222cbf60c10b Mon Sep 17 00:00:00 2001 From: Beng89 Date: Mon, 26 Oct 2015 23:45:30 -0500 Subject: [PATCH 24/24] Added definitions and test for node-array-ext. --- node-array-ext/node-array-ext-tests.ts | 23 +++++++++++++++++++++++ node-array-ext/node-array-ext.d.ts | 17 +++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 node-array-ext/node-array-ext-tests.ts create mode 100644 node-array-ext/node-array-ext.d.ts diff --git a/node-array-ext/node-array-ext-tests.ts b/node-array-ext/node-array-ext-tests.ts new file mode 100644 index 000000000..8981165cd --- /dev/null +++ b/node-array-ext/node-array-ext-tests.ts @@ -0,0 +1,23 @@ +/// +import extensions = require("node-array-ext"); + +var array: Array = [ "hello", "world", "test" ]; +var result: string = ""; +var finish = function(err?: Error) { + if(err) { + console.log(err); + } + else { + console.log(result); + } +} +function each(i: number, element: string, next: (err?: Error) => void): void { + setTimeout(function() { + console.log("%s => %s", i, element); + result += element + " "; + next(); + }, 50 * (array.length - i)); +} + +extensions.asyncEach(array, each, finish); +extensions.awaitEach(array, each, finish); \ No newline at end of file diff --git a/node-array-ext/node-array-ext.d.ts b/node-array-ext/node-array-ext.d.ts new file mode 100644 index 000000000..e8474d6a6 --- /dev/null +++ b/node-array-ext/node-array-ext.d.ts @@ -0,0 +1,17 @@ +// Type definitions for node-array-ext v1.0.00 +// Project: https://github.com/Beng89/node-array-ext +// Definitions by: Ben Goltz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "node-array-ext" { + /** + * Processes each of the elements in the array and triggers a callback once every element has been processed. + * - note that the elements are called in order but are not guaranteed to finish in order. + */ + export function asyncEach (array: Array, each: (i: number, element: T, done: (err?: Error) => void) => void, finish: (err?: Error) => void): void; + /** + * Processes each of the elements in the array and triggers a callback once every element has been processed. + * - note that the elements are called in order and are guaranteed to finish in order. + */ + export function awaitEach (array: Array, each: (i: number, element: T, done: (err?: Error) => void) => void, finish: (err?: Error) => void): void; +} \ No newline at end of file