From d798efd2bae06f89124849e56b293c28e1e3f312 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 9 Mar 2014 22:09:53 +0000 Subject: [PATCH 01/81] Beginning of microsoft ajax definitions This is preliminary and is the foundation. Still need to add to the namespaces that have been declared and port over documentation including testing and re-view all static methods and event handler function arguments. No testing has been completed. --- README.md | 1 + microsoft-ajax/microsoft.ajax.d.ts | 894 +++++++++++++++++++++++++++++ 2 files changed, 895 insertions(+) create mode 100644 microsoft-ajax/microsoft.ajax.d.ts diff --git a/README.md b/README.md index 020897cf8..db1696e55 100755 --- a/README.md +++ b/README.md @@ -193,6 +193,7 @@ List of Definitions * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Ajax] (http://msdn.microsoft.com/en-us/library/bb397536(v=vs.100).aspx) (by [Patrick Magee] (https://github.com/pjmagee)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts new file mode 100644 index 000000000..76bc8da1f --- /dev/null +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -0,0 +1,894 @@ +// Type definitions for microsoft asp.net ajax client side library +// Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx +// Definitions by: Patrick Magee +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//#region Global Namespace + +/** +* Global Namespace +* This section includes members or types that extend the ECMAScript (JavaScript) Global object and other core objects. +* @see {@link http://msdn.microsoft.com/en-us/library/bb310818(v=vs.100).aspx} +*/ + +//#region JavaScript Base Type Extensions + +/** +* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. +* Array Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} +*/ +interface Array { + /** + * Adds an element to the end of an Array object. + */ + add(element: T): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: T, items: T): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): Array; + /** + * Determines whether an element is in an Array object. + */ + contains(element: T): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): T; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: T): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: T[], method: Function, instance: T[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: T[], item: T, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: T[], index: number, item: T); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: T[], item: T): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: T[], index: number): void; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Boolean object. +* Boolean Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} +*/ +interface Boolean { + /** + * Converts a string representation of a logical value to its Boolean object equivalent. + */ + parse(value: string): boolean; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Date object. +* Date Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} +*/ +interface Date { + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; +} + +/** +* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). +* Error Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} +*/ +interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; +} + +/** +* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. +* Number Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} +*/ +interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; +} + +/** +* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. +* Object Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} +*/ +interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. +* String Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} +*/ +interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; +} + +//#endregion + +//#region ASP.NET Types + +/** +* Provides a typing and type-reflection system for ECMAScript (JavaScript) object-oriented programming functionality. +* Type Class +* @see {@link http://msdn.microsoft.com/en-us/library/bb397568(v=vs.100).aspx} +*/ +declare class Type { + /** + * Invokes a base method with specified arguments. + * @returns A value of the class that the base method returns. If the base method does not return a value, no value is returned. + */ + callBaseMethod(instance: any, name: string, baseArguments?: any[]): any; +} + +//#endregion + +//#region Shortcuts to commonly used APIs + +/** +* Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. +* @param type +* The type of the component to create. +* @param properties +* (Optional) A JSON object that describes the properties and their values. +* @param events +* (Optional) A JSON object that describes the events and their handlers. +* @param references +* (Optional) A JSON object that describes the properties that are references to other components. +* @param element +* (Optional) The DOM element that the component should be attached to. +* +* @returns A new instance of a component that uses the specified parameters. +*/ +declare function $create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + +/** +* Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @return A Component object that contains the component requested by ID, if found; otherwise, null. +*/ +declare function $find(id: string, parent?: Sys.Component): Sys.Component; + +//#endregion + +//#endregion + +//#region Sys Namespace + +/** +* Represents the root namespace for the Microsoft Ajax Library, which contains all fundamental classes and base classes. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397702(v=vs.100).aspx} +*/ +declare module Sys { + /** + * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} + */ + class Application { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Events + + /** + * Raised after all scripts have been loaded but before objects are created. + */ + add_init(handler: Function): void; + remove_init(handler: Function): void; + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ + add_load(handler: Function): void; + remove_load(handler: Function): void; + /** + * Occurs when the user clicks the browser's Back or Forward button. + */ + add_navigate(handler: Function): void; + remove_navigate(handler: Function): void; + + //#endregion + + //#region Methods + + /** + * Registers a component with the application and initializes it if the component is not already initialized. + */ + addComponent(component: any): void; + /** + * Instructs the application to start creating components. + */ + beginCreateComponents(): void; + /** + * Creates a history point and adds it to the browser's history stack. + */ + addHistoryPoint(state: Object, title?: string): void; + /** + * Called by the Sys.Application.beginUpdate Method to indicate that the process of setting component properties of the application has begun. + */ + beginUpdate(): void; + /** + * Releases resources and dependencies held by the client application. + */ + dispose(): void; + /** + * Releases resources and dependencies associated with an element and its child nodes. + * @param element + * The element to dispose. + * @param childNodesOnly + * A boolean value used to determine whether to dispose of the element and its child nodes or to dispose only its child nodes. + */ + disposeElement(element: Element, childNodesOnly: boolean): void; + /** + * Instructs the application to finalize component creation. + */ + endCreateComponents(): void; + /** + * Called by the Sys.Application.endCreateComponents Method to indicate that the process of updating the application has completed. + */ + endUpdate(): void; + /** + * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. + * @return A Component object that contains the component requested by ID, if found; otherwise, null. + */ + findComponent(id: string, parent?: Component): Component; + /** + * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. + */ + getComponents(): Component[]; + /** + * This function supports the client-script infrastructure and is not intended to be used directly from your code. + */ + initialize(): void; + /** + * Called by a referenced script to indicate that it has been loaded. This API is obsolete. You no longer need to call this method in order to notify the Microsoft Ajax Library that the JavaScript file has been loaded. + */ + notifyScriptLoaded(): void; + /** + * Raises the load event. This member is static and can be invoked without creating an instance of the class. + */ + raiseLoad(): void; + /** + * Raises the Sys.INotifyPropertyChange.propertyChanged event. + */ + raisePropertyChanged(propertyName: string): void; + /** + * Registers with the application an object that will require disposing. This member is static and can be invoked without creating an instance of the class. + */ + registerDisposableObject(object: any): void; + /** + * Removes the object from the application and disposes the object if it is disposable. This member is static and can be invoked without creating an instance of the class. + */ + removeComponent(component: Component): void; + /** + * Unregisters a disposable object from the application. This member is static and can be invoked without creating an instance of the class. + */ + unregisterDisposableObject(object: any): void; + /** + * Called by the Sys.Application.endUpdate method as a placeholder for additional logic. + */ + updated(): void; + + //#endregion + + //#region Properties + + /** + * Gets or sets a value that indicates whether the Web application supports history point management. + */ + get_enableHistory(): boolean; + /** + * Gets or sets a value that indicates whether the Web application supports history point management. + * @param value + * true to allow the Web application to support history points, or false to not allow history points. + */ + set_enableHistory(value: boolean): void; + /** + * Gets a value that indicates whether the application is in the process of creating components. This member is static and can be invoked without creating an instance of the class. + */ + get_isCreatingComponents(): boolean; + /** + * Gets a value that indicates whether the application is in the process of disposing its resources. This member is static and can be invoked without creating an instance of the class. + */ + get_isDisposing(): boolean; + + //#endregion + } + + /** + * Provides information about the current Web browser. + * @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx} + */ + class Browser { + + //#region Fields + + /** + * Gets an object that represents the user agent of the browser. + */ + agent: any; + /** + * Gets a value that indicates the document compatibility mode of the browser. + */ + documentMode: number; + /* + * Gets a value that indicates whether the browser supports debug statements. + */ + hasDebuggerStatement: boolean; + /** + * Gets the name of the browser. + */ + name: string; + /* + * Gets the version number of the browser. + */ + version: number; + + //#endregion + } + + class Component { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Events + + /** + * Raised when the dispose method is called for a component. + */ + add_disposing(handler: Function): void; + + remove_disposing(handler: Function): void; + + /** + * Raised when the raisePropertyChanged method of the current Component object is called. + */ + add_propertyChanged(handler: Function): void; + + remove_propertyChanged(handler: Function): void; + + //#endregion + + //#region Methods + + /** + * Called by the create method to indicate that the process of setting properties of a component instance has begun. + */ + beginUpdate(): void; + + /** + * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. + * @param type + * The type of the component to create. + * @param properties + * (Optional) A JSON object that describes the properties and their values. + * @param events + * (Optional) A JSON object that describes the events and their handlers. + * @param references + * (Optional) A JSON object that describes the properties that are references to other components. + * @param element + * (Optional) The DOM element that the component should be attached to. + * + * @returns A new instance of a component that uses the specified parameters. + */ + create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Component; + + //#endregion + + //#region Properties + + //#endregion + } + + /** + * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. + */ + class Debug { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Methods + + assert(condition: boolean, message?: string, displayCaller?: boolean): void; + + /** + * Clears all trace messages from the trace console. + */ + clearTrace(): void; + + /** + * Displays a message in the debugger's output window and breaks into the debugger. + * @param message + * The message to display. + */ + fail(message: string): void; + + /** + * Appends a text line to the debugger console and to the trace console, if available. + * @param text + * The text to display. + */ + trace(text: string): void; + + /** + * Dumps an object to the debugger console and to the trace console, if available. + * @param object + * The object to dump. + * @param name + * (Optional) The name of the object. + */ + traceDump(object: any, name?: string): void; + + //#endregion + } + + //#region Event Args + + /** + * Provides a base class for classes that are used by event sources to pass event argument information. + */ + class EventArgs { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Fields + + /** + * A static object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. + */ + Empty: EventArgs; + + //#endregion + + } + + /** + * Provides a class for command events. + */ + class CommandEventArgs extends EventArgs { + + //#region Constructors + + constructor(commandName: string, commandArgument: any, commandSource: any); + + //#endregion + + //#region Properties + + /** + * Gets a string that specifies the command name. + */ + get_commandName(): string; + + /** + * Gets a value that represents the command argument. + */ + get_commandArgument(): any; + + /** + * Gets a value that represents the command source. + */ + get_commandSource(): any; + + //#endregion + } + + /** + * Provides the base class for events that can be canceled. + */ + class CancelEventArgs extends EventArgs { + + //#region Properties + + /** + * true to request that the event be canceled; otherwise, false. The default is false. + */ + set_cancel(value: boolean): void; + + /* + * true to request that the event be canceled; otherwise, false. The default is false. + */ + get_cancel(): boolean; + + //#endregion + + } + + //#endregion + + //#region Exception Types + + /** + * Raised when a function or method is invoked and at least one of the passed arguments does not meet the parameter specification of the called function or method. + */ + class ArgumentException { + + } + /** + * Raised when an argument has an invalid value of null. + */ + class ArgumentNullException { + + } + /** + * Raised when an argument value is outside an acceptable range. + */ + class ArgumentOutOfRangeException { + + } + /** + * Raised when a parameter is not an allowed type. + */ + class ArgumentTypeException { + + } + /** + * Raised when an argument for a required method parameter is undefined. + */ + class ArgumentUndefinedException { + + } + /** + * + */ + class FormatException { + + } + /** + * Raised when a call to a method has failed, but the reason was not invalid arguments. + */ + class InvalidOperationException { + + } + /** + * Raised when a requested method is not supported by an object. + */ + class NotImplementedException { + + } + /** + * Raised when an invalid number of arguments have been passed to a function. + */ + class ParameterCountException { + + } + /** + * Raised by the Microsoft Ajax Library framework when a script does not load successfully. This exception should not be thrown by the developer. + */ + class ScriptLoadFailedException { + + } + + //#endregion + + //#region Sys.Net Namespace + + /** + * The Sys.Net namespace contains classes that manage communication between AJAX-enabled ASP.NET client applications and Web services on the server. For more information, see Using Web Services in ASP.NET AJAX. The Sys.Net namespace is part of the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310860(v=vs.100).aspx} + */ + module Net { + + /** + * Provides the script API to make a Web request. + */ + class WebRequest { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.Net.WebRequest class. + */ + constructor(); + + //#endregion + + //#region Members + + /** + * Registers a handler for the completed request event of the Web request. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310841(v=vs.100).aspx} + */ + add_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; + + /** + * Removes the event handler added by the add_completed method. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397454(v=vs.100).aspx} + */ + remove_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; + + /** + * Gets the resolved URL of the Sys.Net.WebRequest instance. + * @returns The resolved URL that the Web request is directed to. + */ + getResolvedUrl(): string; + + /** + * Executes a Web request. + */ + invoke(): void; + + /** + * Raises the completed event for the associated Sys.Net.WebRequest instance. + * @param eventArgs + * The value to pass to the Web request completed event handler. + */ + completed(eventArgs: Sys.EventArgs): void; + + //#endregion + + } + } + + //#endregion + + //#region Sys.Serialization Namespace + + /** + * Contains classes related to data serialization for AJAX client functionality in ASP.NET. For more information, see Using Web Services in ASP.NET AJAX. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310840(v=vs.100).aspx} + */ + module Serialization { + + /** + * Serializes JavaScript types into JSON-formatted data and deserializes JSON-formatted data into JavaScript types + * The JavaScriptSerializer class contains only static methods. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310857(v=vs.100).aspx} + */ + class JavaScriptSerializer { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.Serialization.JavaScriptSerializer class. + */ + constructor(); + + //#endregion + + //#region Methods + + /** + * Converts an ECMAScript (JavaScript) object graph into a JSON string. This member is static and can be invoked without creating an instance of the class. + * @static + * @param value + * The JavaScript object graph to serialize. + * @exception Sys.ArgumentException + * value contains a value that cannot be serialized. + */ + static serialize(value: any): string; + + /** + * Converts a JSON string into an ECMAScript (JavaScript) object graph. This member is static and can be invoked without creating an instance of the class. + * @static + * @param value + * The JSON string to deserialize. + */ + static deserialize(value: string): any; + + //#endregion + } + } + + //#endregion + + //#region Sys.Services Namespace + + /** + * Contains types that provide script access in AJAX-enabled ASP.NET client applications to the ASP.NET authentication service, profile service, and other application services. + * The Sys.Services namespace is part of the Microsoft Ajax Library. + * For more information @{see Using Web Services in ASP.NET AJAX {@link http://msdn.microsoft.com/en-us/library/bb515101(v=vs.100).aspx}} + * @see {@link http://msdn.microsoft.com/en-us/library/bb311017(v=vs.100).aspx} + */ + module Services { + + /** + * Provides the client proxy class for the authentication service. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310861(v=vs.100).aspx} + */ + class AuthenticationService { + + } + + /** + * Defines a profile group. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} + */ + class ProfileGroup { + + } + + /** + * Provides the client proxy class for the role service. + * @see {@link http://msdn.microsoft.com/en-us/library/bb513880(v=vs.100).aspx} + */ + class RoleService { + + } + + /** + * Provides the client proxy class for the profile service. + * + */ + class ProfileService { + + } + + } + + //#endregion + + + //#region Sys.UI Namespace + + module UI { + + } + + //#endregion + +} + +//#endregion \ No newline at end of file From fc49b70da47c64d056f43f058aed95b21647e45c Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 9 Mar 2014 23:57:57 +0000 Subject: [PATCH 02/81] Added WebForms namespace. Added some preliminary classes from documentation. --- microsoft-ajax/microsoft.ajax.d.ts | 178 +++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 76bc8da1f..1f991830d 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -889,6 +889,184 @@ declare module Sys { //#endregion + //#region Sys.WebForms Namespace + + module WebForms { + + /** + * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class BeginRequestEventArgs extends EventArgs { + + } + + /** + * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class EndRequestEventArgs extends EventArgs { + + } + + /** + * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class InitializeRequestEventArgs extends EventArgs { + + } + + /** + * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. + */ + class PageLoadedEventArgs extends EventArgs { + + + } + + /** + * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. + */ + class PageLoadingEventArgs extends EventArgs { + + } + + /** + * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. + */ + class PageRequestManager extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.WebForms.PageRequestManager Class. + */ + constructor(); + + //#endregion + + //#region Events + + /** + * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. + * @param beginRequestHandler + * The name of the handler method that will be called. + */ + add_beginRequest(beginRequestHandler: (sender, args) => void): void; + + /** + * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. + * @param beginRequestHandler + * The handler method that will be removed. + */ + remove_beginRequest(beginRequestHandler: Function): void; + + + /** + * Raised after an asynchronous postback is finished and control has been returned to the browser. + * @param endRequestHandler + * The name of the handler method that will be called. + */ + add_endRequest(endRequestHandler: (sender, args) => void): void; + + /** + * Raised after an asynchronous postback is finished and control has been returned to the browser. + * @param endRequestHandler + * The name of the handler method that will be removed. + */ + remove_endRequest(endRequestHandler: (sender, args) => void): void; + + /** + * Raised during the initialization of the asynchronous postback. + * @param initializeRequestHandler + * The name of the handler method that will be called. + */ + add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + + /** + * Raised during the initialization of the asynchronous postback. + * @param initializeRequestHandler + * The name of the handler method that will be called. + */ + remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + + /** + * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + + /** + * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + + /** + * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + add_pageLoading(pageLoadingHandler: (sender, args) => void): void; + + /** + * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + remove_pageLoading(pageLoadingHandler: (sender, args) => void): void; + + //#endregion + + //#region Methods + + /** + * Returns the instance of the PageRequestManager class for the page. + * @return The current instance of the PageRequestManager class. You do not create a new instance of the PageRequestManager class directly. Instead, an instance is available when partial-page rendering is enabled. + */ + getInstance(): PageRequestManager; + + /** + * Stops all updates that would occur as a result of an asynchronous postback. + * The abortPostBack method stops the currently executing postback. To cancel a new postback, provide an event handler for the initializeRequest event and use the cancel event of the Sys.CancelEventArgs class. + */ + abortPostBack(): void; + + /** + * Begins an asynchronous postback. + * @param updatePanelsToUpdate (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. + * @param eventTarget (Optional) A string that contains the target of the event. + * @param eventArgument (Optional) A string that contains an argument for the event. + * @param causesValidation (Optional) true to cause validation. + * @param validationGroup (Optional) A string that contains the name of the validation group. + */ + beginAsyncPostBack(updatePanelsToUpdate?: string[], eventTarget?: string, eventArgument?: string, causesValidation?: boolean, validationGroup?: string): void; + + /** + * Releases ECMAScript (JavaScript) resources and detaches events. + * the dispose method to free client resources. The PageRequestManager instance calls the dispose method during the window.unload event of the browser. + * If you call the dispose method and then reference members of the PageRequestManager class, an error occurs. In typical page developer scenarios, you do not have to call the dispose method. + */ + dispose(): void; + + //#endregion + + //#region Properties + + //#endregion + } + + //#region Exceptions + + + + //#endregion + + + } + + //#endregion + } //#endregion \ No newline at end of file From c27ec006092428e016e21e703238719e121e6194 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 10 Mar 2014 00:00:00 +0000 Subject: [PATCH 03/81] Formatting changes. --- microsoft-ajax/microsoft.ajax.d.ts | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1f991830d..6847bb253 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -951,64 +951,54 @@ declare module Sys { * The name of the handler method that will be called. */ add_beginRequest(beginRequestHandler: (sender, args) => void): void; - /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler * The handler method that will be removed. */ remove_beginRequest(beginRequestHandler: Function): void; - - /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be called. */ add_endRequest(endRequestHandler: (sender, args) => void): void; - /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be removed. */ remove_endRequest(endRequestHandler: (sender, args) => void): void; - /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; - /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; - /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; - /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; - /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ add_pageLoading(pageLoadingHandler: (sender, args) => void): void; - /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler @@ -1034,11 +1024,16 @@ declare module Sys { /** * Begins an asynchronous postback. - * @param updatePanelsToUpdate (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. - * @param eventTarget (Optional) A string that contains the target of the event. - * @param eventArgument (Optional) A string that contains an argument for the event. - * @param causesValidation (Optional) true to cause validation. - * @param validationGroup (Optional) A string that contains the name of the validation group. + * @param updatePanelsToUpdate + * (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. + * @param eventTarget + * (Optional) A string that contains the target of the event. + * @param eventArgument + * (Optional) A string that contains an argument for the event. + * @param causesValidation + * (Optional) true to cause validation. + * @param validationGroup + * (Optional) A string that contains the name of the validation group. */ beginAsyncPostBack(updatePanelsToUpdate?: string[], eventTarget?: string, eventArgument?: string, causesValidation?: boolean, validationGroup?: string): void; From fd32c98a5b13424bf5a5c5880ab639785884467f Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 10 Mar 2014 09:21:22 +0000 Subject: [PATCH 04/81] Added UI classes to the definitions Still need to add methods, properties, fields, events --- microsoft-ajax/microsoft.ajax.d.ts | 169 ++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 6847bb253..7a1fbaf96 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -297,6 +297,8 @@ declare function $create(type: Type, properties?: any, events?: any, references? */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; + + //#endregion //#endregion @@ -381,11 +383,11 @@ declare module Sys { * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. * @return A Component object that contains the component requested by ID, if found; otherwise, null. */ - findComponent(id: string, parent?: Component): Component; + findComponent(id: string, parent?: Sys.Component): Sys.Component; /** * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. */ - getComponents(): Component[]; + getComponents(): Sys.Component[]; /** * This function supports the client-script infrastructure and is not intended to be used directly from your code. */ @@ -525,7 +527,7 @@ declare module Sys { * * @returns A new instance of a component that uses the specified parameters. */ - create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Component; + create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; //#endregion @@ -883,8 +885,169 @@ declare module Sys { //#region Sys.UI Namespace + /** + * Contains types related to the user interface (UI), such as controls, events, and UI properties in the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397431(v=vs.100).aspx} + */ module UI { + /** + * Provides a base class for all ASP.NET AJAX clientbehaviors. + */ + class Behavior extends Sys.Component { + + //#region Methods + + /** + * Gets a Sys.UI.Behavior instance with the specified name property from the specified HTML Document Object Model (DOM) element. This member a static member and can be invoked without creating an instance of the class. + * @return The specified Behavior object, if found; otherwise, null. + */ + static getBehaviorByName(element: Sys.UI.DomElement, name: string): Behavior; + /** + * Gets an array of Sys.UI.Behavior objects that are of the specified type from the specified HTML Document Object Model (DOM) element. This method is static and can be invoked without creating an instance of the class. + * @return An array of all Behavior objects of the specified type that are associated with the specified DOM element, if found; otherwise, an empty array. + */ + static getBehaviorsByType(element: Sys.UI.DomElement, type: Sys.UI.Behavior): Behavior[]; + /** + * Gets the Sys.UI.Behavior objects that are associated with the specified HTML Document Object Model (DOM) element. This member is static and can be invoked without creating an instance of the class. + * @param element + * The Sys.UI.DomElement object to search. + * @return An array of references to Behavior objects, or null if no references exist. + */ + static getBehaviors(element: DomElement): Behavior[]; + + /** + * Removes the current Behavior object from the application. + * The dispose method releases all resources from the Sys.UI.Behavior object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. + */ + dispose(): void; + + //#endregion + + //#region Properties + + /** + * Gets the HTML Document Object Model (DOM) element that the current Sys.UI.Behavior object is associated with. + * @return The DOM element that the current Behavior object is associated with. + */ + get_element(): Sys.UI.DomElement; + + /** + * Gets or sets the identifier for the Sys.UI.Behavior object. + * A generated identifier that consists of the ID of the associated Sys.UI.DomElement, the "$" character, and the name value of the Behavior object. + */ + get_id(): string; + + /** + * Gets or sets the identifier for the Sys.UI.Behavior object. + * @param value + * The string value to use as the identifier. + */ + set_id(value: string): void; + + /* + * Gets or sets the name of the Sys.UI.Behavior object. + * If you do not explicitly set the name property, getting the property value sets it to its default value, which is equal to the type of the Behavior object. The name property remains null until it is accessed. + * @param value + * A string value to use as the name. + */ + set_name(value: string): void; + + /** + * Gets or sets the name of the Sys.UI.Behavior object. + */ + get_name(): string; + + //#endregion + + } + /** + * Creates an object that contains a set of integer coordinates representing position, width, and height. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397698(v=vs.100).aspx} + */ + class Bounds { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.Bounds class. + */ + constructor(); + + //#endregion + + //#region Fields + + /** + * Gets the height of an object in pixels. This property is read-only. + * @return A number that represents the height of an object in pixels. + */ + height: number; + + /** + * Gets the width of an object in pixels. This property is read-only. + * @return A number that represents the width of an object in pixels. + */ + width: number; + + /** + * Gets the x-coordinate of an object in pixels. + * @return A number that represents the x-coordinate of an object in pixels. + */ + x: number; + + /** + * Gets the y-coordinate of anobject in pixels. + * @return A number that represents the y-coordinate of an object in pixels. + */ + y: number; + + //#endregion + + } + /** + * Provides the base class for all all ASP.NET AJAX client controls. + */ + class Control extends Sys.Component { + + } + /** + * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. + */ + class DomElement { + + } + /** + * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. + */ + class DomEvent { + + } + /** + * Describes key codes. + */ + enum Key { + + } + /** + * Describes mouse button locations. + */ + enum MouseButton { + + } + /** + * Creates an object that contains a set of integer coordinates that represent a position. + */ + class Point { + + } + /** + * Describes the layout of a DOM element in the page when the element's visible property is set to false. + */ + enum VisibilityMode { + + } + } //#endregion From 950b2ece20a19063e0bbe8ffdaaf5f0710fdab6a Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Tue, 11 Mar 2014 09:26:35 +0000 Subject: [PATCH 05/81] Added Type definitions --- microsoft-ajax/microsoft.ajax.d.ts | 176 ++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 1 deletion(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 7a1fbaf96..06da80605 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -268,6 +268,180 @@ declare class Type { * @returns A value of the class that the base method returns. If the base method does not return a value, no value is returned. */ callBaseMethod(instance: any, name: string, baseArguments?: any[]): any; + /** + * Creates a callback method, given the function to callback and the parameter to pass to it. + * @return + * The callback function. + * + * @param method + * The function for which the callback method will be created. + * @param context + * The parameter to pass to the function. This parameter can be null, but it cannot be omitted. + */ + static createCallback(method: Function, context: Object): Function; + /** + * Creates a delegate function that keeps the context from its creation. The context defines the object instance to which the this keyword points. + * @param instance + * The object instance that will be the context for the function. This parameter can be null. + * @param method + * The function from which the delegate is created. + * @return The delegate function. + */ + static createDelegate(instance: Object, method: Function): Function; + /** + * Returns the base implementation of a method from the base class of the specified instance. + * @param instance + * The instance for which the base method is requested. + * @param name + * The name of the method to retrieve as a reference. + */ + getBaseMethod(instance: Object, name: string): any; + /** + * Returns the base class of the instance. + * Use the getBaseType method to retrieve the base class of the instance. + */ + getBaseType(): Type; + /** + * Returns an Array object that contains the list of interfaces that the type implements. + * Use the getInterfaces function to return a list of objects that define the interfaces on a type object. + * This enables you to enumerate the array to determine the object's interfaces. + * + * @return An Array object that contains the list of interfaces that the type implements. + */ + getInterfaces(): any[]; + /** + * Returns the name of the type of the instance. + * @return A string representing the fully qualified name of the type of the instance. + * @example Object.getType(c[i]).getName() + */ + getName(): string; + /** + * Returns an Array object containing references to all the root namespaces of the client application. This method is static and is invoked without creating an instance of the object. + * Use the getRootNamespaces function to return an array containing references to all the root namespaces of the client application. + * @return An object containing references to all the root namespaces of the client application. + */ + static getRootNamespaces(): any; + /** + * Determines whether a class implements a specified interface type. + * @param interfaceType + * The interface to test. + * @return true if the class implements interfaceType; otherwise, false. + */ + implementsInterface(interfaceType: Type): boolean; + /** + * Determines whether an instance inherits from a specified class. + * @param parentType + * The fully qualified name of the class to test as a base class for the current instance. + * @return true if the instance inherits from parentType; otherwise, false. + */ + inheritsFrom(parentType: string); + /** + * Initializes the base class and its members in the context of a given instance, which provides the model for inheritance and for initializing base members. + * @param instance + * The instance to initialize the base class for. Usually this. + * @param baseArguments + * (Optional) The arguments for the base constructor. Can be null. + */ + initializeBase(instance: any, baseArguments?: any[]): any; + /** + * Returns a value that indicates whether the specified type is a class. This method is static and can be invoked without creating an instance of the object. + * @param type + * The type to test. + * @return true if the specified type is a class; otherwise, false. + */ + static isClass(type: any): boolean; + /** + * Indicates whether the specified type is an enumeration. + * @param type + * The type to test. + * @return true if the type is an enumeration; otherwise, false. + */ + static isEnum(type: any): boolean; + /** + * Get a value that indicates whether the specified type is an integer of flags. + * @param + * The type to test. + * @return true if the type is an integer of flags; otherwise, false. + */ + static isFlags(type: any): boolean; + /** + * Determines whether an instance implements an interface. + * @param typeInstanceVar + * The instance on which the interface is tested. + * @return + */ + isImplementedBy(typeInstanceVar: any): boolean; + /** + * Returns a value that indicates whether an object is an instance of a specified class or of one of its derived classes. + * @param instance + * The object to test. + * @return true if instance is an instance of the class; false if instance does not implement the interface, or if it is undefined or null. + */ + isInstanceOfType(instance: any): boolean; + /** + * Returns a value that indicates whether the specified type is an interface. This is a static member that is invoked directly without creating an instance of the class. + * @param type + * The type to test. + * @return true if the specified type is an interface; otherwise, false. + */ + static isInterface(type: any): boolean; + /** + * Returns a value that indicates whether the specified object is a namespace. This is a static member that is invoked directly without creating an instance of the class. + * @param object + * The object to test. + * @return true if the specified object is a namespace; otherwise, false. + */ + static isNamespace(object: any): boolean; + /** + * Returns an instance of the type specified by a type name. This is a static member that is invoked directly without creating an instance of its class. + * @param typeName + * A string that represents a fully qualified class name. Can be null. + * @param ns + * (Optional) The namespace that contains the class. + * @return The class represented by typeName, or null if a class that matches typeName does not occur in the namespace. + */ + static parse(typeName: string, ns?: string): any; + /** + * Registers a class as defined by a constructor with an optional base type and interface type. + * @param typeName + * A string that represents the fully qualified name of the type. + * @param baseType + * (Optional) The base type. + * @param interfaceTypes + * (Optional) An unbounded array of interface type definitions that the type implements. + * @return The registered type. + */ + registerClass(typeName: string, baseType?: any, interfaceTypes?: any[]): any; + /** + * Registers an enumeration. + * @param name + * The fully-qualified name of the enumeration. + * @param flags + * (Optional) true if the enumeration is a collection of flags; otherwise, false. + */ + registerEnum(name: string, flags?: boolean): void; + /** + * Registers an interface defined by a constructor. + * @param typeName + * A string that represents the fully qualified name of the class to be registered as an interface. + * @return The registered interface. + */ + registerInterface(typeName: string): any; + /** + * Creates a namespace. This member is static and can be invoked without creating an instance of the class. + * @param namespacePath + * A string that represents the fully qualified namespace to register. + */ + static registerNamespace(namespacePath: string): void; + /** + * Copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. This enables you to reflect on the inherited members of a derived type. + * Use the resolveInheritance method to reflect on the inherited members of a derived type. + * You invoke this method from the type that you want to reflect on. + * The resolveInheritance method copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. + * If the derived type overrides a base type member, the base type member is not copied to the derived type's prototype. + * After invoking a derived type's resolveInheritance method, you can examine the members of the derived type to discover all members, which includes inherited members. + */ + resolveInheritance(): void; } //#endregion @@ -1227,4 +1401,4 @@ declare module Sys { } -//#endregion \ No newline at end of file +//#endregion From e6904219b6f2962251640b78fb46621c203b8223 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 13 Mar 2014 08:40:43 +0000 Subject: [PATCH 06/81] Fixed some JSDocs and finished Component Added CultureInfo definition --- microsoft-ajax/microsoft.ajax.d.ts | 96 ++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 06da80605..4084a803c 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -// Type definitions for microsoft asp.net ajax client side library +micro// Type definitions for microsoft asp.net ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -667,14 +667,18 @@ declare module Sys { * Raised when the dispose method is called for a component. */ add_disposing(handler: Function): void; - + /** + * Raised when the dispose method is called for a component. + */ remove_disposing(handler: Function): void; /** * Raised when the raisePropertyChanged method of the current Component object is called. */ add_propertyChanged(handler: Function): void; - + /** + * Raised when the raisePropertyChanged method of the current Component object is called. + */ remove_propertyChanged(handler: Function): void; //#endregion @@ -685,7 +689,6 @@ declare module Sys { * Called by the create method to indicate that the process of setting properties of a component instance has begun. */ beginUpdate(): void; - /** * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. * @param type @@ -701,7 +704,33 @@ declare module Sys { * * @returns A new instance of a component that uses the specified parameters. */ - create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + static create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + /** + * Called by the create method to indicate that the process of setting properties of a component instance has finished. + * This method is called by the create method ($create). + * Sets the isUpdating property of the current Component object to false, calls the initialize method if it has not already been called, and then calls the updated method. + */ + endUpdate(): void; + /** + * Initializes the current Component object. + * The initialize method sets the isInitialized property of the current Component object to true. This function is called by the create method ($create) and overridden in derived classes to initialize the component. + */ + initialize(): void; + /** + * Raises the propertyChanged event for the specified property. + * @param propertyName + * The name of the property that changed. + */ + raisePropertyChanged(propertyName: string): void; + /** + * Called by the endUpdate method as a placeholder for additional logic in derived classes. + * Override the updated method in a derived class to add custom post-update logic. + */ + updated(): void; + /** + * Raises the disposing event of the current Component and removes the component from the application. + */ + dispose(): void; //#endregion @@ -710,6 +739,63 @@ declare module Sys { //#endregion } + /** + * Represents a culture definition that can be applied to objects that accept a culture-related setting. + */ + class CultureInfo { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.CultureInfo class. + * @param name + * The culture value (locale) that represents a language and region. + * @param numberFormat + * A culture-sensitive numeric formatting string. + * @param dateTimeFormat + * A culture-sensitive date formatting string. + */ + constructor(name: string, numberFormat: string, dateTimeFormat: string); + + //#endregion + + //#region Properties + + /** + * Gets an object that contains an array of culture-sensitive formatting and parsing strings values that can be applied to Number type extensions. + * Use the numberFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. + * Each formatting string can be used to specify how to format Number type extensions. + * @return An object that contains an array of culture-sensitive formatting strings. + */ + numberFormat: string[]; + /** + * Gets the culture value (locale) that represents a language and region. + * @return The culture value (locale) that represents a language and region. + */ + name: string; + /** + * Gets the globalization values of the invariant culture as sent by the server. This member is static and can be invoked without creating an instance of the class. + * The InvariantCulture field contains the following fields associated with the invariant (culture-independent) culture: name, dateTimeFormat, and numberFormat. + * @return A CultureInfo object. + */ + static InvariantCulture: CultureInfo; + /** + * Gets the globalization values of the current culture as sent by the server. This member is static and can be invoked without creating an instance of the class. + * The CurrentCulture field contains the following fields associated with the current culture: name, dateTimeFormat, and numberFormat. + * @return A Sys.CultureInfo object. + */ + static CurrentCulture: CultureInfo; + /** + * Gets an object that contains an array of culture-sensitive formatting and parsing string values that can be applied to Date type extensions. + * Use the dateTimeFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. + * Each formatting string can be used to specify how to format Date type extensions. + * @return An object that contains an array of culture-sensitive formatting strings. + */ + dateTimeFormat: string[]; + + //#endregion + } + /** * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. */ From d46fe63ef92f3598dadea9f328873029aacb99e1 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 13 Mar 2014 09:29:22 +0000 Subject: [PATCH 07/81] Sys classes added definitions need to be added. Added and defined IContainer interface, other interfaces need to be defined. --- microsoft-ajax/microsoft.ajax.d.ts | 111 +++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 4084a803c..4da78b840 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -micro// Type definitions for microsoft asp.net ajax client side library +// Type definitions for microsoft asp.net ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -472,7 +472,6 @@ declare function $create(type: Type, properties?: any, events?: any, references? declare function $find(id: string, parent?: Sys.Component): Sys.Component; - //#endregion //#endregion @@ -484,6 +483,9 @@ declare function $find(id: string, parent?: Sys.Component): Sys.Component; * @see {@link http://msdn.microsoft.com/en-us/library/bb397702(v=vs.100).aspx} */ declare module Sys { + + //#region Classes + /** * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ @@ -501,16 +503,25 @@ declare module Sys { * Raised after all scripts have been loaded but before objects are created. */ add_init(handler: Function): void; + /** + * Raised after all scripts have been loaded but before objects are created. + */ remove_init(handler: Function): void; /** * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. */ add_load(handler: Function): void; + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ remove_load(handler: Function): void; /** * Occurs when the user clicks the browser's Back or Forward button. */ add_navigate(handler: Function): void; + /** + * Occurs when the user clicks the browser's Back or Forward button. + */ remove_navigate(handler: Function): void; //#endregion @@ -653,10 +664,16 @@ declare module Sys { //#endregion } + /** + * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. + */ class Component { //#region Constructors + /** + * When overridden in a derived class, initializes an instance of that class and registers it with the application as a disposable object. + */ constructor(); //#endregion @@ -841,6 +858,74 @@ declare module Sys { //#endregion } + + /** + * Describes a change in a collection. + */ + class CollectionChange { + // to define + } + + //#endregion + + //#region Interfaces + + /** + * Provides a common interface for all components that can contain other components. + */ + interface IContainer { + + /** + * Adds a Component object to the current container. + * Implement this method for an object that will contain one or more component objects in order to programmatically add components to that container. + * @param component + * The Component object to add. + */ + addComponent(component: Component): void; + /** + * Returns the specified Component instance. + * Implement this method for an object that will contain one or more component objects to access components within that container. + * @param id + * The ID of the Component object to search for. + * @return The Component instance with the specified ID. + */ + findComponent(id: string): Component; + /** + * Returns an array of all objects in the current container that inherit from Component. + * Implement this method for an object that will contain one or more component objects so that the components in that container are available. Types that implement this method should return a copy of the list of components so that modifying the array does not change the contents of the container. + * @return An array of all objects in the current container that inherit from Component. + */ + getComponents(): Component[]; + /** + * Removes a Component object from the current container. + * @param component + * The Component object to remove. + */ + removeComponent(component: Component): void; + } + + /** + * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. + */ + interface IDisposable { + // to define + } + + /** + * Indicates that the type that implements the interface provides disposing notifications. + */ + interface INotifyDisposing { + // to define + } + + /** + * Defines the propertyChanged event. + */ + interface INotifyPropertyChange { + // to define + } + + //#endregion //#region Event Args @@ -868,6 +953,7 @@ declare module Sys { /** * Provides a class for command events. + * Event handlers can use the cancel property to cancel the operation in progress. The semantics of canceling an event depend on the event source. */ class CommandEventArgs extends EventArgs { @@ -902,6 +988,15 @@ declare module Sys { */ class CancelEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the CancelEventArgs class. + */ + constructor(); + + //#endregion + //#region Properties /** @@ -911,6 +1006,7 @@ declare module Sys { /* * true to request that the event be canceled; otherwise, false. The default is false. + * @return if the event is to be canceled; otherwise, false. */ get_cancel(): boolean; @@ -918,6 +1014,13 @@ declare module Sys { } + /** + * This class is used by the Sys.Application Class to hold event arguments for the navigate event. + */ + class HistoryEventArgs extends EventArgs { + + } + //#endregion //#region Exception Types @@ -951,7 +1054,7 @@ declare module Sys { */ class ArgumentUndefinedException { - } + } /** * */ @@ -1142,7 +1245,6 @@ declare module Sys { //#endregion - //#region Sys.UI Namespace /** @@ -1307,7 +1409,6 @@ declare module Sys { enum VisibilityMode { } - } //#endregion From 96bcc5b084e94ab2b4466478834d694676c183bb Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Fri, 14 Mar 2014 09:16:16 +0000 Subject: [PATCH 08/81] Added more defnitions and added @see JSDoc Including CollectionChange, Observer, Enumeration, IDisposable, INotifyDisposing, INotifyPropertyChanged including NotifyCollectionChangedEventArgs --- microsoft-ajax/microsoft.ajax.d.ts | 305 ++++++++++++++++++++++++++++- 1 file changed, 299 insertions(+), 6 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 4da78b840..ca4886125 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -487,6 +487,9 @@ declare module Sys { //#region Classes /** + * Provides a run-time object that exposes client events and manages client components that are registered with the application. + * The members of this object are available globally after the client application has been initialized. + * The members can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ class Application { @@ -666,6 +669,7 @@ declare module Sys { /** * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397516(v=vs.100).aspx} */ class Component { @@ -758,6 +762,7 @@ declare module Sys { /** * Represents a culture definition that can be applied to objects that accept a culture-related setting. + * @see {@link http://msdn.microsoft.com/en-us/library/bb384004(v=vs.100).aspx} */ class CultureInfo { @@ -815,6 +820,7 @@ declare module Sys { /** * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397422(v=vs.100).aspx} */ class Debug { @@ -861,13 +867,238 @@ declare module Sys { /** * Describes a change in a collection. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393798(v=vs.100).aspx} */ class CollectionChange { - // to define + + //#region Constructors + + /** + * Creates a CollectionChange object based on the supplied parameters. + * @param action + * A NotifyCollectionChangedAction enumeration value. + * @param newItems + * (Optional) The items that were added when the action is add or replace. + * @param newStartingIndex + * (Optional) An integer that represents the index where new items have been inserted. + * @param oldItems + * (Optional) The items that were removed when the action is remove or replace. + * @param oldStartingIndex + * (Optional) An integer that represents the index where old items have been removed. + */ + constructor(action: NotifyCollectionChangedAction, newItems: any[], newStartingIndex: number, oldItems: any[], oldStartingIndex: number); + + //#endregion + + //#region Fields + + /** + * Gets a NotifyCollectionChangedAction object that contains the change action enumeration value. + * @return A NotifyCollectionChangedAction object. + */ + action: NotifyCollectionChangedAction; + /** + * @return An array of items that were added. + */ + newItems: any[]; + /** + * The index where new items have been inserted. + * @return An integer that represents the index where new items have been inserted. + */ + newStartingIndex: number; + /** + * The items that were removed when the NotifyCollectionChangedAction object is set to remove. + * @return An array containing the items that were removed. + */ + oldItems: any[]; + /** + * Gets the index where old items have been removed. + * @return An integer that represents the index where old items have been removed. + */ + oldStartingIndex: number; + + //#endregion } + /** + * Adds update and management functionality to target objects such as arrays, DOM elements, and objects. + * The Sys.Observer class is based on the Observer pattern. The Sys.Observer class maintains a list of interested dependents (observers) in a separate object (the subject). + * All methods that are contained in the Sys.Observer class are static. + * In order to be used with the Sys.Observer class, an object must be an object, array, or DOM element. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393710(v=vs.100).aspx} + */ + class Observer { + + //#region Methods + + /** + * Adds an item to the collection in an observable manner. + * @param target + * The array to which an item will be added. + * @param item + * The item to add. + */ + static add(target: any[], item): void; + + /** + * Adds an event handler to the target. + * @param target The array to which an event handler will be added. + * @param handler The event handler. + */ + static addCollectionChanged(target, handler: Function): void; + + /** + * Adds an observable event handler to the target. + * @param eventName A string that contains the event name. + * @param handler The added function. + */ + static addEventHandler(target, eventName: string, handler: Function): void; + + /** + * Adds a propertyChanged event handler to the target. + * @param target The object to observe. + * @param handler The function handler to add. + */ + static addPropertyChanged(target, handler: Function): void; + + /** + * Adds items to the collection in an observable manner. + * @param target The array to which items will be added. + * @param items The array of items to add. + */ + static addRange(target: any[], items: any[]): void; + + /** + * Begins the process of updating the target object. + * @param target The object to update. + */ + static beginUpdate(target: any): void; + + /** + * Clears the array of its elements in an observable manner. + * @param target The array to clear. + */ + static clear(target: any): void; + + /** + * Ends the process of updating the target object. + * @param target The object being updated. + */ + static endUpdate(target: any): void; + + /** + * Inserts an item at the specified index in an observable manner. + * @param target The array to which the item is inserted. + * @param index A number that represents the index where the item will be inserted. + * @param item The item to insert. + */ + static insert(target: any, index: number, item: any): void; + + /** + * Indicates that the target is being updated. + * @param target The target object to update. + * @return true if given target argument is currently updating; otherwise false. + */ + static isUpdating(target: any): boolean; + + /** + * Makes an object directly observable by adding observable methods to it. + * @param target The object, array, or DOM element to make observable. + * @return The observable object. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393633(v=vs.100).aspx} + */ + static makeObservable(target: any): any; + + /** + * Raises the collectionChanged event. + * @param target The collection to which an event is raised. + * @param changes A Sys.CollectionChange object that contains the list of changes that were performed on the collection since the last event. + */ + static raiseCollectionChanged(target: any[], changes: Sys.CollectionChange): void; + + /** + * Raises an observable event on the target. + * @param target The target object. + * @param eventName A string that contains the event name. + * @param eventArgs A Sys.EventArgs object used to pass event argument information. + */ + static raiseEvent(target: any, eventName: string, eventArgs: Sys.EventArgs): void; + + /** + * Raises a propertyChanged notification event. + * @param target The object to which an event is raised. + * @param propertyName The name of the property that changed. + */ + static raisePropertyChanged(target: any, propertyName: string): void; + + /** + * Removes the first occurrence of an item from the array in an observable manner. + * @param target The array to which the item will be removed. + * @param item The item to remove. + * @return true if the item is found in the array. Otherwise false. + */ + static remove(target: any[], item: any): boolean; + + /** + * Removes the item at the specified index from the array in an observable manner. + * @param target The array to which an item is removed. + * @param index A number that represents the index of the item to remove. + */ + static removeAt(target: any[], index: number): void; + + /** + * Removes the collectionChanged event handler from the target. + * @param target The array from which the collectionChanged event handler is removed. + * @param handler The function to remove. + */ + static removeCollectionChanged(target: any, handler: Function): void; + + /** + * Removes a propertyChanged event handler from the target. + * @param target The object to observe. + * @param handler The event handler to remove. + */ + static removeEventHandler(target: any, handler: Function): void; + + /** + * Sets a property or field on the target in an observable manner. + * The raisePropertyChanged method is called after the setValue method set the value of the target object property. + * @param target The object to which the property is set. + * @param propertyName A string that contains the name of the property or field to set. + * @param value The value to set. + */ + static setValue(target, propertyName, value): void; + + //#endregion + + } + + //#endregion + //#region Enumerations + + /** + * Describes how a collection has changed. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393774(v=vs.100).aspx} + */ + enum NotifyCollectionChangedAction { + /** + * The integer 0, indicating the changed action to the collection is add. + */ + add = 0, + /** + * The integer 1, indicating the changed action to the collection is remove. + */ + remove = 1, + /** + * The integer 2, indicating the changed action to the collection is reset. + */ + reset = 2 + } + + //#endregion + //#region Interfaces /** @@ -875,6 +1106,8 @@ declare module Sys { */ interface IContainer { + //#region Methods + /** * Adds a Component object to the current container. * Implement this method for an object that will contain one or more component objects in order to programmatically add components to that container. @@ -902,28 +1135,59 @@ declare module Sys { * The Component object to remove. */ removeComponent(component: Component): void; + + //#endregion } /** * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. + * Implement the IDisposable interface to provide a common interface for closing or releasing resources held by instances of your registered Microsoft Ajax Library class. + * You register an interface by when you register the class by calling the Type.registerClass method. You specify IDisposable in the interfaceTypes parameter when you call Type.registerClass. */ interface IDisposable { - // to define + /** + * Releases resources held by an object that implements the Sys.IDisposable interface. + * Implement the dispose method to close or release resources held by an object, or to prepare an object for reuse. + */ + dispose(): void; } /** * Indicates that the type that implements the interface provides disposing notifications. + * Implement this interface if the class must notify other objects when it is releasing resources. The base component class already implements this interface. Therefore, typically this interface is already available. */ interface INotifyDisposing { - // to define + /** + * Occurs when an object's resources are released. + * @param handler + * The name of the event handler for the disposing event. + */ + add_disposing(handler: Function): void; + /** + * Occurs when an object's resources are released. + * @param handler + * The name of the event handler for the disposing event. + */ + remove_disposing(handler: Function): void; } /** * Defines the propertyChanged event. */ interface INotifyPropertyChange { - // to define - } + /** + * Occurs when a component property is set to a new value. + * @param handler + * The name of the event handler for the propertyChanged event. + */ + add_propertyChanged(handler: Function): void; + /** + * Occurs when a component property is set to a new value. + * @param handler + * The name of the event handler for the propertyChanged event. + */ + remove_propertyChanged(handler: Function): void; + } //#endregion @@ -1021,6 +1285,35 @@ declare module Sys { } + /** + * Describes how the collection was changed. + */ + class NotifyCollectionChangedEventArgs extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the CancelEventArgs class. + * @param changes + * A CollectionChange object that contains an array of changes that were performed on the collection since the last event. + */ + constructor(changes: CollectionChange); + + //#endregion + + + //#region Properties + + /** + * Gets an array of changes that were performed on the collection since the last event. + * @return An array of CollectionChange objects that were performed on the collection since the last event. + */ + get_changes(): CollectionChange[]; + + //#endregion + + } + //#endregion //#region Exception Types @@ -1254,7 +1547,7 @@ declare module Sys { module UI { /** - * Provides a base class for all ASP.NET AJAX clientbehaviors. + * Provides a base class for all ASP.NET AJAX client behaviors. */ class Behavior extends Sys.Component { From 6ad82f88bd68d2bd13e0b29981abfbe1edc7a38a Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 17 Mar 2014 08:41:09 +0000 Subject: [PATCH 09/81] Added more definitions from the documentation Mainly in the Sys Namespace. --- microsoft-ajax/microsoft.ajax.d.ts | 269 ++++++++++++++++++++++++++++- 1 file changed, 266 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index ca4886125..89eaeddd6 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1072,7 +1072,217 @@ declare module Sys { //#endregion } - + + /** + * Provides static, culture-neutral exception messages that are used by the Microsoft Ajax Library framework. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397705(v=vs.100).aspx} + * This type supports the .NET Framework infrastructure and is not intended to be used directly from your code. + */ + class Res { + + //#region Fields + + /** + * @return "Actual value was {0}." + */ + actualValue: string; + /** + * @return "The application failed to load within the specified time out period." + */ + appLoadTimedout: string; + /** + * @return "Value does not fall within the expected range." + */ + argument: string; + /** + * @return "Value cannot be null." + */ + argumentNull: string; + /** + * @return "Specified argument was out of the range of valid values. + */ + argumentOutOfRange: string; + /** + * @return "Object cannot be converted to the required type." + */ + argumentType: string; + /** + * @return "Object of type '{0}' cannot be converted to type '{1}'." + */ + argumentTypeWithTypes: string; + /** + * @return "Value cannot be undefined." + */ + argumentUndefined: string; + /** + * @return "Assertion Failed: {0}" + */ + assertFailed: string; + /** + * @return "Assertion Failed: {0}\r\nat {1}" + */ + assetFailedCaller: string; + /** + * @return "Base URL does not contain ://." + */ + badBaseUrl1: string; + /** + * @return "Base URL does not contain another /." + */ + badBaseUrl2: string; + /** + * @return "Cannot find last / in base URL." + */ + badBaseUrl3: string; + /** + * @return "{0}\r\n\r\nBreak into debugger?" + */ + breakIntoDebugger: string; + /** + * @return "Cannot abort when executor has not started." + */ + cannotAbortBeforeStart: string; + /** + * @return "Cannot call {0} when responseAvailable is false." + */ + cannotCallBeforeResponse: string; + /** + * @return "Cannot call {0} once started." + */ + cannotCallOnceStarted: string; + /** + * @return "Cannot call {0} outside of a completed event handler." + */ + cannotCallOutsideHandler: string; + /** + * @return "Cannot deserialize empty string." + */ + cannotDeserializeEmptyString: string; + /** + * @return "Cannot serialize non-finite numbers." + */ + cannotSerializeNonFiniteNumbers: string; + /** + * @return "The id property can't be set on a control." + */ + controlCantSetId: string; + /** + * @return "'{0}' is not a valid value for enum {1}." + */ + enumInvalidValue: string; + /** + * @return "Handler was not added through the Sys.UI.DomEvent.addHandler method. + */ + eventHandlerInvalid: string; + /** + * @return "One of the identified items was in an invalid format." + */ + format: string; + /** + * @return "The string was not recognized as a valid Date." + */ + formatBadDate: string; + /** + * @return "Format specifier was invalid." + */ + formatBadFormatSpecifier: string; + /** + * @return "Input string was not in a correct format." + */ + formatInvalidString: string; + /** + * @return "Could not create a valid Sys.Net.WebRequestExecutor from: {0}." + */ + invalidExecutorType: string; + /** + * @return "httpVerb cannot be set to an empty or null string." + */ + invalidHttpVerb: string; + /** + * @return "Operation is not valid due to the current state of the object." + */ + invalidOperation: string; + /** + * @return "Value must be greater than or equal to zero." + */ + invalidTimeout: string; + /** + * @return "Cannot call invoke more than once." + */ + invokeCalledTwice: string; + /** + * @return "The method or operation is not implemented." + */ + notImplemented: string; + /** + * @return "Cannot call executeRequest with a null webRequest." + */ + nullWebRequest: string; + + //#endregion + } + + /** + * Provides a mechanism to concatenate strings. + * The StringBuilder class represents a mutable string of characters and provides a mechanism to concatenate a sequence of strings. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310852(v=vs.100).aspx} + */ + class StringBuilder { + + //#region Constructors + + /** + * Creates a new instance of StringBuilder and optionally accepts initial text to concatenate. You can specify a string in the optional initialText parameter to initialize the value of the StringBuilder instance. + * @param initialText + * (Optional) The string that is used to initialize the value of the instance. If the value is null, the new StringBuilder instance will contain an empty string (""). + */ + constructor(initialText?: string); + + //#endregion + + //#region Methods + + /** + * Appends a copy of a specified string to the end of the Sys.StringBuilder instance. + * Use the append method to append a copy of a specified string to the end of a StringBuilder instance. If text is an empty string, null, or undefined, the StringBuilder instance remains unchanged. + * @param text + * The string to append to the end of the StringBuilder instance. + */ + append(text: string): void; + + /** + * Appends a string with a line terminator to the end of the Sys.StringBuilder instance. + * Use the appendLine method to append a specified string and a line terminator to the end of a Stringbuilder instance. The line terminator is a combination of a carriage return and a newline character. If no string is specified in text, only the line terminator is appended. + * @param text + * (Optional) The string to append with a line terminator to the end of the StringBuilder instance. + */ + appendLine(text: string): void; + + /** + * Clears the contents of the Sys.StringBuilder instance. + * Use the clear method to clear the StringBuilder instance of its current contents. + */ + clear(): void; + + /** + * Determines whether the Sys.StringBuilder object has content. + * Use the isEmpty method to determine whether a StringBuilder instance has any content. If you append an empty string, null, or an undefined value to an empty StringBuilder instance, the instance remains empty and unchanged. + * @return true if the StringBuilder instance contains no elements; otherwise, false. + */ + isEmpty(): boolean; + + /** + * Creates a string from the contents of a Sys.StringBuilder instance, and optionally inserts a delimiter between each element of the created string. + * Use the toString method to create a string from the contents of a StringBuilder instance. Use the toString method with the optional separator parameter to insert a specified string delimiter between each element of the created string. + * @param separator + * (Optional) A string to append between each element of the string that is returned. + * @return A string representation of the StringBuilder instance. If separator is specified, the delimiter string is inserted between each element of the returned string. + */ + toString(separator: string): string; + toString(): string; + + //#endregion + } //#endregion @@ -1195,6 +1405,7 @@ declare module Sys { /** * Provides a base class for classes that are used by event sources to pass event argument information. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx} */ class EventArgs { @@ -1218,6 +1429,7 @@ declare module Sys { /** * Provides a class for command events. * Event handlers can use the cancel property to cancel the operation in progress. The semantics of canceling an event depend on the event source. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393715(v=vs.100).aspx */ class CommandEventArgs extends EventArgs { @@ -1249,6 +1461,7 @@ declare module Sys { /** * Provides the base class for events that can be canceled. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311009(v=vs.100).aspx} */ class CancelEventArgs extends EventArgs { @@ -1280,13 +1493,35 @@ declare module Sys { /** * This class is used by the Sys.Application Class to hold event arguments for the navigate event. + * @see {@link http://msdn.microsoft.com/en-us/library/cc488008(v=vs.100).aspx} */ class HistoryEventArgs extends EventArgs { + //#region Constructors + + /** + * For a live code example that demonstrates this event in action, and for a view of how this event is used in code, see Managing Browser History Using Client Script. + * @param state Object. A collection of key/value pairs that represent the state data. This data will be added to the main state to form the global state of the new history point. + */ + constructor(state: any); + + //#endregion + + //#region Methods + + /** + * Object. A collection of name/value pairs that represent the state of a Web page. + * The state object stores the data that is required in order to restore a Web page to a specified application state. + * @return Object. A collection of name/value pairs that represent the state of a Web page. + */ + get_State(): any; + + //#endregion } /** * Describes how the collection was changed. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393665(v=vs.100).aspx} */ class NotifyCollectionChangedEventArgs extends EventArgs { @@ -1301,7 +1536,6 @@ declare module Sys { //#endregion - //#region Properties /** @@ -1311,7 +1545,36 @@ declare module Sys { get_changes(): CollectionChange[]; //#endregion - + } + + /** + * Used by the propertyChanged event to indicate which property has changed. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310957(v=vs.100).aspx} + */ + class PropertyChangedEventArgs extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the PropertyChangedEventArgs class. + * @param propertyName + * The name of the property that changed. + */ + constructor(propertyName: string); + + //#endregion + + //#region Methods + + /** + * Gets the name of the property that changed. + * Use the propertyName property to determine the name of the property that changed. + * @return A string that contains the name of the property that changed. + */ + propertyName(): string; + + + //#endregion } //#endregion From cdc76877d4a8d042a76b97dd09086d1ce3baa7a2 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 17 Mar 2014 09:11:53 +0000 Subject: [PATCH 10/81] Added BeginRequestEventArgs defintion --- microsoft-ajax/microsoft.ajax.d.ts | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 89eaeddd6..357bfd2b9 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1971,13 +1971,55 @@ declare module Sys { //#region Sys.WebForms Namespace + /** + * The Sys.WebForms namespace contains classes related to partial-page rendering in the Microsoft Ajax Library. + */ module WebForms { /** * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. + * @see {@link http://msdn.microsoft.com/en-us/library/bb384003(v=vs.100).aspx} */ class BeginRequestEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the BeginRequestEventArgs class. + * @param request + * A Sys.Net.WebRequest representing the web request for the EventArgs. + * @param postBackElement + * The postback element that initiated the async postback. + * @param updatePanelsToUpdate + * (Optional) A list of UniqueIDs for UpdatePanel controls that are requested to update their rendering by the client. Server-side processing may update additional UpdatePanels. + */ + constructor(request: Sys.Net.WebRequest, postBackElement: any, updatePanelsToUpdate: string[]); + + //#endregion + + //#region Properties + + /** + * Gets the postback element that initiated the asynchronous postback. This property is read-only. + * @readonly + * @return An HTML DOM element. + */ + get_postBackElement(): HTMLElement; + + /** + * Gets the request object that represents the current postback. + * @return An instance of the Sys.Net.WebRequest class. + */ + get_request(): Sys.Net.WebRequest; + + /** + * Gets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. + * Server-side processing might update additional UpdatePanel controls. + * @return An array of UniqueID values for UpdatePanel controls. + */ + get_updatePanelsToUpdate(): string[]; + + //#endregion } /** @@ -1985,6 +2027,8 @@ declare module Sys { */ class EndRequestEventArgs extends EventArgs { + + } /** From 44446bfc6cea44b585f0f3a66dc53b7da00658d1 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Tue, 18 Mar 2014 09:20:15 +0000 Subject: [PATCH 11/81] Added more definitions --- microsoft-ajax/microsoft.ajax.d.ts | 240 ++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 357bfd2b9..d1bb1098b 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1767,18 +1767,173 @@ declare module Sys { /** * Provides the client proxy class for the authentication service. + * The AuthenticationService class is a singleton; it has only one instance with a global point of access. + * It is always available to your application and you do not have to instantiate it. + * The AuthenticationService class provides script access to user authentication. + * It calls methods of the authentication service through the same infrastructure used to call any other Web service method. * @see {@link http://msdn.microsoft.com/en-us/library/bb310861(v=vs.100).aspx} */ class AuthenticationService { + //#region Constructors + + /** + * Initializes a new instance of the Sys.Services.AuthenticationService class. + */ + constructor(); + + //#endregion + + //#region Fields + + /** + * Specifies the path of the default authentication service. + */ + DefaultWebServicePath: string; + + //#endregion + + //#region Methods + + /** + * Authenticates the user's credentials. + * @param userName (required) The user name to authenticate. + * @param password + * The user's password. The default is null. + * @param isPersistent + * true if the issued authentication ticket should be persistent across browser sessions; otherwise, false. The default is false. + * @param redirctUrl + * The URL to redirect the browser to on successful login. The default is null. + * @param customInfo + * + * @param loginCompletedCallback + * The function to call when the login has finished successfully. The default is null. + * @param failedCallback + * The function to call if the login fails. The default is null. + * @param userContext + * User context information that you are passing to the callback functions. + * @exception Sys.ArgumentNullException - username is null. + */ + login(userName: string, password: string, isPersistent: boolean, customInfo: any, redirectUrl: string, loginCompletedCallback: Function, failedCallback: Function, userContext: any): void; + + /** + * Logs out the currently authenticated user. + * + * If redirectUrl is null or is an empty string, the page is redirected to itself after the call to the authentication Web service finishes and the completed callback function is called. + * This makes sure that any user-related data is cleared from the page. If redirectUrl is not null or is a non-empty string, the page is redirected to the specified URL after a successful call to the Web service. + * This URL can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. + * If the call to the Web service fails, the page is not redirected or refreshed. Instead, the failed callback function is called. + * + * @param redirectUrl + * The URL to redirect the browser to on successful logout. The default is null. + * @param logoutCompletedCallback + * The function that is called when the logout has finished. The default is null. + * @param failedCallback + * The function that is called if the logout has failed. The default is null. + * @param userContext + * User context information that you are passing to the callback functions. + */ + logout(redirectUrl: string, logoutCompletedCallback: Function, failedCallback: Function, userContext: any): void; + + //#endregion + + //#region Properties + + /** + * Gets or sets the name of the default failure callback function. + */ + get_defaultFailedCallback(): Function; + + /** + * Gets or sets the name of the default failure callback function. + * @param value + * A string that contains the name of the default failure callback function. + */ + set_defaultFailedCallback(value: string): void; + + /** + * Gets or sets the default succeeded callback function for the service. + * @return A reference to the succeeded callback function for the service. + */ + defaultSucceededCallback(): Function; + + /** + * Gets or sets the default succeeded callback function for the service. + * @param value + * A reference to the succeeded callback function for the service. + */ + defaultSucceededCallback(value: Function): void; + + /** + * Gets or sets the default user context for the service. + * @return A reference to the user context for the service. + */ + defaultUserContext(): Object + + /** + * Gets or sets the default user context for the service. + * @param value + * A reference to the user context for the service. + */ + defaultUserContext(value: Object): void; + + /** + * Gets the authentication state of the current user. + * The value of this property is set by the ScriptManager object during a page request. + * @return true if the current user is logged in; otherwise, false. + */ + get_isLoggedIn(): boolean; + + + /** + * Gets or sets the authentication service path. + * You usually set the path property in declarative markup. This value can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. + * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. + * @param value + * The authentication service path. + */ + set_path(value: string); + + /** + * Gets or sets the authentication service path. + * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. + */ + get_path(): string; + + /** + * Gets or sets the authentication service time-out value. + * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. + * By setting a time-out interval, you can make sure that a pending request returns based on a time interval that you specify, instead of waiting for the asynchronous communication layer to time out. + * @param value + * The time-out value in milliseconds. + */ + set_timeout(value): void; + + /** + * Gets or sets the authentication service time-out value. + * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. + * The timeout in milliseconds + */ + get_timeout(): number; + + //#endregion } /** * Defines a profile group. + * The ProfileGroup class defines the type of an element as a group in the properties collection of the Sys.Services.ProfileService class. + * Profile group properties are accessed as subproperties of the related group, as shown in the following ECMAScript (JavaScript) example: * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} */ class ProfileGroup { + /** + * Initializes a new instance of the Sys.Services.ProfileGroup class. + * @param properties + * (Optional) An object that contains the settings for this profile group. This parameter can be null. + */ + constructor(properties: Object); + } /** @@ -1791,7 +1946,7 @@ declare module Sys { /** * Provides the client proxy class for the profile service. - * + * @see {@link http://msdn.microsoft.com/en-us/library/bb383800(v=vs.100).aspx} */ class ProfileService { @@ -1973,6 +2128,7 @@ declare module Sys { /** * The Sys.WebForms namespace contains classes related to partial-page rendering in the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397566(v=vs.100).aspx} */ module WebForms { @@ -2024,11 +2180,59 @@ declare module Sys { /** * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397499.aspx} */ class EndRequestEventArgs extends EventArgs { - + /** + * Initializes a new instance of the EndRequestEventArgs class. + * @param error + * An error object. + * @param dataItems + * An object containing data items. + * @param response + * An object of type Sys.Net.WebRequestExecutor. + */ + constructor(error: Error, dataItems: any, response: Sys.Net.WebRequestExecutor); + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * The JavaScript Error object exposes several properties that define the error. The Microsoft Ajax Library provides additional functions for the Error object. + * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + + /** + * Gets the Error object. + * @return A base ECMAScript (JavaScript) Error object. + */ + get_error(): Error; + + /** + * Get or sets a value that indicates whether the error has been handled. + * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. + * @return true if the error has been handled; otherwise false. + */ + get_errorHandled(): boolean; + + /** + * Get or sets a value that indicates whether the error has been handled. + * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. + * @param value + * true or false. + */ + set_errorHandled(value: boolean): void; + + /** + * Gets a response object that is represented by the Sys.Net.WebRequestExecutor class. + * @return A response object that is represented by the WebRequestExecutor class. + */ + get_response(): any; // todo + + //#endregion } /** @@ -2175,9 +2379,39 @@ declare module Sys { //#endregion } - //#region Exceptions + //#region Exceptions: Defines exceptions that can occur during partial-page updates. + /** + * Raised when an error occurs while processing the response from the server. + * If the response to an asynchronous postback returns without an error but there is an error processing the response in the client, the Sys.WebForms.PageRequestManagerParserErrorException is raised. + * For information about how to handle this error condition, see Debugging and Tracing Ajax Applications Overview. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} + */ + class PageRequestManagerParserErrorException { + } + + /** + * Raised when an error occurs on the server. + * If an error occurs on the server while the request is being processed, an error response is returned to the browser and the Sys.WebForms.PageRequestManagerServerErrorException exception is raised. + * To customize error handling and to display more information about the server error, handle the AsyncPostBackError event and use the AsyncPostBackErrorMessage and AllowCustomErrorsRedirect properties. + * For an example of how to provide custom error handling during partial-page updates, see Customizing Error Handling for ASP.NET UpdatePanel Controls. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * + */ + class PageRequestManagerServerErrorException { + + } + + /** + * Raised when the request times out. + * A partial-page update is initiated by a client request (an asynchronous postback) to the server. The server processes the request and returns a response to the client. + * If the browser does not receive a response in a specified time, the Sys.WebForms.PageRequestManagerTimeoutException is raised. + * To change the interval that elapses before asynchronous postbacks time out, set the AsyncPostBackTimeout property of the ScriptManager control. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} + */ + class PageRequestManagerTimeoutException { + + } //#endregion From 25a829db98b4b29f055a52de62d5e7a8b5d32249 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Wed, 19 Mar 2014 09:11:48 +0000 Subject: [PATCH 12/81] Added WebRequestExecutor definitions --- microsoft-ajax/microsoft.ajax.d.ts | 112 +++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index d1bb1098b..abeb345bd 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1654,6 +1654,7 @@ declare module Sys { /** * Provides the script API to make a Web request. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310979(v=vs.100).aspx} */ class WebRequest { @@ -1701,6 +1702,117 @@ declare module Sys { //#endregion } + + /** + * Provides the abstract base class from which network executors derive. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397434(v=vs.100).aspx} + */ + class WebRequestExecutor { + + //#region Constructors + + /** + * Initializes a Sys.Net.WebRequestExecutor instance when implemented in a derived class. + */ + constructor(); + + //#endregion + + //#region Methods + + /** + * Stops the pending network request issued by the executor. + * The specifics of aborting a request vary depending on how an executor is implemented. + * However, all executors that derive from WebRequestExecutor must set their state to aborted and must raise the completed event of the associated Sys.Net.WebRequest object. + * The executor properties do not contain consistent data after abort has been called. + */ + abort(): void; + /** + * Instructs the executor to execute a Web request. + * When this method is called, the executor packages the content of the Web request instance and initiates processing. + * This method is intended to be used by a custom executor. If you are implementing a custom executor, you instantiate the executor, assign it to the Web request instance, and then invoke the method on the executor instance. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383834(v=vs.100).aspx} + */ + executeRequest(): void; + /** + * Gets all the response headers for the current request. + * If a request finished successfully and with valid response data, this method returns all the response headers. + * @return All the response headers + * @see {@link http://msdn.microsoft.com/en-us/library/bb310805(v=vs.100).aspx} + */ + getAllResponseHeaders(): string; + /** + * Gets the value of the specified response header. + * @return The specified response header. + */ + getResponseHeader(): string; + + //#endregion + + //#region Properties + + /** + * Gets the JSON-evaluated object from the response. + * @return The JSON-evaluated response object. + */ + object(): any; + /** + * Gets a value indicating whether the request associated with the executor was aborted. + * When the current instance of the Sys.Net.WebRequestExecutor class is aborted, it must set its state to aborted and it must raise the completed event of the associated request object. + * @return true if the request associated with the executor was aborted; otherwise, false. + */ + get_aborted(): boolean; + /** + * Gets a value indicating whether the request completed successfully. + * Successful completion usually means a well-formed response was received by the executor. + * If a response was received, the current instance of the Sys.Net.WebRequestExecutor class must set its state to completed. + * It must also raise the completed event of the associated request object. + * @return true if the request completed successfully; otherwise, false. + */ + get_responseAvailable(): boolean; + /** + * Gets the text representation of the response body. When a request has completed successfully with valid response data, this property returns the text that is contained in the response body. + * @return The text representation of the response body. + */ + get_responseData(): string; + /** + * Returns a value indicating whether the executor has started processing the request. + * The executor returns true if substantial processing of the request has started. For executors that make network calls, substantial processing means that a network call has been started. + * @return true if the executor has started processing the request; otherwise, false. + */ + get_started(): boolean; + /** + * Gets a success status code. + * The statusCode property returns an integer that specifies that a request completed successfully and with valid response data. + * @return An integer that represents a status code. + */ + get_statusCode(): number; + /** + * Gets status information about a request that completed successfully. + * The statusText property returns status information if a request completed successfully and with valid response data. + * @return the status text + */ + get_statusText(): string; + /** + * Gets a value indicating whether the request timed out. + * Executors use the time-out information associated with the request to raise the completed event on the associated WebRequest object. + * @return true if the request timed out; otherwise, false. + */ + get_timedOut(): boolean; + /** + * Attempts to get the response to the current request as an XMLDOM object. + * If a request finished successfully with valid response data, this method tries to get the response as an XMLDOM object. + */ + get_xml(): XMLDocument; + /** + * Gets the WebRequest object associated with the executor. + * @return The WebRequest object associated with the current executor instance. + */ + get_webRequest(): Sys.Net.WebRequest; + + //#endregion + } + } //#endregion From c5fcfbfc87d283fa695df5f15e33a22508e12141 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 20 Mar 2014 08:43:43 +0000 Subject: [PATCH 13/81] EventArg type definitions --- microsoft-ajax/microsoft.ajax.d.ts | 121 ++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index abeb345bd..0eb400641 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2296,6 +2296,8 @@ declare module Sys { */ class EndRequestEventArgs extends EventArgs { + //#region Constructors + /** * Initializes a new instance of the EndRequestEventArgs class. * @param error @@ -2307,6 +2309,7 @@ declare module Sys { */ constructor(error: Error, dataItems: any, response: Sys.Net.WebRequestExecutor); + //#endregion //#region Properties @@ -2349,24 +2352,140 @@ declare module Sys { /** * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. + * This class contains private members that support the client-script infrastructure and are not intended to be used directly from your code. Names of private members begin with an underscore ( _ ). + * @see {@link http://msdn.microsoft.com/en-us/library/bb311030(v=vs.100).aspx} */ class InitializeRequestEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the EndRequestEventArgs class. + * @param request + * A Sys.Net.WebRequest object that represents the Web request for the EventArgs object. + * @param datapostBackElementItems + * The postback element that initiated the asynchronous postback. + * @param updatePanelsToUpdate + * (Optional) A list of UniqueID values for UpdatePanel controls that are being requested to update their rendering by the client. Server-side processing might update additional UpdatePanel controls. + */ + constructor(request: Sys.Net.WebRequest, postBackElement: any, updatePanelsToUpdate: string[]); + + //#endregion + + //#region Properties + + /** + * Gets the postback element that initiated the asynchronous postback. + * @return An HTML DOM element. + */ + get_postBackElement(): HTMLElement; + + /** + * Gets the request object that represents the current postback. + * @return A request object that is represented by the Sys.Net.WebRequestExecutor class. + */ + get_request(): Sys.Net.WebRequestExecutor; + + /** + * Gets or sets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. + * The returned array can be modified by a client event handler to add or remove UpdatePanel controls that should re-render their content dynamically. Server processing can also modify the array. + * @return An array of UniqueID values for UpdatePanel controls. + */ + get_updatePanelsToUpdate(): string[]; + + //#endregion + } /** * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397476(v=vs.100).aspx} */ class PageLoadedEventArgs extends EventArgs { - + //#region Constructors + + /** + * Initializes a new instance of the PageLoadedEventArgs class. + */ + constructor(); + + //#endregion + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * A page or control must be in partial-page rendering mode to register data items that use the RegisterDataItem method of the ScriptManager class + * Use the IsInAsyncPostBack property to check whether the page is in partial-page rendering mode.The dataItems property returns a JSON data structure that contains name/value pairs. + * The name is the unique ID of the control that is used in the control parameter of the RegisterDataItem method. The value is the dataItem parameter of the RegisterDataItem method. + * + * @return A JSON data structure that contains name/value pairs that were registered as data items that use the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + /** + * Gets an array of HTML div elements that represent UpdatePanel controls that were created when the DOM was updated during the last asynchronous postback. + * If an UpdatePanel control is updated as a result of a partial-page update, the array referenced in the panelsCreated property of the PageLoadedEventArgs class contains a reference to the corresponding div element. + * The pageLoaded event of the Sys.WebForms.PageRequestManager class uses a PageLoadedEventArgs object to return its event data. + * @return An array of div elements that were created during the DOM manipulation that was caused by the last asynchronous postback. If no elements were created, the property returns null. + */ + get_panelsCreated(): HTMLDivElement[]; + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that were updated when the DOM was updated during the last asynchronous postback. + * If an UpdatePanel control is updated as a result of a partial-page update, the array referenced in the panelsUpdated property of the PageLoadedEventArgs class contains a reference to the corresponding
element. + * The pageLoaded event of the Sys.WebForms.PageRequestManager class uses a PageLoadedEventArgs object to return its event data. + * @return An array of
elements that were updated during the DOM manipulation that was the result of the last asynchronous postback. If no elements were created, the property returns null. + */ + get_panelsUpdated(): HTMLDivElement[]; + + //#endregion } /** * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310960(v=vs.100).aspx} */ class PageLoadingEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the PageLoadingEventArgs class. + */ + constructor(); + + //#endregion + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * page or control must be in partial-page rendering mode to register data items that use the RegisterDataItem method of the ScriptManager class. + * Use the IsInAsyncPostBack property to check whether the page is in partial-page rendering mode. + * The dataItems property returns a JSON data structure that contains name/value pairs. + * The name is the unique ID of the control that is used in the control parameter of the RegisterDataItem method. The value is the dataItem parameter of the RegisterDataItem method. + * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that will be deleted from the DOM as a result of the current asynchronous postback. + * If the contents of an UpdatePanel control will be deleted as the result of a partial-page update, the array that is referenced in the panelsDeleting property of the PageLoadingEventArgs class contains a reference to the corresponding
element. + * The pageLoading event of the Sys.WebForms.PageRequestManager class uses a PageLoadingEventArgs object to return its event data. + * @return An array of
elements that will be deleted from the DOM. If no elements will be deleted, the property returns null. + */ + get_panelsDeleted(): HTMLDivElement[]; + + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that will be updated in the DOM as a result of the current asynchronous postback. + * If the contents of any UpdatePanel controls will be updated as the result of a partial-page update, the panelsUpdating property contains an array that references the corresponding
elements. + * The pageLoading event of the Sys.WebForms.PageRequestManager class uses a PageLoadingEventArgs object to return its event data. + * @return An array of
elements that will be updated in the DOM. If no elements will be updated, the property returns null. + */ + get_panelsUpdating(): HTMLDivElement[]; + + //#endregion + } /** From 13800d9fb0b7610353f0ab57294c5381f8c169f5 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 7 Apr 2014 09:20:29 +0100 Subject: [PATCH 14/81] Added missing global functions Beginning of some typescript tests to check typing are working. Need to resolve issue with extensions of built in types from lib.d.ts Array, Boolean, Number etc. --- microsoft-ajax/microsoft.ajax-tests.ts | 113 ++++++++++++ microsoft-ajax/microsoft.ajax.d.ts | 228 ++++++++++++++++--------- 2 files changed, 258 insertions(+), 83 deletions(-) create mode 100644 microsoft-ajax/microsoft.ajax-tests.ts diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts new file mode 100644 index 000000000..24ee4f034 --- /dev/null +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -0,0 +1,113 @@ +// Type definitions for Microsoft ASP.NET Ajax client side library +// Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx +// Definitions by: Patrick Magee +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +//#region Global Namespace Tests + +var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + +//#endregion + + +//#region Sys.Application Tests + +var component = new Sys.Component(); +var element = document.getElementById("#test"); +var id = "#test"; +var propertyName = "test"; +var parent = component; +var registerObject = new Object(); + +function loadHandler() { } +function initHandler() { } +function navigateHandler() { } +function unloadHandler() { } + +Sys.Application.add_load(loadHandler); +Sys.Application.remove_load(loadHandler); +Sys.Application.add_init(initHandler); +Sys.Application.remove_init(initHandler); +Sys.Application.add_navigate(navigateHandler); +Sys.Application.remove_navigate(navigateHandler); +Sys.Application.add_unload(unloadHandler); +Sys.Application.remove_unload(unloadHandler); +Sys.Application.addComponent(component); +Sys.Application.addHistoryPoint("state", "title"); +Sys.Application.beginCreateComponents(); +Sys.Application.beginUpdate(); +Sys.Application.dispose(); +Sys.Application.disposeElement(element, false); +Sys.Application.endCreateComponents(); +Sys.Application.endUpdate(); +Sys.Application.findComponent(id, parent); +Sys.Application.findComponent(id); +$find(id, parent); + +var componentArray = Sys.Application.getComponents(); +for (var i = 0; i < componentArray.length; i++) { + var id = componentArray[i].get_id(); +} + +Sys.Application.initialize(); +Sys.Application.notifyScriptLoaded(); +Sys.Application.raiseLoad(); +Sys.Application.raisePropertyChanged(propertyName); +Sys.Application.registerDisposableObject(registerObject); +Sys.Application.removeComponent(component); +Sys.Application.unregisterDisposableObject(registerObject); +Sys.Application.endUpdate(); +Sys.Application.get_enableHistory(); +Sys.Application.set_enableHistory(true); +Sys.Application.get_isCreatingComponents(); +Sys.Application.get_isDisposing(); + +//#endregion + +//#region ASP.NET Types Tests + +Type.registerNamespace("Samples"); + +var Samples; +Samples.A = function () { } +var a = Samples.A; +a.registerClass('Samples.A'); + + +Samples.B = function () { } +var b = Samples.B; +b.registerClass('Samples.B'); + +Samples.C = function () { + var c = Samples.C; + c.initializeBase(this); +} + +Samples.C.registerClass('Samples.C', Samples.A, Samples.B); + +var isDerived; +isDerived = Samples.B.inheritsFrom(Samples.A); +// Output: "false". +alert(isDerived); + +isDerived = Samples.C.inheritsFrom(Samples.A); +// Output: "true". +alert(isDerived); + +var implementsInterface; +implementsInterface = Samples.C.implementsInterface(Samples.B); +// Output: "true". +alert(implementsInterface); + +//#endregion + +//#region Global Shortcut Methods + +$addHandler($get("Button1"), "click", () => { }); +$addHandlers($get("Button1"), { }); +$removeHandler($get("Button1"), "click", () => { }); +$find('MyComponent'); +$find('MyComponent', $find('#test')); + +//#endregion \ No newline at end of file diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 0eb400641..f7defd1f5 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -// Type definitions for microsoft asp.net ajax client side library +// Type definitions for Microsoft ASP.NET Ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -18,15 +18,29 @@ * Array Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} */ -interface Array { +interface ArrayStatic { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + /** - * Adds an element to the end of an Array object. + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * */ - add(element: T): void; + add(array: any[], element: any): void; /** * Copies all the elements of the specified array to the end of an Array object. */ - addRange(array: T, items: T): void; + addRange(array: any, items: any): void; /** * Removes all elements from an Array object. */ @@ -34,31 +48,31 @@ interface Array { /** * Creates a shallow copy of an Array object. */ - clone(): Array; + clone(): any[]; /** * Determines whether an element is in an Array object. */ - contains(element: T): boolean; + contains(element: any): boolean; /** * Removes the first element from an Array object. */ - dequeue(): T; + dequeue(): any; /** * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. */ - enqueue(element: T): void; + enqueue(element: any): void; /** * Performs a specified action on each element of an Array object. */ - forEach(array: T[], method: Function, instance: T[]): void; + forEach(array: any[], method: Function, instance: any[]): void; /** * Searches for the specified element of an Array object and returns its index. */ - indexOf(array: T[], item: T, startIndex?: number): number; + indexOf(array: any[], item: any, startIndex?: number): number; /** * Inserts a value at the specified location in an Array object. */ - insert(array: T[], index: number, item: T); + insert(array: any[], index: number, item: any); /** * Creates an Array object from a string representation. */ @@ -66,11 +80,11 @@ interface Array { /** * Removes the first occurrence of an element in an Array object. */ - remove(array: T[], item: T): boolean; + remove(array: any[], item: any): boolean; /** * Removes an element at the specified location in an Array object. */ - removeAt(array: T[], index: number): void; + removeAt(array: any[], index: number): void; } /** @@ -356,20 +370,20 @@ declare class Type { * The type to test. * @return true if the type is an enumeration; otherwise, false. */ - static isEnum(type: any): boolean; + static isEnum(type: any): boolean; /** * Get a value that indicates whether the specified type is an integer of flags. * @param * The type to test. * @return true if the type is an integer of flags; otherwise, false. */ - static isFlags(type: any): boolean; + static isFlags(type: any): boolean; /** * Determines whether an instance implements an interface. * @param typeInstanceVar * The instance on which the interface is tested. * @return - */ + */ isImplementedBy(typeInstanceVar: any): boolean; /** * Returns a value that indicates whether an object is an instance of a specified class or of one of its derived classes. @@ -440,7 +454,7 @@ declare class Type { * The resolveInheritance method copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. * If the derived type overrides a base type member, the base type member is not copied to the derived type's prototype. * After invoking a derived type's resolveInheritance method, you can examine the members of the derived type to discover all members, which includes inherited members. - */ + */ resolveInheritance(): void; } @@ -450,6 +464,8 @@ declare class Type { /** * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397487(v=vs.100).aspx} +* * @param type * The type of the component to create. * @param properties @@ -460,17 +476,63 @@ declare class Type { * (Optional) A JSON object that describes the properties that are references to other components. * @param element * (Optional) The DOM element that the component should be attached to. -* * @returns A new instance of a component that uses the specified parameters. */ declare function $create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; /** * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397441(v=vs.100).aspx} +* @param id A string that contains the ID of the component to find. +* @param parent (Optional) The component or element that contains the component to find. * @return A Component object that contains the component requested by ID, if found; otherwise, null. */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; +/* +* Provides a shortcut to the addHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb311019(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param eventName The name of the event. +* @param handler The event handler to add. +* @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. +*/ +declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean); + +/** +* Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb384012(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param events A dictionary of events and their handlers. +* @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. +* @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. +*/ +declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean); + +/** +* Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* For details about the method that this shortcut represents, see Sys.UI.DomEvent clearHandlers Method. +* @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} +* @param The DOM element that exposes the events. +*/ +declare function $clearHandlers(element: Element); + +/** +* Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397717(v=vs.100).aspx} +* @param id The ID of the DOM element to find. +* @param element The parent element to search. The default is the document element. +*/ +declare function $get(id: string, element?: Element); + +/** +* Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397510(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param eventName The name of the DOM event. +* @param handler The event handler to remove. +*/ +declare function $removeHandler(element, eventName, handler); //#endregion @@ -514,9 +576,9 @@ declare module Sys { * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. */ add_load(handler: Function): void; - /** - * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. - */ + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ remove_load(handler: Function): void; /** * Occurs when the user clicks the browser's Back or Forward button. @@ -742,7 +804,7 @@ declare module Sys { * @param propertyName * The name of the property that changed. */ - raisePropertyChanged(propertyName: string): void; + raisePropertyChanged(propertyName: string): void; /** * Called by the endUpdate method as a placeholder for additional logic in derived classes. * Override the updated method in a derived class to add custom post-update logic. @@ -763,7 +825,7 @@ declare module Sys { /** * Represents a culture definition that can be applied to objects that accept a culture-related setting. * @see {@link http://msdn.microsoft.com/en-us/library/bb384004(v=vs.100).aspx} - */ + */ class CultureInfo { //#region Constructors @@ -864,13 +926,13 @@ declare module Sys { //#endregion } - + /** * Describes a change in a collection. * @see {@link http://msdn.microsoft.com/en-us/library/dd393798(v=vs.100).aspx} */ class CollectionChange { - + //#region Constructors /** @@ -937,7 +999,7 @@ declare module Sys { * The array to which an item will be added. * @param item * The item to add. - */ + */ static add(target: any[], item): void; /** @@ -965,9 +1027,9 @@ declare module Sys { * Adds items to the collection in an observable manner. * @param target The array to which items will be added. * @param items The array of items to add. - */ + */ static addRange(target: any[], items: any[]): void; - + /** * Begins the process of updating the target object. * @param target The object to update. @@ -998,7 +1060,7 @@ declare module Sys { * Indicates that the target is being updated. * @param target The target object to update. * @return true if given target argument is currently updating; otherwise false. - */ + */ static isUpdating(target: any): boolean; /** @@ -1013,7 +1075,7 @@ declare module Sys { * Raises the collectionChanged event. * @param target The collection to which an event is raised. * @param changes A Sys.CollectionChange object that contains the list of changes that were performed on the collection since the last event. - */ + */ static raiseCollectionChanged(target: any[], changes: Sys.CollectionChange): void; /** @@ -1021,9 +1083,9 @@ declare module Sys { * @param target The target object. * @param eventName A string that contains the event name. * @param eventArgs A Sys.EventArgs object used to pass event argument information. - */ + */ static raiseEvent(target: any, eventName: string, eventArgs: Sys.EventArgs): void; - + /** * Raises a propertyChanged notification event. * @param target The object to which an event is raised. @@ -1045,7 +1107,7 @@ declare module Sys { * @param index A number that represents the index of the item to remove. */ static removeAt(target: any[], index: number): void; - + /** * Removes the collectionChanged event handler from the target. * @param target The array from which the collectionChanged event handler is removed. @@ -1084,19 +1146,19 @@ declare module Sys { /** * @return "Actual value was {0}." - */ + */ actualValue: string; /** * @return "The application failed to load within the specified time out period." - */ + */ appLoadTimedout: string; /** * @return "Value does not fall within the expected range." - */ + */ argument: string; /** * @return "Value cannot be null." - */ + */ argumentNull: string; /** * @return "Specified argument was out of the range of valid values. @@ -1104,27 +1166,27 @@ declare module Sys { argumentOutOfRange: string; /** * @return "Object cannot be converted to the required type." - */ + */ argumentType: string; /** * @return "Object of type '{0}' cannot be converted to type '{1}'." - */ + */ argumentTypeWithTypes: string; /** * @return "Value cannot be undefined." - */ - argumentUndefined: string; + */ + argumentUndefined: string; /** * @return "Assertion Failed: {0}" - */ + */ assertFailed: string; /** * @return "Assertion Failed: {0}\r\nat {1}" - */ + */ assetFailedCaller: string; /** * @return "Base URL does not contain ://." - */ + */ badBaseUrl1: string; /** * @return "Base URL does not contain another /." @@ -1268,7 +1330,7 @@ declare module Sys { * Determines whether the Sys.StringBuilder object has content. * Use the isEmpty method to determine whether a StringBuilder instance has any content. If you append an empty string, null, or an undefined value to an empty StringBuilder instance, the instance remains empty and unchanged. * @return true if the StringBuilder instance contains no elements; otherwise, false. - */ + */ isEmpty(): boolean; /** @@ -1284,7 +1346,7 @@ declare module Sys { //#endregion } - //#endregion + //#endregion //#region Enumerations @@ -1315,7 +1377,7 @@ declare module Sys { * Provides a common interface for all components that can contain other components. */ interface IContainer { - + //#region Methods /** @@ -1353,7 +1415,7 @@ declare module Sys { * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. * Implement the IDisposable interface to provide a common interface for closing or releasing resources held by instances of your registered Microsoft Ajax Library class. * You register an interface by when you register the class by calling the Type.registerClass method. You specify IDisposable in the interfaceTypes parameter when you call Type.registerClass. - */ + */ interface IDisposable { /** * Releases resources held by an object that implements the Sys.IDisposable interface. @@ -1397,7 +1459,7 @@ declare module Sys { * The name of the event handler for the propertyChanged event. */ remove_propertyChanged(handler: Function): void; - } + } //#endregion @@ -1469,7 +1531,7 @@ declare module Sys { /** * Initializes a new instance of the CancelEventArgs class. - */ + */ constructor(); //#endregion @@ -1552,7 +1614,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310957(v=vs.100).aspx} */ class PropertyChangedEventArgs extends EventArgs { - + //#region Constructors /** @@ -1610,7 +1672,7 @@ declare module Sys { */ class ArgumentUndefinedException { - } + } /** * */ @@ -1643,7 +1705,7 @@ declare module Sys { } //#endregion - + //#region Sys.Net Namespace /** @@ -1678,7 +1740,7 @@ declare module Sys { /** * Removes the event handler added by the add_completed method. * @see {@link http://msdn.microsoft.com/en-us/library/bb397454(v=vs.100).aspx} - */ + */ remove_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; /** @@ -1697,7 +1759,7 @@ declare module Sys { * @param eventArgs * The value to pass to the Web request completed event handler. */ - completed(eventArgs: Sys.EventArgs): void; + completed(eventArgs: Sys.EventArgs): void; //#endregion @@ -1739,7 +1801,7 @@ declare module Sys { * If a request finished successfully and with valid response data, this method returns all the response headers. * @return All the response headers * @see {@link http://msdn.microsoft.com/en-us/library/bb310805(v=vs.100).aspx} - */ + */ getAllResponseHeaders(): string; /** * Gets the value of the specified response header. @@ -1842,7 +1904,7 @@ declare module Sys { //#endregion //#region Methods - + /** * Converts an ECMAScript (JavaScript) object graph into a JSON string. This member is static and can be invoked without creating an instance of the class. * @static @@ -1891,7 +1953,7 @@ declare module Sys { /** * Initializes a new instance of the Sys.Services.AuthenticationService class. - */ + */ constructor(); //#endregion @@ -1900,7 +1962,7 @@ declare module Sys { /** * Specifies the path of the default authentication service. - */ + */ DefaultWebServicePath: string; //#endregion @@ -1944,7 +2006,7 @@ declare module Sys { * The function that is called if the logout has failed. The default is null. * @param userContext * User context information that you are passing to the callback functions. - */ + */ logout(redirectUrl: string, logoutCompletedCallback: Function, failedCallback: Function, userContext: any): void; //#endregion @@ -1988,7 +2050,7 @@ declare module Sys { * A reference to the user context for the service. */ defaultUserContext(value: Object): void; - + /** * Gets the authentication state of the current user. * The value of this property is set by the ScriptManager object during a page request. @@ -2036,7 +2098,7 @@ declare module Sys { * The ProfileGroup class defines the type of an element as a group in the properties collection of the Sys.Services.ProfileService class. * Profile group properties are accessed as subproperties of the related group, as shown in the following ECMAScript (JavaScript) example: * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} - */ + */ class ProfileGroup { /** @@ -2059,7 +2121,7 @@ declare module Sys { /** * Provides the client proxy class for the profile service. * @see {@link http://msdn.microsoft.com/en-us/library/bb383800(v=vs.100).aspx} - */ + */ class ProfileService { } @@ -2082,7 +2144,7 @@ declare module Sys { class Behavior extends Sys.Component { //#region Methods - + /** * Gets a Sys.UI.Behavior instance with the specified name property from the specified HTML Document Object Model (DOM) element. This member a static member and can be invoked without creating an instance of the class. * @return The specified Behavior object, if found; otherwise, null. @@ -2106,7 +2168,7 @@ declare module Sys { * The dispose method releases all resources from the Sys.UI.Behavior object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. */ dispose(): void; - + //#endregion //#region Properties @@ -2151,7 +2213,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397698(v=vs.100).aspx} */ class Bounds { - + //#region Constructors /** @@ -2194,43 +2256,43 @@ declare module Sys { * Provides the base class for all all ASP.NET AJAX client controls. */ class Control extends Sys.Component { - + } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. */ class DomElement { - + } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. */ class DomEvent { - + } /** * Describes key codes. */ enum Key { - + } /** * Describes mouse button locations. */ enum MouseButton { - + } /** * Creates an object that contains a set of integer coordinates that represent a position. */ class Point { - + } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. */ enum VisibilityMode { - + } } @@ -2247,7 +2309,7 @@ declare module Sys { /** * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. * @see {@link http://msdn.microsoft.com/en-us/library/bb384003(v=vs.100).aspx} - */ + */ class BeginRequestEventArgs extends EventArgs { //#region Constructors @@ -2293,7 +2355,7 @@ declare module Sys { /** * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. * @see {@link http://msdn.microsoft.com/en-us/library/bb397499.aspx} - */ + */ class EndRequestEventArgs extends EventArgs { //#region Constructors @@ -2354,9 +2416,9 @@ declare module Sys { * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. * This class contains private members that support the client-script infrastructure and are not intended to be used directly from your code. Names of private members begin with an underscore ( _ ). * @see {@link http://msdn.microsoft.com/en-us/library/bb311030(v=vs.100).aspx} - */ + */ class InitializeRequestEventArgs extends EventArgs { - + //#region Constructors /** @@ -2400,7 +2462,7 @@ declare module Sys { /** * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. * @see {@link http://msdn.microsoft.com/en-us/library/bb397476(v=vs.100).aspx} - */ + */ class PageLoadedEventArgs extends EventArgs { //#region Constructors @@ -2444,7 +2506,7 @@ declare module Sys { /** * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. * @see {@link http://msdn.microsoft.com/en-us/library/bb310960(v=vs.100).aspx} - */ + */ class PageLoadingEventArgs extends EventArgs { //#region Constructors @@ -2490,7 +2552,7 @@ declare module Sys { /** * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. - */ + */ class PageRequestManager extends EventArgs { //#region Constructors @@ -2520,7 +2582,7 @@ declare module Sys { * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be called. - */ + */ add_endRequest(endRequestHandler: (sender, args) => void): void; /** * Raised after an asynchronous postback is finished and control has been returned to the browser. @@ -2628,7 +2690,7 @@ declare module Sys { * To customize error handling and to display more information about the server error, handle the AsyncPostBackError event and use the AsyncPostBackErrorMessage and AllowCustomErrorsRedirect properties. * For an example of how to provide custom error handling during partial-page updates, see Customizing Error Handling for ASP.NET UpdatePanel Controls. * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * - */ + */ class PageRequestManagerServerErrorException { } From 07ace1a8e9c1748258d814b34a07e2c386c28bfc Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 10 Apr 2014 08:16:31 +0100 Subject: [PATCH 15/81] Added more tests Global shortcut method tests Application load event tests collection change tests command event arg tests Component tests Culture info tests --- microsoft-ajax/microsoft.ajax-tests.ts | 139 +++++++++++++++++++++++-- microsoft-ajax/microsoft.ajax.d.ts | 51 ++++++++- 2 files changed, 177 insertions(+), 13 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 24ee4f034..15b52ffcf 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -10,6 +10,15 @@ var arrayVar = new Array("Saturn", "Mars", "Jupiter"); //#endregion +//#region Global Shortcut Methods + +$addHandler($get("Button1"), "click", () => { }); +$addHandlers($get("Button1"), {}); +$removeHandler($get("Button1"), "click", () => { }); +$find('MyComponent'); +$find('MyComponent', $find('#test')); + +//#endregion //#region Sys.Application Tests @@ -65,6 +74,127 @@ Sys.Application.get_isDisposing(); //#endregion +//#region Sys.ApplicationLoadEventArgs Tests + +var a = new Sys.ApplicationLoadEventArgs(new Array(), true); + +var components = a.get_components(); +var isPartialReload = a.get_isPartialLoad(); + +//#endregion + +//#region Sys.Browser Tests + +var browser = Sys.Browser(); + +//#endregion + +//#region Sys.CancelEventArgs Tests + +var args = new Sys.CancelEventArgs(); + +var divElem = 'AlertDiv'; +var messageElem = 'AlertMessage'; + +Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); + +function CheckStatus(sender, args) { + + var prm = Sys.WebForms.PageRequestManager.getInstance(); + + if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { + prm.abortPostBack(); + } + else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + + args.set_cancel(true); + ActivateAlertDiv('visible', 'Still working on previous request.'); + } + else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + ActivateAlertDiv('visible', 'Processing....'); + } +} + +function ActivateAlertDiv(visString, msg) { + var adiv = $get(divElem); + var aspan = $get(messageElem); + adiv.style.visibility = visString; + aspan.innerHTML = msg; +} + +//#endregion + +//#region Sys.CollectionChange Tests + +var action = Sys.NotifyCollectionChangedAction.add; +var newItems = []; +var newStartingIndex = 1; +var oldItems = []; +var oldStartingIndex = 2; + +var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); + +action = MyCChg.action; +newItems = MyCChg.newItems; +newStartingIndex = MyCChg.newStartingIndex; +oldItems = MyCChg.oldItems; +oldStartingIndex = MyCChg.oldStartingIndex; + +//#endregion + +//#region Sys.CommandEventArg Tests + +var commandName = "command name"; +var commandArgument = "command argument"; +var commandSource = "command source"; +var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); +var empty = argsObj.Empty; +commandName = argsObj.get_commandName(); +commandArgument = argsObj.get_commandArgument(); + +//#endregion + +//#region Sys.Component Tests + +var aComponent = new Sys.Component(); + +aComponent.add_disposing(() => { }); +aComponent.remove_disposing(() => { }); + +aComponent.add_propertyChanged(() => { }); +aComponent.remove_propertyChanged(() => { }); + +aComponent.beginUpdate(); + +aComponent.create(type, properties, events, references, element); + +aComponent.dispose(); + +aComponent.endUpdate(); + +aComponent.initialize(); + +aComponent.raisePropertyChanged("propertyName"); + +aComponent.updated(); + +//#endregion + +//#region Sys.CultureInfo Tests + +var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; +var dtfCCObject = currentCultureInfoObj.dateTimeFormat; +var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; +var dtfICObject = invariantCultureInfoObj.dateTimeFormat; + +var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); + +var format = newCulture.dateTimeFormat; +var name = newCulture.name; +var numberFormat = newCulture.numberFormat; + +//#endregion + //#region ASP.NET Types Tests Type.registerNamespace("Samples"); @@ -102,12 +232,3 @@ alert(implementsInterface); //#endregion -//#region Global Shortcut Methods - -$addHandler($get("Button1"), "click", () => { }); -$addHandlers($get("Button1"), { }); -$removeHandler($get("Button1"), "click", () => { }); -$find('MyComponent'); -$find('MyComponent', $find('#test')); - -//#endregion \ No newline at end of file diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index f7defd1f5..5e00ecd0c 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -554,7 +554,7 @@ declare module Sys { * The members can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ - class Application { + interface Application { //#region Constructors @@ -697,11 +697,14 @@ declare module Sys { //#endregion } + var Application: Application; + /** * Provides information about the current Web browser. + * The Sys.Browser object determines which browser is being used and provides some information about it. You can use this object to help customize your code to the unique requirements or capabilities of the browser. * @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx} */ - class Browser { + interface IBrowser { //#region Fields @@ -729,6 +732,8 @@ declare module Sys { //#endregion } + export function Browser(): Sys.IBrowser; + /** * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. * @see {@link http://msdn.microsoft.com/en-us/library/bb397516(v=vs.100).aspx} @@ -1465,6 +1470,42 @@ declare module Sys { //#region Event Args + /* + * Used by the Application class to hold event arguments for the load event. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383787(v=vs.100).aspx} + */ + class ApplicationLoadEventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the ApplicationLoadEventArgs class. + * @param components + * The list of components that were created since the last time the load event was raised. + * @param isPartialLoad + * true to indicate that the event is a partial-page update. + */ + constructor(components: any, isPartialLoad: boolean); + + //#endregion + + //#region Properties + + /** + * Gets an array of all the components that were created since the last time the load event was raised. + * @return An array of all the components that were created since the last time the load event was raised. + */ + get_components(): Component[]; + + /** + * Returns a value that indicates whether the page is engaged in a partial-page update. + * @return true if the page is engaged in a partial-page update; otherwise, false. + */ + get_isPartialLoad(): boolean; + + //#endregion + } + /** * Provides a base class for classes that are used by event sources to pass event argument information. * @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx} @@ -2635,7 +2676,7 @@ declare module Sys { * Returns the instance of the PageRequestManager class for the page. * @return The current instance of the PageRequestManager class. You do not create a new instance of the PageRequestManager class directly. Instead, an instance is available when partial-page rendering is enabled. */ - getInstance(): PageRequestManager; + static getInstance(): PageRequestManager; /** * Stops all updates that would occur as a result of an asynchronous postback. @@ -2667,7 +2708,9 @@ declare module Sys { //#endregion - //#region Properties + //#region Properties + + get_isInAsyncPostBack(): boolean; //#endregion } From 3a28f34a974a472394298120c9c069bd8839669c Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Thu, 17 Apr 2014 17:12:18 +0200 Subject: [PATCH 16/81] Leaflet: Fix the L.tileLayer function typing The current version was being rejected by Typescript 1.0. The new typing follows the advice from the Handbook. --- leaflet/leaflet.d.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 3044970b0..a2d91032a 100644 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -3655,25 +3655,27 @@ declare module L { } } - export class tileLayer { + export interface TileLayerFactory { /** * Instantiates a tile layer object given a URL template and optionally an options * object. */ - function (urlTemplate: string, options?: TileLayerOptions): TileLayer; + (urlTemplate: string, options?: TileLayerOptions): TileLayer; /** * Instantiates a WMS tile layer object given a base URL of the WMS service and * a WMS parameters/options object. */ - static wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS; + wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS; /** * Instantiates a Canvas tile layer object given an options object (optionally). */ - static canvas(options?: TileLayerOptions): L.TileLayer.Canvas; + canvas(options?: TileLayerOptions): L.TileLayer.Canvas; } + + export var tileLayer: TileLayerFactory; } declare module L { From a52dade23ee75d9fd1c8577a0aca911b7c76d0bd Mon Sep 17 00:00:00 2001 From: AdvancedREI Date: Mon, 12 May 2014 17:50:58 -0700 Subject: [PATCH 17/81] Added Auth0 definitions for JS API and widget --- CONTRIBUTORS.md | 4 +- auth0.widget/auth0.widget-tests.ts | 18 +++++ auth0.widget/auth0.widget.d.ts | 48 +++++++++++++ auth0/auth0-tests.ts | 23 +++++++ auth0/auth0.d.ts | 107 +++++++++++++++++++++++++++++ 5 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 auth0.widget/auth0.widget-tests.ts create mode 100644 auth0.widget/auth0.widget.d.ts create mode 100644 auth0/auth0-tests.ts create mode 100644 auth0/auth0.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f39e1f53d..394f420bc 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,4 +1,4 @@ -# Contributors +# Contributors This is a non-exhaustive list of definitions and their creators. If you created a definition but are not listed then feel free to send a pull request on this file with your name and url. @@ -22,6 +22,8 @@ All definitions files include a header with the author and editors, so at some p * [assert](https://github.com/Jxck/assert) (by [vvakame](https://github.com/vvakame)) * [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) * [Atom](https://atom.io/) (by [vvakame](https://github.com/vvakame)) +* [Auth0](https://auth0.com/) (by [Robert McLaws](https://github.com/advancedrei)) +* [Auth0.Widget](https://auth0.com/) (by [Robert McLaws](https://github.com/advancedrei)) * [aws-sdk-js](https://github.com/aws/aws-sdk-js) (by [midknight41](https://github.com/midknight41)) * [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm)) diff --git a/auth0.widget/auth0.widget-tests.ts b/auth0.widget/auth0.widget-tests.ts new file mode 100644 index 000000000..012e9b976 --- /dev/null +++ b/auth0.widget/auth0.widget-tests.ts @@ -0,0 +1,18 @@ +/// +/// + +var widget: Auth0WidgetStatic = new Auth0Widget({ + domain: 'mine.auth0.com', + clientID: 'dsa7d77dsa7d7', + callbackURL: 'http://my-app.com/callback', + callbackOnLocationHash: true +}); + +widget.signin({ + connections: ['facebook', 'google-oauth2', 'twitter', 'Username-Password-Authentication'], + icon: 'https://contoso.com/logo-32.png', + showIcon: true +}, + () => { + // The Auth0 Widget is now loaded. + }); diff --git a/auth0.widget/auth0.widget.d.ts b/auth0.widget/auth0.widget.d.ts new file mode 100644 index 000000000..6be138dcb --- /dev/null +++ b/auth0.widget/auth0.widget.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Auth0Widget.js +// Project: Auth0.com +// Definitions by: Robert McLaws +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +interface Auth0WidgetStatic { + new(params: Auth0Constructor): Auth0WidgetStatic; + + getClient(): Auth0Static; + getProfile(token: string, callback: Function): Auth0UserProfile; + parseHash(hash: string): Auth0DecodedHash; + reset(options: Auth0Options, callback?: Function): Auth0WidgetStatic; + signin(options: Auth0Options, widgetLoadedCallback?: Function, popupCallback?: Function): Auth0WidgetStatic; + signup(options: Auth0Options, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any): Auth0WidgetStatic; + } + +interface Auth0Constructor extends Auth0ClientOptions { + assetsUrl?: string; + cdn?: string; + dict?: any; + } + +interface Auth0Options { + access_token?: string; + connections?: string[]; + container?: string; + enableReturnUserExperience?: boolean; + extraParameters?: any; + icon?: string; + protocol?: string; + request_id?: string; + scope?: string; + showIcon?: boolean; + showForgot?: boolean; + showSignup?: boolean; + state?: any; + userPwdConnectionName?: string; + username_style?: string; +} + +declare var Auth0Widget: Auth0WidgetStatic; + +declare module "Auth0Widget" { + export = Auth0Widget +} \ No newline at end of file diff --git a/auth0/auth0-tests.ts b/auth0/auth0-tests.ts new file mode 100644 index 000000000..9cd903b30 --- /dev/null +++ b/auth0/auth0-tests.ts @@ -0,0 +1,23 @@ +/// + +var auth0 = new Auth0({ + domain: 'mine.auth0.com', + clientID: 'dsa7d77dsa7d7', + callbackURL: 'http://my-app.com/callback', + callbackOnLocationHash: true +}); + +auth0.login({ + connection: 'google-oauth2', + popup: true, + popupOptions: { + width: 450, + height: 800 + } +}, (err, profile, idToken, accessToken, state) => { + if (err) { + alert("something went wrong: " + err.message); + return; + } + alert('hello ' + profile.name); + }); diff --git a/auth0/auth0.d.ts b/auth0/auth0.d.ts new file mode 100644 index 000000000..939928b8e --- /dev/null +++ b/auth0/auth0.d.ts @@ -0,0 +1,107 @@ +// Type definitions for Auth0.js +// Project: Auth0.com +// Definitions by: Robert McLaws +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** This is the interface for the main Auth0 client. */ +interface Auth0Static { + + new(options: Auth0ClientOptions): Auth0Static; + changePassword(options: any, callback?: Function); + decodeJwt(jwt: string): any; + login(options: any, callback: (error, profile?, id_token?, access_token?, state?) => any); + loginWithPopup(options: Auth0LoginOptions, callback: (error, profile?, id_token?, access_token?, state?) => any); + loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); + loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); + logout(query: string): void; + getConnections(callback?: Function) + getDelegationToken(targetClientId, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; + getProfile(id_token: string, callback?: Function): Auth0UserProfile; + getSSOData(withActiveDirectories: any, callback?: Function); + parseHash(hash: string): Auth0DecodedHash; + signup(options: Auth0SignupOptions, callback: Function); + validateUser(options: any, callback: (error?: Auth0Error, valid?) => any); +} + +/** Represents constructor options for the Auth0 client. */ +interface Auth0ClientOptions { + clientID: string; + callbackURL: string; + callbackOnLoactionHash?: boolean; + domain: string; + forceJSONP?: boolean; +} + +/** Represents a normalized UserProfile. */ +interface Auth0UserProfile { + email: string; + family_name: string; + gender: string; + given_name: string; + locale: string; + name: string; + nickname: string; + picture: string; + user_id: string; + /** Represents one or more Identities that may be associated with the User. */ + identities: Auth0Identity[]; +} + +/** Represents */ +interface Auth0Identity { + access_token: string; + connection: string; + isSocial: boolean; + provider: string; + user_id: string; +} + +interface Auth0DecodedHash { + access_token: string; + id_token: string; + profile: Auth0UserProfile; + state: any; +} + +interface Auth0PopupOptions { + width: number; + height: number; +} + +interface Auth0LoginOptions { + auto_login?: boolean; + connection?: string; + email?: string; + username?: string; + password?: string; + popup?: boolean; + popupOptions?: Auth0PopupOptions; +} + +interface Auth0SignupOptions extends Auth0LoginOptions { + auto_login: boolean; +} + +interface Auth0Error { + code: any; + details: any; + name: string; + message: string; + status: any; +} + +/** Represents the response from an API Token Delegation request. */ +interface Auth0DelegationToken { + /** The length of time in seconds the token is valid for. */ + expires_in: string; + /** The JWT for delegated access. */ + id_token: string; + /** The type of token being returned. Possible values: "Bearer" */ + token_type: string; +} + +declare var Auth0: Auth0Static; + +declare module "Auth0" { + export = Auth0 +} \ No newline at end of file From c0f077506056ea4cd0492888769ee2a59463b4ff Mon Sep 17 00:00:00 2001 From: AdvancedREI Date: Mon, 12 May 2014 20:25:33 -0700 Subject: [PATCH 18/81] Auth0: Removing implicit variable types Attempting to pass travis.ci. --- auth0.widget/auth0.widget.d.ts | 2 +- auth0/auth0.d.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/auth0.widget/auth0.widget.d.ts b/auth0.widget/auth0.widget.d.ts index 6be138dcb..932d79c94 100644 --- a/auth0.widget/auth0.widget.d.ts +++ b/auth0.widget/auth0.widget.d.ts @@ -14,7 +14,7 @@ interface Auth0WidgetStatic { parseHash(hash: string): Auth0DecodedHash; reset(options: Auth0Options, callback?: Function): Auth0WidgetStatic; signin(options: Auth0Options, widgetLoadedCallback?: Function, popupCallback?: Function): Auth0WidgetStatic; - signup(options: Auth0Options, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any): Auth0WidgetStatic; + signup(options: Auth0Options, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): Auth0WidgetStatic; } interface Auth0Constructor extends Auth0ClientOptions { diff --git a/auth0/auth0.d.ts b/auth0/auth0.d.ts index 939928b8e..4d0349dd7 100644 --- a/auth0/auth0.d.ts +++ b/auth0/auth0.d.ts @@ -7,20 +7,20 @@ interface Auth0Static { new(options: Auth0ClientOptions): Auth0Static; - changePassword(options: any, callback?: Function); + changePassword(options: any, callback?: Function): void; decodeJwt(jwt: string): any; - login(options: any, callback: (error, profile?, id_token?, access_token?, state?) => any); - loginWithPopup(options: Auth0LoginOptions, callback: (error, profile?, id_token?, access_token?, state?) => any); - loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); - loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?, id_token?, access_token?, state?) => any); + login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; + loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any); + loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void; + loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; logout(query: string): void; - getConnections(callback?: Function) + getConnections(callback?: Function): void; getDelegationToken(targetClientId, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; getProfile(id_token: string, callback?: Function): Auth0UserProfile; - getSSOData(withActiveDirectories: any, callback?: Function); + getSSOData(withActiveDirectories: any, callback?: Function): void; parseHash(hash: string): Auth0DecodedHash; - signup(options: Auth0SignupOptions, callback: Function); - validateUser(options: any, callback: (error?: Auth0Error, valid?) => any); + signup(options: Auth0SignupOptions, callback: Function): void; + validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void; } /** Represents constructor options for the Auth0 client. */ From b9249f4febbfb7471be0b8bf0eedd926e73b2446 Mon Sep 17 00:00:00 2001 From: AdvancedREI Date: Mon, 12 May 2014 20:28:20 -0700 Subject: [PATCH 19/81] Auth0: Missed two implicit variables. --- auth0/auth0.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth0/auth0.d.ts b/auth0/auth0.d.ts index 4d0349dd7..e4b114b6f 100644 --- a/auth0/auth0.d.ts +++ b/auth0/auth0.d.ts @@ -10,12 +10,12 @@ interface Auth0Static { changePassword(options: any, callback?: Function): void; decodeJwt(jwt: string): any; login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; - loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any); + loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void; loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void; logout(query: string): void; getConnections(callback?: Function): void; - getDelegationToken(targetClientId, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; + getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void; getProfile(id_token: string, callback?: Function): Auth0UserProfile; getSSOData(withActiveDirectories: any, callback?: Function): void; parseHash(hash: string): Auth0DecodedHash; From 489927d0b8a721ac6c19d1530e2ecb481d0ee063 Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Sat, 17 May 2014 11:46:38 -0400 Subject: [PATCH 20/81] Work on getting extensions for base types working -New MicrosoftAjaxBaseTypeExtensions module -A few other minor enhancements and JS doc stuff --- microsoft-ajax/microsoft.ajax.d.ts | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 5e00ecd0c..be05be47d 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -269,6 +269,46 @@ interface String { //#endregion +declare module MicrosoftAjaxBaseTypeExtensions { + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Function type by including exception + * details and support for application-compilation modes (debug or release). + * @see {@link http://msdn.microsoft.com/en-us/library/dd409270(v=vs.100).aspx} + */ + interface Function { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; + + /** + * Creates a delegate function that retains the context first used during an objects creation. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx } + */ + createCallback(method: Function, ...context: any[]): Function; + /** + * Creates a callback function that retains the parameter initially used during an object's creation. + * @see {@link http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx } + */ + createDelegate(instance: any, method: Function): Function; + + /** + * A function that does nothing. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393667(v=vs.100).aspx } + */ + emptyMethod(): Function; + + /** + * Validates the parameters to a method are as expected. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx } + */ + validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; + } +} + //#region ASP.NET Types /** @@ -489,6 +529,15 @@ declare function $create(type: Type, properties?: any, events?: any, references? */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; +/** +* Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397441(v=vs.100).aspx} +* @param id A string that contains the ID of the component to find. +* @param parent (Optional) The component or element that contains the component to find. +* @return A Component object that contains the component requested by ID, if found; otherwise, null. +*/ +declare function $find(id: string, parent?: HTMLElement): Sys.Component; + /* * Provides a shortcut to the addHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb311019(v=vs.100).aspx} @@ -589,6 +638,16 @@ declare module Sys { */ remove_navigate(handler: Function): void; + /** + * Raised before all objects in the client application are disposed, typically when the DOM window.unload event is raised. + */ + add_unload(handler: Function): void; + + /** + * Raised before all objects in the client application are disposed, typically when the DOM window.unload event is raised. + */ + remove_unload(handler: Function): void; + //#endregion //#region Methods @@ -635,6 +694,11 @@ declare module Sys { */ findComponent(id: string, parent?: Sys.Component): Sys.Component; /** + * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. + * @return A Component object that contains the component requested by ID, if found; otherwise, null. + */ + findComponent(id: string, parent?: HTMLElement): Sys.Component; + /** * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. */ getComponents(): Sys.Component[]; @@ -760,6 +824,16 @@ declare module Sys { */ remove_disposing(handler: Function): void; + /** + * Gets the ID of the current Component object. + */ + get_id(): string; + /** + * Sets the ID of the current Component object. + * @param value A string that contains the ID of the component. + */ + set_id(value: string): void; + /** * Raised when the raisePropertyChanged method of the current Component object is called. */ @@ -1523,6 +1597,11 @@ declare module Sys { /** * A static object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. */ + static Empty: EventArgs; + + /** + * An object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. + */ Empty: EventArgs; //#endregion From d87ed0be2e0de267e2f5a1c3eda34cd2de1e242f Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Sat, 17 May 2014 11:47:40 -0400 Subject: [PATCH 21/81] Refactoring to ensure each set of tests is in its own function removed //#region declarations as the functions provide the same functionality (for compilation testing purposes anyway) plus eliminate scope conflicts. --- microsoft-ajax/microsoft.ajax-tests.ts | 558 ++++++++++++++++--------- 1 file changed, 349 insertions(+), 209 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 15b52ffcf..9e54d0c14 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -4,231 +4,371 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -//#region Global Namespace Tests +function GlobalNamespace_Tests() { -var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + var arrayVar = new Array("Saturn", "Mars", "Jupiter"); -//#endregion - -//#region Global Shortcut Methods - -$addHandler($get("Button1"), "click", () => { }); -$addHandlers($get("Button1"), {}); -$removeHandler($get("Button1"), "click", () => { }); -$find('MyComponent'); -$find('MyComponent', $find('#test')); - -//#endregion - -//#region Sys.Application Tests - -var component = new Sys.Component(); -var element = document.getElementById("#test"); -var id = "#test"; -var propertyName = "test"; -var parent = component; -var registerObject = new Object(); - -function loadHandler() { } -function initHandler() { } -function navigateHandler() { } -function unloadHandler() { } - -Sys.Application.add_load(loadHandler); -Sys.Application.remove_load(loadHandler); -Sys.Application.add_init(initHandler); -Sys.Application.remove_init(initHandler); -Sys.Application.add_navigate(navigateHandler); -Sys.Application.remove_navigate(navigateHandler); -Sys.Application.add_unload(unloadHandler); -Sys.Application.remove_unload(unloadHandler); -Sys.Application.addComponent(component); -Sys.Application.addHistoryPoint("state", "title"); -Sys.Application.beginCreateComponents(); -Sys.Application.beginUpdate(); -Sys.Application.dispose(); -Sys.Application.disposeElement(element, false); -Sys.Application.endCreateComponents(); -Sys.Application.endUpdate(); -Sys.Application.findComponent(id, parent); -Sys.Application.findComponent(id); -$find(id, parent); - -var componentArray = Sys.Application.getComponents(); -for (var i = 0; i < componentArray.length; i++) { - var id = componentArray[i].get_id(); + $addHandler($get("Button1"), "click", () => { }); + $addHandlers($get("Button1"), {}); + $removeHandler($get("Button1"), "click", () => { }); + $find('MyComponent'); + $find('MyComponent', $find('#test')); } -Sys.Application.initialize(); -Sys.Application.notifyScriptLoaded(); -Sys.Application.raiseLoad(); -Sys.Application.raisePropertyChanged(propertyName); -Sys.Application.registerDisposableObject(registerObject); -Sys.Application.removeComponent(component); -Sys.Application.unregisterDisposableObject(registerObject); -Sys.Application.endUpdate(); -Sys.Application.get_enableHistory(); -Sys.Application.set_enableHistory(true); -Sys.Application.get_isCreatingComponents(); -Sys.Application.get_isDisposing(); - -//#endregion - -//#region Sys.ApplicationLoadEventArgs Tests - -var a = new Sys.ApplicationLoadEventArgs(new Array(), true); - -var components = a.get_components(); -var isPartialReload = a.get_isPartialLoad(); - -//#endregion - -//#region Sys.Browser Tests - -var browser = Sys.Browser(); - -//#endregion - -//#region Sys.CancelEventArgs Tests - -var args = new Sys.CancelEventArgs(); - -var divElem = 'AlertDiv'; -var messageElem = 'AlertMessage'; - -Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); - -function CheckStatus(sender, args) { - - var prm = Sys.WebForms.PageRequestManager.getInstance(); - - if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { - prm.abortPostBack(); +function BaseClassExtensions_Function_Tests() { + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */ + var createDelegateTest = function () { + var context = ""; + var method: MicrosoftAjaxBaseTypeExtensions.Function; + var a = (Function).createCallback(method, context); } - else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { - - args.set_cancel(true); - ActivateAlertDiv('visible', 'Still working on previous request.'); + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx */ + var createDelegateTest = function () { + var instance = this; + var method: MicrosoftAjaxBaseTypeExtensions.Function; + var a = (Function).createDelegate(instance, method); } - else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { - ActivateAlertDiv('visible', 'Processing....'); + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */ + var validateParametersTest = function () { + var arguments = ['test1', 'test2']; + var insert = function Array$insert(array, index, item) { + var e = (Function).validateParameters(arguments, [ + { name: "array", type: Array, elementMayBeNull: true }, + { name: "index", mayBeNull: true }, + { name: "item", mayBeNull: true } + ]); + if (e) throw e; + } + }; +} + + +function Sys_Application_Tests() { + + var component = new Sys.Component(); + var element = document.getElementById("#test"); + var id = "#test"; + var propertyName = "test"; + var registerObject = new Object(); + + function loadHandler() { } + function initHandler() { } + function navigateHandler() { } + function unloadHandler() { } + + Sys.Application.add_load(loadHandler); + Sys.Application.remove_load(loadHandler); + Sys.Application.add_init(initHandler); + Sys.Application.remove_init(initHandler); + Sys.Application.add_navigate(navigateHandler); + Sys.Application.remove_navigate(navigateHandler); + Sys.Application.add_unload(unloadHandler); + Sys.Application.remove_unload(unloadHandler); + Sys.Application.addComponent(component); + Sys.Application.addHistoryPoint("state", "title"); + Sys.Application.beginCreateComponents(); + Sys.Application.beginUpdate(); + Sys.Application.dispose(); + Sys.Application.disposeElement(element, false); + Sys.Application.endCreateComponents(); + Sys.Application.endUpdate(); + Sys.Application.findComponent(id, element); + Sys.Application.findComponent(id, component); + Sys.Application.findComponent(id); + $find(id, element); + + var componentArray = Sys.Application.getComponents(); + for (var i = 0; i < componentArray.length; i++) { + var cid = componentArray[i].get_id(); + } + + Sys.Application.initialize(); + Sys.Application.notifyScriptLoaded(); + Sys.Application.raiseLoad(); + Sys.Application.raisePropertyChanged(propertyName); + Sys.Application.registerDisposableObject(registerObject); + Sys.Application.removeComponent(component); + Sys.Application.unregisterDisposableObject(registerObject); + Sys.Application.endUpdate(); + Sys.Application.get_enableHistory(); + Sys.Application.set_enableHistory(true); + Sys.Application.get_isCreatingComponents(); + Sys.Application.get_isDisposing(); +} + + +function Sys_Application_LoadEventArgs_Tests() { + var a = new Sys.ApplicationLoadEventArgs(new Array(), true); + + var components = a.get_components(); + var isPartialReload = a.get_isPartialLoad(); +} + + +function Sys_Browser_Tests() { + var browser = Sys.Browser(); +} + + + +function Sys_CancelEventArgs_Tests() { + + var args = new Sys.CancelEventArgs(); + + var divElem = 'AlertDiv'; + var messageElem = 'AlertMessage'; + + Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); + + var CheckStatus = function(sender, args) { + + var prm = Sys.WebForms.PageRequestManager.getInstance(); + + if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { + prm.abortPostBack(); + } + else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + + args.set_cancel(true); + ActivateAlertDiv('visible', 'Still working on previous request.'); + } + else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + ActivateAlertDiv('visible', 'Processing....'); + } + } + + var ActivateAlertDiv = function(visString, msg) { + var adiv = $get(divElem); + var aspan = $get(messageElem); + adiv.style.visibility = visString; + aspan.innerHTML = msg; } } -function ActivateAlertDiv(visString, msg) { - var adiv = $get(divElem); - var aspan = $get(messageElem); - adiv.style.visibility = visString; - aspan.innerHTML = msg; + +function Sys_CollectionChange_Tests() { + var action = Sys.NotifyCollectionChangedAction.add; + var newItems = []; + var newStartingIndex = 1; + var oldItems = []; + var oldStartingIndex = 2; + + var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); + + action = MyCChg.action; + newItems = MyCChg.newItems; + newStartingIndex = MyCChg.newStartingIndex; + oldItems = MyCChg.oldItems; + oldStartingIndex = MyCChg.oldStartingIndex; } -//#endregion -//#region Sys.CollectionChange Tests - -var action = Sys.NotifyCollectionChangedAction.add; -var newItems = []; -var newStartingIndex = 1; -var oldItems = []; -var oldStartingIndex = 2; - -var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); - -action = MyCChg.action; -newItems = MyCChg.newItems; -newStartingIndex = MyCChg.newStartingIndex; -oldItems = MyCChg.oldItems; -oldStartingIndex = MyCChg.oldStartingIndex; - -//#endregion - -//#region Sys.CommandEventArg Tests - -var commandName = "command name"; -var commandArgument = "command argument"; -var commandSource = "command source"; -var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); -var empty = argsObj.Empty; -commandName = argsObj.get_commandName(); -commandArgument = argsObj.get_commandArgument(); - -//#endregion - -//#region Sys.Component Tests - -var aComponent = new Sys.Component(); - -aComponent.add_disposing(() => { }); -aComponent.remove_disposing(() => { }); - -aComponent.add_propertyChanged(() => { }); -aComponent.remove_propertyChanged(() => { }); - -aComponent.beginUpdate(); - -aComponent.create(type, properties, events, references, element); - -aComponent.dispose(); - -aComponent.endUpdate(); - -aComponent.initialize(); - -aComponent.raisePropertyChanged("propertyName"); - -aComponent.updated(); - -//#endregion - -//#region Sys.CultureInfo Tests - -var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; -var dtfCCObject = currentCultureInfoObj.dateTimeFormat; -var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; -var dtfICObject = invariantCultureInfoObj.dateTimeFormat; - -var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); - -var format = newCulture.dateTimeFormat; -var name = newCulture.name; -var numberFormat = newCulture.numberFormat; - -//#endregion - -//#region ASP.NET Types Tests - -Type.registerNamespace("Samples"); - -var Samples; -Samples.A = function () { } -var a = Samples.A; -a.registerClass('Samples.A'); - - -Samples.B = function () { } -var b = Samples.B; -b.registerClass('Samples.B'); - -Samples.C = function () { - var c = Samples.C; - c.initializeBase(this); +function Sys_CommandEventArg_Tests() { + var commandName = "command name"; + var commandArgument = "command argument"; + var commandSource = "command source"; + var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); + var empty = argsObj.Empty; + commandName = argsObj.get_commandName(); + commandArgument = argsObj.get_commandArgument(); } -Samples.C.registerClass('Samples.C', Samples.A, Samples.B); -var isDerived; -isDerived = Samples.B.inheritsFrom(Samples.A); -// Output: "false". -alert(isDerived); +function Sys_Component_Tests() { + var aComponent = new Sys.Component(); + var properties: any; + var events: any; + var references: any; + var element: HTMLElement; + var handler: Function; + var MyControl = new Type; + + aComponent.add_disposing(() => { }); + aComponent.remove_disposing(() => { }); -isDerived = Samples.C.inheritsFrom(Samples.A); -// Output: "true". -alert(isDerived); + aComponent.add_propertyChanged(() => { }); + aComponent.remove_propertyChanged(() => { }); -var implementsInterface; -implementsInterface = Samples.C.implementsInterface(Samples.B); -// Output: "true". -alert(implementsInterface); + aComponent.beginUpdate(); -//#endregion + $create(MyControl, { id: 'c1', visible: true }, { click: handler }, null, $get('button1')); + aComponent.dispose(); + + aComponent.endUpdate(); + + aComponent.initialize(); + + aComponent.raisePropertyChanged("propertyName"); + + aComponent.updated(); +} + +function Sys_CultureInfo_Tests() { + var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; + var dtfCCObject = currentCultureInfoObj.dateTimeFormat; + var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; + var dtfICObject = invariantCultureInfoObj.dateTimeFormat; + + var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); + + var format = newCulture.dateTimeFormat; + var name = newCulture.name; + var numberFormat = newCulture.numberFormat; +} + + +function AspNetTypes_Tests() { + Type.registerNamespace("Samples"); + + + var Samples; + Samples.A = function () { }; + var a = Samples.A; + a.registerClass('Samples.A'); + + + Samples.B = function () { }; + var b = Samples.B; + b.registerClass('Samples.B'); + + Samples.C = function () { + var c = Samples.C; + c.initializeBase(this); + }; + + Samples.C.registerClass('Samples.C', Samples.A, Samples.B); + + var isDerived; + isDerived = Samples.B.inheritsFrom(Samples.A); + // Output: "false". + alert(isDerived); + + isDerived = Samples.C.inheritsFrom(Samples.A); + // Output: "true". + alert(isDerived); + + var implementsInterface; + implementsInterface = Samples.C.implementsInterface(Samples.B); + // Output: "true". + alert(implementsInterface); +} + + + +/** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ +function CreatingCustomNonVisualClientComponentsTests() { + var Demo: any; + Type.registerNamespace("Demo"); + + Demo.Timer = function () { + Demo.Timer.initializeBase(this); + + this._interval = 1000; + this._enabled = false; + this._timer = null; + } + + Demo.Timer.prototype = { + // OK to declare value types in the prototype + + + get_interval: function () { + /// Interval in milliseconds + return this._interval; + }, + set_interval: function (value) { + if (this._interval !== value) { + this._interval = value; + this.raisePropertyChanged('interval'); + + if (!this.get_isUpdating() && (this._timer !== null)) { + this._restartTimer(); + } + } + }, + + get_enabled: function () { + /// True if timer is enabled, false if disabled. + return this._enabled; + }, + set_enabled: function (value) { + if (value !== this.get_enabled()) { + this._enabled = value; + this.raisePropertyChanged('enabled'); + if (!this.get_isUpdating()) { + if (value) { + this._startTimer(); + } + else { + this._stopTimer(); + } + } + } + }, + + // events + add_tick: function (handler) { + /// Adds a event handler for the tick event. + /// The handler to add to the event. + this.get_events().addHandler("tick", handler); + }, + remove_tick: function (handler) { + /// Removes a event handler for the tick event. + /// The handler to remove from the event. + this.get_events().removeHandler("tick", handler); + }, + + dispose: function () { + // call set_enabled so the property changed event fires, for potentially attached listeners. + this.set_enabled(false); + // make sure it stopped so we aren't called after disposal + this._stopTimer(); + // be sure to call base.dispose() + Demo.Timer.callBaseMethod(this, 'dispose'); + }, + + updated: function () { + Demo.Timer.callBaseMethod(this, 'updated'); + // called after batch updates, this.beginUpdate(), this.endUpdate(). + if (this._enabled) { + this._restartTimer(); + } + }, + + _timerCallback: function () { + var handler = this.get_events().getHandler("tick"); + if (handler) { + handler(this, Sys.EventArgs.Empty); + } + }, + + _restartTimer: function () { + this._stopTimer(); + this._startTimer(); + }, + + _startTimer: function () { + // save timer cookie for removal later + this._timer = window.setInterval((Function).createDelegate(this, this._timerCallback), this._interval); + }, + + _stopTimer: function () { + if (this._timer) { + window.clearInterval(this._timer); + this._timer = null; + } + } + } + + Demo.Timer.registerClass('Demo.Timer', Sys.Component); + + // Since this script is not loaded by System.Web.Handlers.ScriptResourceHandler + // invoke Sys.Application.notifyScriptLoaded to notify ScriptManager + // that this is the end of the script. + if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); + +} \ No newline at end of file From 760f0c60e4b4a0da05347bab22b37fc0061af1db Mon Sep 17 00:00:00 2001 From: rob-alarcon Date: Mon, 19 May 2014 12:40:09 -0700 Subject: [PATCH 22/81] add file definitions for jQuery FileUpload plugin --- jquery.fileupload/jquery.fileupload-tests.ts | 43 +++++ jquery.fileupload/jquery.fileupload.d.ts | 164 +++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 jquery.fileupload/jquery.fileupload-tests.ts create mode 100644 jquery.fileupload/jquery.fileupload.d.ts diff --git a/jquery.fileupload/jquery.fileupload-tests.ts b/jquery.fileupload/jquery.fileupload-tests.ts new file mode 100644 index 000000000..fec5656d7 --- /dev/null +++ b/jquery.fileupload/jquery.fileupload-tests.ts @@ -0,0 +1,43 @@ +/// + +/* +* Handle the event of adding a file to the jQuery Upload plugin. +* +*/ +var __handleAddingFile = function (event, data) +{ + event.preventDefault(); + + // [PERFORM VALIDATION] + // If the data is valid submit the document + data.submit(); +}; + +class TestFileInput { + + // The whole body will be the container for this test + $el = $('body'); + + // Reference to the whole jQueryFileUpload object of the class + fileInput:JQueryFileUpload; + + constructor() { + + // The file upload object receives a fileInputOptions configuration object + this.fileInput = this.$el.fileupload({ + + dataType: 'json', + + // By default, each file of a selection is uploaded using an individual + // request for XHR type uploads. Set to false to upload file + // selections in one request each: + singleFileUploads: true, + // To limit the number of files uploaded with one XHR request, + // set the following option to an integer greater than 0: + limitMultiFileUploads: 1, + + add: __handleAddingFile + + }); + } +} diff --git a/jquery.fileupload/jquery.fileupload.d.ts b/jquery.fileupload/jquery.fileupload.d.ts new file mode 100644 index 000000000..6379a3e98 --- /dev/null +++ b/jquery.fileupload/jquery.fileupload.d.ts @@ -0,0 +1,164 @@ +// Type definitions for jQuery File Upload Plugin 5.40.1 +// Project: https://github.com/blueimp/jQuery-File-Upload +// Definitions by: Rob Alarcon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +// Interface options for the plugin +interface fileInputOptions { + + // The drop target element(s), by the default the complete document. + // Set to null to disable drag & drop support: + dropZone?: HTMLElement; + + // The paste target element(s), by the default the complete document. + // Set to null to disable paste support: + pasteZone?: HTMLElement; + + // The file input field(s), that are listened to for change events. + // If undefined, it is set to the file input fields inside + // of the widget element on plugin initialization. + // Set to null to disable the change listener. + fileInput?: HTMLElement; + + // By default, the file input field is replaced with a clone after + // each input field change event. This is required for iframe transport + // queues and allows change events to be fired for the same file + // selection, but can be disabled by setting the following option to false: + replaceFileInput?: boolean; + + + // The parameter name for the file form data (the request argument name). + // If undefined or empty, the name property of the file input field is + // used, or "files[]" if the file input name property is also empty, + // can be a string or an array of strings: + paramName?: any; + + // By default, each file of a selection is uploaded using an individual + // request for XHR type uploads. Set to false to upload file + // selections in one request each: + singleFileUploads?: boolean; + + // To limit the number of files uploaded with one XHR request, + // set the following option to an integer greater than 0: + limitMultiFileUploads?: number; + + // The following option limits the number of files uploaded with one + // XHR request to keep the request size under or equal to the defined + // limit in bytes: + limitMultiFileUploadSize?: number; + + // Multipart file uploads add a number of bytes to each uploaded file, + // therefore the following option adds an overhead for each file used + // in the limitMultiFileUploadSize configuration: + limitMultiFileUploadSizeOverhead?: number; + + // Set the following option to true to issue all file upload requests + // in a sequential order: + sequentialUploads?: boolean; + + // To limit the number of concurrent uploads, + // set the following option to an integer greater than 0: + limitConcurrentUploads?: number; + + // Set the following option to true to force iframe transport uploads: + forceIframeTransport?: boolean; + + // Set the following option to the location of a redirect url on the + // origin server, for cross-domain iframe transport uploads: + redirect?: string; + + // The parameter name for the redirect url, sent as part of the form + // data and set to 'redirect' if this option is empty: + redirectParamName?: string; + + // Set the following option to the location of a postMessage window, + // to enable postMessage transport uploads: + postMessage?: string; + + // By default, XHR file uploads are sent as multipart/form-data. + // The iframe transport is always using multipart/form-data. + // Set to false to enable non-multipart XHR uploads: + multipart?: boolean; + + // To upload large files in smaller chunks, set the following option + // to a preferred maximum chunk size. If set to 0, null or undefined, + // or the browser does not support the required Blob API, files will + // be uploaded as a whole. + maxChunkSize?: number; + + // When a non-multipart upload or a chunked multipart upload has been + // aborted, this option can be used to resume the upload by setting + // it to the size of the already uploaded bytes. This option is most + // useful when modifying the options object inside of the "add" or + // "send" callbacks, as the options are cloned for each file upload. + uploadedBytes?: number; + + // By default, failed (abort or error) file uploads are removed from the + // global progress calculation. Set the following option to false to + // prevent recalculating the global progress data: + recalculateProgress?: boolean; + + // Interval in milliseconds to calculate and trigger progress events: + progressInterval?: number; + + // Interval in milliseconds to calculate progress bitrate: + bitrateInterval?: number; + + // By default, uploads are started automatically when adding files: + autoUpload?: boolean; + + // Error and info messages: + messages?: any; + + // Translation function, gets the message key to be translated + // and an object with context specific data as arguments: + i18n?: any; + + // Additional form data to be sent along with the file uploads can be set + // using this option, which accepts an array of objects with name and + // value properties, a function returning such an array, a FormData + // object (for XHR file uploads), or a simple object. + // The form of the first fileInput is given as parameter to the function: + formData?: any; + + // The add callback is invoked as soon as files are added to the fileupload + // widget (via file input selection, drag & drop, paste or add API call). + // If the singleFileUploads option is enabled, this callback will be + // called once for each file in the selection for XHR file uploads, else + // once for each file selection. + // + // The upload starts when the submit method is invoked on the data parameter. + // The data object contains a files property holding the added files + // and allows you to override plugin options as well as define ajax settings. + // + // Listeners for this callback can also be bound the following way: + // .bind('fileuploadadd', func); + // + // data.submit() returns a Promise object and allows to attach additional + // handlers using jQuery's Deferred callbacks: + // data.submit().done(func).fail(func).always(func); + add?: any; + + // The plugin options are used as settings object for the ajax calls. + // The following are jQuery ajax settings required for the file uploads: + processData?: boolean; + + contentType?: string; + + cache?: boolean; + +} + +interface JQueryFileUpload { + + contentType:string; +} + +interface JQuery +{ + // Interface to the main method of jQuery File Upload + fileupload(settings: fileInputOptions): JQueryFileUpload; +} \ No newline at end of file From 93e55932f6dcdd5d71dc4af5a425cfc06fd0c0e0 Mon Sep 17 00:00:00 2001 From: rob-alarcon Date: Tue, 20 May 2014 16:30:36 -0700 Subject: [PATCH 23/81] add explicit type to tests params and add project to contributors.md --- CONTRIBUTORS.md | 1 + jquery.fileupload/jquery.fileupload-tests.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f39e1f53d..ca7d1f7f3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -140,6 +140,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix)) * [jQuery.datetimepicker](http://trentrichardson.com/examples/timepicker/) (by [Doug McDonald](https://github.com/dougajmcdonald)) * [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) +* [jQuery.Fileupload](https://github.com/blueimp/jQuery-File-Upload/) (by [Rob Alarcon](https://github.com/rob-alarcon)) * [jQuery.Finger](http://ngryman.sh/jquery.finger/) (by [Max Ackley](https://github.com/maxackley)) * [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm)) * [jQuery.form](http://malsup.com/jquery/form/) (by [François Guillot](http://fguillot.developpez.com/)) diff --git a/jquery.fileupload/jquery.fileupload-tests.ts b/jquery.fileupload/jquery.fileupload-tests.ts index fec5656d7..87149e015 100644 --- a/jquery.fileupload/jquery.fileupload-tests.ts +++ b/jquery.fileupload/jquery.fileupload-tests.ts @@ -4,7 +4,7 @@ * Handle the event of adding a file to the jQuery Upload plugin. * */ -var __handleAddingFile = function (event, data) +var __handleAddingFile = function (event:any, data:any) { event.preventDefault(); From 11a62f84e9c0a81b6f56f1e3955047d97e20e1e2 Mon Sep 17 00:00:00 2001 From: kerug Date: Wed, 21 May 2014 23:19:38 +0900 Subject: [PATCH 24/81] Updated long.d.ts --- long/long.d.ts | 139 +++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/long/long.d.ts b/long/long.d.ts index 98200e0a8..1e5d2084f 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -3,78 +3,81 @@ // Definitions by: Toshihide Hara // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface LongStatic { - new(low:number, high:number, unsigned?:boolean):Long; - - MAX_SIGNED_VALUE:Long; - MAX_UNSIGNED_VALUE:Long; - MAX_VALUE:Long; - MIN_SIGNED_VALUE:Long; - MIN_UNSIGNED_VALUE:Long; - MIN_VALUE:Long; - NEG_ONE:Long; - ONE:Long; - ZERO:Long; - - from28Bits(part0:number, part1:number, part2:number, unsigned?:boolean):Long; - fromBits(lowBits:number, highBits:number, unsigned?:boolean):Long; - fromInt(value:number, unsigned?:boolean):Long; - fromNumber(value:number, unsigned?:boolean):Long; - fromString(str:string, unsigned?:boolean, radix?:number):Long; - fromString(str:string, unsigned?:number, radix?:number):Long; - fromString(str:string, unsigned?:any, radix?:number):Long; -} - -interface Long { - high:number; - low:number; - unsigned:boolean; - - add(other:Long):Long; - and(other:Long):Long; - clone():Long; - compare(other:Long):number; - div(other:Long):Long; - equals(other:Long):boolean; - getHighBits():number; - getHighBitsUnsigned():number; - getLowBits():number; - getLowBitsUnsigned():number; - getNumBitsAbs():number; - greaterThan(other:Long):boolean; - greaterThanOrEqual(other:Long):boolean; - isEven():boolean; - isNegative():boolean; - isOdd():boolean; - isZero():boolean; - lessThan(other:Long):boolean; - lessThanOrEqual(other:Long):boolean; - modulo(other:Long):Long; - multiply(other:Long):Long; - negate():Long; - not():Long; - notEquals(other:Long):boolean; - or(other:Long):Long; - shiftLeft(numBits:number):Long; - shiftRight(numBits:number):Long; - shiftRightUnsigned(numBits:number):Long; - subtract(other:Long):Long; - toInt():number; - toNumber():number; - toSigned():Long; - toString(radix?:number):string; - toUnsigned():Long; - xor(other:Long):Long; -} - -// for browser declare module dcodeIO { - export var Long:LongStatic; + + interface LongStatic { + new(low:number, high:number, unsigned?:boolean):Long; + + MAX_SIGNED_VALUE:Long; + MAX_UNSIGNED_VALUE:Long; + MAX_VALUE:Long; + MIN_SIGNED_VALUE:Long; + MIN_UNSIGNED_VALUE:Long; + MIN_VALUE:Long; + NEG_ONE:Long; + ONE:Long; + ZERO:Long; + + from28Bits(part0:number, part1:number, part2:number, unsigned?:boolean):Long; + fromBits(lowBits:number, highBits:number, unsigned?:boolean):Long; + fromInt(value:number, unsigned?:boolean):Long; + fromNumber(value:number, unsigned?:boolean):Long; + fromString(str:string, unsigned?:boolean, radix?:number):Long; + fromString(str:string, unsigned?:number, radix?:number):Long; + fromString(str:string, unsigned?:any, radix?:number):Long; + } + + interface Long { + high:number; + low:number; + unsigned:boolean; + + add(other:Long):Long; + and(other:Long):Long; + clone():Long; + compare(other:Long):number; + div(other:Long):Long; + equals(other:Long):boolean; + getHighBits():number; + getHighBitsUnsigned():number; + getLowBits():number; + getLowBitsUnsigned():number; + getNumBitsAbs():number; + greaterThan(other:Long):boolean; + greaterThanOrEqual(other:Long):boolean; + isEven():boolean; + isNegative():boolean; + isOdd():boolean; + isZero():boolean; + lessThan(other:Long):boolean; + lessThanOrEqual(other:Long):boolean; + modulo(other:Long):Long; + multiply(other:Long):Long; + negate():Long; + not():Long; + notEquals(other:Long):boolean; + or(other:Long):Long; + shiftLeft(numBits:number):Long; + shiftRight(numBits:number):Long; + shiftRightUnsigned(numBits:number):Long; + subtract(other:Long):Long; + toInt():number; + toNumber():number; + toSigned():Long; + toString(radix?:number):string; + toUnsigned():Long; + xor(other:Long):Long; + } + + // for browser + var Long:LongStatic; +} + +interface Long extends dcodeIO.Long { } // for node, commonjs declare module "long" { + var Long:dcodeIO.LongStatic; export = Long; } - -declare var Long:LongStatic; From 8098f66b4a0fbb0dfa820169daae886b0b503fcb Mon Sep 17 00:00:00 2001 From: kerug Date: Wed, 21 May 2014 23:56:08 +0900 Subject: [PATCH 25/81] Fixed a missing export --- long/long.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/long/long.d.ts b/long/long.d.ts index 1e5d2084f..df473e9a3 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -70,7 +70,7 @@ declare module dcodeIO { } // for browser - var Long:LongStatic; + export var Long:LongStatic; } interface Long extends dcodeIO.Long { From 6c679c2a13f2f4c6b3569e1b6c6966a88721f8d4 Mon Sep 17 00:00:00 2001 From: rob-alarcon Date: Wed, 21 May 2014 11:56:22 -0700 Subject: [PATCH 26/81] Rename the JQueryFileInputOptions configuration object --- jquery.fileupload/jquery.fileupload.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.fileupload/jquery.fileupload.d.ts b/jquery.fileupload/jquery.fileupload.d.ts index 6379a3e98..0ac8b98f9 100644 --- a/jquery.fileupload/jquery.fileupload.d.ts +++ b/jquery.fileupload/jquery.fileupload.d.ts @@ -7,7 +7,7 @@ // Interface options for the plugin -interface fileInputOptions { +interface JQueryFileInputOptions { // The drop target element(s), by the default the complete document. // Set to null to disable drag & drop support: @@ -160,5 +160,5 @@ interface JQueryFileUpload { interface JQuery { // Interface to the main method of jQuery File Upload - fileupload(settings: fileInputOptions): JQueryFileUpload; + fileupload(settings: JQueryFileInputOptions): JQueryFileUpload; } \ No newline at end of file From 1c50915a7928eeef09d4914db22a997aaf9bf2fc Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Thu, 22 May 2014 11:49:28 +0200 Subject: [PATCH 27/81] Fixed stringTokenize return type The util function stringTokenize returns an string array according to the knockout source --- knockout/knockout.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 7f8451ac5..9c4e02bd8 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -274,7 +274,7 @@ interface KnockoutUtils { stringTrim(str: string): string; - stringTokenize(str: string, delimiter: string): string; + stringTokenize(str: string, delimiter: string): string[]; stringStartsWith(str: string, startsWith: string): string; From 2dae63556a766f9a3c1c7fb8bbb7781368be97fd Mon Sep 17 00:00:00 2001 From: kerug Date: Thu, 22 May 2014 21:05:24 +0900 Subject: [PATCH 28/81] Fixed interface --- long/long-tests.ts | 2 +- long/long.d.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/long/long-tests.ts b/long/long-tests.ts index 6679a820a..c1a05f576 100644 --- a/long/long-tests.ts +++ b/long/long-tests.ts @@ -5,7 +5,7 @@ import Long = require("long"); // --- browser --- //var Long = dcodeIO.Long; -var val:Long; +var val:dcodeIO.Long; var n:number; var b:boolean; var s:string; diff --git a/long/long.d.ts b/long/long.d.ts index df473e9a3..3d6554017 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -73,9 +73,6 @@ declare module dcodeIO { export var Long:LongStatic; } -interface Long extends dcodeIO.Long { -} - // for node, commonjs declare module "long" { var Long:dcodeIO.LongStatic; From 2cce02bc828458775c86bf7845e6a7dfca3f3df2 Mon Sep 17 00:00:00 2001 From: Audrey Date: Thu, 22 May 2014 11:51:11 -0400 Subject: [PATCH 29/81] Update signature of call target for selection.call Per https://github.com/mbostock/d3/wiki/Selections#call --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index f6f3f9d04..2225db5fc 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -767,7 +767,7 @@ declare module D3 { //(filter: string): UpdateSelection; }; - call(callback: (selection: Selection) => void ): Selection; + call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection; each(eachFunction: (data: any, index: number) => any): Selection; on: { (type: string): (data: any, index: number) => any; From 5ad3449648b5268c4f5300b77e71fd9119067779 Mon Sep 17 00:00:00 2001 From: AdvancedREI Date: Thu, 22 May 2014 10:44:17 -0700 Subject: [PATCH 30/81] Auth0: Other UserProfile definitions, etc. Also includes a couple browser window extensions necessary for interacting with the API. --- auth0/auth0.d.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/auth0/auth0.d.ts b/auth0/auth0.d.ts index e4b114b6f..02b8e0196 100644 --- a/auth0/auth0.d.ts +++ b/auth0/auth0.d.ts @@ -3,6 +3,16 @@ // Definitions by: Robert McLaws // Definitions: https://github.com/borisyankov/DefinitelyTyped +/** Extensions to the browser Window object. */ +interface Window { + /** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */ + token: string; +} + +interface Location { + origin: string; +} + /** This is the interface for the main Auth0 client. */ interface Auth0Static { @@ -47,7 +57,23 @@ interface Auth0UserProfile { identities: Auth0Identity[]; } -/** Represents */ +/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */ +interface MicrosoftUserProfile extends Auth0UserProfile { + emails: string[]; +} + +/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */ +interface Office365UserProfile extends Auth0UserProfile { + tenantid: string; + upn: string; +} + +/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */ +interface AdfsUserProfile extends Auth0UserProfile { + issuer: string; +} + +/** Represents multiple identities assigned to a user. */ interface Auth0Identity { access_token: string; connection: string; From 9515c65ee32b9b81b65b75915bce33188c088976 Mon Sep 17 00:00:00 2001 From: pspi Date: Fri, 23 May 2014 12:34:07 +0300 Subject: [PATCH 31/81] Add protractor button text locators. --- angular-protractor/angular-protractor-tests.ts | 2 ++ angular-protractor/angular-protractor.d.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts index 2ed627af8..37c9e49bc 100644 --- a/angular-protractor/angular-protractor-tests.ts +++ b/angular-protractor/angular-protractor-tests.ts @@ -223,6 +223,8 @@ function TestLocatorStrategies() { webElement = ptor.findElement(protractor.By.model('model')); webElement = ptor.findElement(protractor.By.textarea('textarea')); webElement = ptor.findElement(protractor.By.repeater('repeater')); + webElement = ptor.findElement(protractor.By.buttonText('buttonText')); + webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText')); } // This function tests the methods that were added to the base WebElement class diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index a78fc42f3..3c3c0981f 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -646,6 +646,10 @@ declare module protractor { * var rows = element(by.repeater("cat in pets")); */ repeater(repeatDescriptor: string): webdriver.Locator; + + buttonText(searchText: string): webdriver.Locator; + + partialButtonText(searchText: string): webdriver.Locator; } var By: IProtractorLocatorStrategy; From dd5499cc0d0f08736d434df6be47791516fb1c5a Mon Sep 17 00:00:00 2001 From: basarat Date: Fri, 23 May 2014 20:08:56 +1000 Subject: [PATCH 32/81] feat(nodejs) added stronger typing for http status codes --- node/node-tests.ts | 10 ++++++++++ node/node.d.ts | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index 51edd42a7..c36f0da1e 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -100,3 +100,13 @@ var request = http.request('http://0.0.0.0'); request.once('error', function () {}); request.setNoDelay(true); request.abort(); + +//////////////////////////////////////////////////// +/// Http tests : http://nodejs.org/api/http.html +//////////////////////////////////////////////////// +module http_tests { + // Status codes + var code = 100; + var codeMessage = http.STATUS_CODES['400']; + var codeMessage = http.STATUS_CODES[400]; +} \ No newline at end of file diff --git a/node/node.d.ts b/node/node.d.ts index 2bd63497d..5f169c8c8 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -348,7 +348,10 @@ declare module "http" { } export interface Agent { maxSockets: number; sockets: any; requests: any; } - export var STATUS_CODES: any; + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server; export function createClient(port?: number, host?: string): any; export function request(options: any, callback?: Function): ClientRequest; From 9e30ccf2e5f6cf69ade2537ff9033e8751ab0099 Mon Sep 17 00:00:00 2001 From: Jeremy Bell Date: Fri, 23 May 2014 17:47:07 -0400 Subject: [PATCH 33/81] Added overload to angular.mock.inject function to allow array-style dependency injection, which the function supports. Added test excercising the overload. --- angularjs/angular-mocks-tests.ts | 9 +++++++++ angularjs/angular-mocks.d.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts index b43580f36..b94c58f9e 100644 --- a/angularjs/angular-mocks-tests.ts +++ b/angularjs/angular-mocks-tests.ts @@ -21,6 +21,15 @@ mock.inject( function () { return 2; } ); +mock.inject( + ['$rootScope', function ($rootScope) { return 1; }]); + +// This overload is not documented on the website, but flows from +// how the injector works. +mock.inject( + ['$rootScope', function ($rootScope) { return 1; }], + ['$rootScope', function ($rootScope) { return 2; }]); + mock.module('module1', 'module2'); mock.module( function () { return 1; }, diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index a607422dd..34b534a5e 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -30,6 +30,7 @@ declare module ng { // see http://docs.angularjs.org/api/angular.mock.inject inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works // see http://docs.angularjs.org/api/angular.mock.module module(...modules: string[]): any; From 479dd1442e21bb435f9faa449288a1930d04fc39 Mon Sep 17 00:00:00 2001 From: Jeremy Bell Date: Fri, 23 May 2014 17:55:24 -0400 Subject: [PATCH 34/81] fixed errors from --noImplicitAny option --- angularjs/angular-mocks-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts index b94c58f9e..64df49d8a 100644 --- a/angularjs/angular-mocks-tests.ts +++ b/angularjs/angular-mocks-tests.ts @@ -22,13 +22,13 @@ mock.inject( ); mock.inject( - ['$rootScope', function ($rootScope) { return 1; }]); + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]); // This overload is not documented on the website, but flows from // how the injector works. mock.inject( - ['$rootScope', function ($rootScope) { return 1; }], - ['$rootScope', function ($rootScope) { return 2; }]); + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }], + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]); mock.module('module1', 'module2'); mock.module( From f715b480369008c3d41b6ac0e255b0cfabebdd92 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 17:13:34 +0100 Subject: [PATCH 35/81] Further definitions have been added Removed some whitespaces added code formatting. Adding definitions to Sys.UI namespace. Added Sys.UI.Key test. --- microsoft-ajax/microsoft.ajax-tests.ts | 20 +-- microsoft-ajax/microsoft.ajax.d.ts | 221 ++++++++++++++++++++++--- 2 files changed, 209 insertions(+), 32 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 9e54d0c14..532c9c11c 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -45,7 +45,6 @@ function BaseClassExtensions_Function_Tests() { }; } - function Sys_Application_Tests() { var component = new Sys.Component(); @@ -99,7 +98,6 @@ function Sys_Application_Tests() { Sys.Application.get_isDisposing(); } - function Sys_Application_LoadEventArgs_Tests() { var a = new Sys.ApplicationLoadEventArgs(new Array(), true); @@ -107,13 +105,10 @@ function Sys_Application_LoadEventArgs_Tests() { var isPartialReload = a.get_isPartialLoad(); } - function Sys_Browser_Tests() { var browser = Sys.Browser(); } - - function Sys_CancelEventArgs_Tests() { var args = new Sys.CancelEventArgs(); @@ -148,7 +143,6 @@ function Sys_CancelEventArgs_Tests() { } } - function Sys_CollectionChange_Tests() { var action = Sys.NotifyCollectionChangedAction.add; var newItems = []; @@ -165,7 +159,6 @@ function Sys_CollectionChange_Tests() { oldStartingIndex = MyCChg.oldStartingIndex; } - function Sys_CommandEventArg_Tests() { var commandName = "command name"; var commandArgument = "command argument"; @@ -176,7 +169,6 @@ function Sys_CommandEventArg_Tests() { commandArgument = argsObj.get_commandArgument(); } - function Sys_Component_Tests() { var aComponent = new Sys.Component(); var properties: any; @@ -207,6 +199,15 @@ function Sys_Component_Tests() { aComponent.updated(); } +function Sys_UI_Key_Tests() { + + var a = Sys.UI.Key.backspace; + + var b = Sys.UI.Key.del; + + var c = Sys.UI.Key.down; +} + function Sys_CultureInfo_Tests() { var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; var dtfCCObject = currentCultureInfoObj.dateTimeFormat; @@ -220,7 +221,6 @@ function Sys_CultureInfo_Tests() { var numberFormat = newCulture.numberFormat; } - function AspNetTypes_Tests() { Type.registerNamespace("Samples"); @@ -257,8 +257,6 @@ function AspNetTypes_Tests() { alert(implementsInterface); } - - /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { var Demo: any; diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index be05be47d..1c877abae 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2298,20 +2298,17 @@ declare module Sys { * @return The DOM element that the current Behavior object is associated with. */ get_element(): Sys.UI.DomElement; - /** * Gets or sets the identifier for the Sys.UI.Behavior object. * A generated identifier that consists of the ID of the associated Sys.UI.DomElement, the "$" character, and the name value of the Behavior object. */ get_id(): string; - /** * Gets or sets the identifier for the Sys.UI.Behavior object. * @param value * The string value to use as the identifier. */ set_id(value: string): void; - /* * Gets or sets the name of the Sys.UI.Behavior object. * If you do not explicitly set the name property, getting the property value sets it to its default value, which is equal to the type of the Behavior object. The name property remains null until it is accessed. @@ -2319,7 +2316,6 @@ declare module Sys { * A string value to use as the name. */ set_name(value: string): void; - /** * Gets or sets the name of the Sys.UI.Behavior object. */ @@ -2350,19 +2346,16 @@ declare module Sys { * @return A number that represents the height of an object in pixels. */ height: number; - /** * Gets the width of an object in pixels. This property is read-only. * @return A number that represents the width of an object in pixels. */ width: number; - /** * Gets the x-coordinate of an object in pixels. * @return A number that represents the x-coordinate of an object in pixels. */ x: number; - /** * Gets the y-coordinate of anobject in pixels. * @return A number that represents the y-coordinate of an object in pixels. @@ -2386,15 +2379,209 @@ declare module Sys { } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310935(v=vs.100).aspx} */ class DomEvent { + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.DomEvent class and associates it with the specified DomElement object. + * @param domElement + * The DomElement object to associate with the event. + */ + constructor(domElement: DomElement); + constructor(domElement: any); + + //#endregion + + //#region Methods + + /** + * Provides a method to add a DOM event handler to the DOM element that exposes the event. This member is static and can be invoked without creating an instance of the class. + * Use the addHandler method to add a DOM event handler to the element that exposes the event. The eventName parameter should not include the "on" prefix. For example, specify "click" instead of "onclick". + * This method can be accessed through the $addHandler shortcut method. + * + * @param element + * The element that exposes the event. + * @param eventName + * The name of the event. + * @param handler + * The client function that is called when the event occurs. + * @param autoRemove + * (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. + */ + static addHandler(element: any, eventName: string, handler: Function, autoRemove?: boolean): void; + /** + * Adds a list of DOM event handlers to the DOM element that exposes the events. This member is static and can be invoked without creating an instance of the class. + * Use the addHandlers method to add a list of DOM event handlers to the element that exposes the event. + * The events parameter takes a comma-separated list of name/value pairs in the format name:value, where name is the name of the DOM event and value is the name of the handler function. + * If there is more than one name/value pair, the list must be enclosed in braces ({}) to identify it as a single parameter. Multiple name/value pairs are separated with commas. + * Event names should not include the "on" prefix. For example, specify "click" instead of "onclick". + * If handlerOwner is specified, delegates are created for each handler. These delegates are attached to the specified object instance, and the this pointer from the delegate handler will refer to the handlerOwner object. + * This method can be accessed through the $addHandlers shortcut method. + * + * @param element + * The DOM element that exposes the events. + * @param events + * A dictionary of event handlers. + * @param handlerOwner + * (Optional) The object instance that is the context for the delegates that should be created from the handlers. + * @param autoRemove + * (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. + * + * @throws Error.invalidOperation - (Debug) One of the handlers specified in events is not a function. + * + */ + static addHandlers(element: any, events: any, handlerOwner?: any, autoRemove?: boolean): void; + /** + * Removes all DOM event handlers from a DOM element that were added through the Sys.UI.DomEvent addHandler or the Sys.UI.DomEvent addHandlers methods. + * This member is static and can be invoked without creating an instance of the class. + * This method can be accessed through the $clearHandlers shortcut method. + * + * @param element + * The element that exposes the events. + */ + static clearHandlers(element: any): void; + /** + * Removes a DOM event handler from the DOM element that exposes the event. This member is static and can be invoked without creating an instance of the class. + * + * @param element + * The element that exposes the event. + * @param eventName + * The name of the event. + * @param handler + * The event handler to remove. + */ + static removeHandler(element: any, eventName: string, handler: Function): void; + /** + * Prevents the default DOM event action from happening. + * Use the preventDefault method to prevent the default event action for the browser from occurring. + * For example, if you prevent the keydown event of an input element from occurring, the character typed by the user is not automatically appended to the input element's value. + */ + preventDefault(): void; + /** + * Prevents an event from being propagated (bubbled) to parent elements. + * By default, event notification is bubbled from a child object to parent objects until it reaches the document object. + * The event notification stops if the event is handled during the propagation process. + * Use the stopPropagation method to prevent an event from being propagated to parent elements. + */ + stopPropagation(): void; + + //#endregion + + //#region Fields + + /** + * Gets a Boolean value that indicates the state of the ALT key when the associated event occurred. + * Use the altKey field to determine whether the ALT key is pressed when the event occurred. + * + * @return true if the ALT key was pressed when the event occurred; otherwise, false. + */ + altKey: boolean; + /** + * Gets a Sys.UI.MouseButton enumeration value that indicates the button state of the mouse when the related event occurred. + * Use the button field to determine which mouse button was pressed when the related event occurred. + * @return A MouseButton value + */ + button: Sys.UI.MouseButton; + /** + * Gets the character code of the key that raised the associated keyPress event. + * Use the charCode field to get the character code of a pressed key or key combination that raised a keyPress event. + * The keyPress event provides a single character code that identifies key combinations. + * The keyPress event is not raised for single modifier keys such as ALT, CTRL, and SHIFT. + * + * @return An integer value that represents the character code of the key or key combination that was pressed to raise the keyPress event. + */ + charCode: number; + /** + * + */ + clientX: any; // todo + + clientY: any; // todo + + ctrlKey: any; // todo + + keyCode: any; // todo + + offsetX: any; // todo + + offsetY: any; // todo + + screenX: any; // todo + + screenY: any; // todo + + shiftKey: any; // todo + + target: any; // todo + + type: any; // todo + + //#endregion } /** * Describes key codes. + * The values correspond to values in the Document Object Model (DOM). */ enum Key { - + /** + * Represents the BACKSPACE key. + */ + backspace, + /* + * Represents the TAB key. + */ + tab, + /** + * Represents the ENTER key. + */ + enter, + /** + * Represents the ESC key. + */ + esc, + /* + * Represents the SPACEBAR key. + */ + space, + /** + * Represents the PAGE UP key. + */ + pageUp, + /** + * Represents the PAGE DOWN key. + */ + pageDown, + /** + * Represents the END key. + */ + end, + /** + * Represents the HOME key. + */ + home, + /** + * Represents the LEFT ARROW key. + */ + left, + /** + * Represents the UP ARROW key. + */ + up, + /** + * Represents the RIGHT ARROW key. + */ + right, + /** + * Represents the DOWN ARROW key. + */ + down, + /** + * Represents DELETE key. + */ + del } /** * Describes mouse button locations. @@ -2455,13 +2642,11 @@ declare module Sys { * @return An HTML DOM element. */ get_postBackElement(): HTMLElement; - /** * Gets the request object that represents the current postback. * @return An instance of the Sys.Net.WebRequest class. */ get_request(): Sys.Net.WebRequest; - /** * Gets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. * Server-side processing might update additional UpdatePanel controls. @@ -2501,20 +2686,17 @@ declare module Sys { * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. */ get_dataItems(): any; - /** * Gets the Error object. * @return A base ECMAScript (JavaScript) Error object. */ get_error(): Error; - /** * Get or sets a value that indicates whether the error has been handled. * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. * @return true if the error has been handled; otherwise false. */ get_errorHandled(): boolean; - /** * Get or sets a value that indicates whether the error has been handled. * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. @@ -2522,12 +2704,11 @@ declare module Sys { * true or false. */ set_errorHandled(value: boolean): void; - /** * Gets a response object that is represented by the Sys.Net.WebRequestExecutor class. * @return A response object that is represented by the WebRequestExecutor class. */ - get_response(): any; // todo + get_response(): Sys.Net.WebRequestExecutor; //#endregion } @@ -2649,7 +2830,6 @@ declare module Sys { * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. */ get_dataItems(): any; - /** * Gets an array of HTML
elements that represent UpdatePanel controls that will be deleted from the DOM as a result of the current asynchronous postback. * If the contents of an UpdatePanel control will be deleted as the result of a partial-page update, the array that is referenced in the panelsDeleting property of the PageLoadingEventArgs class contains a reference to the corresponding
element. @@ -2657,7 +2837,6 @@ declare module Sys { * @return An array of
elements that will be deleted from the DOM. If no elements will be deleted, the property returns null. */ get_panelsDeleted(): HTMLDivElement[]; - /** * Gets an array of HTML
elements that represent UpdatePanel controls that will be updated in the DOM as a result of the current asynchronous postback. * If the contents of any UpdatePanel controls will be updated as the result of a partial-page update, the panelsUpdating property contains an array that references the corresponding
elements. @@ -2672,6 +2851,7 @@ declare module Sys { /** * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311028(v=vs.100).aspx} */ class PageRequestManager extends EventArgs { @@ -2803,7 +2983,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} */ class PageRequestManagerParserErrorException { - + // Nothing to define } /** @@ -2814,7 +2994,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * */ class PageRequestManagerServerErrorException { - + // Nothing to define } /** @@ -2825,12 +3005,11 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} */ class PageRequestManagerTimeoutException { - + // Nothing to define } //#endregion - } //#endregion From d9bfaa5a619ed14498212d2ec1a4225ce583d9a2 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 17:18:12 +0100 Subject: [PATCH 36/81] Updated contributors with Microsoft Ajax Added Project Name, Project URL, Typed definitions author name and Github link. --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f39e1f53d..6cc50e14f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -206,6 +206,7 @@ All definitions files include a header with the author and editors, so at some p * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Ajax](http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx) (by [Patrick Magee](https://github.com/pjmagee)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame)) * [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) From cfa54ee0ae46621a7e95476df102f2f3957cb1e7 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:11:02 +0100 Subject: [PATCH 37/81] Moved ECMAScript Extensions Moved extensions into a new declared module MicrosoftAjaxBaseTypeExtensions which can be used to cast between the real and declared type because lib.d.ts already has these types defined and cannot easily extend them. --- microsoft-ajax/microsoft.ajax.d.ts | 641 +++++++++++++++++------------ 1 file changed, 371 insertions(+), 270 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1c877abae..1ccef3aaa 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,263 +13,8 @@ //#region JavaScript Base Type Extensions -/** -* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. -* Array Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} -*/ -interface ArrayStatic { - - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; - - /** - * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. - * @param array - * The array to add the item to. - * @param item - * - */ - add(array: any[], element: any): void; - /** - * Copies all the elements of the specified array to the end of an Array object. - */ - addRange(array: any, items: any): void; - /** - * Removes all elements from an Array object. - */ - clear(): void; - /** - * Creates a shallow copy of an Array object. - */ - clone(): any[]; - /** - * Determines whether an element is in an Array object. - */ - contains(element: any): boolean; - /** - * Removes the first element from an Array object. - */ - dequeue(): any; - /** - * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. - */ - enqueue(element: any): void; - /** - * Performs a specified action on each element of an Array object. - */ - forEach(array: any[], method: Function, instance: any[]): void; - /** - * Searches for the specified element of an Array object and returns its index. - */ - indexOf(array: any[], item: any, startIndex?: number): number; - /** - * Inserts a value at the specified location in an Array object. - */ - insert(array: any[], index: number, item: any); - /** - * Creates an Array object from a string representation. - */ - parse(value: string): any[]; - /** - * Removes the first occurrence of an element in an Array object. - */ - remove(array: any[], item: any): boolean; - /** - * Removes an element at the specified location in an Array object. - */ - removeAt(array: any[], index: number): void; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) Boolean object. -* Boolean Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} -*/ -interface Boolean { - /** - * Converts a string representation of a logical value to its Boolean object equivalent. - */ - parse(value: string): boolean; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) Date object. -* Date Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} -*/ -interface Date { - /** - * Formats a date by using the invariant (culture-independent) culture. - */ - format(value: string): string; - /** - * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. - */ - localeFormat(value: string): string; - /** - * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. - * @exception (Debug) formats contains an invalid format. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseLocale(value: string): string; - parseLocale(value: string, formats?: string[]): string; - parseLocale(value: string, ...formats: string[]): string; - /** - * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. - * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseInvariant(value: string): string; - parseInvariant(value: string, formats?: string[]): string; - parseInvariant(value: string, ...formats: string[]): string; -} - -/** -* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). -* Error Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} -*/ -interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; -} - -/** -* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. -* Number Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} -*/ -interface Number { - /** - * Formats a number by using the invariant culture. - */ - format(format: string): string; - /** - * Formats a number by using the current culture. - */ - localeFormat(format: string): string; - /** - * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. - */ - parseInvariant(format: string): number; - /** - * Creates a numeric value from a locale-specific string. - */ - parseLocale(format: string): number; -} - -/** -* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. -* Object Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} -*/ -interface Object { - /** - * Formats a number by using the invariant culture. - */ - getType(instance: any): Type; - /** - * Returns a string that identifies the run-time type name of an object. - */ - getTypeName(instance: any): string; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. -* String Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} -*/ -interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; -} - -//#endregion - declare module MicrosoftAjaxBaseTypeExtensions { + /** * Provides static functions that extend the built-in ECMAScript (JavaScript) Function type by including exception * details and support for application-compilation modes (debug or release). @@ -307,8 +52,265 @@ declare module MicrosoftAjaxBaseTypeExtensions { */ validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; } + + /** + * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. + * Object Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} + */ + interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ + interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; + } + + /** + * Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. + * Number Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} + */ + interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; + } + + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). + * Error Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} + */ + interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Date object. + * Date Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} + */ + interface Date { + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. + * Array Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} + */ + interface Array { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + + /** + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * + */ + add(array: any[], element: any): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: any, items: any): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): any[]; + /** + * Determines whether an element is in an Array object. + */ + contains(element: any): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): any; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: any): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: any[], method: Function, instance: any[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: any[], item: any, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: any[], index: number, item: any); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: any[], item: any): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: any[], index: number): void; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Boolean object. + * Boolean Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} + */ + interface Boolean { + /** + * Converts a string representation of a logical value to its Boolean object equivalent. + */ + parse(value: string): boolean; + } + } +//#endregion + //#region ASP.NET Types /** @@ -2260,6 +2262,7 @@ declare module Sys { /** * Provides a base class for all ASP.NET AJAX client behaviors. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311020(v=vs.100).aspx} */ class Behavior extends Sys.Component { @@ -2370,12 +2373,90 @@ declare module Sys { */ class Control extends Sys.Component { + //#region Constructors + + /** + * When called from a derived class, initializes a new instance of that class. + * The Control constructor is a complete constructor function. However, because the Control class is an abstract base class, the constructor should be called only from derived classes. + * @param element + * The Sys.UI.DomElement object that the control will be associated with. + * + * @throws Error.invalidOperation Function + */ + constructor(element: Sys.UI.DomElement); + + //#endregion + + //#region Methods + + /** + * Adds a CSS class to the HTML Document Object Model (DOM) element that the control is attached to. + * Use the addCssClass method to add a CSS class to a control. If the CSS class has already been added to the control, addCssClass makes no changes to the control. + * @param className + * A string that contains the name of the CSS class to add. + */ + addCssClass(className: string): void; + /** + * Removes the current control from the application. + * The dispose method releases all resources from the Sys.UI.Control object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. + */ + dispose(): void; + /** + * Initializes the current Sys.UI.Control object. + * The initialize method initializes the control and sets the base Sys.Component.isInitialized property to true. You can override this method to include additional initialization logic for your derived class. + */ + initialize(): void; + /** + * Called when an event is raised by the raiseBubbleEvent method. + * + * The onBubbleEvent method returns false to make sure that unhandled events propagate (bubble) to the parent control. + * In derived classes, you should override the onBubbleEvent method and return true when events are handled to prevent the events from bubbling further. + * For an explanation of bubbling, see Sys.UI.Control raiseBubbleEvent Method. + * + * @param source + * The object that triggered the event. + * @param args + * The event arguments. + * @return + * false in all cases. + */ + onBubbleEvent(source: any, args: any): boolean; + /** + * Calls the onBubbleEvent method of the parent control. + * + * When the raiseBubbleEvent method is called, the source object and args values are sent to the onBubbleEvent handler of the current control. + * If onBubbleEvent returns false, they are sent to the onBubbleEvent handler of the parent control. + * This process continues until an onBubbleEvent event handler returns true, which indicates that the event has been handled. + * Any event that bubbles to the Sys.Application instance without being handled is ignored. + * + * @param source + * The object that triggered the event. + * @param args + * The event arguments. + */ + raiseBubbleEvent(source: any, args: any): void; + /** + * Removes a CSS class from the HTML Document Object Model (DOM) element that the control is attached to. + * Use the removeCssClass method to remove a CSS class from a control. If the CSS class has already been removed from the control, removeCssClass makes no changes to the control. + * + * @param className + * A string that contains the name of the CSS class to remove. + */ + removeCssClass(className: string): void; + /** + * Toggles a CSS class of the HTML Document Object Model (DOM) element that the control is attached to. + * @param className + * A string that contains the name of the CSS class to toggle. + */ + toggleCssClass(className: string): void; + + //#endregion } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. */ class DomElement { - + // todo } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. @@ -2498,25 +2579,45 @@ declare module Sys { * */ clientX: any; // todo - + /** + * + */ clientY: any; // todo - + /** + * + */ ctrlKey: any; // todo - + /** + * + */ keyCode: any; // todo - + /** + * + */ offsetX: any; // todo - + /** + * + */ offsetY: any; // todo - + /** + * + */ screenX: any; // todo - + /** + * + */ screenY: any; // todo - + /** + * + */ shiftKey: any; // todo - + /** + * + */ target: any; // todo - + /** + * + */ type: any; // todo //#endregion @@ -2587,19 +2688,19 @@ declare module Sys { * Describes mouse button locations. */ enum MouseButton { - + // todo } /** * Creates an object that contains a set of integer coordinates that represent a position. */ class Point { - + // todo } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. */ enum VisibilityMode { - + // todo } } From f1dabc3be25e85c158e353578263affa11a86136 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:11:29 +0100 Subject: [PATCH 38/81] Added further tests and cleaned up tests. --- microsoft-ajax/microsoft.ajax-tests.ts | 55 ++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 532c9c11c..958ada9f9 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -8,11 +8,24 @@ function GlobalNamespace_Tests() { var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + // Get + $get("Button1"); + $get("Button1", $get("Button2")); + + // Add handler $addHandler($get("Button1"), "click", () => { }); $addHandlers($get("Button1"), {}); + + // Remove handler $removeHandler($get("Button1"), "click", () => { }); + + // Find $find('MyComponent'); $find('MyComponent', $find('#test')); + + // Clear + $clearHandlers($get("Button1")); + } function BaseClassExtensions_Function_Tests() { @@ -99,6 +112,7 @@ function Sys_Application_Tests() { } function Sys_Application_LoadEventArgs_Tests() { + var a = new Sys.ApplicationLoadEventArgs(new Array(), true); var components = a.get_components(); @@ -106,7 +120,9 @@ function Sys_Application_LoadEventArgs_Tests() { } function Sys_Browser_Tests() { + var browser = Sys.Browser(); + } function Sys_CancelEventArgs_Tests() { @@ -144,6 +160,7 @@ function Sys_CancelEventArgs_Tests() { } function Sys_CollectionChange_Tests() { + var action = Sys.NotifyCollectionChangedAction.add; var newItems = []; var newStartingIndex = 1; @@ -160,6 +177,7 @@ function Sys_CollectionChange_Tests() { } function Sys_CommandEventArg_Tests() { + var commandName = "command name"; var commandArgument = "command argument"; var commandSource = "command source"; @@ -170,6 +188,7 @@ function Sys_CommandEventArg_Tests() { } function Sys_Component_Tests() { + var aComponent = new Sys.Component(); var properties: any; var events: any; @@ -200,15 +219,43 @@ function Sys_Component_Tests() { } function Sys_UI_Key_Tests() { - - var a = Sys.UI.Key.backspace; - var b = Sys.UI.Key.del; + var backspace = Sys.UI.Key.backspace; + var del = Sys.UI.Key.del; + var down = Sys.UI.Key.down; + var end = Sys.UI.Key.end; + var pageDown = Sys.UI.Key.pageDown; + var pageUp = Sys.UI.Key.pageUp; + var home = Sys.UI.Key.home; + var enter = Sys.UI.Key.enter; + var esc = Sys.UI.Key.esc; + var tab = Sys.UI.Key.tab; + var key = Sys.UI.Key.up; + var left = Sys.UI.Key.left; + var right = Sys.UI.Key.right; + var space = Sys.UI.Key.space; - var c = Sys.UI.Key.down; +} + +function Sys_UI_Control_Tests() { + + var domElementObj; + var className = "class Name"; + + var a = new Sys.UI.Control(domElementObj); + + a.addCssClass(className); + a.toggleCssClass(className); + a.removeCssClass(className); + + a.initialize(); + a.raiseBubbleEvent(domElementObj, className); + a.onBubbleEvent(domElementObj, className); + a.dispose(); } function Sys_CultureInfo_Tests() { + var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; var dtfCCObject = currentCultureInfoObj.dateTimeFormat; var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; From 3e1b41f4c375dbc3501b164330a6229ca6567b32 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:49:26 +0100 Subject: [PATCH 39/81] Further Base Type Extension tests Realised i put all the base extensions into the declared module of BaseClassExtensions but shouldn't have. Added boolean to BaseClassExtensions to test Parse method. --- microsoft-ajax/microsoft.ajax-tests.ts | 44 +++ microsoft-ajax/microsoft.ajax.d.ts | 495 +++++++++++++------------ 2 files changed, 295 insertions(+), 244 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 958ada9f9..eadd53e37 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -57,6 +57,50 @@ function BaseClassExtensions_Function_Tests() { } }; } + +function BaseClassExtensions_Array_Tests() { + + var arrayVar = Array("one", "two", "three"); + + arrayVar.add(["one"], {}); + arrayVar.addRange({}, ["one", "two", "three"]); + arrayVar.clear(); + arrayVar.clone(); + arrayVar.contains({}); + arrayVar.dequeue(); + arrayVar.enqueue({}); + arrayVar.insert([1, 2, 3], 1, {}); + arrayVar.isArray({}); + arrayVar.parse("1, 2, 3, 4, 5"); + arrayVar.remove([1, 2, 3], 2); + arrayVar.removeAt([1, 2, 3], 1); + +} + +function BaseClassExtensions_Date_Tests() { + + var date = new Date(2014, 5, 25); + date.format("g"); + date.localeFormat("g"); + date.parseLocale("2014/05/25"); + date.parseInvariant("2014/05/25"); +} + +function BaseClassExtensions_Boolean_Tests() { + + (Boolean).parse("false"); + +} + +function BaseClassExtensions_Number_Tests() { + + var x: number = 5; + + x.format("d"); + x.localeFormat("c"); + x.parseInvariant("1"); + x.parseLocale("1"); +} function Sys_Application_Tests() { diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1ccef3aaa..89803db41 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,6 +13,251 @@ //#region JavaScript Base Type Extensions + +/** +* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. +* Object Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} +*/ +interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. +* Array Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} +*/ +interface Array { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + + /** + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * + */ + add(array: any[], element: any): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: any, items: any): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): any[]; + /** + * Determines whether an element is in an Array object. + */ + contains(element: any): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): any; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: any): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: any[], method: Function, instance: any[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: any[], item: any, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: any[], index: number, item: any); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: any[], item: any): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: any[], index: number): void; +} + +/** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ +interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; +} + +/** +* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. +* Number Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} +*/ +interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; +} + +/** +* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). +* Error Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} +*/ +interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Date object. +* Date Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} +*/ +interface Date { + + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; +} + + declare module MicrosoftAjaxBaseTypeExtensions { /** @@ -53,260 +298,22 @@ declare module MicrosoftAjaxBaseTypeExtensions { validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; } - /** - * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. - * Object Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} - */ - interface Object { - /** - * Formats a number by using the invariant culture. - */ - getType(instance: any): Type; - /** - * Returns a string that identifies the run-time type name of an object. - */ - getTypeName(instance: any): string; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. - * String Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} - */ - interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; - } - - /** - * Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. - * Number Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} - */ - interface Number { - /** - * Formats a number by using the invariant culture. - */ - format(format: string): string; - /** - * Formats a number by using the current culture. - */ - localeFormat(format: string): string; - /** - * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. - */ - parseInvariant(format: string): number; - /** - * Creates a numeric value from a locale-specific string. - */ - parseLocale(format: string): number; - } - - /** - * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). - * Error Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} - */ - interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) Date object. - * Date Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} - */ - interface Date { - /** - * Formats a date by using the invariant (culture-independent) culture. - */ - format(value: string): string; - /** - * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. - */ - localeFormat(value: string): string; - /** - * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. - * @exception (Debug) formats contains an invalid format. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseLocale(value: string): string; - parseLocale(value: string, formats?: string[]): string; - parseLocale(value: string, ...formats: string[]): string; - /** - * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. - * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseInvariant(value: string): string; - parseInvariant(value: string, formats?: string[]): string; - parseInvariant(value: string, ...formats: string[]): string; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. - * Array Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} - */ - interface Array { - - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; - - /** - * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. - * @param array - * The array to add the item to. - * @param item - * - */ - add(array: any[], element: any): void; - /** - * Copies all the elements of the specified array to the end of an Array object. - */ - addRange(array: any, items: any): void; - /** - * Removes all elements from an Array object. - */ - clear(): void; - /** - * Creates a shallow copy of an Array object. - */ - clone(): any[]; - /** - * Determines whether an element is in an Array object. - */ - contains(element: any): boolean; - /** - * Removes the first element from an Array object. - */ - dequeue(): any; - /** - * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. - */ - enqueue(element: any): void; - /** - * Performs a specified action on each element of an Array object. - */ - forEach(array: any[], method: Function, instance: any[]): void; - /** - * Searches for the specified element of an Array object and returns its index. - */ - indexOf(array: any[], item: any, startIndex?: number): number; - /** - * Inserts a value at the specified location in an Array object. - */ - insert(array: any[], index: number, item: any); - /** - * Creates an Array object from a string representation. - */ - parse(value: string): any[]; - /** - * Removes the first occurrence of an element in an Array object. - */ - remove(array: any[], item: any): boolean; - /** - * Removes an element at the specified location in an Array object. - */ - removeAt(array: any[], index: number): void; - } - /** * Provides extensions to the base ECMAScript (JavaScript) Boolean object. * Boolean Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} */ interface Boolean { + + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; + /** * Converts a string representation of a logical value to its Boolean object equivalent. */ - parse(value: string): boolean; + parse(value: string): Boolean; } - } //#endregion From 4eb8d6a16428b6f9de9dc87517326b75f00da1a7 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:50:25 +0100 Subject: [PATCH 40/81] Spacing and formatting. --- microsoft-ajax/microsoft.ajax-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index eadd53e37..7fe7dc9fe 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -313,8 +313,8 @@ function Sys_CultureInfo_Tests() { } function AspNetTypes_Tests() { - Type.registerNamespace("Samples"); + Type.registerNamespace("Samples"); var Samples; Samples.A = function () { }; @@ -350,6 +350,7 @@ function AspNetTypes_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { + var Demo: any; Type.registerNamespace("Demo"); @@ -364,7 +365,6 @@ function CreatingCustomNonVisualClientComponentsTests() { Demo.Timer.prototype = { // OK to declare value types in the prototype - get_interval: function () { /// Interval in milliseconds return this._interval; From a73f6c8b118f7659fc34b298e6068e7e067a0354 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 19:56:10 +0100 Subject: [PATCH 41/81] Fixed issues with running npm test Identified several issues in many places both in tests and definitions. Fixed. --- microsoft-ajax/microsoft.ajax-tests.ts | 92 +++- microsoft-ajax/microsoft.ajax.d.ts | 612 +++++++++++++++++++------ 2 files changed, 560 insertions(+), 144 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 7fe7dc9fe..4a1266dab 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -28,6 +28,68 @@ function GlobalNamespace_Tests() { } +function BaseClassExtensions_Error_Tests() { + + // http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx + + function validateNumberRange(input: any, min: number, max: number) { + + // Verify the required parameters were defined. + if (input === undefined) { + // Throw a standard exception type. + var err = (Error).argumentNull("input", "A parameter was undefined."); + throw err; + } + else if (min === undefined) { + var err = (Error).argumentNull("min", "A parameter was undefined."); + throw err; + } + else if (max === undefined) { + var err = (Error).argumentNull("max", "A parameter was undefined."); + throw err; + } + else if (min >= max) { + var err = (Error).invalidOperation("The min parameter must be smaller than max parameter."); + throw err; + } + else if (isNaN(input)) { + var msg = "A number was not entered. "; + msg += (String).format("Please enter a number between {0} and {1}.", min, max); + + var err = (Error).create(msg); + throw err; + } + else if (input < min || input > max) { + msg = "The number entered was outside the acceptable range. "; + msg += (String).format("Please enter a number between {0} and {1}.", min, max); + + var err = (Error).create(msg); + + throw err; + } + + alert("The number entered was within the acceptable range."); + } + + var input: any = undefined; + var min = -10; + var max = 10; + + // Result: A thrown ErrorArgumentNull exception with the following Error object message: + // "Sys.ArgumentNullException: A parameter was undefined. Parameter name: input" + validateNumberRange(input, min, max); +} + +function BaseClassExtensions_String_Tests() { + + (String).format("Please enter a number between {0} and {1}.", 1, 2); + (String).endsWith("test"); + (String).localeFormat("Please enter a number between {0} and {1}", 1, 2); + (String).trim(); + (String).trimEnd(); + (String).trimStart(); +} + function BaseClassExtensions_Function_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */ @@ -47,7 +109,7 @@ function BaseClassExtensions_Function_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */ var validateParametersTest = function () { var arguments = ['test1', 'test2']; - var insert = function Array$insert(array, index, item) { + var insert = function Array$insert(array: any[], index: number, item: any) { var e = (Function).validateParameters(arguments, [ { name: "array", type: Array, elementMayBeNull: true }, { name: "index", mayBeNull: true }, @@ -88,8 +150,7 @@ function BaseClassExtensions_Date_Tests() { function BaseClassExtensions_Boolean_Tests() { - (Boolean).parse("false"); - + (Boolean).parse("false"); } function BaseClassExtensions_Number_Tests() { @@ -178,7 +239,7 @@ function Sys_CancelEventArgs_Tests() { Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); - var CheckStatus = function(sender, args) { + var CheckStatus = function(sender: any, args: any) { var prm = Sys.WebForms.PageRequestManager.getInstance(); @@ -195,7 +256,7 @@ function Sys_CancelEventArgs_Tests() { } } - var ActivateAlertDiv = function(visString, msg) { + var ActivateAlertDiv = function(visString: string, msg: string) { var adiv = $get(divElem); var aspan = $get(messageElem); adiv.style.visibility = visString; @@ -206,9 +267,9 @@ function Sys_CancelEventArgs_Tests() { function Sys_CollectionChange_Tests() { var action = Sys.NotifyCollectionChangedAction.add; - var newItems = []; + var newItems: any[] = []; var newStartingIndex = 1; - var oldItems = []; + var oldItems: any[] = []; var oldStartingIndex = 2; var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); @@ -283,7 +344,7 @@ function Sys_UI_Key_Tests() { function Sys_UI_Control_Tests() { - var domElementObj; + var domElementObj: any; var className = "class Name"; var a = new Sys.UI.Control(domElementObj); @@ -316,7 +377,8 @@ function AspNetTypes_Tests() { Type.registerNamespace("Samples"); - var Samples; + var Samples: any; + Samples.A = function () { }; var a = Samples.A; a.registerClass('Samples.A'); @@ -333,7 +395,7 @@ function AspNetTypes_Tests() { Samples.C.registerClass('Samples.C', Samples.A, Samples.B); - var isDerived; + var isDerived: boolean; isDerived = Samples.B.inheritsFrom(Samples.A); // Output: "false". alert(isDerived); @@ -342,7 +404,7 @@ function AspNetTypes_Tests() { // Output: "true". alert(isDerived); - var implementsInterface; + var implementsInterface: boolean; implementsInterface = Samples.C.implementsInterface(Samples.B); // Output: "true". alert(implementsInterface); @@ -369,7 +431,7 @@ function CreatingCustomNonVisualClientComponentsTests() { /// Interval in milliseconds return this._interval; }, - set_interval: function (value) { + set_interval: function (value: any) { if (this._interval !== value) { this._interval = value; this.raisePropertyChanged('interval'); @@ -384,7 +446,7 @@ function CreatingCustomNonVisualClientComponentsTests() { /// True if timer is enabled, false if disabled. return this._enabled; }, - set_enabled: function (value) { + set_enabled: function (value: any) { if (value !== this.get_enabled()) { this._enabled = value; this.raisePropertyChanged('enabled'); @@ -400,12 +462,12 @@ function CreatingCustomNonVisualClientComponentsTests() { }, // events - add_tick: function (handler) { + add_tick: function (handler: Function) { /// Adds a event handler for the tick event. /// The handler to add to the event. this.get_events().addHandler("tick", handler); }, - remove_tick: function (handler) { + remove_tick: function (handler: Function) { /// Removes a event handler for the tick event. /// The handler to remove from the event. this.get_events().removeHandler("tick", handler); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 89803db41..0f2be8007 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,7 +13,6 @@ //#region JavaScript Base Type Extensions - /** * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. * Object Type Extensions @@ -35,7 +34,9 @@ interface Object { * Array Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} */ -interface Array { +interface Array { + + //#region lib.d.ts new (arrayLength?: number): any[]; new (arrayLength: number): T[]; @@ -46,6 +47,162 @@ interface Array { isArray(arg: any): boolean; prototype: Array; + ///** + // * Returns a string representation of an array. + // */ + //toString(): string; + //toLocaleString(): string; + ///** + // * Combines two or more arrays. + // * @param items Additional items to add to the end of array1. + // */ + //concat(...items: U[]): T[]; + ///** + // * Combines two or more arrays. + // * @param items Additional items to add to the end of array1. + // */ + //concat(...items: T[]): T[]; + ///** + // * Adds all the elements of an array separated by the specified separator string. + // * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + // */ + //join(separator?: string): string; + ///** + // * Removes the last element from an array and returns it. + // */ + //pop(): T; + ///** + // * Appends new elements to an array, and returns the new length of the array. + // * @param items New elements of the Array. + // */ + //push(...items: T[]): number; + ///** + // * Reverses the elements in an Array. + // */ + //reverse(): T[]; + ///** + // * Removes the first element from an array and returns it. + // */ + //shift(): T; + ///** + // * Returns a section of an array. + // * @param start The beginning of the specified portion of the array. + // * @param end The end of the specified portion of the array. + // */ + //slice(start?: number, end?: number): T[]; + + ///** + // * Sorts an array. + // * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + // */ + //sort(compareFn?: (a: T, b: T) => number): T[]; + + ///** + // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + // * @param start The zero-based location in the array from which to start removing elements. + // */ + //splice(start: number): T[]; + + ///** + // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + // * @param start The zero-based location in the array from which to start removing elements. + // * @param deleteCount The number of elements to remove. + // * @param items Elements to insert into the array in place of the deleted elements. + // */ + //splice(start: number, deleteCount: number, ...items: T[]): T[]; + + ///** + // * Inserts new elements at the start of an array. + // * @param items Elements to insert at the start of the Array. + // */ + //unshift(...items: T[]): number; + + ///** + // * Returns the index of the first occurrence of a value in an array. + // * @param searchElement The value to locate in the array. + // * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + // */ + //indexOf(searchElement: T, fromIndex?: number): number; + + ///** + // * Returns the index of the last occurrence of a specified value in an array. + // * @param searchElement The value to locate in the array. + // * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + // */ + //lastIndexOf(searchElement: T, fromIndex?: number): number; + + ///** + // * Determines whether all the members of an array satisfy the specified test. + // * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + ///** + // * Determines whether the specified callback function returns true for any element of an array. + // * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + ///** + // * Performs the specified action for each element in an array. + // * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + ///** + // * Calls a defined callback function on each element of an array, and returns an array that contains the results. + // * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + ///** + // * Returns the elements of an array that meet the condition specified in a callback function. + // * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + ///** + // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + ///** + // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + ///** + // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + ///** + // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + ///** + // * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + // */ + //length: number; + + //[n: number]: T; + + //#endregion + + //#region Extensions + /** * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. * @param array @@ -102,44 +259,8 @@ interface Array { * Removes an element at the specified location in an Array object. */ removeAt(array: any[], index: number): void; -} -/** - * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. - * String Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} - */ -interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; + //#endregion } /** @@ -166,58 +287,6 @@ interface Number { parseLocale(format: string): number; } -/** -* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). -* Error Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} -*/ -interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; -} - /** * Provides extensions to the base ECMAScript (JavaScript) Date object. * Date Type Extensions @@ -266,6 +335,9 @@ declare module MicrosoftAjaxBaseTypeExtensions { * @see {@link http://msdn.microsoft.com/en-us/library/dd409270(v=vs.100).aspx} */ interface Function { + + //#region lib.d.ts + /** * Creates a new function. * @param args A list of arguments the function accepts. @@ -273,7 +345,11 @@ declare module MicrosoftAjaxBaseTypeExtensions { new (...args: string[]): Function; (...args: string[]): Function; prototype: Function; - + + //#endregion + + //#region Extensions + /** * Creates a delegate function that retains the context first used during an objects creation. * @see {@link http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx } @@ -296,6 +372,276 @@ declare module MicrosoftAjaxBaseTypeExtensions { * @see {@link http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx } */ validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; + + //#endregion + } + + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). + * Error Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} + */ + interface Error { + + //#region lib.d.ts + + name: string; + message: string; + + new (message?: string): Error; + (message?: string): Error; + prototype: Error; + + //#endregion + + //#region Extensions + + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; + + //#endregion + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ + interface String { + + //#region lib.d.ts + + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; + + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; + + //#endregion + + //#region Extensions + + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; + + //#endregion } /** @@ -305,17 +651,30 @@ declare module MicrosoftAjaxBaseTypeExtensions { */ interface Boolean { + //#region lib.d.ts + new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; + //#endregion + + //#region Extensions + /** * Converts a string representation of a logical value to its Boolean object equivalent. */ parse(value: string): Boolean; + + //#endregion } } +// declare var Error: MicrosoftAjaxBaseTypeExtensions.Error; +// declare var String: MicrosoftAjaxBaseTypeExtensions.String; +// declare var Boolean: MicrosoftAjaxBaseTypeExtensions.Boolean; +// declare var Function: MicrosoftAjaxBaseTypeExtensions.Function; + //#endregion //#region ASP.NET Types @@ -397,7 +756,7 @@ declare class Type { * The fully qualified name of the class to test as a base class for the current instance. * @return true if the instance inherits from parentType; otherwise, false. */ - inheritsFrom(parentType: string); + inheritsFrom(parentType: string): boolean; /** * Initializes the base class and its members in the context of a given instance, which provides the model for inheritance and for initializing base members. * @param instance @@ -555,7 +914,7 @@ declare function $find(id: string, parent?: HTMLElement): Sys.Component; * @param handler The event handler to add. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean); +declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean): void; /** * Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -565,7 +924,7 @@ declare function $addHandler(element: Element, eventName: string, handler: Funct * @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean); +declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean): void; /** * Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -573,15 +932,19 @@ declare function $addHandlers(element: Element, events: any, handlerOwner?: any, * @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} * @param The DOM element that exposes the events. */ -declare function $clearHandlers(element: Element); +declare function $clearHandlers(element: Element): void; /** * Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb397717(v=vs.100).aspx} -* @param id The ID of the DOM element to find. -* @param element The parent element to search. The default is the document element. +* @param id +* The ID of the DOM element to find. +* @param element +* The parent element to search. The default is the document element. +* @return +* The element */ -declare function $get(id: string, element?: Element); +declare function $get(id: string, element?: Element): HTMLElement; /** * Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -590,7 +953,7 @@ declare function $get(id: string, element?: Element); * @param eventName The name of the DOM event. * @param handler The event handler to remove. */ -declare function $removeHandler(element, eventName, handler); +declare function $removeHandler(element: Element, eventName: string, handler: Function): void; //#endregion @@ -616,7 +979,7 @@ declare module Sys { //#region Constructors - constructor(); + constructor(): void; //#endregion @@ -1088,28 +1451,28 @@ declare module Sys { * @param item * The item to add. */ - static add(target: any[], item): void; + static add(target: any[], item: any): void; /** * Adds an event handler to the target. * @param target The array to which an event handler will be added. * @param handler The event handler. */ - static addCollectionChanged(target, handler: Function): void; + static addCollectionChanged(target: any, handler: Function): void; /** * Adds an observable event handler to the target. * @param eventName A string that contains the event name. * @param handler The added function. */ - static addEventHandler(target, eventName: string, handler: Function): void; + static addEventHandler(target: any, eventName: string, handler: Function): void; /** * Adds a propertyChanged event handler to the target. * @param target The object to observe. * @param handler The function handler to add. */ - static addPropertyChanged(target, handler: Function): void; + static addPropertyChanged(target: any, handler: Function): void; /** * Adds items to the collection in an observable manner. @@ -1217,7 +1580,7 @@ declare module Sys { * @param propertyName A string that contains the name of the property or field to set. * @param value The value to set. */ - static setValue(target, propertyName, value): void; + static setValue(target: any, propertyName: string, value: any): void; //#endregion @@ -2146,48 +2509,40 @@ declare module Sys { * Gets or sets the name of the default failure callback function. */ get_defaultFailedCallback(): Function; - /** * Gets or sets the name of the default failure callback function. * @param value * A string that contains the name of the default failure callback function. */ set_defaultFailedCallback(value: string): void; - /** * Gets or sets the default succeeded callback function for the service. * @return A reference to the succeeded callback function for the service. */ defaultSucceededCallback(): Function; - /** * Gets or sets the default succeeded callback function for the service. * @param value * A reference to the succeeded callback function for the service. */ defaultSucceededCallback(value: Function): void; - /** * Gets or sets the default user context for the service. * @return A reference to the user context for the service. */ defaultUserContext(): Object - /** * Gets or sets the default user context for the service. * @param value * A reference to the user context for the service. */ defaultUserContext(value: Object): void; - /** * Gets the authentication state of the current user. * The value of this property is set by the ScriptManager object during a page request. * @return true if the current user is logged in; otherwise, false. */ get_isLoggedIn(): boolean; - - /** * Gets or sets the authentication service path. * You usually set the path property in declarative markup. This value can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. @@ -2195,14 +2550,12 @@ declare module Sys { * @param value * The authentication service path. */ - set_path(value: string); - + set_path(value: string): void; /** * Gets or sets the authentication service path. * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. */ get_path(): string; - /** * Gets or sets the authentication service time-out value. * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. @@ -2210,12 +2563,13 @@ declare module Sys { * @param value * The time-out value in milliseconds. */ - set_timeout(value): void; - + set_timeout(value: number): void; /** * Gets or sets the authentication service time-out value. * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. * The timeout in milliseconds + * @return + * The timeout */ get_timeout(): number; @@ -2979,7 +3333,7 @@ declare module Sys { * @param beginRequestHandler * The name of the handler method that will be called. */ - add_beginRequest(beginRequestHandler: (sender, args) => void): void; + add_beginRequest(beginRequestHandler: (sender: any, args: any) => void): void; /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler @@ -2991,49 +3345,49 @@ declare module Sys { * @param endRequestHandler * The name of the handler method that will be called. */ - add_endRequest(endRequestHandler: (sender, args) => void): void; + add_endRequest(endRequestHandler: (sender: any, args: any) => void): void; /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be removed. */ - remove_endRequest(endRequestHandler: (sender, args) => void): void; + remove_endRequest(endRequestHandler: (sender: any, args: any) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + add_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + remove_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + add_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + remove_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoading(pageLoadingHandler: (sender, args) => void): void; + add_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoading(pageLoadingHandler: (sender, args) => void): void; + remove_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; //#endregion @@ -3077,7 +3431,7 @@ declare module Sys { //#region Properties - get_isInAsyncPostBack(): boolean; + get_isInAsyncPostBack(): boolean; //#endregion } From 100b96f98fdc4d3f1a14205d79e15478f4395d22 Mon Sep 17 00:00:00 2001 From: Nick Malaguti Date: Sun, 25 May 2014 16:50:42 -0400 Subject: [PATCH 42/81] Added typings for sqlite3 --- sqlite3/sqlite3-tests.ts | 92 ++++++++++++++++++++++++++++++++++++++++ sqlite3/sqlite3.d.ts | 81 +++++++++++++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 sqlite3/sqlite3-tests.ts create mode 100644 sqlite3/sqlite3.d.ts diff --git a/sqlite3/sqlite3-tests.ts b/sqlite3/sqlite3-tests.ts new file mode 100644 index 000000000..7059a439a --- /dev/null +++ b/sqlite3/sqlite3-tests.ts @@ -0,0 +1,92 @@ +/// + +import sqlite3 = require('sqlite3'); +sqlite3.verbose(); + +var db: sqlite3.Database; + +function createDb() { + console.log("createDb chain"); + db = new sqlite3.Database('chain.sqlite3', createTable); +} + +function createTable() { + console.log("createTable lorem"); + db.run("CREATE TABLE IF NOT EXISTS lorem (info TEXT)", insertRows); +} + +function insertRows() { + console.log("insertRows Ipsum i"); + var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); + + for (var i = 0; i < 10; i++) { + stmt.run("Ipsum " + i); + } + + stmt.finalize(readAllRows); +} + +function readAllRows() { + console.log("readAllRows lorem"); + db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) { + rows.forEach(function (row) { + console.log(row.id + ": " + row.info); + }); + closeDb(); + }); +} + +function closeDb() { + console.log("closeDb"); + db.close(); +} + +function runChainExample() { + createDb(); +} + +runChainExample(); + +db.serialize(function() { + db.run("CREATE TABLE lorem (info TEXT)"); + + var stmt = db.prepare("INSERT INTO lorem VALUES (?)"); + for (var i = 0; i < 10; i++) { + stmt.run("Ipsum " + i); + } + stmt.finalize(); + + db.each("SELECT rowid AS id, info FROM lorem", function(err, row) { + console.log(row.id + ": " + row.info); + }); +}); + +db.serialize(function() { + // These two queries will run sequentially. + db.run("CREATE TABLE foo (num)"); + db.run("INSERT INTO foo VALUES (?)", 1, function() { + // These queries will run in parallel and the second query will probably + // fail because the table might not exist yet. + db.run("CREATE TABLE bar (num)"); + db.run("INSERT INTO bar VALUES (?)", 1); + }); +}); + +// Directly in the function arguments. +db.run("UPDATE tbl SET name = ? WHERE id = ?", "bar", 2); + +// As an array. +db.run("UPDATE tbl SET name = ? WHERE id = ?", [ "bar", 2 ]); + +// As an object with named parameters. +db.run("UPDATE tbl SET name = $name WHERE id = $id", { + $id: 2, + $name: "bar" +}); + +db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { + 1: 2, + 5: "bar" +}); + +db.close(); diff --git a/sqlite3/sqlite3.d.ts b/sqlite3/sqlite3.d.ts new file mode 100644 index 000000000..c2c77cad9 --- /dev/null +++ b/sqlite3/sqlite3.d.ts @@ -0,0 +1,81 @@ +// Type definitions for sqlite3 2.2.3 +// Project: https://github.com/mapbox/node-sqlite3 +// Definitions by: Nick Malaguti +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "sqlite3" { + import events = require("events"); + + export var OPEN_READONLY: number; + export var OPEN_READWRITE: number; + export var OPEN_CREATE: number; + + export var cached: { + Database(filename: string, callback?: (err: Error) => void): Database; + Database(filename: string, mode?: number, callback?: (err: Error) => void): Database; + }; + + export interface RunResult { + lastID: number; + changes: number; + } + + export class Statement { + public bind(callback?: (err: Error) => void): Statement; + public bind(...params: any[]): Statement; + + public reset(callback?: (err: Error) => void): Statement; + + public finalize(callback?: (err: Error) => void): Statement; + + public run(callback?: (err: Error) => void): Statement; + public run(...params: any[]): Statement; + + public get(callback?: (err: Error, row: any) => void): Statement; + public get(...params: any[]): Statement; + + public all(callback?: (err: Error, rows: any[]) => void): Statement; + public all(...params: any[]): Statement; + + public each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement; + public each(...params: any[]): Statement; + } + + export class Database extends events.EventEmitter { + constructor(filename: string, callback?: (err: Error) => void); + constructor(filename: string, mode?: number, callback?: (err: Error) => void); + + public close(callback?: (err: Error) => void): void; + + public run(sql: string, callback?: (err: Error) => void): Database; + public run(sql: string, ...params: any[]): Database; + + public get(sql: string, callback?: (err: Error, row: any) => void): Database; + public get(sql: string, ...params: any[]): Database; + + public all(sql: string, callback?: (err: Error, rows: any[]) => void): Database; + public all(sql: string, ...params: any[]): Database; + + public each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database; + public each(sql: string, ...params: any[]): Database; + + public exec(sql: string, callback?: (err: Error) => void): Database; + + public prepare(sql: string, callback?: (err: Error) => void): Statement; + public prepare(sql: string, ...params: any[]): Statement; + + public serialize(callback?: () => void): void; + public parallelize(callback?: () => void): void; + + public on(event: "trace", listener: (sql: string) => void): Database; + public on(event: "profile", listener: (sql: string, time: number) => void): Database; + public on(event: "error", listener: (err: Error) => void): Database; + public on(event: "open", listener: () => void): Database; + public on(event: "close", listener: () => void): Database; + public on(event: string, listener: Function): Database; + } + + function verbose(): void; +} From 0bf411c6a56b74f9b4043c44041498909711f2e8 Mon Sep 17 00:00:00 2001 From: Nick Malaguti Date: Sun, 25 May 2014 16:56:22 -0400 Subject: [PATCH 43/81] Added sqlite3 to CONTRIBUTORS.md --- CONTRIBUTORS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cf7938411..0041c7bd2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,4 +1,4 @@ -# Contributors +# Contributors This is a non-exhaustive list of definitions and their creators. If you created a definition but are not listed then feel free to send a pull request on this file with your name and url. @@ -284,6 +284,7 @@ All definitions files include a header with the author and editors, so at some p * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [sqlite3](https://github.com/mapbox/node-sqlite3) (by [Nick Malaguti](https://github.com/nmalaguti)) * [status-bar](https://github.com/atom/status-bar) (by [vvakame](https://github.com/vvakame)) * [stripe](https://stripe.com/) (by [Eric J. Smith](https://github.com/ejsmith/)) * [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone)) From 6be4ce0be00343056b8f3c5afcabff51b2e5d5e8 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 22:17:55 +0100 Subject: [PATCH 44/81] Added Profile Service definitions Removed spaces and added profile service tests. --- microsoft-ajax/microsoft.ajax-tests.ts | 41 ++++++++--- microsoft-ajax/microsoft.ajax.d.ts | 99 ++++++++++++++++++-------- 2 files changed, 100 insertions(+), 40 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 4a1266dab..084f6de93 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -11,7 +11,7 @@ function GlobalNamespace_Tests() { // Get $get("Button1"); $get("Button1", $get("Button2")); - + // Add handler $addHandler($get("Button1"), "click", () => { }); $addHandlers($get("Button1"), {}); @@ -25,7 +25,7 @@ function GlobalNamespace_Tests() { // Clear $clearHandlers($get("Button1")); - + } function BaseClassExtensions_Error_Tests() { @@ -91,14 +91,14 @@ function BaseClassExtensions_String_Tests() { } function BaseClassExtensions_Function_Tests() { - + /** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */ var createDelegateTest = function () { var context = ""; var method: MicrosoftAjaxBaseTypeExtensions.Function; var a = (Function).createCallback(method, context); } - + /** Sample code from http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx */ var createDelegateTest = function () { var instance = this; @@ -149,7 +149,7 @@ function BaseClassExtensions_Date_Tests() { } function BaseClassExtensions_Boolean_Tests() { - + (Boolean).parse("false"); } @@ -162,7 +162,7 @@ function BaseClassExtensions_Number_Tests() { x.parseInvariant("1"); x.parseLocale("1"); } - + function Sys_Application_Tests() { var component = new Sys.Component(); @@ -239,7 +239,7 @@ function Sys_CancelEventArgs_Tests() { Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); - var CheckStatus = function(sender: any, args: any) { + var CheckStatus = function (sender: any, args: any) { var prm = Sys.WebForms.PageRequestManager.getInstance(); @@ -256,7 +256,7 @@ function Sys_CancelEventArgs_Tests() { } } - var ActivateAlertDiv = function(visString: string, msg: string) { + var ActivateAlertDiv = function (visString: string, msg: string) { var adiv = $get(divElem); var aspan = $get(messageElem); adiv.style.visibility = visString; @@ -301,7 +301,7 @@ function Sys_Component_Tests() { var element: HTMLElement; var handler: Function; var MyControl = new Type; - + aComponent.add_disposing(() => { }); aComponent.remove_disposing(() => { }); @@ -352,7 +352,7 @@ function Sys_UI_Control_Tests() { a.addCssClass(className); a.toggleCssClass(className); a.removeCssClass(className); - + a.initialize(); a.raiseBubbleEvent(domElementObj, className); a.onBubbleEvent(domElementObj, className); @@ -373,6 +373,26 @@ function Sys_CultureInfo_Tests() { var numberFormat = newCulture.numberFormat; } +function Sys_Services_Profile_Service_Group_Tests() { + + var Street = Sys.Services.ProfileService.properties.Address.Street; + var City = Sys.Services.ProfileService.properties.Address.City; + + Sys.Services.ProfileService.properties.Address = new Sys.Services.ProfileGroup(); + Sys.Services.ProfileService.properties.Address.Street = "street name"; + Sys.Services.ProfileService.properties.Address.City = "city name"; + Sys.Services.ProfileService.properties.Address.State = "state name"; + + var SaveCompletedCallback = () => { }; + var ProfileFailedCallback = () => { }; + var LoadCompletedCallback = () => { }; + + Sys.Services.ProfileService.save(null, SaveCompletedCallback, ProfileFailedCallback, null); + Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null); + +} + + function AspNetTypes_Tests() { Type.registerNamespace("Samples"); @@ -410,6 +430,7 @@ function AspNetTypes_Tests() { alert(implementsInterface); } + /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 0f2be8007..91c06555b 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -670,11 +670,6 @@ declare module MicrosoftAjaxBaseTypeExtensions { } } -// declare var Error: MicrosoftAjaxBaseTypeExtensions.Error; -// declare var String: MicrosoftAjaxBaseTypeExtensions.String; -// declare var Boolean: MicrosoftAjaxBaseTypeExtensions.Boolean; -// declare var Function: MicrosoftAjaxBaseTypeExtensions.Function; - //#endregion //#region ASP.NET Types @@ -1150,18 +1145,26 @@ declare module Sys { agent: any; /** * Gets a value that indicates the document compatibility mode of the browser. + * @return + * */ documentMode: number; /* * Gets a value that indicates whether the browser supports debug statements. + * @return + * True if the browser supports debug statements */ hasDebuggerStatement: boolean; /** * Gets the name of the browser. + * @return + * The name of the browser */ name: string; /* * Gets the version number of the browser. + * @return + * The version of the browser */ version: number; @@ -1195,7 +1198,6 @@ declare module Sys { * Raised when the dispose method is called for a component. */ remove_disposing(handler: Function): void; - /** * Gets the ID of the current Component object. */ @@ -1205,7 +1207,6 @@ declare module Sys { * @param value A string that contains the ID of the component. */ set_id(value: string): void; - /** * Raised when the raisePropertyChanged method of the current Component object is called. */ @@ -1346,26 +1347,22 @@ declare module Sys { //#region Methods assert(condition: boolean, message?: string, displayCaller?: boolean): void; - /** * Clears all trace messages from the trace console. */ clearTrace(): void; - /** * Displays a message in the debugger's output window and breaks into the debugger. * @param message * The message to display. */ fail(message: string): void; - /** * Appends a text line to the debugger console and to the trace console, if available. * @param text * The text to display. */ trace(text: string): void; - /** * Dumps an object to the debugger console and to the trace console, if available. * @param object @@ -1452,53 +1449,45 @@ declare module Sys { * The item to add. */ static add(target: any[], item: any): void; - /** * Adds an event handler to the target. * @param target The array to which an event handler will be added. * @param handler The event handler. */ static addCollectionChanged(target: any, handler: Function): void; - /** * Adds an observable event handler to the target. * @param eventName A string that contains the event name. * @param handler The added function. */ static addEventHandler(target: any, eventName: string, handler: Function): void; - /** * Adds a propertyChanged event handler to the target. * @param target The object to observe. * @param handler The function handler to add. */ static addPropertyChanged(target: any, handler: Function): void; - /** * Adds items to the collection in an observable manner. * @param target The array to which items will be added. * @param items The array of items to add. */ static addRange(target: any[], items: any[]): void; - /** * Begins the process of updating the target object. * @param target The object to update. */ static beginUpdate(target: any): void; - /** * Clears the array of its elements in an observable manner. * @param target The array to clear. */ static clear(target: any): void; - /** * Ends the process of updating the target object. * @param target The object being updated. */ static endUpdate(target: any): void; - /** * Inserts an item at the specified index in an observable manner. * @param target The array to which the item is inserted. @@ -1506,14 +1495,12 @@ declare module Sys { * @param item The item to insert. */ static insert(target: any, index: number, item: any): void; - /** * Indicates that the target is being updated. * @param target The target object to update. * @return true if given target argument is currently updating; otherwise false. */ static isUpdating(target: any): boolean; - /** * Makes an object directly observable by adding observable methods to it. * @param target The object, array, or DOM element to make observable. @@ -1521,14 +1508,12 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/dd393633(v=vs.100).aspx} */ static makeObservable(target: any): any; - /** * Raises the collectionChanged event. * @param target The collection to which an event is raised. * @param changes A Sys.CollectionChange object that contains the list of changes that were performed on the collection since the last event. */ static raiseCollectionChanged(target: any[], changes: Sys.CollectionChange): void; - /** * Raises an observable event on the target. * @param target The target object. @@ -1536,14 +1521,12 @@ declare module Sys { * @param eventArgs A Sys.EventArgs object used to pass event argument information. */ static raiseEvent(target: any, eventName: string, eventArgs: Sys.EventArgs): void; - /** * Raises a propertyChanged notification event. * @param target The object to which an event is raised. * @param propertyName The name of the property that changed. */ static raisePropertyChanged(target: any, propertyName: string): void; - /** * Removes the first occurrence of an item from the array in an observable manner. * @param target The array to which the item will be removed. @@ -1551,28 +1534,24 @@ declare module Sys { * @return true if the item is found in the array. Otherwise false. */ static remove(target: any[], item: any): boolean; - /** * Removes the item at the specified index from the array in an observable manner. * @param target The array to which an item is removed. * @param index A number that represents the index of the item to remove. */ static removeAt(target: any[], index: number): void; - /** * Removes the collectionChanged event handler from the target. * @param target The array from which the collectionChanged event handler is removed. * @param handler The function to remove. */ static removeCollectionChanged(target: any, handler: Function): void; - /** * Removes a propertyChanged event handler from the target. * @param target The object to observe. * @param handler The event handler to remove. */ static removeEventHandler(target: any, handler: Function): void; - /** * Sets a property or field on the target in an observable manner. * The raisePropertyChanged method is called after the setValue method set the value of the target object property. @@ -1942,7 +1921,6 @@ declare module Sys { * @return An array of all the components that were created since the last time the load event was raised. */ get_components(): Component[]; - /** * Returns a value that indicates whether the page is engaged in a partial-page update. * @return true if the page is engaged in a partial-page update; otherwise, false. @@ -2583,14 +2561,27 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} */ class ProfileGroup { + + //#region Constructors + + constructor(); /** * Initializes a new instance of the Sys.Services.ProfileGroup class. * @param properties * (Optional) An object that contains the settings for this profile group. This parameter can be null. */ + constructor(properties: Object); + //#endregion + + //#region Methods + + + + //#endregion + } /** @@ -2607,6 +2598,54 @@ declare module Sys { */ class ProfileService { + //#region Fields + + /** + * Specifies the path of the default profile service. + */ + static DefaultWebServicePath: string; + /** + * Contains the loaded profile data. You can access the loaded profile data directly from the properties field. + * An element in the properties field can be a property group of type ProfileGroup. If it is, the related properties appear as sub-properties. For more information, see Sys.Services.ProfileGroup Class. + */ + static properties: any; + + //#endregion + + //#region Methods + + /** + * Loads the specified profile properties. + * + * If propertyNames is not supplied, all profile properties enabled for read access are loaded from the server. + * The loaded profile can then be accessed directly from the properties field. + * This enables your application to access the profile properties by using simple field syntax, as shown in the following example: + * @example + * Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null); + * + * @param propertyName + * A string array that contains the profile properties to load. + * @param loadCompletedCallback + * The function that is called when loading has completed. The default is null. + * @param failedCallback + * The function that is called when loading has failed. The default is null. + * @param userContext + * User context information passed to the callback functions. + */ + static load(propertyNames: string[], loadCompletedCallback: Function, failedCallback: Function, userContext: any): void; + /** + * @param propertyNames + * A string array that contains the profile properties to save. + * @param saveCompletedCallback + * The function that is called when the save method has finished. The default is null. + * @param failedCallback + * The function that is called if the save method has failed. The default is null. + * @param userContext + * User context information passed to the callback functions. + */ + static save(propertyNames: string[], saveCompletedCallback: Function, failedCallback: Function, userContext: any): void; + + //#endregion } } From 1fb2e3990ce5f4d90ce61852317be7e5b73a225d Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 22:42:41 +0100 Subject: [PATCH 45/81] Further profile service definitions and tests --- microsoft-ajax/microsoft.ajax-tests.ts | 14 +++++ microsoft-ajax/microsoft.ajax.d.ts | 72 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 084f6de93..0e3d5da87 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -390,6 +390,20 @@ function Sys_Services_Profile_Service_Group_Tests() { Sys.Services.ProfileService.save(null, SaveCompletedCallback, ProfileFailedCallback, null); Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null); + Sys.Services.ProfileService.set_defaultFailedCallback("Function"); + var defaultFailedCallback = Sys.Services.ProfileService.get_defaultFailedCallback(); + + Sys.Services.ProfileService.set_defaultLoadCompletedCallback("Function"); + var defaultLoadCompletedCallback = Sys.Services.ProfileService.get_defaultLoadCompletedCallback(); + + Sys.Services.ProfileService.set_defaultSaveCompletedCallback("Function"); + var defaultSaveCompletedCallback = Sys.Services.ProfileService.get_defaultSaveCompletedCallback(); + + Sys.Services.ProfileService.set_path("path"); + Sys.Services.ProfileService.get_path(); + + var timeout = Sys.Services.ProfileService.get_timeout(); + } diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 91c06555b..e0a68e41f 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2598,6 +2598,8 @@ declare module Sys { */ class ProfileService { + new(): ProfileService; + //#region Fields /** @@ -2646,6 +2648,76 @@ declare module Sys { static save(propertyNames: string[], saveCompletedCallback: Function, failedCallback: Function, userContext: any): void; //#endregion + + //#region Properties + + /** + * Gets or sets the name of the default failure callback function. + * @param value + * A string that contains the name of the default failure callback function. + */ + static set_defaultFailedCallback(value: string): void; + static get_defaultFailedCallback(): Function; + /** + * Gets or sets the name of the default load-completed callback function. + * + * @param value + * A string that contains the name of the default load-completed callback function. + */ + static set_defaultLoadCompletedCallback(value: string): void; + static get_defaultLoadCompletedCallback(): Function; + /** + * Gets or sets the name of the default save-completed callback function. + * @param value + * A string that contains the name of the default save-completed callback function. + */ + static set_defaultSaveCompletedCallback(value: string): void; + static get_defaultSaveCompletedCallback(): Function; + /** + * Gets or sets the default succeeded callback function for the service. + * @return + * A reference to the succeeded callback function for the service. + */ + static defaultSucceededCallback(): Function; + static defaultSucceededCallback(value: Function); + /** + * Gets or sets the default user context for the service. + * @return + * A reference to the user context for the service. + */ + static defaultUserContext(): Object; + /** + * Gets or sets the default user context for the service. + */ + static defaultUserContext(value: Object); + /** + * Gets or sets the profile service path. + * @param value + * A string that contains the profile service path. + */ + static set_path(value: string); + /** + * Gets or sets the profile service path. + * @return + * The profile path + */ + static get_path(): string; + + /** + * Gets or sets the profile service time-out value. + * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. + * By setting a time-out interval, you can make sure that a pending request returns based on a time interval that you specify, instead of waiting for the asynchronous communication layer to time out. + * + * @param value + * The time-out value in milliseconds. + */ + static set_timeout(value: number); + /** + * Gets or sets the profile service time-out value. + */ + static get_timeout(): number; + + //#endregion } } From 63f3460679ad51ac0cdcf6fbf5c9c8ac6660b9d9 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 01:00:50 +0100 Subject: [PATCH 46/81] Added missing browser properties to test. --- microsoft-ajax/microsoft.ajax-tests.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 0e3d5da87..7346aabe2 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -227,7 +227,11 @@ function Sys_Application_LoadEventArgs_Tests() { function Sys_Browser_Tests() { var browser = Sys.Browser(); - + var agent = browser.agent; + var name = browser.name; + var version = browser.version; + var hasDebuggerStatement = browser.hasDebuggerStatement; + } function Sys_CancelEventArgs_Tests() { @@ -406,7 +410,6 @@ function Sys_Services_Profile_Service_Group_Tests() { } - function AspNetTypes_Tests() { Type.registerNamespace("Samples"); From b95b94765da041bb40ec7f3f45459c405c764336 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 01:03:39 +0100 Subject: [PATCH 47/81] Fixed definition signatures to pass npm test --- microsoft-ajax/microsoft.ajax.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index e0a68e41f..bf8f07bcd 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2679,7 +2679,7 @@ declare module Sys { * A reference to the succeeded callback function for the service. */ static defaultSucceededCallback(): Function; - static defaultSucceededCallback(value: Function); + static defaultSucceededCallback(value: Function): void; /** * Gets or sets the default user context for the service. * @return @@ -2689,13 +2689,13 @@ declare module Sys { /** * Gets or sets the default user context for the service. */ - static defaultUserContext(value: Object); + static defaultUserContext(value: Object): void; /** * Gets or sets the profile service path. * @param value * A string that contains the profile service path. */ - static set_path(value: string); + static set_path(value: string): void; /** * Gets or sets the profile service path. * @return @@ -2711,7 +2711,7 @@ declare module Sys { * @param value * The time-out value in milliseconds. */ - static set_timeout(value: number); + static set_timeout(value: number): void; /** * Gets or sets the profile service time-out value. */ From adb3a29aa82ff5fec795bdad820fb28abed2bfd7 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 26 May 2014 12:50:31 +0200 Subject: [PATCH 48/81] updated chai-assert.d.ts fixed chai test --- chai/chai-assert-tests.ts | 48 ++++------- chai/chai-assert.d.ts | 171 +++++++++++++++++++++----------------- 2 files changed, 112 insertions(+), 107 deletions(-) diff --git a/chai/chai-assert-tests.ts b/chai/chai-assert-tests.ts index 19429b4c9..4dc430f0c 100644 --- a/chai/chai-assert-tests.ts +++ b/chai/chai-assert-tests.ts @@ -33,17 +33,25 @@ THE SOFTWARE. /// //stubs -declare module chai { - var AssertionError; - function expect(body):any; -} + //tdd -declare function suite(description, action):void; -declare function test(description, action):void; -declare function err(action, msg?):void; +declare function suite(description: string, action: Function):void; +declare function test(description: string, action: Function):void; +declare function err(action: any, msg?: string):void; interface FieldObj { field: any; } +class Foo { + constructor() { + + } +} + +class CrashyObject { + inspect (): void { + throw new Error("Arg's inspect() called even though the test passed"); + } +} suite('assert', function () { @@ -56,12 +64,6 @@ suite('assert', function () { }, "expected foo to equal `bar`"); }); - test('fail', function () { - chai.expect(function () { - assert.fail(); - }).to.throw(chai.AssertionError); - }); - test('isTrue', function () { assert.isTrue(true); @@ -109,7 +111,7 @@ suite('assert', function () { }); test('equal', function () { - var foo; + var foo: any; assert.equal(foo, undefined); }); @@ -133,27 +135,15 @@ suite('assert', function () { }); test('instanceOf', function () { - function Foo() { - } - assert.instanceOf(new Foo(), Foo); err(function () { assert.instanceOf(5, Foo); }, "expected 5 to be an instance of Foo"); - - function CrashyObject() { - }; - CrashyObject.prototype.inspect = function () { - throw new Error("Arg's inspect() called even though the test passed"); - }; assert.instanceOf(new CrashyObject(), CrashyObject); }); test('notInstanceOf', function () { - function Foo() { - } - assert.notInstanceOf(new Foo(), String); err(function () { @@ -162,9 +152,6 @@ suite('assert', function () { }); test('isObject', function () { - function Foo() { - } - assert.isObject({}); assert.isObject(new Foo()); @@ -182,9 +169,6 @@ suite('assert', function () { }); test('isNotObject', function () { - function Foo() { - } - assert.isNotObject(5); err(function () { diff --git a/chai/chai-assert.d.ts b/chai/chai-assert.d.ts index b8845bc6b..0790cb17f 100644 --- a/chai/chai-assert.d.ts +++ b/chai/chai-assert.d.ts @@ -1,114 +1,135 @@ -// Type definitions for chai v1.7.0 assert style +// Type definitions for chai v1.9.0 assert style // Project: http://chaijs.com/ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module chai -{ - interface Assert - { - (express:any, msg?:string):void; +declare module chai { + export class AssertionError { + constructor(message: string, _props?: any, ssf?: Function); + name: string; + message: string; + showDiff: boolean; + stack: string; + } + export function use(plugin: any): void; - fail(actual?:any, expected?:any, msg?:string, operator?:string):void; + export var Assertion: ChaiAssertion; + export var assert: Assert; + export var config: ChaiConfig; - ok(val:any, msg?:string):void; - notOk(val:any, msg?:string):void; + export interface ChaiConfig { + includeStack: boolean; + } - equal(act:any, exp:any, msg?:string):void; - notEqual(act:any, exp:any, msg?:string):void; + export interface ChaiAssertion { + // what? + } - strictEqual(act:any, exp:any, msg?:string):void; - notStrictEqual(act:any, exp:any, msg?:string):void; + export interface Assert { + (express: any, msg?: string):void; - deepEqual(act:any, exp:any, msg?:string):void; - notDeepEqual(act:any, exp:any, msg?:string):void; + fail(actual?: any, expected?: any, msg?: string, operator?: string):void; - isTrue(val:any, msg?:string):void; - isFalse(val:any, msg?:string):void; + ok(val: any, msg?: string):void; + notOk(val: any, msg?: string):void; - isNull(val:any, msg?:string):void; - isNotNull(val:any, msg?:string):void; + equal(act: any, exp: any, msg?: string):void; + notEqual(act: any, exp: any, msg?: string):void; - isUndefined(val:any, msg?:string):void; - isDefined(val:any, msg?:string):void; + strictEqual(act: any, exp: any, msg?: string):void; + notStrictEqual(act: any, exp: any, msg?: string):void; - isFunction(val:any, msg?:string):void; - isNotFunction(val:any, msg?:string):void; + deepEqual(act: any, exp: any, msg?: string):void; + notDeepEqual(act: any, exp: any, msg?: string):void; - isObject(val:any, msg?:string):void; - isNotObject(val:any, msg?:string):void; + isTrue(val: any, msg?: string):void; + isFalse(val: any, msg?: string):void; - isArray(val:any, msg?:string):void; - isNotArray(val:any, msg?:string):void; + isNull(val: any, msg?: string):void; + isNotNull(val: any, msg?: string):void; - isString(val:any, msg?:string):void; - isNotString(val:any, msg?:string):void; + isUndefined(val: any, msg?: string):void; + isDefined(val: any, msg?: string):void; - isNumber(val:any, msg?:string):void; - isNotNumber(val:any, msg?:string):void; + isFunction(val: any, msg?: string):void; + isNotFunction(val: any, msg?: string):void; - isBoolean(val:any, msg?:string):void; - isNotBoolean(val:any, msg?:string):void; + isObject(val: any, msg?: string):void; + isNotObject(val: any, msg?: string):void; - typeOf(val:any, type:string, msg?:string):void; - notTypeOf(val:any, type:string, msg?:string):void; + isArray(val: any, msg?: string):void; + isNotArray(val: any, msg?: string):void; - instanceOf(val:any, type:Function, msg?:string):void; - notInstanceOf(val:any, type:Function, msg?:string):void; + isString(val: any, msg?: string):void; + isNotString(val: any, msg?: string):void; - include(exp:string, inc:any, msg?:string):void; - include(exp:any[], inc:any, msg?:string):void; + isNumber(val: any, msg?: string):void; + isNotNumber(val: any, msg?: string):void; - notInclude(exp:string, inc:any, msg?:string):void; - notInclude(exp:any[], inc:any, msg?:string):void; + isBoolean(val: any, msg?: string):void; + isNotBoolean(val: any, msg?: string):void; - match(exp:any, re:RegExp, msg?:string):void; - notMatch(exp:any, re:RegExp, msg?:string):void; + typeOf(val: any, type: string, msg?: string):void; + notTypeOf(val: any, type: string, msg?: string):void; - property(obj:Object, prop:string, msg?:string):void; - notProperty(obj:Object, prop:string, msg?:string):void; - deepProperty(obj:Object, prop:string, msg?:string):void; - notDeepProperty(obj:Object, prop:string, msg?:string):void; + instanceOf(val: any, type: Function, msg?: string):void; + notInstanceOf(val: any, type: Function, msg?: string):void; - propertyVal(obj:Object, prop:string, val:any, msg?:string):void; - propertyNotVal(obj:Object, prop:string, val:any, msg?:string):void; + include(exp: string, inc: any, msg?: string):void; + include(exp: any[], inc: any, msg?: string):void; - deepPropertyVal(obj:Object, prop:string, val:any, msg?:string):void; - deepPropertyNotVal(obj:Object, prop:string, val:any, msg?:string):void; + notInclude(exp: string, inc: any, msg?: string):void; + notInclude(exp: any[], inc: any, msg?: string):void; - lengthOf(exp:any, len:number, msg?:string):void; + match(exp: any, re: RegExp, msg?: string):void; + notMatch(exp: any, re: RegExp, msg?: string):void; + property(obj: Object, prop: string, msg?: string):void; + notProperty(obj: Object, prop: string, msg?: string):void; + deepProperty(obj: Object, prop: string, msg?: string):void; + notDeepProperty(obj: Object, prop: string, msg?: string):void; + + propertyVal(obj: Object, prop: string, val: any, msg?: string):void; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void; + + lengthOf(exp: any, len: number, msg?: string):void; //alias frenzy - throw(fn:Function, msg?:string):void; - throw(fn:Function, regExp:RegExp):void; - throw(fn:Function, errType:Function, msg?:string):void; - throw(fn:Function, errType:Function, regExp:RegExp):void; + throw(fn: Function, msg?: string):void; + throw(fn: Function, regExp: RegExp):void; + throw(fn: Function, errType: Function, msg?: string):void; + throw(fn: Function, errType: Function, regExp: RegExp):void; - throws(fn:Function, msg?:string):void; - throws(fn:Function, regExp:RegExp):void; - throws(fn:Function, errType:Function, msg?:string):void; - throws(fn:Function, errType:Function, regExp:RegExp):void; + throws(fn: Function, msg?: string):void; + throws(fn: Function, regExp: RegExp):void; + throws(fn: Function, errType: Function, msg?: string):void; + throws(fn: Function, errType: Function, regExp: RegExp):void; - Throw(fn:Function, msg?:string):void; - Throw(fn:Function, regExp:RegExp):void; - Throw(fn:Function, errType:Function, msg?:string):void; - Throw(fn:Function, errType:Function, regExp:RegExp):void; + Throw(fn: Function, msg?: string):void; + Throw(fn: Function, regExp: RegExp):void; + Throw(fn: Function, errType: Function, msg?: string):void; + Throw(fn: Function, errType: Function, regExp: RegExp):void; - doesNotThrow(fn:Function, msg?:string):void; - doesNotThrow(fn:Function, regExp:RegExp):void; - doesNotThrow(fn:Function, errType:Function, msg?:string):void; - doesNotThrow(fn:Function, errType:Function, regExp:RegExp):void; + doesNotThrow(fn: Function, msg?: string):void; + doesNotThrow(fn: Function, regExp: RegExp):void; + doesNotThrow(fn: Function, errType: Function, msg?: string):void; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void; - operator(val:any, operator:string, val2:any, msg?:string):void; - closeTo(act:number, exp:number, delta:number, msg?:string):void; + operator(val: any, operator: string, val2: any, msg?: string):void; + closeTo(act: number, exp: number, delta: number, msg?: string):void; - sameMembers(set1:any[], set2:any[], msg?:string):void; - includeMembers(set1:any[], set2:any[], msg?:string):void; + sameMembers(set1: any[], set2: any[], msg?: string):void; + includeMembers(set1: any[], set2: any[], msg?: string):void; - ifError(val:any, msg?:string):void; + ifError(val: any, msg?: string):void; } - //node module - var assert:Assert; } + //browser global declare var assert:chai.Assert; + +declare module 'chai' { +export = chai; +} From cc82b36997dc6e4a841b1a52dd23e6a008698216 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 26 May 2014 14:20:05 +0200 Subject: [PATCH 49/81] added defs for some (stream) utils --- findup-sync/findup-sync-tests.ts | 13 +++++++ findup-sync/findup-sync.d.ts | 15 ++++++++ from/from-tests.ts | 12 +++++++ from/from.d.ts | 21 +++++++++++ readdir-stream/readdir-stream-tests.ts | 8 +++++ readdir-stream/readdir-stream.d.ts | 11 ++++++ stream-to-array/stream-to-array-tests.ts | 10 ++++++ stream-to-array/stream-to-array.d.ts | 6 ++++ through2/through2-tests.ts | 44 ++++++++++++++++++++++++ through2/through2.d.ts | 23 +++++++++++++ 10 files changed, 163 insertions(+) create mode 100644 findup-sync/findup-sync-tests.ts create mode 100644 findup-sync/findup-sync.d.ts create mode 100644 from/from-tests.ts create mode 100644 from/from.d.ts create mode 100644 readdir-stream/readdir-stream-tests.ts create mode 100644 readdir-stream/readdir-stream.d.ts create mode 100644 stream-to-array/stream-to-array-tests.ts create mode 100644 stream-to-array/stream-to-array.d.ts create mode 100644 through2/through2-tests.ts create mode 100644 through2/through2.d.ts diff --git a/findup-sync/findup-sync-tests.ts b/findup-sync/findup-sync-tests.ts new file mode 100644 index 000000000..f4aab395a --- /dev/null +++ b/findup-sync/findup-sync-tests.ts @@ -0,0 +1,13 @@ +/// +/// + +import findup = require('findup-sync'); + +var str: string; + +str = findup('foo'); +str = findup(['foo', 'bar']); + +str = findup('foo', { + debug: true +}); diff --git a/findup-sync/findup-sync.d.ts b/findup-sync/findup-sync.d.ts new file mode 100644 index 000000000..a5bb5b49d --- /dev/null +++ b/findup-sync/findup-sync.d.ts @@ -0,0 +1,15 @@ +// Type definitions for findup-sync v0.1.3 +// Project: https://github.com/cowboy/node-findup-sync +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'findup-sync' { + import minimatch = require('minimatch'); + + function mod(pattern: string, opts?: minimatch.IOptions): string; + function mod(pattern: string[], opts?: minimatch.IOptions): string; + + export = mod; +} diff --git a/from/from-tests.ts b/from/from-tests.ts new file mode 100644 index 000000000..ce3a11d86 --- /dev/null +++ b/from/from-tests.ts @@ -0,0 +1,12 @@ +/// +/// + +import from = require('from'); + +var rs: NodeJS.ReadableStream; + +rs = from([]); +rs = from(function (count: number, next: () => any) { + this.emit('end'); +}); + diff --git a/from/from.d.ts b/from/from.d.ts new file mode 100644 index 000000000..dadf1fb65 --- /dev/null +++ b/from/from.d.ts @@ -0,0 +1,21 @@ +// Type definitions for from v0.1.3 +// Project: https://github.com/dominictarr/from +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'from' { + + var mod: mod.From; + + module mod { + interface From { + (getChunk: (count: number, next: () => any) => any): NodeJS.ReadableStream; + (chunks: any[]): NodeJS.ReadableStream; + emit(type: string, data: any): void; + } + } + + export = mod; +} diff --git a/readdir-stream/readdir-stream-tests.ts b/readdir-stream/readdir-stream-tests.ts new file mode 100644 index 000000000..a731e86ba --- /dev/null +++ b/readdir-stream/readdir-stream-tests.ts @@ -0,0 +1,8 @@ +/// +/// + +import readdir = require('readdir-stream'); + +var rs: NodeJS.ReadableStream; + +rs = readdir('foo'); diff --git a/readdir-stream/readdir-stream.d.ts b/readdir-stream/readdir-stream.d.ts new file mode 100644 index 000000000..5c4818507 --- /dev/null +++ b/readdir-stream/readdir-stream.d.ts @@ -0,0 +1,11 @@ +// Type definitions for readdir-stream v0.1.0 +// Project: https://github.com/logicalparadox/readdir-stream +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'readdir-stream' { + function readdir(dir: string): NodeJS.ReadableStream; + export = readdir; +} diff --git a/stream-to-array/stream-to-array-tests.ts b/stream-to-array/stream-to-array-tests.ts new file mode 100644 index 000000000..a4803d051 --- /dev/null +++ b/stream-to-array/stream-to-array-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +import toArray = require('stream-to-array'); + +var rs: NodeJS.ReadableStream; + +toArray(rs, (err, arr) => { + +}); diff --git a/stream-to-array/stream-to-array.d.ts b/stream-to-array/stream-to-array.d.ts new file mode 100644 index 000000000..4fd48acdf --- /dev/null +++ b/stream-to-array/stream-to-array.d.ts @@ -0,0 +1,6 @@ +/// + +declare module 'stream-to-array' { + function toArray(stream: NodeJS.ReadableStream, callback: (err: any, arr: any[]) => void): NodeJS.ReadWriteStream; + export = toArray; +} diff --git a/through2/through2-tests.ts b/through2/through2-tests.ts new file mode 100644 index 000000000..6ea9a52d5 --- /dev/null +++ b/through2/through2-tests.ts @@ -0,0 +1,44 @@ +/// +/// + +import through2 = require('through2'); + +var rws: NodeJS.ReadWriteStream; + +rws = through2({ + objectMode: true, + allowHalfOpen: true +}, function (entry: any, enc: string, callback: () => void) { + this.push('foo'); + callback(); +}, () => { + +}); + +rws = through2(function (entry: any, enc: string, callback: () => void) { + this.push('foo'); + callback(); +}, () => { + +}); + +rws = through2(function (entry: any, enc: string, callback: () => void) { + this.push('foo'); + callback(); +}); + +rws = through2(); + +// obj +rws = through2.obj(function (entry: any, enc: string, callback: () => void) { + this.push('foo'); + callback(); +}, () => { + +}); + +rws = through2.obj(function (entry: any, enc: string, callback: () => void) { + this.push('foo'); + callback(); +}); + diff --git a/through2/through2.d.ts b/through2/through2.d.ts new file mode 100644 index 000000000..3eb16f2e6 --- /dev/null +++ b/through2/through2.d.ts @@ -0,0 +1,23 @@ +// Type definitions for through2 v 0.4.2 +// Project: https://github.com/rvagg/through2 +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'through2' { + import stream = require('stream'); + + var mod: mod.Through2; + + module mod { + interface Through2 { + (transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream; + (opts: stream.DuplexOptions, transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream; + obj(transform: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream; + push(data: any): void; + } + } + export = mod; +} + From 5a77a8a133c00f01547b9c10c7a50f780ff1d2d2 Mon Sep 17 00:00:00 2001 From: Audrey Date: Mon, 26 May 2014 10:22:29 -0400 Subject: [PATCH 50/81] Update watchExpressions definition for $watchGroup Per https://docs.angularjs.org/api/ng/type/$rootScope.Scope, the watchExpressions is an array of string OR Function(scope). Array. --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index f4cc59a04..1ee9079d3 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -236,7 +236,7 @@ declare module ng { $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; - $watchGroup(watchExpressions: string[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; $watchGroup(watchExpressions: {(scope: IScope) : any}[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; $parent: IScope; From dee274ce0b1b935417df4bd6bcd1428bbaab5185 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 21:20:14 +0100 Subject: [PATCH 51/81] Added missing definitions, Sys.Debug tests Added missing properties to Component definitions. Added debug tests. Fixed invalid definitions for Debug class, documentation doesn't state that these methods are static, but the examples appear that Debug is singleton and methods are static. Cleaned up Observer definition methods / properties. Sys.Res Tests have been added and definitions added missing static. --- microsoft-ajax/microsoft.ajax-tests.ts | 66 ++++++++++- microsoft-ajax/microsoft.ajax.d.ts | 158 ++++++++++++++++--------- 2 files changed, 160 insertions(+), 64 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 7346aabe2..4b334cad0 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -314,17 +314,18 @@ function Sys_Component_Tests() { aComponent.beginUpdate(); - $create(MyControl, { id: 'c1', visible: true }, { click: handler }, null, $get('button1')); + var component = $create(MyControl, { id: 'c1', visible: true }, { click: handler }, null, $get('button1')); aComponent.dispose(); - aComponent.endUpdate(); - aComponent.initialize(); - aComponent.raisePropertyChanged("propertyName"); - aComponent.updated(); + + var id = aComponent.get_id(); + aComponent.set_id("#button1"); + var isInitialized = aComponent.get_isInitialized(); + var isUpdating = aComponent.get_isUpdating(); } function Sys_UI_Key_Tests() { @@ -363,6 +364,22 @@ function Sys_UI_Control_Tests() { a.dispose(); } +function Sys_Debug_Tests() { + + var condition = true; + + Sys.Debug.assert(condition); + Sys.Debug.assert(condition, "true"); + Sys.Debug.assert(condition, "true", true); + + var obj = {}; + Sys.Debug.traceDump(obj, "Name"); + Sys.Debug.trace("Trace text"); + Sys.Debug.fail("Fail message"); + + Sys.Debug.clearTrace(); +} + function Sys_CultureInfo_Tests() { var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; @@ -377,6 +394,44 @@ function Sys_CultureInfo_Tests() { var numberFormat = newCulture.numberFormat; } +function Sys_Res_Tests() { + + var actualValue = Sys.Res.actualValue; + var appLoadTimedout = Sys.Res.appLoadTimedout; + var argument = Sys.Res.argument; + var argumentNull = Sys.Res.argumentNull; + var argumentOutOfRange = Sys.Res.argumentOutOfRange; + var argumentType = Sys.Res.argumentType; + var argumentTypeWithTypes = Sys.Res.argumentTypeWithTypes; + var argumentUndefined = Sys.Res.argumentUndefined; + var assertFailed = Sys.Res.assertFailed; + var assetFailedCaller = Sys.Res.assetFailedCaller; + var badBaseUrl1 = Sys.Res.badBaseUrl1; + var badBaseUrl2 = Sys.Res.badBaseUrl2; + var badBaseUrl3 = Sys.Res.badBaseUrl3; + var breakIntoDebugger = Sys.Res.breakIntoDebugger; + var cannotAbortBeforeStart = Sys.Res.cannotAbortBeforeStart; + var cannotCallBeforeResponse = Sys.Res.cannotCallBeforeResponse; + var cannotCallOnceStarted = Sys.Res.cannotCallOnceStarted; + var cannotCallOutsideHandler = Sys.Res.cannotCallOutsideHandler; + var cannotDeserializeEmptyString = Sys.Res.cannotDeserializeEmptyString; + var cannotSerializeNonFiniteNumbers = Sys.Res.cannotSerializeNonFiniteNumbers; + var controlCantSetId = Sys.Res.controlCantSetId; + var enumInvalidValue = Sys.Res.enumInvalidValue; + var eventHandlerInvalid = Sys.Res.eventHandlerInvalid; + var format = Sys.Res.format; + var formatBadDate = Sys.Res.formatBadDate; + var formatBadFormatSpecifier = Sys.Res.formatBadFormatSpecifier; + var formatInvalidString = Sys.Res.formatInvalidString; + var invalidExecutorType = Sys.Res.invalidExecutorType; + var invalidHttpVerb = Sys.Res.invalidHttpVerb; + var invalidOperation = Sys.Res.invalidOperation; + var invalidTimeout = Sys.Res.invalidTimeout; + var invokeCalledTwice = Sys.Res.invokeCalledTwice; + var notImplemented = Sys.Res.notImplemented; + var nullWebRequest = Sys.Res.nullWebRequest; +} + function Sys_Services_Profile_Service_Group_Tests() { var Street = Sys.Services.ProfileService.properties.Address.Street; @@ -447,7 +502,6 @@ function AspNetTypes_Tests() { alert(implementsInterface); } - /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index bf8f07bcd..037720a28 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1199,15 +1199,6 @@ declare module Sys { */ remove_disposing(handler: Function): void; /** - * Gets the ID of the current Component object. - */ - get_id(): string; - /** - * Sets the ID of the current Component object. - * @param value A string that contains the ID of the component. - */ - set_id(value: string): void; - /** * Raised when the raisePropertyChanged method of the current Component object is called. */ add_propertyChanged(handler: Function): void; @@ -1271,6 +1262,37 @@ declare module Sys { //#region Properties + /** + * Gets an EventHandlerList object that contains references to all the event handlers that are mapped to the current component's events. + * This member supports the client-script infrastructure and is not intended to be used directly from your code. + * @return + * An EventHandlerList object that contains references to all the events and handlers for this component. + */ + get_events(): any; + /** + * Gets the ID of the current Component object. + * @return + * The id + */ + get_id(): string; + /** + * Sets the ID of the current Component object. + * @param value A string that contains the ID of the component. + */ + set_id(value: string): void; + /** + * Gets a value indicating whether the current Component object is initialized. + * @return + * true if the current Component is initialized; otherwise, false. + */ + get_isInitialized(): boolean; + /** + * Gets a value indicating whether the current Component object is updating. + * @return + * true if the current Component object is updating; otherwise, false. + */ + get_isUpdating(): boolean; + //#endregion } @@ -1340,29 +1362,45 @@ declare module Sys { //#region Constructors + /** + * Initializes a new instance of the Sys.Debug class. + */ constructor(); //#endregion //#region Methods - assert(condition: boolean, message?: string, displayCaller?: boolean): void; + /** + * Checks for a condition, and if the condition is false, displays a message and prompts the user to break into the debugger. + * When you call the assert method in your code, express the success of an operation as true or false and use that value for condition. If the operation fails (if condition is false), the assert logic is executed. + * The assert method should be used to catch developer errors. To respond to user errors and to run-time error conditions such as network errors or permission failures, throw an exception. + * Debugging behavior, requirements, and the output of trace messages vary with different browsers. For more information, see Debugging and Tracing Ajax Applications Overview. + * + * @param condition + * true to continue to execute code; false to display message and break into the debugger. + * @param message + * (Optional) The message to display. The default is an empty string (""). + * @param displayCaller + * (Optional) true to indicate that the name of the function that is calling assert should be displayed in the message. The default is false. + */ + static assert(condition: boolean, message?: string, displayCaller?: boolean): void; /** * Clears all trace messages from the trace console. */ - clearTrace(): void; + static clearTrace(): void; /** * Displays a message in the debugger's output window and breaks into the debugger. * @param message * The message to display. */ - fail(message: string): void; + static fail(message: string): void; /** * Appends a text line to the debugger console and to the trace console, if available. * @param text * The text to display. */ - trace(text: string): void; + static trace(text: string): void; /** * Dumps an object to the debugger console and to the trace console, if available. * @param object @@ -1370,7 +1408,7 @@ declare module Sys { * @param name * (Optional) The name of the object. */ - traceDump(object: any, name?: string): void; + static traceDump(object: any, name?: string): void; //#endregion } @@ -1496,12 +1534,6 @@ declare module Sys { */ static insert(target: any, index: number, item: any): void; /** - * Indicates that the target is being updated. - * @param target The target object to update. - * @return true if given target argument is currently updating; otherwise false. - */ - static isUpdating(target: any): boolean; - /** * Makes an object directly observable by adding observable methods to it. * @param target The object, array, or DOM element to make observable. * @return The observable object. @@ -1563,6 +1595,16 @@ declare module Sys { //#endregion + //#region Properties + + /** + * Indicates that the target is being updated. + * @param target The target object to update. + * @return true if given target argument is currently updating; otherwise false. + */ + static isUpdating(target: any): boolean; + + //#endregion } /** @@ -1577,139 +1619,139 @@ declare module Sys { /** * @return "Actual value was {0}." */ - actualValue: string; + static actualValue: string; /** * @return "The application failed to load within the specified time out period." */ - appLoadTimedout: string; + static appLoadTimedout: string; /** * @return "Value does not fall within the expected range." */ - argument: string; + static argument: string; /** * @return "Value cannot be null." */ - argumentNull: string; + static argumentNull: string; /** * @return "Specified argument was out of the range of valid values. */ - argumentOutOfRange: string; + static argumentOutOfRange: string; /** * @return "Object cannot be converted to the required type." */ - argumentType: string; + static argumentType: string; /** * @return "Object of type '{0}' cannot be converted to type '{1}'." */ - argumentTypeWithTypes: string; + static argumentTypeWithTypes: string; /** * @return "Value cannot be undefined." */ - argumentUndefined: string; + static argumentUndefined: string; /** * @return "Assertion Failed: {0}" */ - assertFailed: string; + static assertFailed: string; /** * @return "Assertion Failed: {0}\r\nat {1}" */ - assetFailedCaller: string; + static assetFailedCaller: string; /** * @return "Base URL does not contain ://." */ - badBaseUrl1: string; + static badBaseUrl1: string; /** * @return "Base URL does not contain another /." */ - badBaseUrl2: string; + static badBaseUrl2: string; /** * @return "Cannot find last / in base URL." */ - badBaseUrl3: string; + static badBaseUrl3: string; /** * @return "{0}\r\n\r\nBreak into debugger?" */ - breakIntoDebugger: string; + static breakIntoDebugger: string; /** * @return "Cannot abort when executor has not started." */ - cannotAbortBeforeStart: string; + static cannotAbortBeforeStart: string; /** * @return "Cannot call {0} when responseAvailable is false." */ - cannotCallBeforeResponse: string; + static cannotCallBeforeResponse: string; /** * @return "Cannot call {0} once started." */ - cannotCallOnceStarted: string; + static cannotCallOnceStarted: string; /** * @return "Cannot call {0} outside of a completed event handler." */ - cannotCallOutsideHandler: string; + static cannotCallOutsideHandler: string; /** * @return "Cannot deserialize empty string." */ - cannotDeserializeEmptyString: string; + static cannotDeserializeEmptyString: string; /** * @return "Cannot serialize non-finite numbers." */ - cannotSerializeNonFiniteNumbers: string; + static cannotSerializeNonFiniteNumbers: string; /** * @return "The id property can't be set on a control." */ - controlCantSetId: string; + static controlCantSetId: string; /** * @return "'{0}' is not a valid value for enum {1}." */ - enumInvalidValue: string; + static enumInvalidValue: string; /** * @return "Handler was not added through the Sys.UI.DomEvent.addHandler method. */ - eventHandlerInvalid: string; + static eventHandlerInvalid: string; /** * @return "One of the identified items was in an invalid format." */ - format: string; + static format: string; /** * @return "The string was not recognized as a valid Date." */ - formatBadDate: string; + static formatBadDate: string; /** * @return "Format specifier was invalid." */ - formatBadFormatSpecifier: string; + static formatBadFormatSpecifier: string; /** * @return "Input string was not in a correct format." */ - formatInvalidString: string; + static formatInvalidString: string; /** * @return "Could not create a valid Sys.Net.WebRequestExecutor from: {0}." */ - invalidExecutorType: string; + static invalidExecutorType: string; /** * @return "httpVerb cannot be set to an empty or null string." */ - invalidHttpVerb: string; + static invalidHttpVerb: string; /** * @return "Operation is not valid due to the current state of the object." */ - invalidOperation: string; + static invalidOperation: string; /** * @return "Value must be greater than or equal to zero." */ - invalidTimeout: string; + static invalidTimeout: string; /** * @return "Cannot call invoke more than once." */ - invokeCalledTwice: string; + static invokeCalledTwice: string; /** * @return "The method or operation is not implemented." */ - notImplemented: string; + static notImplemented: string; /** * @return "Cannot call executeRequest with a null webRequest." */ - nullWebRequest: string; + static nullWebRequest: string; //#endregion } @@ -2561,9 +2603,9 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} */ class ProfileGroup { - + //#region Constructors - + constructor(); /** @@ -2571,14 +2613,14 @@ declare module Sys { * @param properties * (Optional) An object that contains the settings for this profile group. This parameter can be null. */ - + constructor(properties: Object); //#endregion //#region Methods - + //#endregion From b77e343551199a85f4fe1ff30743509b18541855 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 21:37:04 +0100 Subject: [PATCH 52/81] Added Sys.StringBuilder tests --- microsoft-ajax/microsoft.ajax-tests.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 4b334cad0..3e1f44f0e 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -432,6 +432,30 @@ function Sys_Res_Tests() { var nullWebRequest = Sys.Res.nullWebRequest; } +function Sys_StringBuilder_Tests() { + + // Example taken from http://msdn.microsoft.com/en-us/library/bb310852(v=vs.100).aspx + function buildAString(title: string) { + var headTagStart = ""; + var headTagEnd = ""; + var titleTagStart = ""; + var titleTagEnd = ""; + + var sb = new Sys.StringBuilder(this._headTagStart); + sb.append(titleTagEnd); + sb.append(title); + sb.append(titleTagEnd); + sb.append(headTagEnd); + // Displays: "The result: A Title" + alert("The result" + sb.toString()); + } + + var title = "A Title"; + buildAString(title); + + +} + function Sys_Services_Profile_Service_Group_Tests() { var Street = Sys.Services.ProfileService.properties.Address.Street; From 2c056a113ebd362aa0abe0982f1a51d55b2e571b Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 21:43:16 +0100 Subject: [PATCH 53/81] Cleaned up StringBuilder ToString definition overload with optional parameter. --- microsoft-ajax/microsoft.ajax.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 037720a28..bd2e43617 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1812,8 +1812,7 @@ declare module Sys { * (Optional) A string to append between each element of the string that is returned. * @return A string representation of the StringBuilder instance. If separator is specified, the delimiter string is inserted between each element of the returned string. */ - toString(separator: string): string; - toString(): string; + toString(separator?: string): string; //#endregion } From 61175f7598a044c057095648ffa045889777a1dc Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 21:47:23 +0100 Subject: [PATCH 54/81] Sys.EventArgs definitions and tests --- microsoft-ajax/microsoft.ajax-tests.ts | 7 +++++++ microsoft-ajax/microsoft.ajax.d.ts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 3e1f44f0e..e8d9ab49f 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -234,6 +234,13 @@ function Sys_Browser_Tests() { } +function Sys_EventArgs_Tests() { + + var anEventArgs = new Sys.EventArgs(); + var eventArgs = anEventArgs.Empty; + +} + function Sys_CancelEventArgs_Tests() { var args = new Sys.CancelEventArgs(); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index bd2e43617..8d2349520 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1973,12 +1973,16 @@ declare module Sys { /** * Provides a base class for classes that are used by event sources to pass event argument information. + * The EventArgs class is a base class and not intended to be used directly. Override this constructor to provide specific functionality. * @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx} */ class EventArgs { //#region Constructors + /** + * Initializes a new instance of the EventArgs class. + */ constructor(); //#endregion From a6ff228746a197fe0226cce1e4930f5c91f87108 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 21:47:48 +0100 Subject: [PATCH 55/81] Region cleanup for Web Essentials //#region support. --- microsoft-ajax/microsoft.ajax.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 8d2349520..e7dcec610 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1888,11 +1888,16 @@ declare module Sys { * You register an interface by when you register the class by calling the Type.registerClass method. You specify IDisposable in the interfaceTypes parameter when you call Type.registerClass. */ interface IDisposable { + + //#region Methods + /** * Releases resources held by an object that implements the Sys.IDisposable interface. * Implement the dispose method to close or release resources held by an object, or to prepare an object for reuse. */ dispose(): void; + + //#endregion } /** @@ -1900,6 +1905,9 @@ declare module Sys { * Implement this interface if the class must notify other objects when it is releasing resources. The base component class already implements this interface. Therefore, typically this interface is already available. */ interface INotifyDisposing { + + //#region Events + /** * Occurs when an object's resources are released. * @param handler @@ -1912,12 +1920,17 @@ declare module Sys { * The name of the event handler for the disposing event. */ remove_disposing(handler: Function): void; + + //#endregion } /** * Defines the propertyChanged event. */ interface INotifyPropertyChange { + + //#region Events + /** * Occurs when a component property is set to a new value. * @param handler @@ -1930,6 +1943,8 @@ declare module Sys { * The name of the event handler for the propertyChanged event. */ remove_propertyChanged(handler: Function): void; + + //#endregion } //#endregion From 518fbb37c72340c7867f39232a60a42148f0d47c Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 26 May 2014 20:39:20 +0200 Subject: [PATCH 56/81] added filter method to minimatch and options optional --- minimatch/minimatch-tests.ts | 2 ++ minimatch/minimatch.d.ts | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/minimatch/minimatch-tests.ts b/minimatch/minimatch-tests.ts index a9f4f7e92..a4892ef35 100644 --- a/minimatch/minimatch-tests.ts +++ b/minimatch/minimatch-tests.ts @@ -11,3 +11,5 @@ var r = m.makeRe(); var f = ["test.ts"]; mm.match(f, pattern, options); + +mm.filter('foo')('bar'); diff --git a/minimatch/minimatch.d.ts b/minimatch/minimatch.d.ts index baf246394..e83d976a8 100644 --- a/minimatch/minimatch.d.ts +++ b/minimatch/minimatch.d.ts @@ -8,7 +8,8 @@ declare module "minimatch" { function M(target:string, pattern:string, options?:M.IOptions):void; module M { - function match(filenames:string[], pattern:string, options:IOptions):string[]; + function match(filenames:string[], pattern:string, options?:IOptions):string[]; + function filter(pattern:string, options?:IOptions): (target: string) => boolean; var Minimatch:IMinimatchStatic; @@ -27,7 +28,7 @@ declare module "minimatch" { } interface IMinimatchStatic { - new (pattern:string, options:IOptions):IMinimatch; + new (pattern:string, options?:IOptions):IMinimatch; } interface IMinimatch { @@ -36,11 +37,11 @@ declare module "minimatch" { parseNegate():void; braceExpand(pattern:string, options:IOptions):void; parse(pattern:string, isSub?:boolean):void; - makeRe():any; // regexp or boolean - match(file:string, pattern:string, options:IOptions):boolean; - matchOne(file:string, pattern:string, partial:any):boolean; + makeRe():RegExp; // regexp or boolean + match(file:string):boolean; + matchOne(files:string[], pattern:string[], partial:any):boolean; } } - export = M; +export = M; } From 15bcf54deed1b5293fd9af22e9a576960a2772c0 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 26 May 2014 22:54:16 +0200 Subject: [PATCH 57/81] fixed lingering typo in semver --- semver/semver-tests.ts | 12 ++++++------ semver/semver.d.ts | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/semver/semver-tests.ts b/semver/semver-tests.ts index 009a47daf..bf0e794bc 100644 --- a/semver/semver-tests.ts +++ b/semver/semver-tests.ts @@ -10,7 +10,7 @@ var exp:RegExp; var strArr:string[]; var numArr:string[]; -var mod:typeof SemverModule; +var mod:typeof SemVerModule; var v1:string, v2:string; var version:string; @@ -42,7 +42,7 @@ bool = mod.gtr(version, str, loose); bool = mod.ltr(version, str, loose); bool = mod.outside(version, str, str, loose); -var ver = new mod.Semver(str, bool); +var ver = new mod.SemVer(str, bool); str = ver.raw; bool = ver.loose; str = ver.format(); @@ -62,7 +62,7 @@ num = ver.comparePre(ver); ver = ver.inc(str); -var comp = new SemverModule.Comparator(str, bool); +var comp = new SemVerModule.Comparator(str, bool); str = comp.raw; bool = comp.loose; str = comp.format(); @@ -76,7 +76,7 @@ comp.parse(str); bool = comp.test(ver); -var range = new SemverModule.Range(str, bool); +var range = new SemVerModule.Range(str, bool); str = range.raw; bool = range.loose; str = range.format(); @@ -85,8 +85,8 @@ str = range.toString(); bool = range.test(ver); -var sets:SemverModule.Comparator[][]; +var sets:SemVerModule.Comparator[][]; sets = range.set(); -var lims:SemverModule.Comparator[]; +var lims:SemVerModule.Comparator[]; lims = range.parseRange(str); diff --git a/semver/semver.d.ts b/semver/semver.d.ts index 67f536af5..89755df37 100644 --- a/semver/semver.d.ts +++ b/semver/semver.d.ts @@ -3,7 +3,7 @@ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module SemverModule { +declare module SemVerModule { function valid(v:string, loose?:boolean):string; // Return the parsed version, or null if it's not valid. //TODO maybe add an enum for release? @@ -28,7 +28,7 @@ declare module SemverModule { function ltr(version:string, range:string, loose?:boolean):boolean; // Return true if version is less than all the versions possible in the range. function outside(version:string, range:string, hilo:string, loose?:boolean):boolean; // Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.) - class SemverBase { + class SemVerBase { raw:string; loose:boolean; format():string; @@ -36,7 +36,7 @@ declare module SemverModule { toString():string; } - class Semver extends SemverBase { + class SemVer extends SemVerBase { constructor(version:string, loose?:boolean); major:number; @@ -46,30 +46,30 @@ declare module SemverModule { build:string[]; prerelease:string[]; - compare(other:Semver):number; - compareMain(other:Semver):number; - comparePre(other:Semver):number; - inc(release:string):Semver; + compare(other:SemVer):number; + compareMain(other:SemVer):number; + comparePre(other:SemVer):number; + inc(release:string):SemVer; } - class Comparator extends SemverBase { + class Comparator extends SemVerBase { constructor(comp:string, loose?:boolean); - semver:Semver; + semver:SemVer; operator:string; value:boolean; parse(comp:string) :void; - test(version:Semver):boolean; + test(version:SemVer):boolean; } - class Range extends SemverBase { + class Range extends SemVerBase { constructor(range:string, loose?:boolean); set():Comparator[][]; parseRange(range:string):Comparator[]; - test(version:Semver):boolean; + test(version:SemVer):boolean; } } declare module "semver" { -export = SemverModule; +export = SemVerModule; } From 0823eb6b58939cfaff8bd4b51b3319020a653e59 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 26 May 2014 23:34:18 +0200 Subject: [PATCH 58/81] fixed semver.Comparator.set --- semver/semver-tests.ts | 2 +- semver/semver.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/semver/semver-tests.ts b/semver/semver-tests.ts index bf0e794bc..f339be75b 100644 --- a/semver/semver-tests.ts +++ b/semver/semver-tests.ts @@ -86,7 +86,7 @@ str = range.toString(); bool = range.test(ver); var sets:SemVerModule.Comparator[][]; -sets = range.set(); +sets = range.set; var lims:SemVerModule.Comparator[]; lims = range.parseRange(str); diff --git a/semver/semver.d.ts b/semver/semver.d.ts index 89755df37..12909d90e 100644 --- a/semver/semver.d.ts +++ b/semver/semver.d.ts @@ -65,7 +65,7 @@ declare module SemVerModule { class Range extends SemVerBase { constructor(range:string, loose?:boolean); - set():Comparator[][]; + set:Comparator[][]; parseRange(range:string):Comparator[]; test(version:SemVer):boolean; } From 38e236edbe35490282ffab10db3fcfdbdb1b6e92 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 26 May 2014 22:43:39 +0100 Subject: [PATCH 59/81] Added NetworkRequestEventArgs and WebRequestManager definitions and tests. --- microsoft-ajax/microsoft.ajax-tests.ts | 20 ++++ microsoft-ajax/microsoft.ajax.d.ts | 136 +++++++++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index e8d9ab49f..749af378e 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -496,6 +496,26 @@ function Sys_Services_Profile_Service_Group_Tests() { } +function Sys_Net_NetworkRequestEventArgsTests() { + + var value = new Sys.Net.WebRequest(); + var netWorkEventArgs = new Sys.Net.NetWorkRequestEventArgs(value); + var webRequest = netWorkEventArgs.get_webRequest(); +} + +function Sys_Net_WebRequestManagerTests() { + + var handler = (sender: any, args: any) => { } + + Sys.Net.WebRequestManager.add_completedRequest(handler); + Sys.Net.WebRequestManager.add_invokingRequest(handler); + Sys.Net.WebRequestManager.executeRequest(new Sys.Net.WebRequest()); + Sys.Net.WebRequestManager.remove_completedRequest(handler); + Sys.Net.WebRequestManager.set_defaultTimeout(100); + var customDefaultTimeout = Sys.Net.WebRequestManager.get_defaultTimeout(); + +} + function AspNetTypes_Tests() { Type.registerNamespace("Samples"); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index e7dcec610..527e4414a 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2244,6 +2244,53 @@ declare module Sys { */ module Net { + /** + * Generated Proxy Classes + * Enables your application to call Web services asynchronously by using ECMAScript (JavaScript). + * @see {@link http://msdn.microsoft.com/en-us/library/bb310823(v=vs.100).aspx} + */ + // Cannot create definitions for generated proxy classes. + + /** + * Contains information about a Web request that is ready to be sent to the current Sys.Net.WebRequestExecutor instance. + * This class represents the type for the second parameter of the callback function added by the add_invokingRequest method. + * The callback function is called before the Web request is routed to the current instance of the WebRequestExecutor class. + * + * @see {@link http://msdn.microsoft.com/en-us/library/bb397488(v=vs.100).aspx} + */ + class NetWorkRequestEventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.Net.NetworkRequestEventArgs. class. + * @param value + * The current WebRequest instance. + */ + constructor(value: WebRequest); + + //#endregion + + //#region Methods + + //#endregion + + //#region Properties + + /** + * Gets the Web request to be routed to the current Sys.Net.WebRequestExecutor instance. + * Use this property to inspect the contents of a Web request before it is routed to the current instance of the Sys.Net.WebRequestExecutor class. + * You can access the Web request instance from the handler that is called before the request is routed. + * This event handler is added by using the add_invokingRequest method. + * @return + * The WebRequest. + */ + get_webRequest(): WebRequest; + + //#endregion + + } + /** * Provides the script API to make a Web request. * @see {@link http://msdn.microsoft.com/en-us/library/bb310979(v=vs.100).aspx} @@ -2405,6 +2452,95 @@ declare module Sys { //#endregion } + + /** + * Manages the flow of the Web requests issued by the Sys.Net.WebRequest object to the associated executor object. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397435(v=vs.100).aspx} + */ + class IWebRequestManager { + + //#region Constructor + + /** + * Initializes a new instance of the Sys.Net.WebRequestManager class when implemented in a derived class. + */ + constructor(); + + //#endregion + + //#region Methods + + /** + * Registers a handler for the completed request event of the WebRequestManager. + * @param handler + * The function registered to handle the completed request event. + */ + add_completedRequest(handler: (sender: any, eventArgs: any) => void): void; + /** + * Registers a handler for processing the invoking request event of the WebRequestManager. + * @param handler + * The function registered to handle the invoking request event. + */ + add_invokingRequest(handler: (sender: any, networkRequestEventArgs: any) => void): void; + /** + * Sends Web requests to the default network executor. + * This member supports the client-script infrastructure and is not intended to be used directly from your code. + * @param WebRequest + * An instance of the Sys.Net.WebRequest class. + */ + executeRequest(WebRequest: Sys.Net.WebRequest): void; + /** + * Removes the event handler set by the add_completedRequest method. + * Use the remove_ completedRequest method to remove the event handler you set using the add_ completedRequest method. + * @param handler + * The function that handles the completed request event. + */ + remove_completedRequest(handler: Function): void; + /** + * Removes the event handler set by the add_invokingRequest method. + * Use the remove_invokingRequest method to remove the event handler you set using the add_invokingRequest method. + * @param handler + * The function that handles the invoking request event. + */ + remove_invokingRequest(handler: Function): void; + + //#endregion + + //#region Properties + + /** + * Gets or sets the default network executor type that is used to make network requests. + * @return + * The object that represents the default Web request executor. + */ + get_defaultExecutorType(): Sys.Net.WebRequestExecutor; + /** + * Gets or sets the default network executor type that is used to make network requests. + * @param value + * A reference to an implementation of the WebRequestExecutor class. + */ + set_defaultExecutorType(value: Sys.Net.WebRequestExecutor): void; + /** + * Gets or sets the time-out for the default network executor. + * @return + * An integer value that indicates the current time-out for the default executor. + */ + get_defaultTimeout(): number; + /** + * Gets or sets the time-out for the default network executor. + * + * @throws Sys.ArgumentOutOfRangeException An invalid parameter was passed. + * @param value + * The time in milliseconds that the default executor should wait before timing out a Web request. This value must be 0 or a positive integer. + */ + set_defaultTimeout(value: number): void; + + //#endregion + + } + + export var WebRequestManager: IWebRequestManager; + } //#endregion From fc0f486ed2b451b71ecfd7d6ba9e18c2ba92dccc Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 27 May 2014 00:24:00 +0200 Subject: [PATCH 60/81] added definition for bl (BufferList) --- bl/bl-tests.ts | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ bl/bl.d.ts | 40 +++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 bl/bl-tests.ts create mode 100644 bl/bl.d.ts diff --git a/bl/bl-tests.ts b/bl/bl-tests.ts new file mode 100644 index 000000000..96bfb8e3b --- /dev/null +++ b/bl/bl-tests.ts @@ -0,0 +1,68 @@ +/// + +import BufferList = require('bl'); + +var bl: BufferList; +var buffer: Buffer; +var offset: number; +var num: number; +var str: string; +var noAssert: boolean; + +bl = new BufferList(); +bl = new BufferList((err:Error, buffer:Buffer) => { + +}); + +bl.append(buffer); +num = bl.get(num); + +buffer = bl.slice(num, num); +buffer = bl.slice(num); +buffer = bl.slice(); + +bl.copy(buffer, num, num, num); +bl.copy(buffer, num, num); +bl.copy(buffer, num); +bl.copy(buffer); + +bl = bl.duplicate(); + +bl.consume(); +bl.consume(num); + +str = bl.toString(str, num, num); +str = bl.toString(str, num); +str = bl.toString(str); +str = bl.toString(); + +num = bl.length; + +buffer = bl.readDoubleBE(offset, noAssert); +buffer = bl.readDoubleBE(offset); +buffer = bl.readDoubleLE(offset, noAssert); +buffer = bl.readDoubleLE(offset); +buffer = bl.readFloatBE(offset, noAssert); +buffer = bl.readFloatBE(offset); +buffer = bl.readFloatLE(offset, noAssert); +buffer = bl.readFloatLE(offset); +buffer = bl.readInt32BE(offset, noAssert); +buffer = bl.readInt32BE(offset); +buffer = bl.readInt32LE(offset, noAssert); +buffer = bl.readInt32LE(offset); +buffer = bl.readUInt32BE(offset, noAssert); +buffer = bl.readUInt32BE(offset); +buffer = bl.readUInt32LE(offset, noAssert); +buffer = bl.readUInt32LE(offset); +buffer = bl.readInt16BE(offset, noAssert); +buffer = bl.readInt16BE(offset); +buffer = bl.readInt16LE(offset, noAssert); +buffer = bl.readInt16LE(offset); +buffer = bl.readUInt16BE(offset, noAssert); +buffer = bl.readUInt16BE(offset); +buffer = bl.readUInt16LE(offset, noAssert); +buffer = bl.readUInt16LE(offset); +buffer = bl.readInt8(offset, noAssert); +buffer = bl.readInt8(offset); +buffer = bl.readUInt8(offset, noAssert); +buffer = bl.readUInt8(offset); diff --git a/bl/bl.d.ts b/bl/bl.d.ts new file mode 100644 index 000000000..c277ea44b --- /dev/null +++ b/bl/bl.d.ts @@ -0,0 +1,40 @@ +// Type definitions for BufferList v0.8.0 +// Project: https://github.com/rvagg/bl +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'bl' { + import stream = require('stream'); + + class BufferList extends stream.Duplex { + new (callback?:(err:Error, buffer:Buffer) => void): void; + + append(buffer: Buffer):void; + get(index: number): number; + slice(start?: number, end?: number): Buffer; + copy(dest: Buffer, destStart?: number, srcStart?: number, srcEnd?: number): void; + duplicate(): BufferList; + consume(bytes?: number): void; + toString(encoding?: string, start?: number, end?: number): string; + length: number; + + readDoubleBE(offset: number, noAssert?: boolean): Buffer; + readDoubleLE(offset: number, noAssert?: boolean): Buffer; + readFloatBE(offset: number, noAssert?: boolean): Buffer; + readFloatLE(offset: number, noAssert?: boolean): Buffer; + readInt32BE(offset: number, noAssert?: boolean): Buffer; + readInt32LE(offset: number, noAssert?: boolean): Buffer; + readUInt32BE(offset: number, noAssert?: boolean): Buffer; + readUInt32LE(offset: number, noAssert?: boolean): Buffer; + readInt16BE(offset: number, noAssert?: boolean): Buffer; + readInt16LE(offset: number, noAssert?: boolean): Buffer; + readUInt16BE(offset: number, noAssert?: boolean): Buffer; + readUInt16LE(offset: number, noAssert?: boolean): Buffer; + readInt8(offset: number, noAssert?: boolean): Buffer; + readUInt8(offset: number, noAssert?: boolean): Buffer; + } + + export = BufferList; +} From 790e8660966028799a862f0baf8b03207d507525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9nes=20Harmath?= Date: Wed, 28 May 2014 13:16:20 +0200 Subject: [PATCH 61/81] Fix wrong space --- elm/elm.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elm/elm.d.ts b/elm/elm.d.ts index 1185394be..dbc330fcb 100644 --- a/elm/elm.d.ts +++ b/elm/elm.d.ts @@ -18,11 +18,11 @@ interface ElmComponent

{ ports: P; } -interface PortToElm { +interface PortToElm { send(value: V): void; } interface PortFromElm { subscribe(handler: (value: V) => void): void; unsubscribe(handler: (value: V) => void): void; -} \ No newline at end of file +} From c92d26b6159d054dcf781d1983757171d58ae0aa Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Wed, 28 May 2014 14:17:51 +0100 Subject: [PATCH 62/81] Added PageRequestManager Tests and EndRequestEventArgs Tests Minor changes to PageRequestManager definitions and Browser --- microsoft-ajax/microsoft.ajax-tests.ts | 46 ++++++++++++++++++++++++-- microsoft-ajax/microsoft.ajax.d.ts | 8 ++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 749af378e..9b70bc134 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -195,6 +195,7 @@ function Sys_Application_Tests() { Sys.Application.findComponent(id, element); Sys.Application.findComponent(id, component); Sys.Application.findComponent(id); + $find(id, element); var componentArray = Sys.Application.getComponents(); @@ -496,14 +497,14 @@ function Sys_Services_Profile_Service_Group_Tests() { } -function Sys_Net_NetworkRequestEventArgsTests() { +function Sys_Net_NetworkRequestEventArgs_Tests() { var value = new Sys.Net.WebRequest(); var netWorkEventArgs = new Sys.Net.NetWorkRequestEventArgs(value); var webRequest = netWorkEventArgs.get_webRequest(); } -function Sys_Net_WebRequestManagerTests() { +function Sys_Net_WebRequestManager_Tests() { var handler = (sender: any, args: any) => { } @@ -516,6 +517,47 @@ function Sys_Net_WebRequestManagerTests() { } +function Sys_WebForms_PageRequestManager_Tests() { + + var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); + + var eventArgs = pageRequestManager.Empty; + + var handler = (sender: any, args: any) => { } + + var isInAsyncPostBack = pageRequestManager.get_isInAsyncPostBack(); + + pageRequestManager.add_beginRequest(handler); + pageRequestManager.add_endRequest(handler); + pageRequestManager.add_initializeRequest(handler); + pageRequestManager.add_pageLoading(handler); + pageRequestManager.add_pageLoaded(handler); + pageRequestManager.remove_beginRequest(handler); + pageRequestManager.remove_pageLoaded(handler); + pageRequestManager.remove_pageLoading(handler); + pageRequestManager.beginAsyncPostBack(); + pageRequestManager.abortPostBack(); + pageRequestManager.dispose(); +} + +function Sys_WebForms_EndRequestEventArgs_Tests() { + + var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); + + var handler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { + + var error = args.get_error(); + var response = args.get_response(); + var dataItems = args.get_dataItems(); + var eventArgs = args.Empty; + + args.set_errorHandled(true); + var errorHandled = args.get_errorHandled(); + } + + pageRequestManager.add_endRequest(handler); +} + function AspNetTypes_Tests() { Type.registerNamespace("Samples"); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 527e4414a..5dda0ae6c 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1135,7 +1135,7 @@ declare module Sys { * The Sys.Browser object determines which browser is being used and provides some information about it. You can use this object to help customize your code to the unique requirements or capabilities of the browser. * @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx} */ - interface IBrowser { + interface Browser { //#region Fields @@ -1171,7 +1171,7 @@ declare module Sys { //#endregion } - export function Browser(): Sys.IBrowser; + export function Browser(): Sys.Browser; /** * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. @@ -3652,13 +3652,13 @@ declare module Sys { * @param endRequestHandler * The name of the handler method that will be called. */ - add_endRequest(endRequestHandler: (sender: any, args: any) => void): void; + add_endRequest(endRequestHandler: (sender: any, args: Sys.WebForms.EndRequestEventArgs) => void): void; /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be removed. */ - remove_endRequest(endRequestHandler: (sender: any, args: any) => void): void; + remove_endRequest(endRequestHandler: (sender: any, args: Sys.WebForms.EndRequestEventArgs) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler From bb07dae8abfa7bf2fc543c6d7bbe04c1298018de Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Wed, 28 May 2014 14:30:50 +0100 Subject: [PATCH 63/81] Added error fields to test. --- microsoft-ajax/microsoft.ajax-tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 9b70bc134..f29b3f3bf 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -547,6 +547,8 @@ function Sys_WebForms_EndRequestEventArgs_Tests() { var handler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { var error = args.get_error(); + var message = error.message; + var name = error.name; var response = args.get_response(); var dataItems = args.get_dataItems(); var eventArgs = args.Empty; From c61e78e7b2c37ad6405aac9768a2bb04af912ee8 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Fri, 30 May 2014 17:02:45 +0900 Subject: [PATCH 64/81] add x2js type definitions --- x2js/xml2json-tests.ts | 300 +++++++++++++++++++++++++++++++++++++++++ x2js/xml2json.d.ts | 32 +++++ 2 files changed, 332 insertions(+) create mode 100644 x2js/xml2json-tests.ts create mode 100644 x2js/xml2json.d.ts diff --git a/x2js/xml2json-tests.ts b/x2js/xml2json-tests.ts new file mode 100644 index 000000000..d5a8568e8 --- /dev/null +++ b/x2js/xml2json-tests.ts @@ -0,0 +1,300 @@ +/// + +// Create x2js instance with default config +var x2js = new X2JS(); + +// JSON to DOM +var xmlDoc = x2js.json2xml( + { + MyRoot: { + MyChild: 'my_child_value', + MyAnotherChild: 10, + MyArray: [ 'test', 'test2' ], + MyArrayRecords: [ + { + ttt: 'vvvv' + }, + { + ttt: 'vvvv2' + } + ] + } + } +); + + +// JSON to XML string +var xmlDocStr = x2js.json2xml_str( + { + MyRoot: { + MyChild: 'my_child_value', + MyAnotherChild: 10, + MyArray: [ 'test', 'test2' ], + MyArrayRecords: [ + { + ttt: 'vvvv' + }, + { + ttt: 'vvvv2' + } + ] + } + } +); + +console.log(xmlDocStr); + +// JSON arrays to string +var xmlDocStr = x2js.json2xml_str( + { + MyRoot: { + namedItemArray: { + item: [ + { first: 'success1' } , + { first: 'success2' } + ] + }, + namedArray: [ + { first: 'success1' } , + { first: 'success2' } + ], + justArray: [ 'just success1', 'just success2' ], + arrayWithAttrs: [ + { + _test: 'successAttr', + __text: 'success', + temp: 'successTemp' + }, + { + _test: 'successAttr2', + __text: 'success2', + temp: 'successTemp2' + } + ] + } + } +); + +console.log(xmlDocStr); + +// XML string to JSON +var xmlText = "Successddsfgdsdgfdgfd"; +var jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.MyOperation.test); + +// Array access form examples +console.log(x2js.asArray(jsonObj.MyOperation.test)[0]); +// Or old style (1.0.+): +var x2jsOld = new X2JS({arrayAccessForm: "property"}); +jsonObj = x2jsOld.xml_str2json(xmlText); +console.log("Old is " + jsonObj.MyOperation.test_asArray[0]); + +// XML/DOM to JSON +var xmlText = " - Success - TestText ddsfg TestText2 dsdgfdgfd" +xmlDoc = x2js.parseXmlString(xmlText); + +var jsonObj = x2js.xml2json(xmlDoc); +console.log(jsonObj.MyOperation.test); + +// Parsing XML attrs +var xmlText = "SUCCESS TXTSuccessddsfgdsdgfdgfd"; +var jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.MyOperation._myAttr); +console.log(jsonObj.MyOperation.test2._myAttr); +console.log(jsonObj.MyOperation.txtAttrChild._sAttr); +console.log(jsonObj.MyOperation.txtAttrChild.__text); +console.log(jsonObj.MyOperation.txtAttrChild.toString()); + +// JSON to XML attrs +var xmlDocStr = x2js.json2xml_str( + { + TestAttrRoot: { + _myAttr: 'myAttrValue', + MyChild: 'my_child_value', + MyAnotherChild: 10, + MyTextAttrChild: { + _myTextAttr: 'myTextAttrValue', + __text: 'HelloText' + } + } + } +); + +console.log(xmlDocStr); + +//Change prefix for attributes +var x2jsChangedAttrs = new X2JS({ + // XML attributes. Default is "_" + attributePrefix: "$" +}); +jsonObj = x2jsChangedAttrs.xml_str2json(xmlText); +console.log(jsonObj.MyOperation.$myAttr); +console.log(jsonObj.MyOperation.test2.$myAttr); +console.log(jsonObj.MyOperation.txtAttrChild.$sAttr); + +xmlDocStr = x2jsChangedAttrs.json2xml_str({ + TestAttrRoot: { + _myAttr: 'myAttrValue', + MyChild: 'my_child_value', + MyAnotherChild: 10, + MyTextAttrChild: { + $myTextAttr: 'myTextAttrValue', + __text: 'HelloText' + } + } + } +); + +console.log(xmlDocStr); + + +// Parse XML with namespaces +var xmlText = "SuccessddsfgdsdgfdgfdtestArrSize"; +var jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.MyOperation.test); +if (jsonObj.MyOperation.test2.item.length > 2) + console.log("Error! Incorrect array len!"); + +var testObjC = { + 'm:TestAttrRoot': { + '_tns:m': 'http://www.example.org', + '_tns:cms': 'http://www.example.org', + MyChild: 'my_child_value', + 'cms:MyAnotherChild': 'vdfd' + } +} + +// Parse JSON object with namespaces +var xmlDocStr = x2js.json2xml_str( + testObjC +); + +console.log(xmlDocStr); + +// Parse JSON object constructed with another NS-style +var testObjNew = { + TestAttrRoot: { + __prefix: 'm', + '_tns:m': 'http://www.example.org', + '_tns:cms': 'http://www.example.org', + MyChild: 'my_child_value', + MyAnotherChild: { + __prefix: 'cms', + __text: 'vdfd' + } + } +} + +// Parse JSON object with namespaces +var xmlDocStr = x2js.json2xml_str( + testObjNew +); + +console.log(xmlDocStr); + +// Parse XML with header +var xmlText = "\n" + + "XML HEADER SUCCESS!"; + +var jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.test); + +// Parse XML with CDATA +var xmlText = "simple success]]> "; + +var jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.test.data.toString()); +console.log(jsonObj.test.data.__cdata); +console.log(jsonObj.test.simple); + + +// Parse JSON object with CDATA +var xmlDocStr = x2js.json2xml_str( + jsonObj +); +console.log(xmlDocStr); + +// Parse JSON with emtpy attributes +var xmlDocStr = x2js.json2xml_str( + { + MyRoot: { + MyNullChild: null, + MyNullChild2: undefined, + MyAnotherChild: 10, + MyEmptyChild: { + _attr: "test" + }, + MyEmptyChild2: { + _attr: "test", + __text: "Empty Nodes Test" + } + } + } +); + +console.log(xmlDocStr); + +// Escaping XML characters +xmlDocStr = x2js.json2xml_str( + { + MyRoot: { + MyEscapeXmlChild: " & \" ' / ", + MyEscapeXmlChild2: { + _attr: "success", + __text: " & \" ' / " + }, + MyEscapeXmlChildNonString: false + } + } +); + +console.log(xmlDocStr); + +jsonObj = x2js.xml_str2json(xmlDocStr); +console.log(jsonObj.MyRoot.MyEscapeXmlChild); +console.log(jsonObj.MyRoot.MyEscapeXmlChild2.toString()); + +console.log(x2js.getVersion()); + +// Array access path demos +x2js = new X2JS({ + arrayAccessFormPaths: [ + "MyArrays.test4.item", + /.*\.test3\.item/ + ] +}); + +xmlText = "" + + "successsecond" + + "success" + + "success" + + "success" + + ""; + + +jsonObj = x2js.xml_str2json(xmlText); +console.log(jsonObj.MyArrays.test3.item[0]); +console.log(jsonObj.MyArrays.test4.item[0]); +console.log(jsonObj.MyArrays.test5.item); + +// Working with datetimes +x2js = new X2JS({ + datetimeAccessFormPaths: [ + "MyDts.testds", + /.*\.testdt.*/ + ] +}); + +xmlText = "" + + "2002-10-10T12:00:00+04:00" + + "2002-10-10T12:00:00Z" + + "2002-10-10T12:00:00" + + "2002-10-10T12:00:00Z" + + ""; +jsonObj = x2js.xml_str2json(xmlText); + +console.log(jsonObj.MyDts.testds); +console.log(jsonObj.MyDts.testdt1); +console.log(jsonObj.MyDts.testdt2); +console.log(x2js.asDateTime(jsonObj.MyDts.testdc)); + diff --git a/x2js/xml2json.d.ts b/x2js/xml2json.d.ts new file mode 100644 index 000000000..c202eface --- /dev/null +++ b/x2js/xml2json.d.ts @@ -0,0 +1,32 @@ + +interface IX2JS { + new (config?: IX2JSOption): IX2JS; + + getVersion(): string; + + xml2json(dom: Node): T; + json2xml(json: T): Node; + xml_str2json(xml: string): T; + json2xml_str(json: T): string; + parseXmlString(xml: string): Node; + + asArray(prop: any): any[]; + asDateTime(key: string): string; + asXmlDateTime(date: Date): string; + asXmlDateTime(date: number): string; +} + +interface IX2JSOption { + escapeMode?: boolean; + attributePrefix?: string; + arrayAccessForm?: string; + emptyNodeForm?: string; + enableToStringFunc?: boolean; + arrayAccessFormPaths?: any[]; + skipEmptyTextNodesForObj?: boolean; + stripWhitespaces?: boolean; + datetimeAccessFormPaths?: any[]; +} + +declare var X2JS: IX2JS; + From 88cfb5390050716d61b5465dfbcd2e720a89d7d4 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Fri, 30 May 2014 17:05:19 +0900 Subject: [PATCH 65/81] append CONTRIBUTORS --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 355990539..532e0404e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -324,6 +324,7 @@ All definitions files include a header with the author and editors, so at some p * [WinJS](http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx) (from TypeScript samples) * [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) (from TypeScript samples) * [ws](http://einaros.github.io/ws/) (by [Paul Loyd](https://github.com/loyd)) +* [x2js](https://code.google.com/p/x2js/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) * [XRegExp](http://xregexp.com/) (by [Bart van der Schoor](https://github.com/Bartvds)) * [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/)) * [YouTube Analytics API](https://developers.google.com/youtube/analytics/) (by [Frank M](https://github.com/sgtfrankieboy)) From 74781f59c54c508326de5bd4112d300d46436a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Stroi=C5=84ski?= Date: Fri, 30 May 2014 19:11:11 +0100 Subject: [PATCH 66/81] Add defined and specified --- requirejs/require.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/requirejs/require.d.ts b/requirejs/require.d.ts index 6b2cc125f..8623de8d6 100644 --- a/requirejs/require.d.ts +++ b/requirejs/require.d.ts @@ -262,6 +262,18 @@ interface Require { **/ 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 From 8fb6309e8d96aefa1f2b2e6c9961d10cc136ae06 Mon Sep 17 00:00:00 2001 From: Phips Peter Date: Fri, 30 May 2014 12:34:46 -0700 Subject: [PATCH 67/81] Adding type definitions for pg This is heavily based on the definitions from sqlite3. The Connection class is not defined because pg says that it is private for most use cases. I left that work for people who need it. --- pg/pg-tests.ts | 36 +++++++++++++++++++++ pg/pg.d.ts | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 pg/pg-tests.ts create mode 100644 pg/pg.d.ts diff --git a/pg/pg-tests.ts b/pg/pg-tests.ts new file mode 100644 index 000000000..dd9c75378 --- /dev/null +++ b/pg/pg-tests.ts @@ -0,0 +1,36 @@ +/// +import pg = require("pg"); +var conString = "postgres://username:password@localhost/database"; + +// Client pooling +pg.connect(conString, (err, client, done) => { + if (err) { + return console.error("Error fetching client from pool", err); + } + client.query("SELECT $1::int AS number", ["1"], (err, result) => { + done(); + if (err) { + return console.error("Error running query", err); + } + console.log(result.rows[0]["number"]); + return null; + }); + return null; +}); + +// Simple +var client = new pg.Client(conString); +client.connect((err) => { + if (err) { + return console.error("Could not connect to postgres", err); + } + client.query("SELECT NOW() AS 'theTime'", (err, result) => { + if (err) { + return console.error("Error running query", err); + } + console.log(result.rows[0]["theTime"]); + client.end(); + return null; + }); + return null; +}); \ No newline at end of file diff --git a/pg/pg.d.ts b/pg/pg.d.ts new file mode 100644 index 000000000..efdda0e4a --- /dev/null +++ b/pg/pg.d.ts @@ -0,0 +1,88 @@ +// Type definitions for pg +// Project: https://github.com/brianc/node-postgres +// Definitions by: Phips Peter +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "pg" { + import events = require("events"); + import stream = require("stream"); + + export function connect(connection: string, callback: (err: Error, client: Client, done: () => void) => void): void; + export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: () => void) => void): void; + export function end(): void; + + export interface ConnectionConfig { + user?: string; + database?: string; + password?: string; + port?: number; + host?: string; + } + + export interface Defaults extends ConnectionConfig { + poolSize?: number; + poolIdleTimeout?: number; + reapIntervalMillis?: number; + binary?: boolean; + parseInt8?: boolean; + } + + export interface ClientConfig extends ConnectionConfig { + ssl?: boolean; + } + + export interface QueryConfig { + name?: string; + text: string; + values?: any[]; + } + + export interface QueryResult { + rows: any[]; + } + + export interface ResultBuilder extends QueryResult { + command: string; + rowCount: number; + oid: number; + addRow(row: any): void; + } + + export class Client extends events.EventEmitter { + constructor(connection: string); + constructor(config: ClientConfig); + + connect(callback?: (err:Error) => void): void; + end(): void; + + query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query; + query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query; + + copyFrom(queryText: string): stream.Writable; + copyTo(queryText: string): stream.Readable; + + pauseDrain(): void; + resumeDrain(): void; + + public on(event: "drain", listener: () => void): Client; + public on(event: "error", listener: (err: Error) => void): Client; + public on(event: "notification", listener: (message: any) => void): Client; + public on(event: "notice", listener: (message: any) => void): Client; + public on(event: string, listener: Function): Client; + } + + export class Query extends events.EventEmitter { + public on(event: "row", listener: (row: any, result?: ResultBuilder) => void): Query; + public on(event: "error", listener: (err: Error) => void): Query; + public on(event: "end", listener: (result: ResultBuilder) => void): Query; + public on(event: string, listener: Function): Query; + } + + export class Events extends events.EventEmitter { + public on(event: "error", listener: (err: Error, client: Client) => void): Events; + public on(event: string, listener: Function): Events; + } +} \ No newline at end of file From 27bbb4195c3d76718f2c62fc188420c9fdac2b6d Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sat, 31 May 2014 19:52:15 +0100 Subject: [PATCH 68/81] Added Sys.UI.DomElement definitions and tests. Added Sys.UI.Point definitions and tests. Fixed minor definitions with some overrides. --- microsoft-ajax/microsoft.ajax-tests.ts | 91 ++++++++- microsoft-ajax/microsoft.ajax.d.ts | 245 +++++++++++++++++++++++-- 2 files changed, 318 insertions(+), 18 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index f29b3f3bf..34aa95a5a 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -269,8 +269,8 @@ function Sys_CancelEventArgs_Tests() { } var ActivateAlertDiv = function (visString: string, msg: string) { - var adiv = $get(divElem); - var aspan = $get(messageElem); + var adiv = $get(divElem); + var aspan = $get(messageElem); adiv.style.visibility = visString; aspan.innerHTML = msg; } @@ -372,6 +372,93 @@ function Sys_UI_Control_Tests() { a.dispose(); } +function Sy_UI_Point_Tests() { + + var elementRef: Sys.UI.DomElement; + var result: string; + // Get the location of the element + var elementLoc = Sys.UI.DomElement.getLocation(elementRef); + result += "Before move - Label1 location (x,y) = (" + + elementLoc.x + "," + elementLoc.y + ")
"; + // Move the element + Sys.UI.DomElement.setLocation(elementRef, 100, elementLoc.y); + elementLoc = Sys.UI.DomElement.getLocation(elementRef); + result += "After move - Label1 location (x,y) = (" + + elementLoc.x + "," + elementLoc.y + ")
"; + +} + +function Sys_UI_DomElement_Tests() { + + // Add CSS class + Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor"); + + var elementRef = $get("Label1"); + var elementBounds = Sys.UI.DomElement.getBounds(elementRef); + var toggleCssClassMethod = () => {}; + var removeCssClassMethod = () => {}; + var containsClass = Sys.UI.DomElement.containsCssClass(elementRef, "class-name"); + + // Add handler using the getElementById method + $addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod); + // Add handler using the shortcut to the getElementById method + $addHandler($get("Button2"), "click", removeCssClassMethod); + + Sys.UI.DomElement.toggleCssClass($get("id"), "redBackgroundColor"); + + + // Add handlers using the $get shortcut to the + // Sys.UI.DomElement.getElementById method + $addHandler($get("Button1"), "click", toggleVisible); + $addHandler($get("Button2"), "click", toggleVisibilityMode); + + // This method is called when Button2 is clicked. + function toggleVisible() { + var anElement = $get("Label1"); + if (Sys.UI.DomElement.getVisible(anElement)) { + Sys.UI.DomElement.setVisible(anElement, false); + } + else { + Sys.UI.DomElement.setVisible(anElement, true); + } + } + + // This method is called when Button1 is clicked. + function toggleVisibilityMode() { + + var anElement = $get("Label1"); + + var visMode = Sys.UI.DomElement.getVisibilityMode(anElement); + + var status = visMode; + + if (visMode === 0) { + Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.collapse); + if (document.all) { + anElement.innerText = + "Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse"; + } + else { + //Firefox + anElement.textContent = + "Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse"; + } + } + else { + Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.hide); + if (document.all) { + anElement.innerText = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide"; + } + else { + //Firefox + anElement.textContent = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide"; + } + } + } + + +} + function Sys_Debug_Tests() { var condition = true; diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 5dda0ae6c..ccd30afe9 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -326,7 +326,6 @@ interface Date { parseInvariant(value: string, ...formats: string[]): string; } - declare module MicrosoftAjaxBaseTypeExtensions { /** @@ -909,7 +908,7 @@ declare function $find(id: string, parent?: HTMLElement): Sys.Component; * @param handler The event handler to add. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean): void; +declare function $addHandler(element: Sys.UI.DomElement, eventName: string, handler: Function, autoRemove?: boolean): void; /** * Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -919,7 +918,7 @@ declare function $addHandler(element: Element, eventName: string, handler: Funct * @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean): void; +declare function $addHandlers(element: Sys.UI.DomElement, events: any, handlerOwner?: any, autoRemove?: boolean): void; /** * Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -927,7 +926,7 @@ declare function $addHandlers(element: Element, events: any, handlerOwner?: any, * @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} * @param The DOM element that exposes the events. */ -declare function $clearHandlers(element: Element): void; +declare function $clearHandlers(element: Sys.UI.DomElement): void; /** * Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. @@ -937,9 +936,11 @@ declare function $clearHandlers(element: Element): void; * @param element * The parent element to search. The default is the document element. * @return -* The element +* The Sys.UI.DomElement */ -declare function $get(id: string, element?: Element): HTMLElement; +declare function $get(id: string): any; // Examples use HTMLElement and DomElement +declare function $get(id: string, element?: HTMLElement): HTMLElement; +declare function $get(id: string, element?: Sys.UI.DomElement): Sys.UI.DomElement; /** * Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -948,7 +949,9 @@ declare function $get(id: string, element?: Element): HTMLElement; * @param eventName The name of the DOM event. * @param handler The event handler to remove. */ -declare function $removeHandler(element: Element, eventName: string, handler: Function): void; +declare function $removeHandler(element: any, eventName: string, handler: Function): void; +declare function $removeHandler(element: HTMLElement, eventName: string, handler: Function): void; +declare function $removeHandler(element: Sys.UI.DomElement, eventName: string, handler: Function): void; //#endregion @@ -1384,7 +1387,7 @@ declare module Sys { * @param displayCaller * (Optional) true to indicate that the name of the function that is calling assert should be displayed in the message. The default is false. */ - static assert(condition: boolean, message?: string, displayCaller?: boolean): void; + static assert(condition: boolean, message?: string, displayCaller?: boolean): void; /** * Clears all trace messages from the trace console. */ @@ -2250,7 +2253,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310823(v=vs.100).aspx} */ // Cannot create definitions for generated proxy classes. - + /** * Contains information about a Web request that is ready to be sent to the current Sys.Net.WebRequestExecutor instance. * This class represents the type for the second parameter of the callback function added by the add_invokingRequest method. @@ -2259,7 +2262,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397488(v=vs.100).aspx} */ class NetWorkRequestEventArgs { - + //#region Constructors /** @@ -2536,7 +2539,7 @@ declare module Sys { set_defaultTimeout(value: number): void; //#endregion - + } export var WebRequestManager: IWebRequestManager; @@ -3122,10 +3125,184 @@ declare module Sys { } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383788(v=vs.100).aspx} */ - class DomElement { - // todo + interface DomElement { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.DomElement class. + */ + constructor(): void; + + //#endregion + + //#region Methods + + /** + * Adds a CSS class to a DOM element if the class is not already part of the DOM element. This member is static and can be invoked without creating an instance of the class. + * If the element does not support a CSS class, no change is made to the element. + * @param element + * The Sys.UI.DomElement object to add the CSS class to. + * @param className + * The name of the CSS class to add. + */ + addCssClass(element: Sys.UI.DomElement, className: string): void; + /** + * Gets a value that indicates whether the DOM element contains the specified CSS class. This member is static and can be invoked without creating an instance of the class. + * @param element + * The Sys.UI.DomElement object to test for the CSS class. + * @param className + * The name of the CSS class to test for. + * @return + * true if the element contains the specified CSS class; otherwise, false. + */ + containsCssClass(element: Sys.UI.DomElement, className: string): boolean; + /** + * Gets a set of integer coordinates that represent the position, width, and height of a DOM element. This member is static and can be invoked without creating an instance of the class. + * + * @param element + * The Sys.UI.DomElement instance to get the coordinates of. + * @return + * An object of the JavaScript type Object that contains the x-coordinate and y-coordinate of the upper-left corner, the width, and the height of the element in pixels. + */ + getBounds(element: Sys.UI.DomElement): Object; + /** + * @param id + * The ID of the element to find. + * @param element + * (optional) The parent element to search in. The default is the document element. + */ + getElementById(id: string): Sys.UI.DomElement; + getElementById(id: string, element?: Sys.UI.DomElement): Sys.UI.DomElement; + getElementById(id: string, element?: HTMLElement): HTMLElement; + getElementById(id: string, element: any): any; + /** + * Gets the absolute position of a DOM element relative to the upper-left corner of the owner frame or window. This member is static and can be invoked without creating an instance of the class. * + * @param element + * The target element. * + * @return + * An object of the JavaScript type Object that contains the x-coordinate and y-coordinate of the element in pixels. + */ + getLocation(element: Sys.UI.DomElement): Sys.UI.Point; + getLocation(element: any): Object; + /* + * Returns a value that represents the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. This member is static and can be invoked without creating an instance of the class. + * @param element + * The target DOM element. + * @return + * A Sys.UI.VisibilityMode enumeration value that indicates the layout characteristics of element when it is hidden by invoking the setVisible method. + */ + getVisibilityMode(element: Sys.UI.DomElement): Sys.UI.VisibilityMode; + getVisibilityMode(element: any): Sys.UI.VisibilityMode; + /** + * Gets a value that indicates whether a DOM element is currently visible on the Web page. This member is static and can be invoked without creating an instance of the class. + * @param element + * The target DOM element. + * @return + * true if element is visible on the Web page; otherwise, false + */ + getVisible(element: any): boolean; + /** + * Determines whether the specified object is a DOM element. + * @param obj + * An object + * @return + * true if the object is a DOM element; otherwise, false. + */ + isDomElement(obj: any): boolean; + /** + * Raises a bubble event. A bubble event causes an event to be raised and then propagated up the control hierarchy until it is handled. + * @param source + * The DOM element that triggers the event. + * @param args + * The event arguments + */ + raiseBubbleEvent(source: Sys.UI.DomElement, args: EventArgs): void; + raiseBubbleEvent(source: any, args: any): void; + /** + * Removes a CSS class from a DOM element. This member is static and can be invoked without creating an instance of the class. If the element does not include a CSS class, no change is made to the element. + * @param element + * The Sys.UI.DomElement object to remove the CSS class from. + * @param className + * The name of the CSS class to remove. + */ + removeCssClass(element: Sys.UI.DomElement, className: string): void; + removeCssClass(element: HTMLElement, className: string): void; + removeCssClass(element: any, className: string): void; + /** + * Returns the element that has either the specified ID in the specified container, or is the specified element itself. + * The resolveElement method is used to verify that an ID or an object can be resolved as an element. * + * @param elementOrElementId + * The element to resolve, or the ID of the element to resolve. This parameter can be null. + * @param containerElement + * (Optional) The specified container. + * @return + * A DOM element. + */ + resolveElement(elementOrElementId: Sys.UI.DomElement, containerElement?: Sys.UI.DomElement): Sys.UI.DomElement; + resolveElement(elementOrElementId: HTMLElement, containerElement?: HTMLElement): HTMLElement; + resolveElement(elementOrElementId: string): any; + /** + * Sets the position of a DOM element. This member is static and can be invoked without creating an instance of the class. + * he left and top style attributes (upper-left corner) of an element specify the relative position of an element. + * The actual position will depend on the offsetParent property of the target element and the positioning mode of the element. * + * @param element The target element. + * @param x The x-coordinate in pixels. + * @param y The y-coordinate in pixels. + */ + setLocation(element: Sys.UI.DomElement, x: number, y: number): void; + setLocation(element: HTMLElement, x: number, y: number): void; + setLocation(element: any, x: number, y: number): void; + /** + * Sets the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. + * This member is static and can be invoked without creating an instance of the class. + * + * Use the setVisibilityMode method to set the layout characteristics of a DOM element when it is hidden by invoking the Sys.UI.DomElement.setVisible method. + * For example, if value is set to Sys.UI.VisibilityMode.collapse, the element uses no space on the page when the setVisible method is called to hide the element. + * + * @param element + * The target DOM element. + * @param value + * A Sys.UI.VisibilityMode enumeration value. + */ + setVisibilityMode(element: Sys.UI.DomElement, value: Sys.UI.VisibilityMode): void; + /** + * Sets a DOM element to be visible or hidden. This member is static and can be invoked without creating an instance of the class. + * + * Use the setVisible method to set a DOM element as visible or hidden on the Web page. + * If you invoke this method with value set to false for an element whose visibility mode is set to "hide," the element will not be visible. + * However, it will occupy space on the page. If the element's visibility mode is set to "collapse," the element will occupy no space in the page. + * For more information about how to set the layout characteristics of hidden DOM elements, see Sys.UI.DomElement setVisibilityMode Method. + * + * @param element + * The target DOM element. + * @param value + * true to make element visible on the Web page; false to hide element. + */ + setVisible(element: Sys.UI.DomElement, value: boolean): void; + setVisible(element: HTMLElement, value: boolean): void; + setVisible(element: any, value: boolean): void; + /** + * Toggles a CSS class in a DOM element. This member is static and can be invoked without creating an instance of the class. + * Use the toggleCssClass method to hide a CSS class of an element if it is shown, or to show a CSS class of an element if it is hidden. + * + * @param element + * The Sys.UI.DomElement object to toggle. + * @param className + * The name of the CSS class to toggle. + */ + toggleCssClass(element: Sys.UI.DomElement, className: string): void; + toggleCssClass(element: HTMLElement, className: string): void; + toggleCssClass(element: any, className: string): void; + + //#endregion + } + + var DomElement: Sys.UI.DomElement; + /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. * @see {@link http://msdn.microsoft.com/en-us/library/bb310935(v=vs.100).aspx} @@ -3359,16 +3536,52 @@ declare module Sys { // todo } /** - * Creates an object that contains a set of integer coordinates that represent a position. + * Creates an object that contains a set of integer coordinates that represent a position. The getLocation method of the Sys.UI.DomElement class returns a Point object. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383992(v=vs.100).aspx} * */ class Point { - // todo + + //#region Constructors + + /** + * Creates an object that contains a set of integer coordinates that represent a position. + * @param x The number of pixels between the location and the left edge of the parent frame. + * @param y The number of pixels between the location and the top edge of the parent frame. + */ + constructor(x: number, y: number); + + //#endregion + + //#region Fields + + /** + * Gets the x-coordinate of a Sys.UI.Point object in pixels. This property is read-only. + * @return A number that represents the x-coordinate of the Point object in pixels. + */ + x: number; + + /** + * Gets the y-coordinate of a Sys.UI.Point object in pixels. This property is read-only. + * @return A number that represents the y-coordinate of the Point object in pixels. + */ + y: number; + + //#endregion + } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397498(v=vs.100).aspx} */ enum VisibilityMode { - // todo + /** + * The element is not visible, but it occupies space on the page. + */ + hide, + /** + * The element is not visible, and the space it occupies is collapsed. + */ + collapse } } From 8c715e9f85d62236e1a54449bbfbcf07826c6ea1 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sat, 31 May 2014 20:12:49 +0100 Subject: [PATCH 69/81] Fixed PageRequestManager event handlers and definitions to take in the correct EventArgs type. Corrected tests to reflect the definitions. --- microsoft-ajax/microsoft.ajax-tests.ts | 23 ++++++++++++++--------- microsoft-ajax/microsoft.ajax.d.ts | 14 +++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 34aa95a5a..05f993238 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -610,18 +610,23 @@ function Sys_WebForms_PageRequestManager_Tests() { var eventArgs = pageRequestManager.Empty; - var handler = (sender: any, args: any) => { } + var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => { } + var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { } + var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => { } + var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => { } + var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => { } + var isInAsyncPostBack = pageRequestManager.get_isInAsyncPostBack(); - pageRequestManager.add_beginRequest(handler); - pageRequestManager.add_endRequest(handler); - pageRequestManager.add_initializeRequest(handler); - pageRequestManager.add_pageLoading(handler); - pageRequestManager.add_pageLoaded(handler); - pageRequestManager.remove_beginRequest(handler); - pageRequestManager.remove_pageLoaded(handler); - pageRequestManager.remove_pageLoading(handler); + pageRequestManager.add_beginRequest(beginRequestHandler); + pageRequestManager.add_endRequest(endRequestHandler); + pageRequestManager.add_initializeRequest(initializeRequestHandler); + pageRequestManager.add_pageLoading(pageLoadingRequestHandler); + pageRequestManager.add_pageLoaded(pageLoadedRequestHandler); + pageRequestManager.remove_beginRequest(beginRequestHandler); + pageRequestManager.remove_pageLoaded(pageLoadedRequestHandler); + pageRequestManager.remove_pageLoading(pageLoadingRequestHandler); pageRequestManager.beginAsyncPostBack(); pageRequestManager.abortPostBack(); pageRequestManager.dispose(); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index ccd30afe9..6b765e565 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -3853,7 +3853,7 @@ declare module Sys { * @param beginRequestHandler * The name of the handler method that will be called. */ - add_beginRequest(beginRequestHandler: (sender: any, args: any) => void): void; + add_beginRequest(beginRequestHandler: (sender: any, args: BeginRequestEventArgs) => void): void; /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler @@ -3877,37 +3877,37 @@ declare module Sys { * @param initializeRequestHandler * The name of the handler method that will be called. */ - add_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; + add_initializeRequest(initializeRequestHandler: (sender: any, args: InitializeRequestEventArgs) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - remove_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; + remove_initializeRequest(initializeRequestHandler: (sender: any, args: InitializeRequestEventArgs) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; + add_pageLoaded(pageLoadedHandler: (sender: any, args: PageLoadedEventArgs) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; + remove_pageLoaded(pageLoadedHandler: (sender: any, args: PageLoadedEventArgs) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; + add_pageLoading(pageLoadingHandler: (sender: any, args: PageLoadingEventArgs) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; + remove_pageLoading(pageLoadingHandler: (sender: any, args: PageLoadingEventArgs) => void): void; //#endregion From 865f1e6970889220e1b22831d27f3dad330fc140 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sat, 31 May 2014 20:18:52 +0100 Subject: [PATCH 70/81] Added arg definition methods to the event handlers in the Tests for PageRequestManager. --- microsoft-ajax/microsoft.ajax-tests.ts | 37 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 05f993238..2ebc56894 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -610,11 +610,38 @@ function Sys_WebForms_PageRequestManager_Tests() { var eventArgs = pageRequestManager.Empty; - var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => { } - var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { } - var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => { } - var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => { } - var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => { } + var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => { + var postBackElement = args.get_postBackElement(); + var webRequest = args.get_request(); + var updatePanelsToUpdate = args.get_updatePanelsToUpdate(); + var empty = args.Empty; + } + var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { + var dataItems = args.get_dataItems(); + var error = args.get_error(); + var errorHandled = args.get_errorHandled(); + var webRequestExecutor = args.get_response(); + var handled = args.set_errorHandled(true); + + } + var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => { + var postBackElement = args.get_postBackElement(); + var webRequestExecutor = args.get_request(); + var updatePanelsToUpdate = args.get_updatePanelsToUpdate(); + var empty = args.Empty; + } + var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => { + var dataItems = args.get_dataItems(); + var panelsCreated = args.get_panelsCreated(); + var panelsUpdated = args.get_panelsUpdated(); + var empty = args.Empty; + } + var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => { + var dataItems = args.get_dataItems(); + var panelsDeleted = args.get_panelsDeleted(); + var panelsUpdating = args.get_panelsUpdating(); + var empty = args.Empty; + } var isInAsyncPostBack = pageRequestManager.get_isInAsyncPostBack(); From cfc14059a1c1d0ffcc9eb3736ff762ed303b926c Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sat, 31 May 2014 22:03:13 +0100 Subject: [PATCH 71/81] Fixed definition issue where PageRequestManager extends from EventArgs which is invalid. --- microsoft-ajax/microsoft.ajax.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 6b765e565..b6ca115e8 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -3835,7 +3835,7 @@ declare module Sys { * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. * @see {@link http://msdn.microsoft.com/en-us/library/bb311028(v=vs.100).aspx} */ - class PageRequestManager extends EventArgs { + class PageRequestManager { //#region Constructors From ed742eda2f9af85912a962d6a6befa43acaa63ab Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sat, 31 May 2014 22:26:20 +0100 Subject: [PATCH 72/81] Added Sys.UI.DomEvent definitions and tests. Made some tests have Explicitly typed variables to see immediately the returning type. --- microsoft-ajax/microsoft.ajax-tests.ts | 116 +++++++++++++++---------- microsoft-ajax/microsoft.ajax.d.ts | 55 +++++++----- 2 files changed, 102 insertions(+), 69 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 2ebc56894..763c1e7fb 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -338,20 +338,20 @@ function Sys_Component_Tests() { function Sys_UI_Key_Tests() { - var backspace = Sys.UI.Key.backspace; - var del = Sys.UI.Key.del; - var down = Sys.UI.Key.down; - var end = Sys.UI.Key.end; - var pageDown = Sys.UI.Key.pageDown; - var pageUp = Sys.UI.Key.pageUp; - var home = Sys.UI.Key.home; - var enter = Sys.UI.Key.enter; - var esc = Sys.UI.Key.esc; - var tab = Sys.UI.Key.tab; - var key = Sys.UI.Key.up; - var left = Sys.UI.Key.left; - var right = Sys.UI.Key.right; - var space = Sys.UI.Key.space; + var backspace: number = Sys.UI.Key.backspace; + var del: number = Sys.UI.Key.del; + var down: number = Sys.UI.Key.down; + var end: number = Sys.UI.Key.end; + var pageDown: number = Sys.UI.Key.pageDown; + var pageUp: number = Sys.UI.Key.pageUp; + var home: number = Sys.UI.Key.home; + var enter: number = Sys.UI.Key.enter; + var esc: number = Sys.UI.Key.esc; + var tab: number = Sys.UI.Key.tab; + var key: number = Sys.UI.Key.up; + var left: number = Sys.UI.Key.left; + var right: number = Sys.UI.Key.right; + var space: number = Sys.UI.Key.space; } @@ -388,12 +388,36 @@ function Sy_UI_Point_Tests() { } +function Sys_UI_DomEvent_Tests() { + + var object: any; + + Sys.UI.DomEvent.addHandler(object, "eventName", () => { }); + Sys.UI.DomEvent.addHandler(object, "eventName", () => { }, true); + + Sys.UI.DomEvent.addHandlers(object, object, object, true); + Sys.UI.DomEvent.removeHandler(object, "eventName", () => { }); + Sys.UI.DomEvent.clearHandlers(object); + + var domEvent = new Sys.UI.DomEvent(object); + var altKey: boolean = domEvent.altKey; + var mouseButton: Sys.UI.MouseButton = domEvent.button; + var charCode: number = domEvent.charCode; + var clientX: number = domEvent.clientX; + var ctrlKey: boolean = domEvent.ctrlKey; + var screenX: number = domEvent.screenX; + var screenY: number = domEvent.screenY; + var target: any = domEvent.target; + var shiftKey: boolean = domEvent.shiftKey; + var type: string = domEvent.type; +} + function Sys_UI_DomElement_Tests() { // Add CSS class Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor"); - var elementRef = $get("Label1"); + var elementRef: Sys.UI.DomElement = $get("Label1"); var elementBounds = Sys.UI.DomElement.getBounds(elementRef); var toggleCssClassMethod = () => {}; var removeCssClassMethod = () => {}; @@ -606,45 +630,43 @@ function Sys_Net_WebRequestManager_Tests() { function Sys_WebForms_PageRequestManager_Tests() { - var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); - - var eventArgs = pageRequestManager.Empty; + var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => { - var postBackElement = args.get_postBackElement(); - var webRequest = args.get_request(); - var updatePanelsToUpdate = args.get_updatePanelsToUpdate(); - var empty = args.Empty; + var postBackElement: HTMLElement = args.get_postBackElement(); + var webRequest: Sys.Net.WebRequest = args.get_request(); + var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate(); + var empty: Sys.EventArgs = args.Empty; } var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { - var dataItems = args.get_dataItems(); - var error = args.get_error(); - var errorHandled = args.get_errorHandled(); - var webRequestExecutor = args.get_response(); - var handled = args.set_errorHandled(true); + var dataItems: any = args.get_dataItems(); + var error: Error = args.get_error(); + var errorHandled: boolean = args.get_errorHandled(); + var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_response(); + args.set_errorHandled(true); } var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => { - var postBackElement = args.get_postBackElement(); - var webRequestExecutor = args.get_request(); - var updatePanelsToUpdate = args.get_updatePanelsToUpdate(); - var empty = args.Empty; + var postBackElement: HTMLElement = args.get_postBackElement(); + var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_request(); + var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate(); + var empty: Sys.EventArgs = args.Empty; } var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => { - var dataItems = args.get_dataItems(); - var panelsCreated = args.get_panelsCreated(); - var panelsUpdated = args.get_panelsUpdated(); - var empty = args.Empty; + var dataItems: any = args.get_dataItems(); + var panelsCreated: HTMLDivElement[] = args.get_panelsCreated(); + var panelsUpdated: HTMLDivElement[] = args.get_panelsUpdated(); + var empty: Sys.EventArgs = args.Empty; } var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => { - var dataItems = args.get_dataItems(); - var panelsDeleted = args.get_panelsDeleted(); + var dataItems: any = args.get_dataItems(); + var panelsDeleted: HTMLDivElement[] = args.get_panelsDeleted(); var panelsUpdating = args.get_panelsUpdating(); - var empty = args.Empty; + var empty: Sys.EventArgs = args.Empty; } - var isInAsyncPostBack = pageRequestManager.get_isInAsyncPostBack(); + var isInAsyncPostBack: boolean = pageRequestManager.get_isInAsyncPostBack(); pageRequestManager.add_beginRequest(beginRequestHandler); pageRequestManager.add_endRequest(endRequestHandler); @@ -661,19 +683,19 @@ function Sys_WebForms_PageRequestManager_Tests() { function Sys_WebForms_EndRequestEventArgs_Tests() { - var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); + var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance(); var handler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => { - var error = args.get_error(); - var message = error.message; - var name = error.name; - var response = args.get_response(); - var dataItems = args.get_dataItems(); - var eventArgs = args.Empty; + var error: Error = args.get_error(); + var message: string = error.message; + var name: string = error.name; + var response: Sys.Net.WebRequestExecutor = args.get_response(); + var dataItems: any = args.get_dataItems(); + var eventArgs: Sys.EventArgs = args.Empty; args.set_errorHandled(true); - var errorHandled = args.get_errorHandled(); + var errorHandled: boolean = args.get_errorHandled(); } pageRequestManager.add_endRequest(handler); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index b6ca115e8..1c8968f44 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -3421,49 +3421,60 @@ declare module Sys { */ charCode: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the client area of the browser window, excluding window scroll bars. + * @return An integer that represents the x-coordinate in pixels. */ - clientX: any; // todo + clientX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the client area of the browser window, excluding window scroll bars. + * @return An integer that represents the y-coordinate in pixels. */ - clientY: any; // todo + clientY: number; /** - * + * Gets a Boolean value that indicates the state of the CTRL key when the associated event occurred. + * @return true if the CTRL key was pressed when the event occurred; otherwise, false. */ - ctrlKey: any; // todo + ctrlKey: boolean; /** - * + * Gets the key code of the key that raised the keyUp or keyDown event. + * @return An integer value that represents the key code of the key that was pressed to raise the keyUp or keyDown event. */ - keyCode: any; // todo + keyCode: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the object that raised the event. + * @return An integer that represents the x-coordinate in pixels. */ - offsetX: any; // todo + offsetX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the object that raised the event. + * @return An integer that represents the y-coordinate in pixels. */ - offsetY: any; // todo + offsetY: number; /** - * + * Gets the x-coordinate of the mouse pointer's position relative to the user's screen. + * @return An integer that represents the x-coordinate in pixels. */ - screenX: any; // todo + screenX: number; /** - * + * Gets the y-coordinate of the mouse pointer's position relative to the user's screen. + * @return An integer that represents the y-coordinate in pixels. */ - screenY: any; // todo + screenY: number; /** - * + * Gets a Boolean value that indicates the state of the SHIFT key when the associated event occurred. + * @return true if the SHIFT key was pressed when the event occurred; otherwise, false. */ - shiftKey: any; // todo + shiftKey: boolean; /** - * + * Gets the object that the event acted on. + * @return An object that represents the target that the event acted on. */ - target: any; // todo + target: any; /** - * + * Gets the name of the event that was raised. + * @return A string that represents the name of the event that was raised. */ - type: any; // todo + type: string; //#endregion } From c054ffe0c547df45118e395061500f847734b8c5 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Mon, 2 Jun 2014 10:01:14 +0200 Subject: [PATCH 73/81] Ensure async.d.ts compiles with --noImplicitAny --- async/async.d.ts | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/async/async.d.ts b/async/async.d.ts index b8666febf..f0b8cacdf 100644 --- a/async/async.d.ts +++ b/async/async.d.ts @@ -27,28 +27,28 @@ interface Async { forEach(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; forEachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; forEachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; - map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); - detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); - all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); - concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); - concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); + map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback): any; + detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any): any; + all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any): any; + concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; + concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): any; // Control Flow series(tasks: T[], callback?: AsyncMultipleResultsCallback): void; From 2e030fa8c428767e335df204015fed5d8e2a775f Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 2 Jun 2014 14:13:54 +0100 Subject: [PATCH 74/81] Added typing to IHttpService --- angularjs/angular-tests.ts | 8 +- angularjs/angular.d.ts | 157 +++++++++++++++++++++++++++++++------ 2 files changed, 139 insertions(+), 26 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 4acd18eeb..419bed0d6 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -98,12 +98,12 @@ module HttpAndRegularPromiseTests { } var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { - $http.get("http://somewhere/some/resource") + $http.get("http://somewhere/some/resource") .success((data: ExpectedResponse) => { $scope.person = data; }); - $http.get("http://somewhere/some/resource") + $http.get("http://somewhere/some/resource") .then((response: ng.IHttpPromiseCallbackArg) => { // typing lost, so something like // var i: number = response.data @@ -111,7 +111,7 @@ module HttpAndRegularPromiseTests { $scope.person = response.data; }); - $http.get("http://somewhere/some/resource") + $http.get("http://somewhere/some/resource") .then((response: ng.IHttpPromiseCallbackArg) => { // typing lost, so something like // var i: number = response.data @@ -148,7 +148,7 @@ module HttpAndRegularPromiseTests { var buildFooData: Function = () => 42; var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { - $http.get('/foo', buildFooData()) + $http.get('/foo', buildFooData()) .success(callback); } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 1ee9079d3..f1637fe40 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -589,44 +589,157 @@ declare module ng { register(name: string, dependencyAnnotatedConstructor: any[]): void; } - /////////////////////////////////////////////////////////////////////////// - // HttpService - // see http://docs.angularjs.org/api/ng.$http - /////////////////////////////////////////////////////////////////////////// + /** + * HttpService + * see http://docs.angularjs.org/api/ng/service/$http + */ interface IHttpService { - // At least moethod and url must be provided... - (config: IRequestConfig): IHttpPromise; - get (url: string, RequestConfig?: any): IHttpPromise; - delete (url: string, RequestConfig?: any): IHttpPromise; - head(url: string, RequestConfig?: any): IHttpPromise; - jsonp(url: string, RequestConfig?: any): IHttpPromise; - post(url: string, data: any, RequestConfig?: any): IHttpPromise; - put(url: string, data: any, RequestConfig?: any): IHttpPromise; + /** + * 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?: any): 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?: any): 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?: any): 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?: any): 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?: any): 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?: any): IHttpPromise; + + /** + * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. + */ defaults: IRequestConfig; - // For debugging, BUT it is documented as public, so... + /** + * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. + */ pendingRequests: any[]; } - // This is just for hinting. - // Some opetions might not be available depending on the request. - // see http://docs.angularjs.org/api/ng.$http#Usage for options explanations - interface IRequestConfig { - method: string; - url: string; + /** + * 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; - // XXX it has it's own structure... perhaps we should define it in the future + /** + * 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; - // These accept multiple types, so let's define them as any + /** + * {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; - timeout?: any; // number | promise + + /** + * {number|Promise} + * Timeout in milliseconds, or promise that should abort the request when resolved. + */ + timeout?: any; + + /** + * See requestType. + */ + responseType?: string; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestConfig extends IRequestShortcutConfig { + /** + * HTTP method (e.g. 'GET', 'POST', etc) + */ + method: string; + /** + * Absolute or relative URL of the resource that is being requested. + */ + url: string; } interface IHttpPromiseCallback { From 0b740a4d8f0e37e96806bfadf1248117b1a66a92 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Mon, 2 Jun 2014 14:33:33 +0100 Subject: [PATCH 75/81] Switch config from any to IRequestShortcutConfig --- angularjs/angular.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index f1637fe40..9d5074945 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -605,7 +605,7 @@ declare module ng { * @param url Relative or absolute URL specifying the destination of the request * @param config Optional configuration object */ - get(url: string, config?: any): IHttpPromise; + get(url: string, config?: IRequestShortcutConfig): IHttpPromise; /** * Shortcut method to perform DELETE request. @@ -613,7 +613,7 @@ declare module ng { * @param url Relative or absolute URL specifying the destination of the request * @param config Optional configuration object */ - delete(url: string, config?: any): IHttpPromise; + delete(url: string, config?: IRequestShortcutConfig): IHttpPromise; /** * Shortcut method to perform HEAD request. @@ -621,7 +621,7 @@ declare module ng { * @param url Relative or absolute URL specifying the destination of the request * @param config Optional configuration object */ - head(url: string, config?: any): IHttpPromise; + head(url: string, config?: IRequestShortcutConfig): IHttpPromise; /** * Shortcut method to perform JSONP request. @@ -629,7 +629,7 @@ declare module ng { * @param url Relative or absolute URL specifying the destination of the request * @param config Optional configuration object */ - jsonp(url: string, config?: any): IHttpPromise; + jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise; /** * Shortcut method to perform POST request. @@ -638,7 +638,7 @@ declare module ng { * @param data Request content * @param config Optional configuration object */ - post(url: string, data: any, config?: any): IHttpPromise; + post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; /** * Shortcut method to perform PUT request. @@ -647,7 +647,7 @@ declare module ng { * @param data Request content * @param config Optional configuration object */ - put(url: string, data: any, config?: any): IHttpPromise; + put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; /** * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. From d84b415d60a612d3911755e675e13aa1ebdf1aa2 Mon Sep 17 00:00:00 2001 From: noxhj Date: Wed, 4 Jun 2014 11:28:47 +0200 Subject: [PATCH 76/81] header option should be optional just like the other Column options --- slickgrid/slick.headerbuttons.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slickgrid/slick.headerbuttons.d.ts b/slickgrid/slick.headerbuttons.d.ts index ab160ea83..613203f43 100644 --- a/slickgrid/slick.headerbuttons.d.ts +++ b/slickgrid/slick.headerbuttons.d.ts @@ -8,7 +8,7 @@ declare module Slick { export interface Column { - header: Header; + header?: Header; } export interface Header { From cee2ec09485f20f2dabe43aa8871937872c48bd5 Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Wed, 4 Jun 2014 12:16:32 +0200 Subject: [PATCH 77/81] Add typings file for ansicolors NPM module. --- ansicolors/ansicolors.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 ansicolors/ansicolors.d.ts diff --git a/ansicolors/ansicolors.d.ts b/ansicolors/ansicolors.d.ts new file mode 100644 index 000000000..0ffc99910 --- /dev/null +++ b/ansicolors/ansicolors.d.ts @@ -0,0 +1,4 @@ +declare module "ansicolors" { + var colors: {[index: string]: (s: string) => string;}; + export = colors; +} From c09276c31696e589ef14bb5733827bfbcd3a9901 Mon Sep 17 00:00:00 2001 From: Jaco Erasmus Date: Wed, 4 Jun 2014 15:41:52 +0200 Subject: [PATCH 78/81] Changed - Fully qualified "Range" to "D3.Time.Range" --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 2225db5fc..41fc04dff 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -2743,7 +2743,7 @@ declare module D3 { clamp(clamp: boolean): TimeScale; ticks: { (count: number): any[]; - (range: Range, count: number): any[]; + (range: D3.Time.Range, count: number): any[]; }; tickFormat(count: number): (n: number) => string; copy(): TimeScale; From 7197351c94cd863f96fcf28abe6d09a3bd6e0b54 Mon Sep 17 00:00:00 2001 From: Jaco Erasmus Date: Wed, 4 Jun 2014 15:44:48 +0200 Subject: [PATCH 79/81] Added - KoliteAsyncCommand interface (makes "isExecuting" public) --- kolite/kolite.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kolite/kolite.d.ts b/kolite/kolite.d.ts index 42efda4a9..4aa55fd81 100644 --- a/kolite/kolite.d.ts +++ b/kolite/kolite.d.ts @@ -58,6 +58,10 @@ interface KoliteCommand { execute(...args: any[]): any; } +interface KoliteAsyncCommand extends KoliteCommand { + isExecuting: KnockoutObservable; +} + interface KoLiteCommandOptions { execute?: any; canExecute?: (isExecuting: boolean) => any; @@ -65,7 +69,7 @@ interface KoLiteCommandOptions { interface KnockoutStatic { command(options: KoLiteCommandOptions): KoliteCommand; - asyncCommand(optons: KoLiteCommandOptions): KoliteCommand; + asyncCommand(optons: KoLiteCommandOptions): KoliteAsyncCommand; } interface KnockoutUtils { From e4426f902b38582f86c04cecb6cf2821affe5f87 Mon Sep 17 00:00:00 2001 From: Jaco Erasmus Date: Wed, 4 Jun 2014 16:44:50 +0200 Subject: [PATCH 80/81] Kolite - Added asyncCommand.isExecuting() unit test --- kolite/kolite-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kolite/kolite-tests.ts b/kolite/kolite-tests.ts index f2013241d..4306ede53 100644 --- a/kolite/kolite-tests.ts +++ b/kolite/kolite-tests.ts @@ -30,6 +30,22 @@ function test_asyncCommand() { }); } +function test_asyncCommand_isExecuting() { + var primaryCommand = ko.asyncCommand({ + execute: (complete) => { + $.when().always(complete); + }, + canExecute: (isExecuting) => { + return !isExecuting; + } + }); + + var firstRun = true; + var canCancel = ko.computed(() => { + return firstRun && !primaryCommand.isExecuting(); + }); +} + function test_dirtyFlag() { var viewModel; viewModel.dirtyFlag = new ko.DirtyFlag(viewModel.model); From a0d12e107cca69cc58f4030c6ffd5945319055ae Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Wed, 4 Jun 2014 19:28:55 +0200 Subject: [PATCH 81/81] fixed typo in fs-extra header --- fs-extra/fs-extra.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts index 75f6c71a0..3d1af12ac 100644 --- a/fs-extra/fs-extra.d.ts +++ b/fs-extra/fs-extra.d.ts @@ -1,4 +1,4 @@ -// Type definitions for aws-sdk +// Type definitions for fs-extra // Project: https://github.com/jprichardson/node-fs-extra // Definitions by: midknight41 // Definitions: https://github.com/borisyankov/DefinitelyTyped