From 90fe3e51ea05b90acd58cd65ccc17dd578771b65 Mon Sep 17 00:00:00 2001 From: Javier Date: Tue, 21 Apr 2015 11:14:03 -0700 Subject: [PATCH 0001/1680] PlayerOptions width and height should be strings, adds Player.destroy() Per https://developers.google.com/youtube/iframe_api_reference PlayerOptions can be other than numbers, in fact in the API reference are created as strings even though they are specified as numbers: '100%' works. Also adds the Player.destroy() method, which removes the iframe from the DOM. --- youtube/youtube.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 85f96b22f8..42262f452c 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -50,8 +50,8 @@ declare module YT { } export interface PlayerOptions { - width?: number; - height?: number; + width?: string; + height?: string; videoId?: string; playerVars?: PlayerVars; events?: Events; @@ -147,6 +147,9 @@ declare module YT { // Event Listener addEventListener(event: string, handler: EventHandler): void; + + // DOM + destroy(): void; } export enum PlayerState { From 88b29b7995a27a11dfc241cb236c926e151b0a3e Mon Sep 17 00:00:00 2001 From: Alexey Gorshkov Date: Mon, 11 May 2015 01:51:24 +0300 Subject: [PATCH 0002/1680] Added jsurl --- jsurl/jsurl-tests.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ jsurl/jsurl.d.ts | 18 ++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 jsurl/jsurl-tests.ts create mode 100644 jsurl/jsurl.d.ts diff --git a/jsurl/jsurl-tests.ts b/jsurl/jsurl-tests.ts new file mode 100644 index 0000000000..f573feb49e --- /dev/null +++ b/jsurl/jsurl-tests.ts @@ -0,0 +1,67 @@ +/// + +var u = new Url; // curent document URL will be used +// or we can instantiate as +var u2 = new Url("http://example.com/some/path?a=b&c=d#someAnchor"); +// it should support relative URLs also +var u3 = new Url("/my/site/doc/path?foo=bar#baz"); + +// get the value of some query string parameter +alert(u2.query.a); +// or +alert(u3.query["foo"]); + +// Manupulating query string parameters +u.query.a = [1, 2, 3]; // adds/replaces in query string params a=1&a=2&a=3 +u.query.b = 'woohoo'; // adds/replaces in query string param b=woohoo + +if (u.query.a instanceof Array) { // the way to add a parameter + u.query.a.push(4); // now it's "a=1&a=2&a=3&a=4&b=woohoo" +} + +else { // if not an array but scalar value here is a way how to convert to array + u.query.a = [u.query.a]; + u.query.a.push(8) +} + + +// The way to remove the parameter: +delete u.query.a +// or: +delete u.query["a"] + +// If you need to remove all query string params: +u.query.clear(); +alert(u); + +// Lookup URL parts: +alert( + 'protocol = ' + u.protocol + '\n' + + 'user = ' + u.user + '\n' + + 'pass = ' + u.pass + '\n' + + 'host = ' + u.host + '\n' + + 'port = ' + u.port + '\n' + + 'path = ' + u.path + '\n' + + 'query = ' + u.query + '\n' + + 'hash = ' + u.hash + ); + +// Manipulating URL parts +u.path = '/some/new/path'; // the way to change URL path +u.protocol = 'https' // the way to force https protocol on the source URL + +// inject into string +var str = 'My Cool Link'; + +// or use in DOM context +var a = document.createElement('a'); +a.href = u; +a.innerHTML = 'test'; +document.body.appendChild(a); + +// Stringify +u += ''; +String(u); +u.toString(); +// NOTE, that usually it will be done automatically, so only in special +// cases direct stringify is required \ No newline at end of file diff --git a/jsurl/jsurl.d.ts b/jsurl/jsurl.d.ts new file mode 100644 index 0000000000..a5f7902578 --- /dev/null +++ b/jsurl/jsurl.d.ts @@ -0,0 +1,18 @@ +// Type definitions for jsurl 1.2.2 +// Project: https://github.com/Mikhus/jsurl +// Definitions by: Alexey Gorshkov +// Definitions: https://github.com/agorshkov23/DefinitelyTyped + +declare class Url { + constructor(url?: string); + query: any; + protocol: string; + user: string; + pass: string; + host: string; + port: string; + path: string; + hash: string; + href: string; + toString(): string; +} \ No newline at end of file From eaf505ec376a948681f7bae7d3557f793b9787cb Mon Sep 17 00:00:00 2001 From: Dustin Wehr Date: Mon, 15 Jun 2015 13:35:40 -0400 Subject: [PATCH 0003/1680] type defs for debug() and newInMemoryDocument() --- .../google-drive-realtime-api.d.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/google-drive-realtime-api/google-drive-realtime-api.d.ts b/google-drive-realtime-api/google-drive-realtime-api.d.ts index 95f239a349..8d549355db 100644 --- a/google-drive-realtime-api/google-drive-realtime-api.d.ts +++ b/google-drive-realtime-api/google-drive-realtime-api.d.ts @@ -483,6 +483,36 @@ declare module gapi.drive.realtime { saveAs(fileId:string) : void; } + + // INCOMPLETE + // https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime.Error + export class Error { } + + // Complete + // Opens the debugger application on the current page. The debugger shows all realtime documents that the + // page has loaded and is able to view, edit and debug all aspects of each realtime document. + export function debug() : void; + + /* Creates a new file with fake network communications. This file will not talk to the server and will only + exist in memory for as long as the browser session persists. + https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime#.newInMemoryDocument + @Param opt_onLoaded {function(non-null gapi.drive.realtime.Document)} + A callback that will be called when the realtime document is ready. The created or opened realtime document + object will be passed to this function. + + @Param opt_initializerFn {function(non-null gapi.drive.realtime.Model)} + An optional initialization function that will be called before onLoaded only the first time that the document + is loaded. The document's gapi.drive.realtime.Model object will be passed to this function. + + @Param opt_errorFn {function(non-null gapi.drive.realtime.Error)} + An optional error handling function that will be called if an error occurs while the document is being + loaded or edited. A gapi.drive.realtime.Error object describing the error will be passed to this function. + */ + export function newInMemoryDocument( + opt_onLoaded? : (d:Document) => void, + opt_initializerFn? : (m:Model) => void, + opt_errorFn? : (e:gapi.drive.realtime.Error) => void + ) : Document; } From 1c4dd1d54fa50115c605b514d13fc083ef130a1c Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Fri, 24 Jul 2015 11:43:24 +0200 Subject: [PATCH 0004/1680] Add introjs definition --- introjs/introjs-tests.ts | 54 +++++++++++++++++++++++++++++++ introjs/introjs.d.ts | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 introjs/introjs-tests.ts create mode 100644 introjs/introjs.d.ts diff --git a/introjs/introjs-tests.ts b/introjs/introjs-tests.ts new file mode 100644 index 0000000000..151222d47d --- /dev/null +++ b/introjs/introjs-tests.ts @@ -0,0 +1,54 @@ +/// + +var intro = introJs(); + +intro.setOption('doneLabel', 'Next page'); +intro.setOptions({ + steps: [ + { + intro: "Hello world!" + }, + { + element: document.querySelector('#step1'), + intro : "This is a tooltip." + }, + { + element : document.querySelectorAll('#step2')[0], + intro : "Ok, wasn't that fun?", + position: 'right' + }, + { + element : '#step3', + intro : 'More features, more fun.', + position: 'left' + }, + { + element : '#step4', + intro : "Another step.", + position: 'bottom' + }, + { + element: '#step5', + intro : 'Get it, use it.' + } + ] +}); + +intro.start() + .nextStep() + .previousStep() + .goToStep(2) + .exit() + .refresh() + .onbeforechange(function (element) { + element.getAttribute('class'); + }) + .onafterchange(function (element) { + element.getAttribute('class'); + }) + .onchange(function () { + alert('Changed'); + }) + .oncomplete(function () { + alert('Done'); + }); diff --git a/introjs/introjs.d.ts b/introjs/introjs.d.ts new file mode 100644 index 0000000000..f74733c5e3 --- /dev/null +++ b/introjs/introjs.d.ts @@ -0,0 +1,70 @@ +// Type definitions for intro.js +// Project: https://github.com/usablica/intro.js +// Definitions by: Maxime Fabre +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module IntroJs { + enum Positions { + top, + left, + right, + bottom + } + + interface Step { + intro: string; + element?: string|HTMLElement; + position?: Positions; + } + + interface Options { + nextLabel?: string; + prevLabel?: string; + skipLabel?: string; + doneLabel?: string; + tooltipPosition?: string; + tooltipClass?: string; + highlightClass?: string; + exitOnEsc?: boolean; + exitOnOverlayClick?: boolean; + showStepNumbers?: boolean; + keyboardNavigation?: boolean; + showButtons?: boolean; + showBullets?: boolean; + showProgress?: boolean; + scrollToElement?: boolean; + overlayOpacity?: number; + positionPrecedence?: string[]; + disableInteraction?: boolean; + steps: Step[]; + } + + interface IntroJs { + start(): IntroJs; + exit(): IntroJs; + + goToStep(step: number): IntroJs; + nextStep(): IntroJs; + previousStep(): IntroJs; + + refresh(): IntroJs; + + setOption(option: string, value: string|number): IntroJs; + setOptions(options: Options): IntroJs; + + onexit(callback: Function): IntroJs; + onbeforechange(callback: (element: HTMLElement) => any): IntroJs; + onafterchange(callback: (element: HTMLElement) => any): IntroJs; + onchange(callback: Function): IntroJs; + oncomplete(callback: Function): IntroJs; + } + + interface Factory { + (element?: string): IntroJs; + } +} + +declare var introJs: IntroJs.Factory; +declare module 'intro.js' { + export = IntroJs; +} From 1890b86fee132877a507bdae615d37c044bc88c4 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Fri, 24 Jul 2015 13:40:06 +0200 Subject: [PATCH 0005/1680] Add version to header --- introjs/introjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/introjs/introjs.d.ts b/introjs/introjs.d.ts index f74733c5e3..d54a5456ef 100644 --- a/introjs/introjs.d.ts +++ b/introjs/introjs.d.ts @@ -1,4 +1,4 @@ -// Type definitions for intro.js +// Type definitions for intro.js 1.0.0 // Project: https://github.com/usablica/intro.js // Definitions by: Maxime Fabre // Definitions: https://github.com/borisyankov/DefinitelyTyped From c1e7392f397fa3901d3b67cedf711058bcb2d698 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Tue, 28 Jul 2015 17:16:35 +0200 Subject: [PATCH 0006/1680] Rename files --- introjs/introjs-tests.ts => intro.js/intro.js-tests.ts | 0 introjs/introjs.d.ts => intro.js/intro.js.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename introjs/introjs-tests.ts => intro.js/intro.js-tests.ts (100%) rename introjs/introjs.d.ts => intro.js/intro.js.d.ts (100%) diff --git a/introjs/introjs-tests.ts b/intro.js/intro.js-tests.ts similarity index 100% rename from introjs/introjs-tests.ts rename to intro.js/intro.js-tests.ts diff --git a/introjs/introjs.d.ts b/intro.js/intro.js.d.ts similarity index 100% rename from introjs/introjs.d.ts rename to intro.js/intro.js.d.ts From 733c28850d96ddeb6cf181be1d5c0006d3ffc589 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Thu, 6 Aug 2015 10:11:40 +0200 Subject: [PATCH 0007/1680] Fix reference in test --- intro.js/intro.js-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index 151222d47d..b49eb5078e 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -1,4 +1,4 @@ -/// +/// var intro = introJs(); From 6ed8a559b50507a8e974a5c7528310d5cdc9db63 Mon Sep 17 00:00:00 2001 From: Luuk Date: Sun, 13 Sep 2015 23:04:38 +0200 Subject: [PATCH 0008/1680] Added Safari extension TypeScript definitions --- safari/safari-content-tests.ts | 64 +++++ safari/safari-content.d.ts | 110 ++++++++ safari/safari-tests.ts | 159 ++++++++++++ safari/safari.d.ts | 457 +++++++++++++++++++++++++++++++++ 4 files changed, 790 insertions(+) create mode 100644 safari/safari-content-tests.ts create mode 100644 safari/safari-content.d.ts create mode 100644 safari/safari-tests.ts create mode 100644 safari/safari.d.ts diff --git a/safari/safari-content-tests.ts b/safari/safari-content-tests.ts new file mode 100644 index 0000000000..b58735b9d0 --- /dev/null +++ b/safari/safari-content-tests.ts @@ -0,0 +1,64 @@ +/// + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingExtensionToolbars/AddingExtensionToolbars.html#//apple_ref/doc/uid/TP40009977-CH5-SW7 +var theBody = document.body; +// create a para and insert it at the top of the body +var element = document.createElement("p"); +element.id = "status"; +element.style.cssText = "float:right; color:red"; +element.textContent = "Waiting..."; +theBody.insertBefore(element, theBody.firstChild); + +function replyToMessage(aMessageEvent: SafariExtensionMessageEvent) { + if (aMessageEvent.name === "hey") { + document.getElementById("status").textContent="Message received."; + safari.self.tab.dispatchMessage("gotIt","Message acknowledged."); + } +} +// register for message events +safari.self.addEventListener("message", replyToMessage, false); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingContextualMenuItems/AddingContextualMenuItems.html#//apple_ref/doc/uid/TP40009977-CH4-SW15 +document.addEventListener("contextmenu", handleContextMenu, false); + +function handleContextMenu(event: MouseEvent) { + safari.self.tab.setContextMenuEventUserInfo(event, (event.target).nodeName); +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingContextualMenuItems/AddingContextualMenuItems.html#//apple_ref/doc/uid/TP40009977-CH4-SW16 +document.addEventListener("contextmenu", handleContextMenu2, false); + +function handleContextMenu2(event: MouseEvent) { + if ((event.target).nodeName == "VIDEO") { + event.preventDefault(); + } +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW2 +var initialVal=1; +var calculatedVal=0 ; + +function doBigCalc(theData: number) { + safari.self.tab.dispatchMessage("calcThis",theData); +} + +function getAnswer(theMessageEvent: SafariExtensionMessageEvent) { + if (theMessageEvent.name === "theAnswer") { + calculatedVal=theMessageEvent.message; + console.log(calculatedVal); + } +} +safari.self.addEventListener("message", getAnswer, false); + +doBigCalc(initialVal); + +//https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW9 +function isItOkay(event: BeforeLoadEvent) { + var myMessageData = event.url; + var theAnswer = safari.self.tab.canLoad(event, myMessageData); + if (theAnswer == "block") { + event.preventDefault(); + } +} + +document.addEventListener("beforeload", isItOkay, true); diff --git a/safari/safari-content.d.ts b/safari/safari-content.d.ts new file mode 100644 index 0000000000..3b0fead5ce --- /dev/null +++ b/safari/safari-content.d.ts @@ -0,0 +1,110 @@ +// Type definitions for Safari extension development (content-scripts) +// Project: https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/InjectingScripts/InjectingScripts.html#//apple_ref/doc/uid/TP40009977-CH6-SW1 +// Definitions by: Luuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Window { + safari: typeof safari; +} + +declare module safari { + export var extension: SafariContentExtension; + export var self: SafariContentWebPage; +} + +interface SafariEvent { + /** + * The type of the event. + * The string used to identify a particular type of event is documented in the reference for that class. + */ + type: string; + + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariEventTarget; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariEventTarget; + + /** + * The time and date that the event was created. + */ + timestamp: number; + + /** + * The event-handling phase that the event is in. + * The values for this property are the same as the values used by Webkit to identify the event-handling phases. + */ + eventPhase: number; + + /** + * A Boolean value that indicates whether the event goes through the bubbling phase. + */ + bubbles: boolean; + + /** + * A Boolean value that indicates whether the event can be canceled. + */ + cancelable: boolean; + + /** + * A Boolean value that indicates whether the event’s default action has been prevented. + */ + defaultPrevented: boolean; + + /** + * Prevents the event from any further propagation. + * Propagation can be stopped only fon cancelable events. After propagation is stopped, the event is not sent to any other targets. + */ + stopPropagation() : void; + + /** + * Prevents the browser from performing the default action for an event. + * Use this method to indicate that your extension has already fully handled the event; you don’t want the browser to do anything. Note that preventing the default action does not stop an event from propagating. + */ + preventDefault(): void; +} + +interface SafariExtensionMessageEvent extends SafariEvent { + /** + * The name of the message. + */ + name: string; + + /** + * The message data. + */ + message: any; +} + +interface SafariEventListener extends Function { + (event: SafariEvent): any; +} + +interface SafariEventTarget { + addEventListener(type: string, listener: SafariEventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: SafariEventListener, useCapture?: boolean): void; +} + +interface SafariContentExtension { + baseURI: string; +} + +interface SafariContentWebPage extends SafariEventTarget { + tab: SafariContentBrowserTabProxy; +} + +interface SafariContentBrowserTabProxy { + canLoad(event: any, message: any): any; + dispatchMessage(name: string, message?: any): void; + setContextMenuEventUserInfo(event: MouseEvent, userInfo: any): void; +} + +interface BeforeLoadEvent extends Event { + url: string; +} \ No newline at end of file diff --git a/safari/safari-tests.ts b/safari/safari-tests.ts new file mode 100644 index 0000000000..b4e5cfd603 --- /dev/null +++ b/safari/safari-tests.ts @@ -0,0 +1,159 @@ +/// + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AccessingResourcesWithinYourExtensionFolder/AccessingResourcesWithinYourExtensionFolder.html#//apple_ref/doc/uid/TP40009977-CH18-SW2 +var img = document.createElement("img"); +img.src = safari.extension.baseURI + 'Images/myImage.png' + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingExtensionToolbars/AddingExtensionToolbars.html#//apple_ref/doc/uid/TP40009977-CH5-SW2 +const bars = safari.extension.bars; +const activeBrowserWindow = safari.application.activeBrowserWindow; +for (var i = 0; i < bars.length; ++i) { + var bar = bars[i]; + if (bar.browserWindow === activeBrowserWindow && bar.identifier === "Audio Controls") { + /* Do something. */ + } +} + + +var server = "http://developer.apple.com/"; +var reflib = "safari/library/documentation/AppleApplications/Reference/" +function openInTab(source: string) { + var newTab = (safari.self).browserWindow.openTab(); + newTab.url = source; +} + +function sendMessage() { + document.getElementById("textField").innerHTML = "Sending message..."; + safari.application.activeBrowserWindow.activeTab.page.dispatchMessage("hey", "there"); +} + +function respondToMessage(messageEvent: SafariExtensionMessageEvent) { + if (messageEvent.name === "gotIt") + document.getElementById("textField").innerHTML = messageEvent.message; +} + +(safari.self).browserWindow.addEventListener("message", respondToMessage, false); + +const myBars = safari.extension.bars; +function updateAllBars() { + for (var i = 0; i < myBars.length; ++i) { + var barWindow = myBars[i].contentWindow; + barWindow.doSomething(); + var myWindow = safari.application.activeBrowserWindow; + if (myBars[i].browserWindow == myWindow) { + barWindow.doSomethingSpecial(); + } + } +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingaGlobalHTMLPage/AddingaGlobalHTMLPage.html#//apple_ref/doc/uid/TP40009977-CH16-SW2 +const myGlobal: any = safari.extension.globalPage.contentWindow; + +function doButton() { + myGlobal.calcThis(myGlobal.theAnswer); + var mButton = document.getElementById("myButton"); + mButton.value = ("Increment " + myGlobal.theAnswer); +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingButtonstotheMainSafariToolbar/AddingButtonstotheMainSafariToolbar.html#//apple_ref/doc/uid/TP40009977-CH3-SW12 +var itemArray = safari.extension.toolbarItems; +for (var i = 0; i < itemArray.length; ++i) { + var item = itemArray[i]; + if (item.identifier == "my lovely button") { + /* Do something. */ + } +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingButtonstotheMainSafariToolbar/AddingButtonstotheMainSafariToolbar.html#//apple_ref/doc/uid/TP40009977-CH3-SW8 +function performCommand(event: SafariCommandEvent) { + if (event.command === "reload-page") { + var currentURL = (event.target).browserWindow.activeTab.url; + if (currentURL) + (event.target).browserWindow.activeTab.url = currentURL; + } +} + +function validateCommand(event: SafariValidateEvent) { + if (event.command === "reload-page") { + // Disable the button if there is no URL loaded in the tab. + (event.target).disabled = !(event.target).browserWindow.activeTab.url; + } +} + +// if event handlers are in the global HTML page, +// register with application: +safari.application.addEventListener("command", performCommand, false); +safari.application.addEventListener("validate", validateCommand, false); +// if event handlers are in an extension bar, +// register with parent window: +(safari.self).browserWindow.addEventListener("command", performCommand, false); +(safari.self).browserWindow.addEventListener("validate", validateCommand, false); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingExtensionMenus/AddingExtensionMenus.html#//apple_ref/doc/uid/TP40009977-CH20-SW8 +var myMenu = safari.extension.createMenu("menuId"); +safari.extension.removeMenu("menuId"); +myMenu.removeMenuItem(0); +myMenu.appendMenuItem("identifier", "title"); +myMenu.insertMenuItem(1, "identifier", "title"); +myMenu.appendSeparator("identifier"); +myMenu.insertSeparator(1, "identifier"); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingPopovers/AddingPopovers.html#//apple_ref/doc/uid/TP40009977-CH21-SW7 +var validateHandler = (event: SafariValidateEvent) => { + if ((event.target).identifier !== "myToolbarItemID") return; +}; +var popoverHandler = (event: SafariEvent) => { + if ((event.target).identifier !== "myToolbarItemID") return; +}; +safari.application.addEventListener("validate", validateHandler, true); +safari.application.addEventListener("popover", popoverHandler, true); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingPopovers/AddingPopovers.html#//apple_ref/doc/uid/TP40009977-CH21-SW8 +var width = 400; +var height = 400; +var myPop = safari.extension.createPopover("myPopoverID", safari.extension.baseURI + "myFile.html", width, height); + +var myToolbarItem = safari.extension.toolbarItems[0]; +myToolbarItem.popover = myPop; +myToolbarItem.popover = null; +safari.extension.removePopover("myPopoverID"); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingContextualMenuItems/AddingContextualMenuItems.html#//apple_ref/doc/uid/TP40009977-CH4-SW17 +safari.application.addEventListener("contextmenu", handleContextMenu, false); + +function handleContextMenu(event: SafariExtensionContextMenuEvent) { + if (event.userInfo === "IMG") { + event.contextMenu.appendContextMenuItem("enlarge", "Enlarge Item"); + } +} + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/MessagesandProxies/MessagesandProxies.html#//apple_ref/doc/uid/TP40009977-CH14-SW2 +function bigCalc(startVal: number, event: SafariExtensionMessageEvent) { + // imagine hundreds of lines of code here... + var endVal = startVal + 2; + // return to sender + (event.target).page.dispatchMessage("theAnswer", endVal); +} + +function respondToMessage2(theMessageEvent: SafariExtensionMessageEvent) { + if (theMessageEvent.name === "calcThis") { + var startVal = theMessageEvent.message; + bigCalc(startVal, theMessageEvent); + } +} + +safari.application.addEventListener("message", respondToMessage2, false); + +// https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/ExtensionSettings/ExtensionSettings.html#//apple_ref/doc/uid/TP40009977-CH11-SW13 +var myVolume: number; +function volumeChanged(event: SafariExtensionSettingsChangeEvent) { + if (event.key == "volume") { + myVolume = event.newValue; + } +} + +safari.extension.settings.addEventListener("change", volumeChanged, false); +safari.extension.settings["volume"] = myVolume; +safari.extension.settings.setItem("volume", myVolume); +safari.extension.secureSettings["volume"] = myVolume; +safari.extension.secureSettings.setItem("volume", myVolume); \ No newline at end of file diff --git a/safari/safari.d.ts b/safari/safari.d.ts new file mode 100644 index 0000000000..621bcc8245 --- /dev/null +++ b/safari/safari.d.ts @@ -0,0 +1,457 @@ +// Type definitions for Safari extension development +// Project: https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009977-CH1-SW1 +// Definitions by: Luuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Window { + safari: typeof safari; +} + +declare module safari { + export var application: SafariApplication; + export var extension: SafariExtension; + export var self: SafariExtensionGlobalPage | SafariExtensionBar; +} + +interface SafariEvent { + /** + * The type of the event. + * The string used to identify a particular type of event is documented in the reference for that class. + */ + type: string; + + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariEventTarget; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariEventTarget; + + /** + * The time and date that the event was created. + */ + timestamp: number; + + /** + * The event-handling phase that the event is in. + * The values for this property are the same as the values used by Webkit to identify the event-handling phases. + */ + eventPhase: number; + + /** + * A Boolean value that indicates whether the event goes through the bubbling phase. + */ + bubbles: boolean; + + /** + * A Boolean value that indicates whether the event can be canceled. + */ + cancelable: boolean; + + /** + * A Boolean value that indicates whether the event’s default action has been prevented. + */ + defaultPrevented: boolean; + + /** + * Prevents the event from any further propagation. + * Propagation can be stopped only fon cancelable events. After propagation is stopped, the event is not sent to any other targets. + */ + stopPropagation() : void; + + /** + * Prevents the browser from performing the default action for an event. + * Use this method to indicate that your extension has already fully handled the event; you don’t want the browser to do anything. Note that preventing the default action does not stop an event from propagating. + */ + preventDefault(): void; +} + +interface SafariEventListener extends Function { + (event: SafariEvent): any; +} + +interface SafariEventTarget { + addEventListener(type: string, listener: SafariEventListener, useCapture?: boolean): void; + removeEventListener(type: string, listener: SafariEventListener, useCapture?: boolean): void; +} + +interface SafariBrowserWindow extends SafariEventTarget { + tabs: Array; + visible: boolean; + activeTab: SafariBrowserTab; + + activate(): void; + close(): void; + + /** + * Opens a new tab in the window. + * Available in Safari 5.0 and later. + * @param visibility Either foreground if the tab should be opened in the foreground, or background if it should be opened in the background. + * @param index The desired location of the new tab. + * @returns A new tab. + */ + openTab (visibility?: string, index?: number): SafariBrowserTab; + insertTab(tab: SafariBrowserTab, index: number): SafariBrowserTab; +} + +interface SafariBrowserTab extends SafariEventTarget { + browserWindow: SafariBrowserWindow; + reader: SafariReader; + + /** + * The tab’s current title. + * The tab’s title is the same as the title of the webpage in most cases. For example, the title of the webpage may be truncated for display, but the value of this property is not truncated. + * Available in Safari 5.0 and later. + */ + title: string; + page: SafariWebPageProxy; + + /** + * The URL loaded in this tab. + * Setting this attribute to a new value loads the page at the new URL in the tab. + * Available in Safari 5.0 and later. + */ + url: string; + + visibleContentsAsDataURL(): string; + activate(): void; + close(): void; +} + +interface SafariReader extends SafariEventTarget { + available: boolean; + tab: SafariBrowserTab; + visible: boolean; + + enter(): void; + exit(): void; + dispatchMessage (name: string, message?: any): void; +} + +interface SafariWebPageProxy { + dispatchMessage (name: string, message?: any): void; +} + +interface SafariExtensionGlobalPage { + contentWindow: Window; +} + +interface SafariExtensionPopover extends SafariEventTarget { + identifier: string; + visible: boolean; + + contentWindow: Window; + height: number; + width: number; + + hide(): void; +} + +interface SafariExtensionMenu { + identifier: string; + menuItems: Array; + visible: boolean; + + appendMenuItem (identifier: string, title: string, command?: string): SafariExtensionMenuItem; + appendSeparator (identifier: string): SafariExtensionMenuItem; + insertMenuItem (index: number, identifier: string, title: string, command?: string): SafariExtensionMenuItem; + insertSeparator (index: number, identifier: string): SafariExtensionMenuItem; + removeMenuItem (index: number): void; +} + +interface SafariExtensionMenuItem extends SafariEventTarget { + command: string; + identifier: string; + separator: boolean; + title: string; + image: string; + submenu: SafariExtensionMenu; + + visible: boolean; + disabled: boolean; + checkedState: number; +} + +interface SafariExtensionSettings extends SafariEventTarget { + [index: string]: any; + [index: number]: any; + getItem(key: string): any; + setItem(key: string, value: any): void; + removeItem(key: string): void; + clear(): void; +} + +interface SafariExtensionSecureSettings extends SafariEventTarget { + [index: string]: any; + getItem(key: string): any; + setItem(key: string, value: any): void; + removeItem(key: string): void; + clear(): void; +} + +interface SafariExtensionBar extends SafariEventTarget { + identifier: string; + label: string; + visible: boolean; + browserWindow: SafariBrowserWindow; + contentWindow: Window; + + hide(doNotRemember?: boolean): void; + show(doNotRemember?: boolean): void; +} + +interface SafariExtensionToolbarItem extends SafariEventTarget { + + /** + * The current badge number. + */ + badge: number; + + /** + * The URL of the current image. + */ + image: string; + + /** + * The label of the toolbar item, as shown in the toolbar’s overflow menu. + */ + label: string; + + /** + * The label of the toolbar item, as shown in the Customize palette. + * This attribute is optional; its value defaults to the value of label. + */ + paletteLabel: string; + + /** + * The tooltip (help tag) of the toolbar item. + * This attribute is optional; its value defaults to the value of label. + */ + toolTip: string; + menu: SafariExtensionMenu; + popover: SafariExtensionPopover; + browserWindow: SafariBrowserWindow; + command: string; + disabled: boolean; + identifier: string; + + showMenu(): void; + showPopover(): void; + validate(): void; +} + +interface SafariPrivateBrowsing { + enabled: boolean; +} + +interface SafariExtension { + bars: Array; + baseURI: string; + globalPage: SafariExtensionGlobalPage; + toolbarItems: Array; + + displayVersion: string; + bundleVersion: string; + + menus: Array; + createMenu (identifier: string): SafariExtensionMenu; + removeMenu (identifier: string): void; + + popovers: Array; + createPopover(identifier: string, url: string, width?: number, height?: number): SafariExtensionPopover; + removePopover(identifier: string): void; + + addContentScript (source: string, whitelist: Array, blacklist: Array, runAtEnd: boolean): string; + addContentScriptFromURL (url: string, whitelist: Array, blacklist: Array, runAtEnd: boolean): string; + addContentStyleSheet (source: string, whitelist: Array, blacklist: Array): string; + addContentStyleSheetFromURL (url: string, whitelist: Array, blacklist: Array): string; + removeContentScript(url: string): void; + removeContentScripts(): void; + removeContentStyleSheet(url: string): void; + removeContentStyleSheets(): void; + + settings: SafariExtensionSettings; + secureSettings: SafariExtensionSecureSettings; +} + +interface SafariApplication extends SafariEventTarget { + activeBrowserWindow: SafariBrowserWindow; + browserWindows: Array; + privateBrowsing: SafariPrivateBrowsing; + openBrowserWindow(): SafariBrowserWindow; +} + +interface SafariExtensionContextMenuEvent extends SafariEvent { + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariExtensionContextMenuItem; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariExtensionContextMenuItem; + + /** + * Information about the current context menu event. + */ + userInfo: any; + + /** + * The context menu being built up. + */ + contextMenu: SafariExtensionContextMenu; +} + +interface SafariExtensionContextMenu { + /** + * Returns a list of the context menu items from this extension. + * Only menu items from your extension are returned. + */ + contextMenuItems: any[]; + + /** + * Appends a menu item to the contextual menu. + * If another menu item with the same identifier already exists, it is removed before appending the menu item. If command is not supplied, identifier is used as the command identifier. + * @param identifier The unique identifier of the menu item. + * @param title The title of the menu item. + * @param command The command identifier that the context menu item sends when activated. + * @returns The context menu item that was appended. + */ + appendContextMenuItem (identifier: string, title: string, command?: string) : SafariExtensionContextMenuItem; + + /** + * Inserts a menu item at a specific index in the contextual menu. + * If another menu item with the same identifier already exists, it is removed before appending the menu item. If command is not supplied, identifier is used as the command identifier. + * @param index The index where the menu item is being inserted. + * @param identifier The unique identifier of the menu item. + * @param title The title of the menu item. + * @param command The command identifier that the context menu item sends when activated. + * @returns The context menu item that was inserted. + */ + insertContextMenuItem (index: number, identifier: string, title: string, command?: string): SafariExtensionContextMenuItem; +} + +interface SafariExtensionContextMenuItem extends SafariEventTarget { + /** + * The command identifier that the context menu item sends when activated. + * Setting an empty string, null, or undefined has no effect. + */ + command: string; + + /** + * A Boolean value that indicates whether a context menu item is disabled. + * Disabled menu items are not displayed in the context menu. + */ + disabled: boolean; + + /** + * The unique identifier of the context menu item. + */ + identifier: string; + + /** + * The title displayed in the context menu. + */ + title: string; +} + +interface SafariValidateEvent extends SafariEvent { + /** + * The command identifier of the target being validated. + */ + command: string; +} + +interface SafariExtensionContextMenuItemValidateEvent { + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariExtensionContextMenuItem; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariExtensionContextMenuItem; + + /** + * Information about the current context menu event. + */ + userInfo: any; +} + +interface SafariCommandEvent extends SafariEvent { + /** + * The command identifier of the target being dispatched. + */ + command: string; +} + +interface SafariExtensionContextMenuItemCommandEvent extends SafariCommandEvent { + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariExtensionContextMenuItem; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariExtensionContextMenuItem; + + /** + * The user info object for this context menu event. + */ + userInfo: any; +} + +interface SafariExtensionSettingsChangeEvent extends SafariEvent { + /** + * The target of the event. + * This attribute stays the same as the event moves through the event-dispatch hierarchy. Its value is the same as the object that the event is sent to during the targeting phase. + */ + target: SafariExtensionSettings|SafariExtensionSecureSettings; + + /** + * The object that the event is currently being sent to. + * This attribute varies as the event progresses through the phases, changing as the event moves through the event-dispatch hierarchy. + */ + currentTarget: SafariExtensionSettings|SafariExtensionSecureSettings; + + /** + * The key identifier of the setting that was changed. + */ + key: string; + + /** + * The value before the settings change. + */ + oldValue: any; + + /** + * The value after the settings change. + */ + newValue: any; +} + +interface SafariExtensionMessageEvent extends SafariEvent { + /** + * The name of the message. + */ + name: string; + + /** + * The message data. + */ + message: any; +} \ No newline at end of file From e4ff04e164e36ee9a9de52268be208f4a162c36e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Mon, 14 Sep 2015 10:56:09 +0200 Subject: [PATCH 0009/1680] added polymer ts definition --- polymer-ts/polymer-ts.d.ts | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 polymer-ts/polymer-ts.d.ts diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts new file mode 100644 index 0000000000..4f44de6d28 --- /dev/null +++ b/polymer-ts/polymer-ts.d.ts @@ -0,0 +1,127 @@ +declare module polymer { + class PolymerBase extends HTMLElement { + $: any; + $$: any; + root: HTMLElement; + shadyRoot: HTMLElement; + style: CSSStyleDeclaration; + customStyle: { + [property: string]: string; + }; + arrayDelete(path: string, item: string | any): any; + async(callback: Function, waitTime?: number): any; + attachedCallback(): void; + attributeFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + cancelAsync(handle: number): void; + cancelDebouncer(jobName: string): void; + classFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; + create(tag: string, props: Object): any; + debounce(jobName: string, callback: Function, wait?: number): void; + deserialize(value: string, type: any): any; + distributeContent(): void; + domHost(): void; + elementMatches(selector: string, node: Element): any; + fire(type: string, detail?: Object, options?: FireOptions): any; + flushDebouncer(jobName: string): void; + get(path: string | Array): any; + getContentChildNodes(slctr: string): any; + getContentChildren(slctr: string): any; + getNativePrototype(tag: string): any; + getPropertyInfo(property: string): any; + importHref(href: string, onload?: Function, onerror?: Function): any; + instanceTemplate(template: any): any; + isDebouncerActive(jobName: string): any; + linkPaths(to: string, from: string): void; + listen(node: Element, eventName: string, methodName: string): void; + mixin(target: Object, source: Object): void; + notifyPath(path: string, value: any, fromAbove?: any): void; + pop(path: string): any; + push(path: string, value: any): any; + reflectPropertyToAttribute(name: string): void; + resolveUrl(url: string): any; + scopeSubtree(container: Element, shouldObserve: boolean): void; + serialize(value: string): any; + serializeValueToAttribute(value: any, attribute: string, node: Element): void; + set(path: string, value: any, root?: Object): any; + setScrollDirection(direction: string, node: HTMLElement): void; + shift(path: string, value: any): any; + splice(path: string, start: number, deleteCount: number): any; + toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void; + toggleClass(name: string, bool: boolean, node?: HTMLElement): void; + transform(transform: string, node?: HTMLElement): void; + translate3d(x: any, y: any, z: any, node?: HTMLElement): void; + unlinkPaths(path: string): void; + unshift(path: string, value: any): any; + updateStyles(): void; + } + interface dom { + (node: HTMLElement): HTMLElement; + (node: polymer.Base): HTMLElement; + flush(): any; + } + interface FireOptions { + node?: HTMLElement | polymer.Base; + bubbles?: boolean; + cancelable?: boolean; + } + interface Element { + properties?: Object; + listeners?: Object; + behaviors?: Object[]; + observers?: String[]; + factoryImpl?(...args: any[]): void; + ready?(): void; + created?(): void; + attached?(): void; + detached?(): void; + attributeChanged?(attrName: string, oldVal: any, newVal: any): void; + prototype?: Object; + } + interface PolymerTSElement { + $custom_cons?: FunctionConstructor; + $custom_cons_args?: any[]; + template?: string; + style?: string; + } + interface Property { + name?: string; + type?: any; + value?: any; + reflectToAttribute?: boolean; + readonly?: boolean; + notify?: boolean; + computed?: string; + observer?: string; + } + class Base extends polymer.PolymerBase implements polymer.Element { + static create(...args: any[]): T; + static register(): void; + is: string; + } + function createEs6PolymerBase(): void; + function prepareForRegistration(elementClass: Function): polymer.Element; + function createDomModule(definition: polymer.Element): void; + function createElement(element: new (...args: any[]) => T): new (...args: any[]) => T; + function createClass(element: new (...args: any[]) => T): new (...args: any[]) => T; + function isRegistered(element: polymer.Element): boolean; +} +declare var Polymer: { + (prototype: polymer.Element): FunctionConstructor; + Class(prototype: polymer.Element): Function; + dom: polymer.dom; + appendChild(node: HTMLElement): HTMLElement; + insertBefore(node: HTMLElement, beforeNode: HTMLElement): HTMLElement; + removeChild(node: HTMLElement): HTMLElement; + updateStyles(): void; + Base: any; +}; +declare function component(tagname: string, extendsTag?: string): (target: Function) => void; +declare function extend(tagname: string): (target: Function) => void; +declare function template(templateString: string): (target: Function) => void; +declare function style(styleString: string): (target: Function) => void; +declare function hostAttributes(attributes: Object): (target: Function) => void; +declare function property(ob?: polymer.Property): (target: polymer.Element, propertyKey: string) => void; +declare function computed(ob?: polymer.Property): (target: polymer.Element, computedFuncName: string) => void; +declare function listen(eventName: string): (target: polymer.Element, propertyKey: string) => void; +declare function behavior(behaviorObject: any): any; +declare function observe(observedProps: string): (target: polymer.Element, observerFuncName: string) => void; From da0bddb559bd1dc599237a0fbc808d45bb71ad87 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:33:30 +0200 Subject: [PATCH 0010/1680] added backbone local storage def --- .../backbone.localStorage.d.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts new file mode 100644 index 0000000000..b0a554828e --- /dev/null +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -0,0 +1,46 @@ + + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + declare class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(); + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id): string; + }; +} + +export Store = Backbone.LocalStorage; + From ea76cec95c4f1698cda13ae5f0393eb30dcbc178 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:40:41 +0200 Subject: [PATCH 0011/1680] wrong version committed --- backbone.localStorage/backbone.localStorage.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index b0a554828e..e0af97e1d2 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,12 +1,11 @@ - declare module Backbone { interface Serializer { serialize(item: any): any; deserialize(data: any): any; } - declare class LocalStorage { + class LocalStorage { name: string; serializer: Serializer; records: string[]; @@ -39,8 +38,8 @@ declare module Backbone { _storageSize(): number; _itemName(id): string; - }; + } } -export Store = Backbone.LocalStorage; +import Store = Backbone.LocalStorage; From 581d094508cb40e4b571e2027142d5dd6134722e Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:44:37 +0200 Subject: [PATCH 0012/1680] added def typed header comments --- backbone.localStorage/backbone.localStorage.d.ts | 6 ++++++ polymer-ts/polymer-ts.d.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index e0af97e1d2..5696fa3d9f 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -1,3 +1,9 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare module Backbone { interface Serializer { diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index 4f44de6d28..cd96dfe21a 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,3 +1,8 @@ +// Type definitions for PolymerTS 0.1.17 +// Project: https://github.com/nippur72/PolymerTS +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module polymer { class PolymerBase extends HTMLElement { $: any; From 99a76bb80179d43f48d5e942257135e41ddc4781 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Fri, 18 Sep 2015 16:46:49 +0200 Subject: [PATCH 0013/1680] fixed implicit any --- backbone.localStorage/backbone.localStorage.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts index 5696fa3d9f..122c475876 100644 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ b/backbone.localStorage/backbone.localStorage.d.ts @@ -18,7 +18,7 @@ declare module Backbone { constructor(name: string, serializer?: Serializer); - save(); + save(): void; // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already // have an id of it's own. @@ -43,7 +43,7 @@ declare module Backbone { _storageSize(): number; - _itemName(id): string; + _itemName(id: any): string; } } From 8088f834010654f82033838c8baabc1b35c285e9 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:17:47 +0200 Subject: [PATCH 0014/1680] deleted for rename --- .../backbone.localStorage.d.ts | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 backbone.localStorage/backbone.localStorage.d.ts diff --git a/backbone.localStorage/backbone.localStorage.d.ts b/backbone.localStorage/backbone.localStorage.d.ts deleted file mode 100644 index 122c475876..0000000000 --- a/backbone.localStorage/backbone.localStorage.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for backbone.localStorage 1.0.0 -// Project: https://github.com/jeromegn/Backbone.localStorage -// Definitions by: Louis Grignon -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module Backbone { - interface Serializer { - serialize(item: any): any; - deserialize(data: any): any; - } - - class LocalStorage { - name: string; - serializer: Serializer; - records: string[]; - - constructor(name: string, serializer?: Serializer); - - save(): void; - - // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already - // have an id of it's own. - create(model: any): any; - - // Update a model by replacing its copy in `this.data`. - update(model: any): any; - - // Retrieve a model from `this.data` by id. - find(model: any): any; - - // Return the array of all models currently in storage. - findAll(): any; - - // Delete a model from `this.data`, returning it. - destroy(model: T): T; - - localStorage(): any; - - // Clear localStorage for specific collection. - _clear(): void; - - _storageSize(): number; - - _itemName(id: any): string; - } -} - -import Store = Backbone.LocalStorage; - From 7f6349d245f67a5b56cf6c339a51bd80a293a359 Mon Sep 17 00:00:00 2001 From: lgrignon Date: Sun, 20 Sep 2015 10:20:47 +0200 Subject: [PATCH 0015/1680] renamed backbone.localStorage to backbone.localstorage --- .../backbone.localstorage.d.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backbone.localstorage/backbone.localstorage.d.ts diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts new file mode 100644 index 0000000000..122c475876 --- /dev/null +++ b/backbone.localstorage/backbone.localstorage.d.ts @@ -0,0 +1,51 @@ +// Type definitions for backbone.localStorage 1.0.0 +// Project: https://github.com/jeromegn/Backbone.localStorage +// Definitions by: Louis Grignon +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Backbone { + interface Serializer { + serialize(item: any): any; + deserialize(data: any): any; + } + + class LocalStorage { + name: string; + serializer: Serializer; + records: string[]; + + constructor(name: string, serializer?: Serializer); + + save(): void; + + // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already + // have an id of it's own. + create(model: any): any; + + // Update a model by replacing its copy in `this.data`. + update(model: any): any; + + // Retrieve a model from `this.data` by id. + find(model: any): any; + + // Return the array of all models currently in storage. + findAll(): any; + + // Delete a model from `this.data`, returning it. + destroy(model: T): T; + + localStorage(): any; + + // Clear localStorage for specific collection. + _clear(): void; + + _storageSize(): number; + + _itemName(id: any): string; + } +} + +import Store = Backbone.LocalStorage; + From 34cf33dfb4e42f4f5bb564afec15aa747aa2a6cb Mon Sep 17 00:00:00 2001 From: timramone Date: Sat, 26 Sep 2015 15:05:52 +0300 Subject: [PATCH 0016/1680] Make 'partial' generic --- underscore/underscore-tests.ts | 6 +- underscore/underscore.d.ts | 2302 +++++++++++++++++++++++++++++++- 2 files changed, 2294 insertions(+), 14 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 13410c23b8..c0817be705 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -169,6 +169,10 @@ var exclaim = function (statement) { return statement + "!"; }; var welcome = _.compose(exclaim, greet); welcome('moe'); +var partialApplicationTestFunction = (a: string, b: number, c: boolean, d: string, e: number, f: string) => { } +var partialApplicationResult = _.partial(partialApplicationTestFunction, "", 1); +var parametersCanBeStubbed = _.partial(partialApplicationResult, _, _, _, ""); + /////////////////////////////////////////////////////////////////////////////////////// _.keys({ one: 1, two: 2, three: 3 }); @@ -336,7 +340,7 @@ function chain_tests() { .flatten() .find(num => num % 2 == 0) .value(); - + var firstVal: number = _.chain([1, 2, 3]) .first() .value(); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 7dea66a84a..feca43620c 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -655,7 +655,7 @@ interface UnderscoreStatic { size(list: _.Collection): number; /** - * Split array into two arrays: + * Split array into two arrays: * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. * @param array Array to split in two. * @param iterator Filter iterator function for each element in `array`. @@ -1003,15 +1003,2291 @@ interface UnderscoreStatic { /** * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. - * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be - * pre-filled, but left open to supply at call-time. + * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be + * pre-filled, but left open to supply at call-time. * @param fn Function to partially fill in arguments. * @param arguments The partial arguments. * @return `fn` with partially filled in arguments. **/ - partial( - fn: Function, - ...arguments: any[]): Function; + + partial( + fn: { (p1: T1):T2 }, + p1: T1 + ): { (): T2 }; + + partial( + fn: { (p1: T1, p2: T2):T3 }, + p1: T1 + ): { (p2: T2): T3 }; + + partial( + fn: { (p1: T1, p2: T2):T3 }, + p1: T1, + p2: T2 + ): { (): T3 }; + + partial( + fn: { (p1: T1, p2: T2):T3 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1): T3 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + p1: T1 + ): { (p2: T2, p3: T3): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + p1: T1, + p2: T2 + ): { (p3: T3): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1, p3: T3): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + p1: T1, + p2: T2, + p3: T3 + ): { (): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3 + ): { (p1: T1): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3 + ): { (p2: T2): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3):T4 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3 + ): { (p1: T1, p2: T2): T4 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1 + ): { (p2: T2, p3: T3, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + p2: T2 + ): { (p3: T3, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1, p3: T3, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + p2: T2, + p3: T3 + ): { (p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3 + ): { (p1: T1, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3 + ): { (p2: T2, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3 + ): { (p1: T1, p2: T2, p4: T4): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4 + ): { (): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4 + ): { (p1: T1): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p2: T2): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p1: T1, p2: T2): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p3: T3): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p3: T3): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p2: T2, p3: T3): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4):T5 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p2: T2, p3: T3): T5 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1 + ): { (p2: T2, p3: T3, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2 + ): { (p3: T3, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1, p3: T3, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + p3: T3 + ): { (p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3 + ): { (p1: T1, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3 + ): { (p2: T2, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3 + ): { (p1: T1, p2: T2, p4: T4, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4 + ): { (p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4 + ): { (p1: T1, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p2: T2, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p1: T1, p2: T2, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p3: T3, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p3: T3, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p2: T2, p3: T3, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p2: T2, p3: T3, p5: T5): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p2: T2): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p3: T3): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p3: T3): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p2: T2, p3: T3): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p3: T3, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p3: T3, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p3: T3, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5):T6 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3, p4: T4): T6 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1 + ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2 + ): { (p3: T3, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3 + ): { (p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3 + ): { (p1: T1, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3 + ): { (p2: T2, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3 + ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4 + ): { (p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4 + ): { (p1: T1, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p2: T2, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p1: T1, p2: T2, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p3: T3, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p3: T3, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p2: T2, p3: T3, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p2: T2, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p3: T3, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p3: T3, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p2: T2, p3: T3, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p3: T3, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p3: T3, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p3: T3, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p2: T2): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p3: T3): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p3: T3): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p2: T2, p3: T3): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p2: T2, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p3: T3, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p3: T3, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p2: T2, p3: T3, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p4: T4): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p3: T3, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p3: T3, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p3: T3, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p3: T3, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p3: T3, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p3: T3, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6):T7 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5): T7 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1 + ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2 + ): { (p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2 + ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3 + ): { (p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3 + ): { (p1: T1, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3 + ): { (p2: T2, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3 + ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4 + ): { (p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4 + ): { (p1: T1, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p2: T2, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4 + ): { (p1: T1, p2: T2, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p3: T3, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p2: T2, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4 + ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p2: T2, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p3: T3, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p3: T3, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p2: T2, p3: T3, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p3: T3, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p2: T2, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p2: T2, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p3: T3, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p3: T3, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p2: T2, p3: T3, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p2: T2, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p3: T3, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p3: T3, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p2: T2, p3: T3, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p3: T3, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p3: T3, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p3: T3, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p3: T3, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p2: T2, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p7: T7): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p2: T2): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p3: T3): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p3: T3): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p2: T2, p3: T3): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p2: T2, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p3: T3, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p3: T3, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p2: T2, p3: T3, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p4: T4): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p2: T2, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p3: T3, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p3: T3, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p2: T2, p3: T3, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p2: T2, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p3: T3, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p3: T3, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p2: T2, p3: T3, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + p6: T6, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p3: T3, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p3: T3, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p3: T3, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p3: T3, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p3: T3, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p3: T3, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + p5: T5, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p3: T3, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p3: T3, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p3: T3, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + p4: T4, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + p3: T3, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p3: T3, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + p2: T2, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + p1: T1, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; + + partial( + fn: { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6, p7: T7):T8 }, + stub1: UnderscoreStatic, + stub2: UnderscoreStatic, + stub3: UnderscoreStatic, + stub4: UnderscoreStatic, + stub5: UnderscoreStatic, + stub6: UnderscoreStatic, + p7: T7 + ): { (p1: T1, p2: T2, p3: T3, p4: T4, p5: T5, p6: T6): T8 }; /** * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. @@ -1170,7 +3446,7 @@ interface UnderscoreStatic { * @return List of all the values on `object`. **/ values(object: any): any[]; - + /** * Like map, but for objects. Transform the value of each property in turn. * @param object The object to transform @@ -1179,7 +3455,7 @@ interface UnderscoreStatic { * @return a new _.Dictionary of property values */ mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; - + /** * Like map, but for objects. Transform the value of each property in turn. * @param object The object to transform @@ -1187,7 +3463,7 @@ interface UnderscoreStatic { * @param context The optional context (value of `this`) to bind to */ mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; - + /** * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property * @param object The object to transform @@ -1242,7 +3518,7 @@ interface UnderscoreStatic { extendOwn( destination: any, ...source: any[]): any; - + /** * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) */ @@ -1487,7 +3763,7 @@ interface UnderscoreStatic { constant(value: T): () => T; /** - * Returns undefined irrespective of the arguments passed to it. Useful as the default + * Returns undefined irrespective of the arguments passed to it. Useful as the default * for optional callback arguments. * Note there is no way to indicate a 'undefined' return, so it is currently typed as void. * @return undefined @@ -1590,7 +3866,7 @@ interface UnderscoreStatic { * @return Returns the compiled Underscore HTML template. **/ template(templateString: string, settings?: _.TemplateSettings): (...data: any[]) => string; - + /** * By default, Underscore uses ERB-style template delimiters, change the * following template settings to use alternative delimiters. @@ -3305,7 +5581,7 @@ interface _Chain { /************* * * Array proxy * ************** */ - + /** * Returns a new array comprised of the array on which it is called * joined with the array(s) and/or value(s) provided as arguments. From 86bbeb0727634a4167760128de57790a5ccb1d2a Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Tue, 29 Sep 2015 20:54:55 +0300 Subject: [PATCH 0017/1680] Update react-router 0.13.3 -> 1.0.0-rc1 --- react-router/history.d.ts | 152 ++++++++ react-router/react-router-test.ts | 425 ---------------------- react-router/react-router.d.ts | 570 ++++++++++++++---------------- 3 files changed, 423 insertions(+), 724 deletions(-) create mode 100644 react-router/history.d.ts delete mode 100644 react-router/react-router-test.ts diff --git a/react-router/history.d.ts b/react-router/history.d.ts new file mode 100644 index 0000000000..ede3d719c9 --- /dev/null +++ b/react-router/history.d.ts @@ -0,0 +1,152 @@ +// Type definitions for history v1.11.1 +// Project: https://github.com/rackt/history +// Definitions by: Sergey Buturlakin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare namespace HistoryModule { + + // types based on https://github.com/rackt/history/blob/master/docs/Terms.md + + type Action = string + + type BeforeUnloadHook = () => string + + type CreateHistory = (options: HistoryOptions) => History + + type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory + + interface History { + listenBefore: (hook: TransitionHook) => Function + listen: (listener: LocationListener) => Function + transitionTo(location: Location): void + pushState(state: LocationState, path: Path): void + replaceState(state: LocationState, path: Path): void + setState(state: LocationState): void + go(n: number): void + goBack(): void + goForward(): void + createKey(): LocationKey + createPath(path: Path): Path + createHref(path: Path): Href + } + + type HistoryOptions = Object + + type Href = string + + type Location = { + pathname: Pathname + search: QueryString + query: Query + state: LocationState + action: Action + key: LocationKey + } + + type LocationKey = string + + type LocationListener = (location: Location) => void + + type LocationState = Object + + type Path = string // Pathname + QueryString + + type Pathname = string + + type QueryString = string + + type Query = Object + + type TransitionHook = (location: Location, callback: Function) => any + +} + + +declare module "history/lib/createBrowserHistory" { + + export default function createBrowserHistory(): HistoryModule.History + +} + + +declare module "history/lib/createHashHistory" { + + export default function createHashHistory(): HistoryModule.History + +} + + +declare module "history/lib/createMemoryHistory" { + + export default function createMemoryHistory(): HistoryModule.History + +} + + +declare module "history/lib/createLocation" { + + export default function createLocation(): HistoryModule.Location + +} + + +declare module "history/lib/useBasename" { + + export default function useBasename(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/useBeforeUnload" { + + export default function useBeforeUnload(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/useQueries" { + + export default function useQueries(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + +} + + +declare module "history/lib/actions" { + + export const PUSH: string + + export const REPLACE: string + + export const POP: string + + export default { + PUSH, + REPLACE, + POP + } + +} + + +declare module "history" { + + export { default as createHistory } from "history/lib/createBrowserHistory" + + export { default as createHashHistory } from "history/lib/createHashHistory" + + export { default as createMemoryHistory } from "history/lib/createMemoryHistory" + + export { default as createLocation } from "history/lib/createLocation" + + export { default as useBasename } from "history/lib/useBasename" + + export { default as useBeforeUnload } from "history/lib/useBeforeUnload" + + export { default as useQueries } from "history/lib/useQueries" + + import * as Actions from "history/lib/actions" + + export { Actions } + +} diff --git a/react-router/react-router-test.ts b/react-router/react-router-test.ts deleted file mode 100644 index 115c8b77f9..0000000000 --- a/react-router/react-router-test.ts +++ /dev/null @@ -1,425 +0,0 @@ -/// -"use strict"; - -import React = require('react'); -import ReactAddons = require('react/addons'); -import Router = require('react-router'); - -// Mixin -class NavigationTest { - v: T; - - makePath() { - var v1: string = this.v.makePath('to'); - var v2: string = this.v.makePath('to', {id: 1}); - var v3: string = this.v.makePath('to', {id: 1}, {type: 'json'}); - } - makeHref() { - var v1: string = this.v.makeHref('to'); - var v2: string = this.v.makeHref('to', {id: 1}); - var v3: string = this.v.makeHref('to', {id: 1}, {type: 'json'}); - } - transitionTo() { - var v1: void = this.v.transitionTo('to'); - var v2: void = this.v.transitionTo('to', {id: 1}); - var v3: void = this.v.transitionTo('to', {id: 1}, {type: 'json'}); - } - replaceWith() { - var v1: void = this.v.replaceWith('to'); - var v2: void = this.v.replaceWith('to', {id: 1}); - var v3: void = this.v.replaceWith('to', {id: 1}, {type: 'json'}); - } - goBack() { - var v1: void = this.v.goBack(); - } -} - -class StateTest { - v: T; - - getPath() { - var v1: string = this.v.getPath(); - } - - getRoutes() { - var v1: Router.Route[] = this.v.getRoutes(); - } - - getPathname() { - var v1: string = this.v.getPathname(); - } - - getParams() { - var v1: {} = this.v.getParams(); - } - - getQuery() { - var v1: {} = this.v.getQuery(); - } - - isActive() { - var v1: boolean = this.v.isActive('to'); - var v2: boolean = this.v.isActive('to', {id: 1}); - var v3: boolean = this.v.isActive('to', {id: 1}, {type: 'json'}); - } -} - - -// Location -class LocationTest { - v: T; - - push() { - var v1: void = this.v.push('path/to/hoge'); - } - - replace() { - var v1: void = this.v.replace('path/to/hoge'); - } - - pop() { - var v1: void = this.v.pop(); - } - - getCurrentPath() { - var v1: void = this.v.getCurrentPath(); - } -} -new LocationTest(); -new LocationTest(); -new LocationTest(); - -class LocationListenerTest { - v: T; - - addChangeListener() { - var v1: void = this.v.addChangeListener(() => console.log(1)); - } - - removeChangeListener() { - var v1: void = this.v.removeChangeListener(() => console.log(1)); - } -} -new LocationListenerTest(); -new LocationListenerTest(); - - -// Behavior -class ScrollBehaviorTest { - v: T; - - updateScrollPosition() { - var v1: void = this.v.updateScrollPosition({x: 33, y: 102}, 'scrollTop'); - } -} -new ScrollBehaviorTest(); -new ScrollBehaviorTest(); - - -// Component -class DefaultRouteTest { - v: Router.DefaultRoute; - - props() { - var name: string = this.v.props.name; - var handler: React.ComponentClass = this.v.props.handler; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.DefaultRoute, null); - React.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); - - ReactAddons.createElement(Router.DefaultRoute, null); - ReactAddons.createElement(Router.DefaultRoute, {name: 'name', handler: Handler}); - } -} - -class LinkTest { - v: Router.Link; - - constructor() { - new NavigationTest(); - new StateTest(); - } - - props() { - var activeClassName: string = this.v.props.activeClassName; - var to: string = this.v.props.to; - var params: {} = this.v.props.params; - var query: {} = this.v.props.query; - var onClick: Function = this.v.props.onClick; - } - - getHref() { - var v1: string = this.v.getHref(); - } - - getClassName() { - var v1: string = this.v.getClassName(); - } - - createElement() { - React.createElement(Router.Link, null); - React.createElement(Router.Link, {to: 'home'}); - React.createElement(Router.Link, { - activeClassName: 'name', - to: 'home', - params: {}, - query: {}, - onClick: () => console.log(1) - }); - - ReactAddons.createElement(Router.Link, null); - ReactAddons.createElement(Router.Link, {to: 'home'}); - ReactAddons.createElement(Router.Link, { - activeClassName: 'name', - to: 'home', - params: {}, - query: {}, - onClick: () => console.log(1) - }); - } -} - -class NotFoundRouteTest { - v: Router.NotFoundRoute; - - props() { - var name: string = this.v.props.name; - var handler: React.ComponentClass = this.v.props.handler; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.NotFoundRoute, null); - React.createElement(Router.NotFoundRoute, {handler: Handler}); - React.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); - - ReactAddons.createElement(Router.NotFoundRoute, null); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler}); - ReactAddons.createElement(Router.NotFoundRoute, {handler: Handler, name: "home"}); - } -} - -class RedirectTest { - v: Router.Redirect; - - props() { - var path: string = this.v.props.path; - var from: string = this.v.props.from; - var to: string = this.v.props.to; - } - - createElement() { - React.createElement(Router.Redirect, null); - React.createElement(Router.Redirect, {}); - React.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); - - ReactAddons.createElement(Router.Redirect, null); - ReactAddons.createElement(Router.Redirect, {}); - ReactAddons.createElement(Router.Redirect, {path: 'a', from: 'a', to: 'b'}); - } -} - -class RouteTest { - v: Router.Route; - - props() { - var name: string = this.v.props.name; - var path: string = this.v.props.path; - var handler: React.ComponentClass = this.v.props.handler; - var ignoreScrollBehavior: boolean = this.v.props.ignoreScrollBehavior; - } - - createElement() { - var Handler: React.ComponentClass; - React.createElement(Router.Route, null); - React.createElement(Router.Route, {}); - React.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); - - ReactAddons.createElement(Router.Route, null); - ReactAddons.createElement(Router.Route, {}); - ReactAddons.createElement(Router.Route, {name: "home", path: "/", handler: Handler, ignoreScrollBehavior: true}); - } -} - -class RouteHandlerTest { - v: Router.RouteHandler; - - createElement() { - React.createElement(Router.RouteHandler, null); - React.createElement(Router.RouteHandler, {}); - - ReactAddons.createElement(Router.RouteHandler, null); - ReactAddons.createElement(Router.RouteHandler, {}); - } -} - - -// History -class HistoryTest { - v: Router.History; - - length() { - var v1: number = this.v.length; - } - - back() { - var v1: void = this.v.back(); - } -} - - -// Router -class CreateTest { - v: Router.Router; - - constructor() { - // React.createElement() version - this.v = Router.create({ - routes: React.createElement(Router.Route, null) - }); - this.v = Router.create({ - routes: React.createElement(Router.Route, null), - location: Router.HistoryLocation, - scrollBehavior: Router.ImitateBrowserBehavior - }); - - // React.createFactory() version - this.v = Router.create({ - routes: React.createFactory(Router.Route)() - }); - this.v = Router.create({ - routes: React.createFactory(Router.Route)(), - location: Router.HistoryLocation, - scrollBehavior: Router.ImitateBrowserBehavior - }); - } - - run() { - this.v.run((Handler) => console.log(Handler)); - this.v.run((Handler, state) => console.log(Handler, state)); - } -} - -class RunTest { - constructor() { - // React.createElement() version - var v1: Router.Router = Router.run(React.createElement(Router.Route, null), (Handler) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v2: Router.Router = Router.run(React.createElement(Router.Route, null), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v3: Router.Router = Router.run(React.createElement(Router.Route, null), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - - // React.createFactory() version - var v4: Router.Router = Router.run(React.createFactory(Router.Route)(), (Handler) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v5: Router.Router = Router.run(React.createFactory(Router.Route)(), Router.HistoryLocation, (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - var v6: Router.Router = Router.run(React.createFactory(Router.Route)(), '/foo/bar', (Handler, state) => { - React.render(React.createElement(Handler, null), document.body); - }); - } -} - - -// Transition -class TransitionTest { - constructor() { - var v1: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params, query, callback) => { - transition.abort(); - transition.redirect('to'); - transition.redirect('to', {id: 1}); - transition.redirect('to', {id: 1}, {type: 'json'}); - transition.retry(); - }, - willTransitionFrom: (transition, component, callback) => {} - }; - var v2: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params, query) => {}, - willTransitionFrom: (transition, component) => {} - }; - var v3: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition, params) => {}, - willTransitionFrom: (transition) => {} - }; - var v4: Router.TransitionStaticLifecycle = { - willTransitionTo: (transition) => {}, - willTransitionFrom: () => {} - }; - var v5: Router.TransitionStaticLifecycle = { - willTransitionTo: () => {} - }; - var v6: Router.TransitionStaticLifecycle = { - willTransitionFrom: () => {} - }; - } -} - - -// Context -class ContextTest { - v: Router.Context - - makePath() { - var v1: string = this.v.makePath('home'); - var v2: string = this.v.makePath('home', {p1: 1}); - var v3: string = this.v.makePath('home', {p1: 1}, {q1: 1}); - } - - makeHref() { - var v1: string = this.v.makeHref('home'); - var v2: string = this.v.makeHref('home', {p1: 1}); - var v3: string = this.v.makeHref('home', {p1: 1}, {q1: 1}); - } - - transitionTo() { - var v1: void = this.v.transitionTo('home'); - var v2: void = this.v.transitionTo('home', {p1: 1}); - var v3: void = this.v.transitionTo('home', {p1: 1}, {q1: 1}); - } - - replaceWith() { - var v1: void = this.v.replaceWith('home'); - var v2: void = this.v.replaceWith('home', {p1: 1}); - var v3: void = this.v.replaceWith('home', {p1: 1}, {q1: 1}); - } - - goBack() { - var v: void = this.v.goBack(); - } - - getCurrentPath() { - var v: string = this.v.getCurrentPath(); - } - - getCurrentRoutes() { - var v: Router.Route[] = this.v.getCurrentRoutes(); - } - - getCurrentPathname() { - var v: string = this.v.getCurrentPathname(); - } - - getCurrentParams() { - var v: {} = this.v.getCurrentParams(); - } - - getCurrentQuery() { - var v: {} = this.v.getCurrentQuery(); - } - - isActive() { - var v1: boolean = this.v.isActive('home'); - var v2: boolean = this.v.isActive('home', {p1: 1}); - var v3: boolean = this.v.isActive('home', {p1: 1}, {q1: 1}); - } -} diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 4cebcfab36..b1da6e0060 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -1,354 +1,326 @@ -// Type definitions for React Router 0.13.3 +// Type definitions for history v1.0.0-rc1 // Project: https://github.com/rackt/react-router -// Definitions by: Yuichi Murata , Václav Ostrožlík +// Definitions by: Sergey Buturlakin // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// -declare module ReactRouter { - import React = __React; +/// - // - // Transition - // ---------------------------------------------------------------------- - interface Transition { - path: string; - abortReason: any; - retry(): void; - abort(reason?: any): void; - redirect(to: string, params?: {}, query?: {}): void; - cancel(): void; - from: (transition: Transition, routes: Route[], components?: React.ReactElement[], callback?: (error?: any) => void) => void; - to: (transition: Transition, routes: Route[], params?: {}, query?: {}, callback?: (error?: any) => void) => void; + +declare namespace ReactRouter { + + // types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md + + type Action = string + + type Component = React.ReactType + + type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any + + type LeaveHook = () => any + + interface Location { + pathname: Pathname + search: QueryString + query: Query + state: LocationState + action: Action + key: LocationKey } - interface TransitionStaticLifecycle { - willTransitionTo?( - transition: Transition, - params: {}, - query: {}, - callback: Function - ): void; + type LocationKey = string - willTransitionFrom?( - transition: Transition, - component: React.ReactElement, - callback: Function - ): void; + type LocationListener = (location: Location) => void + + type LocationState = Object + + type Params = Object + + type Path = string // Pathname + QueryString + + type Pathname = string + + type Query = Object + + type QueryString = string + + type RedirectFunction = (state: LocationState, pathname: Pathname | Path, query?: Query) => void + + interface RouteComponentProps { + history?: RouterObject + location?: Location + params?: Params + route?: RouteObject + routeParams?: Params + routes?: PlainRoute[] } - // - // Route Configuration - // ---------------------------------------------------------------------- - // DefaultRoute - interface DefaultRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface DefaultRoute extends React.ReactElement {} - interface DefaultRouteClass extends React.ComponentClass {} + type RouteComponent = React.ComponentClass - // NotFoundRoute - interface NotFoundRouteProp { - name?: string; - handler: React.ComponentClass; - } - interface NotFoundRoute extends React.ReactElement {} - interface NotFoundRouteClass extends React.ComponentClass {} + type RouteConfig = RouteObject[] - // Redirect - interface RedirectProp { - path?: string; - from?: string; - to?: string; - } - interface Redirect extends React.ReactElement {} - interface RedirectClass extends React.ComponentClass {} + type RouteHook = (nextLocation?: Location) => any - // Route - interface RouteProp { - name?: string; - path?: string; - handler?: React.ComponentClass; - ignoreScrollBehavior?: boolean; - } - interface Route extends React.ReactElement {} - interface RouteClass extends React.ComponentClass {} + type RoutePattern = string - var DefaultRoute: DefaultRouteClass; - var NotFoundRoute: NotFoundRouteClass; - var Redirect: RedirectClass; - var Route: RouteClass; - - interface CreateRouteOptions { - name?: string; - path?: string; - ignoreScrollBehavior?: boolean; - isDefault?: boolean; - isNotFound?: boolean; - onEnter?: (transition: Transition, params: {}, query: {}, callback: Function) => void; - onLeave?: (transition: Transition, wtf: any, callback: Function) => void; - handler?: Function; - parentRoute?: Route; + interface RouteObject { + component: RouteComponent + path: RoutePattern + onEnter: EnterHook + onLeave: LeaveHook } - type CreateRouteCallback = (route: Route) => void; - - function createRoute(callback: CreateRouteCallback): Route; - function createRoute(options: CreateRouteOptions | string, callback: CreateRouteCallback): Route; - function createDefaultRoute(options?: CreateRouteOptions | string): Route; - function createNotFoundRoute(options?: CreateRouteOptions | string): Route; - - interface CreateRedirectOptions extends CreateRouteOptions { - path?: string; - from?: string; - to: string; - params?: {}; - query?: {}; + interface RouterObject { + transitionTo: (location: Location) => void + pushState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void + replaceState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void + go(n: Number): void + listen(listener: RouterListener): Function + match(location: Location, callback: RouterListener): void } - function createRedirect(options: CreateRedirectOptions): Redirect; - function createRoutesFromReactChildren(children: Route): Route[]; - // - // Components - // ---------------------------------------------------------------------- - // Link - interface LinkProp extends React.HTMLAttributes { - activeClassName?: string; - activeStyle?: {}; - to: string; - params?: {}; - query?: {}; - } - interface Link extends React.ReactElement, Navigation, State { - handleClick(event: any): void; - getHref(): string; - getClassName(): string; - getActiveState(): boolean; - } - interface LinkClass extends React.ComponentClass {} - - // RouteHandler - interface RouteHandlerProp { } - interface RouteHandlerChildContext { - routeDepth: number; - } - interface RouteHandler extends React.ReactElement { - getChildContext(): RouteHandlerChildContext; - getRouteDepth(): number; - createChildRouteHandler(props: {}): RouteHandler; - } - interface RouteHandlerClass extends React.ComponentClass {} - - var Link: LinkClass; - var RouteHandler: RouteHandlerClass; - - - // - // Top-Level - // ---------------------------------------------------------------------- - interface Router extends React.ReactElement { - run(callback: RouterRunCallback): void; - } + type RouterListener = (error: Error, nextState: RouterState) => void interface RouterState { - path: string; - action: string; - pathname: string; - params: {}; - query: {}; - routes: Route[]; + location: Location + routes: RouteConfig + params: Params + components: Component[] } - interface RouterCreateOption { - routes: Route; - location?: LocationBase; - scrollBehavior?: ScrollBehaviorBase; - onError?: (error: any) => void; - onAbort?: (error: any) => void; + + interface HistoryProp { + listen(listener: LocationListener): Function + pushState(state: LocationState, path: Path): void + replaceState(state: LocationState, path: Path): void + go(n: number): void } - type RouterRunCallback = (Handler: RouteClass, state: RouterState) => void; + type RouteType = Route | IndexRoute | PlainRoute | Redirect - function create(options: RouterCreateOption): Router; - function run(routes: Route, callback: RouterRunCallback): Router; - function run(routes: Route, location: LocationBase | string, callback: RouterRunCallback): Router; + type Components = { [key: string]: Component } - // - // Location - // ---------------------------------------------------------------------- - interface LocationBase { - getCurrentPath(): void; - toString(): string; + interface RouterProps { + history?: HistoryProp + children?: RouteType[] + routes?: RouteType[] // alias for children + createElement?: (component: Component, props: Object) => any + onError?: (err: any) => any + onUpdate?: () => any + parseQueryString?: (queryString: QueryString) => Query + stringifyQuery?: (queryObject: Query) => QueryString } - interface Location extends LocationBase { - push(path: string): void; - replace(path: string): void; - pop(): void; + interface Router extends React.ComponentClass {} + interface RouterElement extends React.ReactElement {} + const Router: Router + + + interface LinkProps extends React.HTMLAttributesBase { + activeStyle?: React.CSSProperties + activeClassName?: string + onlyActiveOnIndex?: boolean + to: RoutePattern + query?: Query + state?: LocationState + } + interface Link extends React.ComponentClass {} + interface LinkElement extends React.DOMElement {} + const Link: Link + + + interface RoutePropsBase { + children?: RouteType[] + ignoreScrollBehavior?: boolean + component?: Component + components?: Components + getComponent?: (location: Location, cb: (err: any, component?: Component) => void) => void + getComponents?: (location: Location, cb: (err: any, components?: Components) => void) => void + onEnter?: EnterHook + onLeave?: LeaveHook } - interface LocationListener { - addChangeListener(listener: Function): void; - removeChangeListener(listener: Function): void; + interface RouteProps extends RoutePropsBase { + path?: RoutePattern + } + interface Route extends React.ComponentClass {} + interface RouteElement extends React.ReactElement {} + const Route: Route + + + interface PlainRoute extends RoutePropsBase { + childRoutes: RouteType[] + getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteType[]) => void) => void } - interface HashLocation extends Location, LocationListener { } - interface HistoryLocation extends Location, LocationListener { } - interface RefreshLocation extends Location { } - interface StaticLocation extends LocationBase { } - interface TestLocation extends Location, LocationListener { } - var HashLocation: HashLocation; - var HistoryLocation: HistoryLocation; - var RefreshLocation: RefreshLocation; - var StaticLocation: StaticLocation; - var TestLocation: TestLocation; + interface RedirectProps { + path?: RoutePattern + from?: RoutePattern // alias for path + to: RoutePattern + query?: Query + state?: LocationState - - // - // Behavior - // ---------------------------------------------------------------------- - interface ScrollBehaviorBase { - updateScrollPosition(position: { x: number; y: number; }, actionType: string): void; } - interface ImitateBrowserBehavior extends ScrollBehaviorBase { } - interface ScrollToTopBehavior extends ScrollBehaviorBase { } - - var ImitateBrowserBehavior: ImitateBrowserBehavior; - var ScrollToTopBehavior: ScrollToTopBehavior; + interface Redirect extends React.ReactElement {} + interface RedirectELement extends React.ReactElement {} + const Redirect: Redirect - // - // Mixin - // ---------------------------------------------------------------------- - interface Navigation { - makePath(to: string, params?: {}, query?: {}): string; - makeHref(to: string, params?: {}, query?: {}): string; - transitionTo(to: string, params?: {}, query?: {}): void; - replaceWith(to: string, params?: {}, query?: {}): void; - goBack(): void; - } + interface IndexRouteProps extends RoutePropsBase {} + interface IndexRoute extends React.ComponentClass {} + interface IndexRouteElement extends React.ReactElement {} + const IndexRoute: IndexRoute - interface State { - getPath(): string; - getRoutes(): Route[]; - getPathname(): string; - getParams(): {}; - getQuery(): {}; - isActive(to: string, params?: {}, query?: {}): boolean; - } - - var Navigation: Navigation; - var State: State; - - - // - // History - // ---------------------------------------------------------------------- - interface History { - back(): void; - length: number; - } - var History: History; - - - // - // Context - // ---------------------------------------------------------------------- - interface Context { - makePath(to: string, params?: {}, query?: {}): string; - makeHref(to: string, params?: {}, query?: {}): string; - transitionTo(to: string, params?: {}, query?: {}): void; - replaceWith(to: string, params?: {}, query?: {}): void; - goBack(): void; - - getCurrentPath(): string; - getCurrentRoutes(): Route[]; - getCurrentPathname(): string; - getCurrentParams(): {}; - getCurrentQuery(): {}; - isActive(to: string, params?: {}, query?: {}): boolean; - } } + +declare module "react-router/lib/Router" { + + export default ReactRouter.Router + +} + + +declare module "react-router/lib/Link" { + + export default ReactRouter.Link + +} + + +declare module "react-router/lib/IndexRoute" { + + export default ReactRouter.IndexRoute + +} + + +declare module "react-router/lib/Redirect" { + + export default ReactRouter.Redirect + +} + + +declare module "react-router/lib/Route" { + + export default ReactRouter.Route + +} + + +declare module "react-router/lib/History" { + + const History: any + + export default History + +} + + +declare module "react-router/lib/Lifecycle" { + + const Lifecycle: any + + export default Lifecycle + +} + + +declare module "react-router/lib/RouteContext" { + + const RouteContext: any + + export default RouteContext + +} + + +declare module "react-router/lib/useRoutes" { + + const useRoutes: any + + export default useRoutes + +} + + +declare module "react-router/lib/RouteUtils" { + + export const createRoutes: any + +} + + +declare module "react-router/lib/RoutingContext" { + + const RoutingContext: any + + export default RoutingContext + +} + + +declare module "react-router/lib/PropTypes" { + + const PropTypes: any + + export default PropTypes + +} + + +declare module "react-router/lib/match" { + + const match: any + + export default match + +} + + declare module "react-router" { - export = ReactRouter; -} -declare module __React { + import Router from "react-router/lib/Router" - // for DefaultRoute - function createElement( - type: ReactRouter.DefaultRouteClass, - props: ReactRouter.DefaultRouteProp, - ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + import Link from "react-router/lib/Link" - // for Link - function createElement( - type: ReactRouter.LinkClass, - props: ReactRouter.LinkProp, - ...children: __React.ReactNode[]): ReactRouter.Link; + import IndexRoute from "react-router/lib/IndexRoute" - // for NotFoundRoute - function createElement( - type: ReactRouter.NotFoundRouteClass, - props: ReactRouter.NotFoundRouteProp, - ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + import Redirect from "react-router/lib/Redirect" - // for Redirect - function createElement( - type: ReactRouter.RedirectClass, - props: ReactRouter.RedirectProp, - ...children: __React.ReactNode[]): ReactRouter.Redirect; + import Route from "react-router/lib/Route" - // for Route - function createElement( - type: ReactRouter.RouteClass, - props: ReactRouter.RouteProp, - ...children: __React.ReactNode[]): ReactRouter.Route; + import History from "react-router/lib/History" - // for RouteHandler - function createElement( - type: ReactRouter.RouteHandlerClass, - props: ReactRouter.RouteHandlerProp, - ...children: __React.ReactNode[]): ReactRouter.RouteHandler; -} + import Lifecycle from "react-router/lib/Lifecycle" -declare module "react/addons" { - // for DefaultRoute - function createElement( - type: ReactRouter.DefaultRouteClass, - props: ReactRouter.DefaultRouteProp, - ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + import RouteContext from "react-router/lib/RouteContext" - // for Link - function createElement( - type: ReactRouter.LinkClass, - props: ReactRouter.LinkProp, - ...children: __React.ReactNode[]): ReactRouter.Link; + import { createRoutes } from "react-router/lib/RouteUtils" - // for NotFoundRoute - function createElement( - type: ReactRouter.NotFoundRouteClass, - props: ReactRouter.NotFoundRouteProp, - ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + import RoutingContext from "react-router/lib/RoutingContext" - // for Redirect - function createElement( - type: ReactRouter.RedirectClass, - props: ReactRouter.RedirectProp, - ...children: __React.ReactNode[]): ReactRouter.Redirect; + import PropTypes from "react-router/lib/PropTypes" - // for Route - function createElement( - type: ReactRouter.RouteClass, - props: ReactRouter.RouteProp, - ...children: __React.ReactNode[]): ReactRouter.Route; + import match from "react-router/lib/match" + + export { + Router, + Link, + IndexRoute, + Redirect, + Route, + History, + Lifecycle, + RouteContext, + createRoutes, + RoutingContext, + PropTypes, + match + } + + export default Router - // for RouteHandler - function createElement( - type: ReactRouter.RouteHandlerClass, - props: ReactRouter.RouteHandlerProp, - ...children: __React.ReactNode[]): ReactRouter.RouteHandler; } From fb14688db7ba1f2dd4cf5978ef03cbc318d45b40 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 17:51:09 +0300 Subject: [PATCH 0018/1680] Update History for use as global and minor fixes --- react-router/history.d.ts | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/react-router/history.d.ts b/react-router/history.d.ts index ede3d719c9..e432a2418c 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -12,13 +12,12 @@ declare namespace HistoryModule { type BeforeUnloadHook = () => string - type CreateHistory = (options: HistoryOptions) => History + type CreateHistory = (options?: HistoryOptions) => History type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory - interface History { - listenBefore: (hook: TransitionHook) => Function - listen: (listener: LocationListener) => Function + interface HistoryBase { + listenBefore(hook: TransitionHook): Function transitionTo(location: Location): void pushState(state: LocationState, path: Path): void replaceState(state: LocationState, path: Path): void @@ -31,6 +30,10 @@ declare namespace HistoryModule { createHref(path: Path): Href } + interface History { + listen(listener: LocationListener): Function + } + type HistoryOptions = Object type Href = string @@ -54,32 +57,51 @@ declare namespace HistoryModule { type Pathname = string - type QueryString = string - type Query = Object + type QueryString = string + type TransitionHook = (location: Location, callback: Function) => any + // Global usage, without modules, needs the small trick, because lib.d.ts + // already has `history` and `History` global definitions: + // var history_: HistoryModule.Module = window['History']; + // history_.createHistory(); + interface Module { + createHistory: CreateHistory + createHashHistory: CreateHistory + createMemoryHistory: CreateHistory + createLocation(): Location + useBasename(enhancer: CreateHistoryEnhancer): CreateHistory + useBeforeUnload(enhancer: CreateHistoryEnhancer): CreateHistory + useQueries(enhancer: CreateHistoryEnhancer): CreateHistory + actions: { + PUSH: string + REPLACE: string + POP: string + } + } + } declare module "history/lib/createBrowserHistory" { - export default function createBrowserHistory(): HistoryModule.History + export default function createBrowserHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } declare module "history/lib/createHashHistory" { - export default function createHashHistory(): HistoryModule.History + export default function createHashHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } declare module "history/lib/createMemoryHistory" { - export default function createMemoryHistory(): HistoryModule.History + export default function createMemoryHistory(options?: HistoryModule.HistoryOptions): HistoryModule.History } From ef5f58533485fd056b4c642d9c49c92667d8f290 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 17:52:15 +0300 Subject: [PATCH 0019/1680] Complete react-router v1.0.0-rc1 definitions --- react-router/react-router.d.ts | 215 ++++++++++++++++++++------------- 1 file changed, 132 insertions(+), 83 deletions(-) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index b1da6e0060..c96fe284dc 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -1,17 +1,18 @@ -// Type definitions for history v1.0.0-rc1 +// Type definitions for react-router v1.0.0-rc1 // Project: https://github.com/rackt/react-router // Definitions by: Sergey Buturlakin // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// +/// +/// declare namespace ReactRouter { // types based on https://github.com/rackt/react-router/blob/master/docs/Glossary.md - type Action = string + import H = HistoryModule type Component = React.ReactType @@ -19,38 +20,17 @@ declare namespace ReactRouter { type LeaveHook = () => any - interface Location { - pathname: Pathname - search: QueryString - query: Query - state: LocationState - action: Action - key: LocationKey - } - - type LocationKey = string - - type LocationListener = (location: Location) => void - - type LocationState = Object - type Params = Object - type Path = string // Pathname + QueryString + type ParseQueryString = (queryString: H.QueryString) => H.Query - type Pathname = string - - type Query = Object - - type QueryString = string - - type RedirectFunction = (state: LocationState, pathname: Pathname | Path, query?: Query) => void + type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void interface RouteComponentProps { - history?: RouterObject + history?: History location?: Location params?: Params - route?: RouteObject + route?: PlainRoute routeParams?: Params routes?: PlainRoute[] } @@ -63,20 +43,24 @@ declare namespace ReactRouter { type RoutePattern = string - interface RouteObject { - component: RouteComponent - path: RoutePattern - onEnter: EnterHook - onLeave: LeaveHook - } + type RouteObject = PlainRoute - interface RouterObject { - transitionTo: (location: Location) => void - pushState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void - replaceState: (state: LocationState, pathname: Pathname | Path, query?: Query) => void - go(n: Number): void + type StringifyQuery = (queryObject: H.Query) => H.QueryString + + + interface History extends H.HistoryBase { + pushState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void + replaceState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void + createPath(path: H.Path, query?: H.Query): H.Path + createHref(path: H.Path, query?: H.Query): H.Href + isActive(pathname: H.Pathname, query: H.Query): boolean + registerRouteHook(route: PlainRoute, hook: H.LocationListener): void + unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void listen(listener: RouterListener): Function - match(location: Location, callback: RouterListener): void + match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void + routes: PlainRoute[] + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery } type RouterListener = (error: Error, nextState: RouterState) => void @@ -89,27 +73,22 @@ declare namespace ReactRouter { } - interface HistoryProp { - listen(listener: LocationListener): Function - pushState(state: LocationState, path: Path): void - replaceState(state: LocationState, path: Path): void - go(n: number): void - } - type RouteType = Route | IndexRoute | PlainRoute | Redirect + type RouteTypes = RouteType | RouteType[] + type Components = { [key: string]: Component } interface RouterProps { - history?: HistoryProp - children?: RouteType[] - routes?: RouteType[] // alias for children + history?: H.History + children?: RouteTypes + routes?: RouteTypes // alias for children createElement?: (component: Component, props: Object) => any onError?: (err: any) => any onUpdate?: () => any - parseQueryString?: (queryString: QueryString) => Query - stringifyQuery?: (queryObject: Query) => QueryString + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery } interface Router extends React.ComponentClass {} interface RouterElement extends React.ReactElement {} @@ -121,8 +100,8 @@ declare namespace ReactRouter { activeClassName?: string onlyActiveOnIndex?: boolean to: RoutePattern - query?: Query - state?: LocationState + query?: H.Query + state?: H.LocationState } interface Link extends React.ComponentClass {} interface LinkElement extends React.DOMElement {} @@ -130,7 +109,7 @@ declare namespace ReactRouter { interface RoutePropsBase { - children?: RouteType[] + children?: RouteTypes ignoreScrollBehavior?: boolean component?: Component components?: Components @@ -148,9 +127,9 @@ declare namespace ReactRouter { const Route: Route - interface PlainRoute extends RoutePropsBase { - childRoutes: RouteType[] - getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteType[]) => void) => void + interface PlainRoute extends RouteProps { + childRoutes: RouteTypes + getChildRoutes: (location: Location, cb: (err: any, routesArray: RouteTypes) => void) => void } @@ -158,12 +137,11 @@ declare namespace ReactRouter { path?: RoutePattern from?: RoutePattern // alias for path to: RoutePattern - query?: Query - state?: LocationState - + query?: H.Query + state?: H.LocationState } interface Redirect extends React.ReactElement {} - interface RedirectELement extends React.ReactElement {} + interface RedirectElement extends React.ReactElement {} const Redirect: Redirect @@ -172,6 +150,51 @@ declare namespace ReactRouter { interface IndexRouteElement extends React.ReactElement {} const IndexRoute: IndexRoute + + interface RoutingContextProps { + history: H.History + createElement?: (component: Component, props: Object) => any + location: Location + routes: RouteTypes + params: Params + components?: Components + } + interface RoutingContext extends React.ReactElement {} + interface RoutingContextElement extends React.ReactElement {} + const RoutingContext: RoutingContext + + + interface LifecycleMixin { + routerWillLeave(nextLocation: Location): string | boolean + } + const Lifecycle: React.Mixin + + + const RouteContext: React.Mixin + + + interface HistoryMixin { + history: History + } + const History: React.Mixin + + + function useRoutes(enhancer: H.CreateHistoryEnhancer): H.CreateHistory + + function createRoutes(routes: RouteTypes): PlainRoute[] + + interface MatchArgs { + routes?: RouteTypes + history?: H.History + location?: Location + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery + } + interface MatchState extends RouterState { + history: History + } + function match(args: MatchArgs, cb: (error: any, nextLocation: H.Location, nextState: MatchState) => void): void + } @@ -189,6 +212,15 @@ declare module "react-router/lib/Link" { } +declare module "react-router/lib/IndexLink" { + + const IndexLink: ReactRouter.Link + + export default IndexLink + +} + + declare module "react-router/lib/IndexRoute" { export default ReactRouter.IndexRoute @@ -212,70 +244,87 @@ declare module "react-router/lib/Route" { declare module "react-router/lib/History" { - const History: any - - export default History + export default ReactRouter.History } declare module "react-router/lib/Lifecycle" { - const Lifecycle: any - - export default Lifecycle + export default ReactRouter.Lifecycle } declare module "react-router/lib/RouteContext" { - const RouteContext: any - - export default RouteContext + export default ReactRouter.RouteContext } declare module "react-router/lib/useRoutes" { - const useRoutes: any - - export default useRoutes + export default ReactRouter.useRoutes } declare module "react-router/lib/RouteUtils" { - export const createRoutes: any + type E = React.ReactElement + + export function isReactChildren(object: E | E[]): boolean + + export function createRouteFromReactElement(element: E): ReactRouter.PlainRoute + + export function createRoutesFromReactChildren(children: E | E[], parentRoute: ReactRouter.PlainRoute): ReactRouter.PlainRoute[] + + import createRoutes = ReactRouter.createRoutes + + export { createRoutes } } declare module "react-router/lib/RoutingContext" { - const RoutingContext: any - - export default RoutingContext + export default ReactRouter.RoutingContext } declare module "react-router/lib/PropTypes" { - const PropTypes: any + export function falsy(props: any, propName: string, componentName: string): Error; - export default PropTypes + export const history: React.Requireable + + export const location: React.Requireable + + export const component: React.Requireable + + export const components: React.Requireable + + export const route: React.Requireable + + export const routes: React.Requireable + + export default { + falsy, + history, + location, + component, + components, + route + } } declare module "react-router/lib/match" { - const match: any - - export default match + export default ReactRouter.match } From 4a33c914d17fd680916dc0dbfa27df1ce41aea26 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Wed, 30 Sep 2015 19:27:10 +0300 Subject: [PATCH 0020/1680] Add tests Restore old definitions as react-router-0.13.3.d.ts Update react-redux to use old definitions --- react-redux/react-redux-tests.tsx | 2 +- react-router/history.d.ts | 7 +- react-router/react-router-0.13.3.d.ts | 354 ++++++++++++++++++ react-router/react-router-tests.tsx | 67 ++++ react-router/react-router-tests.tsx.tscparams | 1 + react-router/react-router.d.ts | 8 +- 6 files changed, 430 insertions(+), 9 deletions(-) create mode 100644 react-router/react-router-0.13.3.d.ts create mode 100644 react-router/react-router-tests.tsx create mode 100644 react-router/react-router-tests.tsx.tscparams diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 9bd662295a..eb2a5b5bc1 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// import { Component } from 'react'; diff --git a/react-router/history.d.ts b/react-router/history.d.ts index e432a2418c..c982bd2299 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -63,10 +63,9 @@ declare namespace HistoryModule { type TransitionHook = (location: Location, callback: Function) => any - // Global usage, without modules, needs the small trick, because lib.d.ts - // already has `history` and `History` global definitions: - // var history_: HistoryModule.Module = window['History']; - // history_.createHistory(); + // Global usage, without modules, needs the small trick, because lib.d.ts + // already has `history` and `History` global definitions: + // var createHistory = ((window as any).History as HistoryModule.Module).createHistory; interface Module { createHistory: CreateHistory createHashHistory: CreateHistory diff --git a/react-router/react-router-0.13.3.d.ts b/react-router/react-router-0.13.3.d.ts new file mode 100644 index 0000000000..4cebcfab36 --- /dev/null +++ b/react-router/react-router-0.13.3.d.ts @@ -0,0 +1,354 @@ +// Type definitions for React Router 0.13.3 +// Project: https://github.com/rackt/react-router +// Definitions by: Yuichi Murata , Václav Ostrožlík +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ReactRouter { + import React = __React; + + // + // Transition + // ---------------------------------------------------------------------- + interface Transition { + path: string; + abortReason: any; + retry(): void; + abort(reason?: any): void; + redirect(to: string, params?: {}, query?: {}): void; + cancel(): void; + from: (transition: Transition, routes: Route[], components?: React.ReactElement[], callback?: (error?: any) => void) => void; + to: (transition: Transition, routes: Route[], params?: {}, query?: {}, callback?: (error?: any) => void) => void; + } + + interface TransitionStaticLifecycle { + willTransitionTo?( + transition: Transition, + params: {}, + query: {}, + callback: Function + ): void; + + willTransitionFrom?( + transition: Transition, + component: React.ReactElement, + callback: Function + ): void; + } + + // + // Route Configuration + // ---------------------------------------------------------------------- + // DefaultRoute + interface DefaultRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface DefaultRoute extends React.ReactElement {} + interface DefaultRouteClass extends React.ComponentClass {} + + // NotFoundRoute + interface NotFoundRouteProp { + name?: string; + handler: React.ComponentClass; + } + interface NotFoundRoute extends React.ReactElement {} + interface NotFoundRouteClass extends React.ComponentClass {} + + // Redirect + interface RedirectProp { + path?: string; + from?: string; + to?: string; + } + interface Redirect extends React.ReactElement {} + interface RedirectClass extends React.ComponentClass {} + + // Route + interface RouteProp { + name?: string; + path?: string; + handler?: React.ComponentClass; + ignoreScrollBehavior?: boolean; + } + interface Route extends React.ReactElement {} + interface RouteClass extends React.ComponentClass {} + + var DefaultRoute: DefaultRouteClass; + var NotFoundRoute: NotFoundRouteClass; + var Redirect: RedirectClass; + var Route: RouteClass; + + interface CreateRouteOptions { + name?: string; + path?: string; + ignoreScrollBehavior?: boolean; + isDefault?: boolean; + isNotFound?: boolean; + onEnter?: (transition: Transition, params: {}, query: {}, callback: Function) => void; + onLeave?: (transition: Transition, wtf: any, callback: Function) => void; + handler?: Function; + parentRoute?: Route; + } + + type CreateRouteCallback = (route: Route) => void; + + function createRoute(callback: CreateRouteCallback): Route; + function createRoute(options: CreateRouteOptions | string, callback: CreateRouteCallback): Route; + function createDefaultRoute(options?: CreateRouteOptions | string): Route; + function createNotFoundRoute(options?: CreateRouteOptions | string): Route; + + interface CreateRedirectOptions extends CreateRouteOptions { + path?: string; + from?: string; + to: string; + params?: {}; + query?: {}; + } + function createRedirect(options: CreateRedirectOptions): Redirect; + function createRoutesFromReactChildren(children: Route): Route[]; + + // + // Components + // ---------------------------------------------------------------------- + // Link + interface LinkProp extends React.HTMLAttributes { + activeClassName?: string; + activeStyle?: {}; + to: string; + params?: {}; + query?: {}; + } + interface Link extends React.ReactElement, Navigation, State { + handleClick(event: any): void; + getHref(): string; + getClassName(): string; + getActiveState(): boolean; + } + interface LinkClass extends React.ComponentClass {} + + // RouteHandler + interface RouteHandlerProp { } + interface RouteHandlerChildContext { + routeDepth: number; + } + interface RouteHandler extends React.ReactElement { + getChildContext(): RouteHandlerChildContext; + getRouteDepth(): number; + createChildRouteHandler(props: {}): RouteHandler; + } + interface RouteHandlerClass extends React.ComponentClass {} + + var Link: LinkClass; + var RouteHandler: RouteHandlerClass; + + + // + // Top-Level + // ---------------------------------------------------------------------- + interface Router extends React.ReactElement { + run(callback: RouterRunCallback): void; + } + + interface RouterState { + path: string; + action: string; + pathname: string; + params: {}; + query: {}; + routes: Route[]; + } + + interface RouterCreateOption { + routes: Route; + location?: LocationBase; + scrollBehavior?: ScrollBehaviorBase; + onError?: (error: any) => void; + onAbort?: (error: any) => void; + } + + type RouterRunCallback = (Handler: RouteClass, state: RouterState) => void; + + function create(options: RouterCreateOption): Router; + function run(routes: Route, callback: RouterRunCallback): Router; + function run(routes: Route, location: LocationBase | string, callback: RouterRunCallback): Router; + + + // + // Location + // ---------------------------------------------------------------------- + interface LocationBase { + getCurrentPath(): void; + toString(): string; + } + interface Location extends LocationBase { + push(path: string): void; + replace(path: string): void; + pop(): void; + } + + interface LocationListener { + addChangeListener(listener: Function): void; + removeChangeListener(listener: Function): void; + } + + interface HashLocation extends Location, LocationListener { } + interface HistoryLocation extends Location, LocationListener { } + interface RefreshLocation extends Location { } + interface StaticLocation extends LocationBase { } + interface TestLocation extends Location, LocationListener { } + + var HashLocation: HashLocation; + var HistoryLocation: HistoryLocation; + var RefreshLocation: RefreshLocation; + var StaticLocation: StaticLocation; + var TestLocation: TestLocation; + + + // + // Behavior + // ---------------------------------------------------------------------- + interface ScrollBehaviorBase { + updateScrollPosition(position: { x: number; y: number; }, actionType: string): void; + } + interface ImitateBrowserBehavior extends ScrollBehaviorBase { } + interface ScrollToTopBehavior extends ScrollBehaviorBase { } + + var ImitateBrowserBehavior: ImitateBrowserBehavior; + var ScrollToTopBehavior: ScrollToTopBehavior; + + + // + // Mixin + // ---------------------------------------------------------------------- + interface Navigation { + makePath(to: string, params?: {}, query?: {}): string; + makeHref(to: string, params?: {}, query?: {}): string; + transitionTo(to: string, params?: {}, query?: {}): void; + replaceWith(to: string, params?: {}, query?: {}): void; + goBack(): void; + } + + interface State { + getPath(): string; + getRoutes(): Route[]; + getPathname(): string; + getParams(): {}; + getQuery(): {}; + isActive(to: string, params?: {}, query?: {}): boolean; + } + + var Navigation: Navigation; + var State: State; + + + // + // History + // ---------------------------------------------------------------------- + interface History { + back(): void; + length: number; + } + var History: History; + + + // + // Context + // ---------------------------------------------------------------------- + interface Context { + makePath(to: string, params?: {}, query?: {}): string; + makeHref(to: string, params?: {}, query?: {}): string; + transitionTo(to: string, params?: {}, query?: {}): void; + replaceWith(to: string, params?: {}, query?: {}): void; + goBack(): void; + + getCurrentPath(): string; + getCurrentRoutes(): Route[]; + getCurrentPathname(): string; + getCurrentParams(): {}; + getCurrentQuery(): {}; + isActive(to: string, params?: {}, query?: {}): boolean; + } +} + +declare module "react-router" { + export = ReactRouter; +} + +declare module __React { + + // for DefaultRoute + function createElement( + type: ReactRouter.DefaultRouteClass, + props: ReactRouter.DefaultRouteProp, + ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + + // for Link + function createElement( + type: ReactRouter.LinkClass, + props: ReactRouter.LinkProp, + ...children: __React.ReactNode[]): ReactRouter.Link; + + // for NotFoundRoute + function createElement( + type: ReactRouter.NotFoundRouteClass, + props: ReactRouter.NotFoundRouteProp, + ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + + // for Redirect + function createElement( + type: ReactRouter.RedirectClass, + props: ReactRouter.RedirectProp, + ...children: __React.ReactNode[]): ReactRouter.Redirect; + + // for Route + function createElement( + type: ReactRouter.RouteClass, + props: ReactRouter.RouteProp, + ...children: __React.ReactNode[]): ReactRouter.Route; + + // for RouteHandler + function createElement( + type: ReactRouter.RouteHandlerClass, + props: ReactRouter.RouteHandlerProp, + ...children: __React.ReactNode[]): ReactRouter.RouteHandler; +} + +declare module "react/addons" { + // for DefaultRoute + function createElement( + type: ReactRouter.DefaultRouteClass, + props: ReactRouter.DefaultRouteProp, + ...children: __React.ReactNode[]): ReactRouter.DefaultRoute; + + // for Link + function createElement( + type: ReactRouter.LinkClass, + props: ReactRouter.LinkProp, + ...children: __React.ReactNode[]): ReactRouter.Link; + + // for NotFoundRoute + function createElement( + type: ReactRouter.NotFoundRouteClass, + props: ReactRouter.NotFoundRouteProp, + ...children: __React.ReactNode[]): ReactRouter.NotFoundRoute; + + // for Redirect + function createElement( + type: ReactRouter.RedirectClass, + props: ReactRouter.RedirectProp, + ...children: __React.ReactNode[]): ReactRouter.Redirect; + + // for Route + function createElement( + type: ReactRouter.RouteClass, + props: ReactRouter.RouteProp, + ...children: __React.ReactNode[]): ReactRouter.Route; + + // for RouteHandler + function createElement( + type: ReactRouter.RouteHandlerClass, + props: ReactRouter.RouteHandlerProp, + ...children: __React.ReactNode[]): ReactRouter.RouteHandler; +} diff --git a/react-router/react-router-tests.tsx b/react-router/react-router-tests.tsx new file mode 100644 index 0000000000..4c2abc7ef7 --- /dev/null +++ b/react-router/react-router-tests.tsx @@ -0,0 +1,67 @@ + +/// +/// +/// + + +import * as React from "react"; + +import { Router, Route, IndexRoute, Link } from "react-router"; + +import createHistory from "history/lib/createBrowserHistory" + + +class Master extends React.Component, {}> { + + render() { + return
+

Master

+ Dashboard Users +

{this.props.children}

+
+ } + +} + + +class Dashboard extends React.Component<{}, {}> { + + render() { + return
+ This is a dashboard +
+ } + +} + +class NotFound extends React.Component<{}, {}> { + + render() { + return
+ This path does not exists +
+ } + +} + + +class Users extends React.Component<{}, {}> { + + render() { + return
+ This is a user list +
+ } + +} + + +React.render(( + + + + + + + +), document.body) diff --git a/react-router/react-router-tests.tsx.tscparams b/react-router/react-router-tests.tsx.tscparams new file mode 100644 index 0000000000..f479837784 --- /dev/null +++ b/react-router/react-router-tests.tsx.tscparams @@ -0,0 +1 @@ +--noImplicitAny -jsx react --target es5 \ No newline at end of file diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index c96fe284dc..2a6445a3f1 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -26,16 +26,16 @@ declare namespace ReactRouter { type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void - interface RouteComponentProps { + interface RouteComponentProps { history?: History location?: Location - params?: Params + params?: P route?: PlainRoute - routeParams?: Params + routeParams?: R routes?: PlainRoute[] } - type RouteComponent = React.ComponentClass + type RouteComponent = React.ComponentClass type RouteConfig = RouteObject[] From f0d5440f90b1c40292a1c345d75bdc8656cded18 Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Thu, 1 Oct 2015 11:03:39 +0300 Subject: [PATCH 0021/1680] Micro update of createRoutes export --- react-router/react-router.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 2a6445a3f1..3869978764 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -280,9 +280,7 @@ declare module "react-router/lib/RouteUtils" { export function createRoutesFromReactChildren(children: E | E[], parentRoute: ReactRouter.PlainRoute): ReactRouter.PlainRoute[] - import createRoutes = ReactRouter.createRoutes - - export { createRoutes } + export import createRoutes = ReactRouter.createRoutes } From 0d64ea1b82ad1d804892ceec14d98a9be85f64fb Mon Sep 17 00:00:00 2001 From: Sergey Buturlakin Date: Thu, 1 Oct 2015 12:31:03 +0300 Subject: [PATCH 0022/1680] History enhancers definitions improved using union types --- react-router/history.d.ts | 42 ++++++++++++++++++------------ react-router/react-router.d.ts | 47 +++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/react-router/history.d.ts b/react-router/history.d.ts index c982bd2299..2d88184e68 100644 --- a/react-router/history.d.ts +++ b/react-router/history.d.ts @@ -12,12 +12,13 @@ declare namespace HistoryModule { type BeforeUnloadHook = () => string - type CreateHistory = (options?: HistoryOptions) => History + type CreateHistory = (options?: HistoryOptions) => T - type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory + type CreateHistoryEnhancer = (createHistory: CreateHistory) => CreateHistory - interface HistoryBase { + interface History { listenBefore(hook: TransitionHook): Function + listen(listener: LocationListener): Function transitionTo(location: Location): void pushState(state: LocationState, path: Path): void replaceState(state: LocationState, path: Path): void @@ -30,10 +31,6 @@ declare namespace HistoryModule { createHref(path: Path): Href } - interface History { - listen(listener: LocationListener): Function - } - type HistoryOptions = Object type Href = string @@ -63,17 +60,30 @@ declare namespace HistoryModule { type TransitionHook = (location: Location, callback: Function) => any + + interface HistoryBeforeUnload { + listenBeforeUnload(hook: () => string | boolean): Function + } + + interface HistoryQueries { + pushState(state: LocationState, pathname: Pathname | Path, query?: Query): void + replaceState(state: LocationState, pathname: Pathname | Path, query?: Query): void + createPath(path: Path, query?: Query): Path + createHref(path: Path, query?: Query): Href + } + + // Global usage, without modules, needs the small trick, because lib.d.ts // already has `history` and `History` global definitions: // var createHistory = ((window as any).History as HistoryModule.Module).createHistory; interface Module { - createHistory: CreateHistory - createHashHistory: CreateHistory - createMemoryHistory: CreateHistory + createHistory: CreateHistory + createHashHistory: CreateHistory + createMemoryHistory: CreateHistory createLocation(): Location - useBasename(enhancer: CreateHistoryEnhancer): CreateHistory - useBeforeUnload(enhancer: CreateHistoryEnhancer): CreateHistory - useQueries(enhancer: CreateHistoryEnhancer): CreateHistory + useBasename(createHistory: CreateHistory): CreateHistory + useBeforeUnload(createHistory: CreateHistory): CreateHistory + useQueries(createHistory: CreateHistory): CreateHistory actions: { PUSH: string REPLACE: string @@ -114,21 +124,21 @@ declare module "history/lib/createLocation" { declare module "history/lib/useBasename" { - export default function useBasename(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useBasename(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } declare module "history/lib/useBeforeUnload" { - export default function useBeforeUnload(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useBeforeUnload(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } declare module "history/lib/useQueries" { - export default function useQueries(enhancer: HistoryModule.CreateHistoryEnhancer): HistoryModule.CreateHistory + export default function useQueries(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory } diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 3869978764..0834954048 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -16,6 +16,8 @@ declare namespace ReactRouter { type Component = React.ReactType + type Components = { [key: string]: Component } + type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any type LeaveHook = () => any @@ -47,24 +49,6 @@ declare namespace ReactRouter { type StringifyQuery = (queryObject: H.Query) => H.QueryString - - interface History extends H.HistoryBase { - pushState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void - replaceState(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void - createPath(path: H.Path, query?: H.Query): H.Path - createHref(path: H.Path, query?: H.Query): H.Href - isActive(pathname: H.Pathname, query: H.Query): boolean - registerRouteHook(route: PlainRoute, hook: H.LocationListener): void - unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void - listen(listener: RouterListener): Function - match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void - routes: PlainRoute[] - parseQueryString?: ParseQueryString - stringifyQuery?: StringifyQuery - } - - type RouterListener = (error: Error, nextState: RouterState) => void - interface RouterState { location: Location routes: RouteConfig @@ -72,12 +56,18 @@ declare namespace ReactRouter { components: Component[] } - type RouteType = Route | IndexRoute | PlainRoute | Redirect type RouteTypes = RouteType | RouteType[] - type Components = { [key: string]: Component } + + interface HistoryBase extends H.History { + routes: PlainRoute[] + parseQueryString?: ParseQueryString + stringifyQuery?: StringifyQuery + } + + type History = HistoryBase & H.HistoryQueries & HistoryRoutes interface RouterProps { @@ -179,10 +169,22 @@ declare namespace ReactRouter { const History: React.Mixin - function useRoutes(enhancer: H.CreateHistoryEnhancer): H.CreateHistory + type RouterListener = (error: Error, nextState: RouterState) => void + + interface HistoryRoutes { + isActive(pathname: H.Pathname, query: H.Query): boolean + registerRouteHook(route: PlainRoute, hook: H.LocationListener): void + unregisterRouteHook(route: PlainRoute, hook: H.LocationListener): void + listen(listener: RouterListener): Function + match(location: H.Location, callback: (error: any, nextState: RouterState, nextLocation: H.Location) => void): void + } + + function useRoutes(createHistory: HistoryModule.CreateHistory): HistoryModule.CreateHistory + function createRoutes(routes: RouteTypes): PlainRoute[] + interface MatchArgs { routes?: RouteTypes history?: H.History @@ -345,6 +347,8 @@ declare module "react-router" { import RouteContext from "react-router/lib/RouteContext" + import useRoutes from "react-router/lib/useRoutes" + import { createRoutes } from "react-router/lib/RouteUtils" import RoutingContext from "react-router/lib/RoutingContext" @@ -362,6 +366,7 @@ declare module "react-router" { History, Lifecycle, RouteContext, + useRoutes, createRoutes, RoutingContext, PropTypes, From 158f0715ab75c32dcef74c361b64d79a1fa305b9 Mon Sep 17 00:00:00 2001 From: Tadeusz Hucal Date: Sat, 3 Oct 2015 18:58:28 +0200 Subject: [PATCH 0023/1680] Restangular: restore synchronization with Angular's request configuration --- restangular/restangular.d.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index b09e4affd0..b407cefd4d 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -29,17 +29,6 @@ declare module restangular { $object: T[]; } - interface IRequestConfig { - params?: any; - headers?: any; - cache?: any; - withCredentials?: boolean; - data?: any; - transformRequest?: any; - transformResponse?: any; - timeout?: any; // number | promise - } - interface IResponse { status: number; data: any; @@ -65,8 +54,8 @@ declare module restangular { addResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: ng.IDeferred) => any): void; setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; addRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; - setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {element: any; headers: any; params: any}): void; - addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {headers: any; params: any; element: any; httpConfig: IRequestConfig}): void; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: ng.IRequestShortcutConfig) => {element: any; headers: any; params: any}): void; + addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: ng.IRequestShortcutConfig) => {headers: any; params: any; element: any; httpConfig: ng.IRequestShortcutConfig}): void; setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: ng.IDeferred) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void; @@ -124,7 +113,7 @@ declare module restangular { clone(): IElement; plain(): any; plain(): T; - withHttpConfig(httpConfig: IRequestConfig): IElement; + withHttpConfig(httpConfig: ng.IRequestShortcutConfig): IElement; save(queryParams?: any, headers?: any): IPromise; getRestangularUrl(): string; } @@ -139,7 +128,7 @@ declare module restangular { options(queryParams?: any, headers?: any): IPromise; patch(queryParams?: any, headers?: any): IPromise; putElement(idx: any, params: any, headers: any): IPromise; - withHttpConfig(httpConfig: IRequestConfig): ICollection; + withHttpConfig(httpConfig: ng.IRequestShortcutConfig): ICollection; clone(): ICollection; plain(): any; plain(): T[]; From 1c1d000362c240f6a6f9318e6325de9fbfce052c Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Sun, 4 Oct 2015 15:20:31 +0200 Subject: [PATCH 0024/1680] Added typings for jquery cropbox plugin --- jquery.cropbox/jquery.cropbox.d.ts | 115 +++++++++++++++++++++++++ jquery.cropbox/jquery.cropbox.tests.ts | 39 +++++++++ 2 files changed, 154 insertions(+) create mode 100644 jquery.cropbox/jquery.cropbox.d.ts create mode 100644 jquery.cropbox/jquery.cropbox.tests.ts diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery.cropbox/jquery.cropbox.d.ts new file mode 100644 index 0000000000..70e09a46ae --- /dev/null +++ b/jquery.cropbox/jquery.cropbox.d.ts @@ -0,0 +1,115 @@ +// Type definitions for jQuery cropbox +// Project: https://github.com/acornejo/jquery-cropbox +// Definitions by: Per Kastman +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module jQueryCropBox { + + enum ShowControls { + never, + always, + hover, + auto + } + + interface CropboxArea { + cropX: number; + cropY: number; + cropW: number; + cropH: number; + } + + interface CropboxOptions { + /** + * Width in pixels of the cropping window + */ + width?: number; + /** + * Height in pixels of the cropping window + */ + height?: number; + /** + * Number of incremental zoom steps. With the default of 10, you have to click the zoom-in button 9 times to reach 100%. + */ + zoom?: number; + /** + * Maximum zoom value. With the default of 1.0 users can't zoom beyond the maximum image resolution. + */ + maxZoom?: number; + /** + * If not null, this is the entire html block that should appear on hover over the image for instructions and/or buttons (could include the zoom in/out buttons for example). If null, the default html block is used which has the text "Click to drag" and the zoom in/out buttons. Use false to disable controls. + */ + controls?: any; + /** + * Set the initial cropping area + */ + result?: CropboxArea; + /** + * This flag is used to determine when to display the controls. Never, always and hover do exactly what you would expect (never show them, always show them, show them on hover). The auto flag is the same as the hover flag, except that on mobile devices it always shows the controls (since there is no hover event). + */ + showControls?: ShowControls + } + + interface CropboxDragOptions { + startX: number, + startY: number, + dx: number, + dy: number + } + + interface CropboxSetCropOptions { + cropX: number, + cropY: number, + cropW: number, + cropH: number + } + + interface Cropbox { + /** + * Increase image zoom level by one step + */ + zoomIn(): void; + /** + * Decrease image zoom level by one step + */ + zoomOut(): void; + /** + * Set zoom leevl to a value between 0 and 1. Need to call update to reflect the changes. + */ + zoom(percent: number): void; + /** + * Simulate image dragging, starting from (startX,startY) and moving a delta of (dx,dy). Need to call update to reflect the changes. + */ + drag(options: CropboxDragOptions): void; + /** + * Set crop window. + */ + setCrop(options: CropboxSetCropOptions): void; + /** + * Update the cropped result (must call after zoom and drag). + */ + update(): void; + /** + * Generate a URL for the cropped image on the client (requires HTML5 compliant browser). + */ + getDataURL(): string; + /** + * Generate a Blob with the cropped image (requires HTML5 compliant browser). + */ + getBlob(): any; + /** + * Remove the cropbox functionality from the image. + */ + remove(): void; + } + +} +interface JQuery { + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox +} + +interface JQueryStatic { + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox +} diff --git a/jquery.cropbox/jquery.cropbox.tests.ts b/jquery.cropbox/jquery.cropbox.tests.ts new file mode 100644 index 0000000000..cb8f0be5ac --- /dev/null +++ b/jquery.cropbox/jquery.cropbox.tests.ts @@ -0,0 +1,39 @@ +/// +/// + +var cropboxWithDefaultSettings = $("#element").cropbox(); + +var cropboxOptions: jQueryCropBox.CropboxOptions = { + height: 500, + zoom: 5, + width: 0.5, +}; + +var cropboxWithOptions = $("#element").cropbox(cropboxOptions); + +cropboxWithOptions.zoomIn(); +cropboxWithOptions.zoomOut(); +cropboxWithOptions.zoom(50); + +var cropDragOption: jQueryCropBox.CropboxDragOptions = { + startX: 10, + startY: 0, + dx: 100, + dy: 100 +}; + +cropboxWithOptions.drag(cropDragOption); + +var cropboxSetCropOption: jQueryCropBox.CropboxSetCropOptions = { + cropX: 10, + cropY: 10, + cropW: 50, + cropH: 50 +}; + +cropboxWithOptions.setCrop(cropboxSetCropOption); + +cropboxWithOptions.update(); +cropboxWithOptions.getDataURL(); +cropboxWithOptions.getBlob(); +cropboxWithOptions.remove(); From 10c7ec397f4617dfb0fc7274fa9a8c054ff362b2 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Sun, 4 Oct 2015 15:25:44 +0200 Subject: [PATCH 0025/1680] Cleanup --- jquery.cropbox/jquery.cropbox.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery.cropbox/jquery.cropbox.d.ts index 70e09a46ae..82b550bf30 100644 --- a/jquery.cropbox/jquery.cropbox.d.ts +++ b/jquery.cropbox/jquery.cropbox.d.ts @@ -104,8 +104,8 @@ declare module jQueryCropBox { */ remove(): void; } - } + interface JQuery { cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } From 729ca9b124a7d4b4631b6295d9ce8f2d848ae4fe Mon Sep 17 00:00:00 2001 From: David Pertiller Date: Mon, 5 Oct 2015 23:23:24 +0200 Subject: [PATCH 0026/1680] included method definition for onrendered event which provides the rendered canvas element --- html2canvas/html2canvas.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html2canvas/html2canvas.d.ts b/html2canvas/html2canvas.d.ts index 6894219715..61eba51fd2 100644 --- a/html2canvas/html2canvas.d.ts +++ b/html2canvas/html2canvas.d.ts @@ -37,6 +37,8 @@ declare module Html2Canvas { /** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */ useCORS?: boolean; + /** Callback providing the rendered canvas element after rendering */ + onrendered?(canvas: HTMLElement): void; } } From b9a7194092297ca857f96d971e290612bc2618d7 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 18:56:29 +0200 Subject: [PATCH 0027/1680] Renamed according to naming convention --- .../jquery.cropbox.d.ts => jquery-cropbox/jquery-cropbox.d.ts | 4 ++-- .../jquery-cropbox.tests.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename jquery.cropbox/jquery.cropbox.d.ts => jquery-cropbox/jquery-cropbox.d.ts (96%) rename jquery.cropbox/jquery.cropbox.tests.ts => jquery-cropbox/jquery-cropbox.tests.ts (94%) diff --git a/jquery.cropbox/jquery.cropbox.d.ts b/jquery-cropbox/jquery-cropbox.d.ts similarity index 96% rename from jquery.cropbox/jquery.cropbox.d.ts rename to jquery-cropbox/jquery-cropbox.d.ts index 82b550bf30..fba9846bba 100644 --- a/jquery.cropbox/jquery.cropbox.d.ts +++ b/jquery-cropbox/jquery-cropbox.d.ts @@ -107,9 +107,9 @@ declare module jQueryCropBox { } interface JQuery { - cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox + cropbox(params?: jQueryCropBox.CropboxOptions): JQuery } interface JQueryStatic { - cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox + cropbox(params?: jQueryCropBox.CropboxOptions): JQueryStatic } diff --git a/jquery.cropbox/jquery.cropbox.tests.ts b/jquery-cropbox/jquery-cropbox.tests.ts similarity index 94% rename from jquery.cropbox/jquery.cropbox.tests.ts rename to jquery-cropbox/jquery-cropbox.tests.ts index cb8f0be5ac..e8db3847c6 100644 --- a/jquery.cropbox/jquery.cropbox.tests.ts +++ b/jquery-cropbox/jquery-cropbox.tests.ts @@ -1,5 +1,5 @@ /// -/// +/// var cropboxWithDefaultSettings = $("#element").cropbox(); From 68d3c81d8d635bd03136a19fd2d40d3dc500c7b9 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 19:16:44 +0200 Subject: [PATCH 0028/1680] Fixed incorrect return type --- jquery-cropbox/jquery-cropbox.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery-cropbox/jquery-cropbox.d.ts b/jquery-cropbox/jquery-cropbox.d.ts index fba9846bba..82b550bf30 100644 --- a/jquery-cropbox/jquery-cropbox.d.ts +++ b/jquery-cropbox/jquery-cropbox.d.ts @@ -107,9 +107,9 @@ declare module jQueryCropBox { } interface JQuery { - cropbox(params?: jQueryCropBox.CropboxOptions): JQuery + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } interface JQueryStatic { - cropbox(params?: jQueryCropBox.CropboxOptions): JQueryStatic + cropbox(params?: jQueryCropBox.CropboxOptions): jQueryCropBox.Cropbox } From 1e9273d62eb6e2c2de01116c6446f006b47916b7 Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Tue, 6 Oct 2015 19:29:47 +0200 Subject: [PATCH 0029/1680] Updated according to naming convention --- .../{jquery-cropbox.tests.ts => jquery-cropbox-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jquery-cropbox/{jquery-cropbox.tests.ts => jquery-cropbox-tests.ts} (100%) diff --git a/jquery-cropbox/jquery-cropbox.tests.ts b/jquery-cropbox/jquery-cropbox-tests.ts similarity index 100% rename from jquery-cropbox/jquery-cropbox.tests.ts rename to jquery-cropbox/jquery-cropbox-tests.ts From 202d240a0a0c86661b30f3a97169e70f72484293 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:07:44 -0600 Subject: [PATCH 0030/1680] 'request': Added more tests from project page and fixed definitions accordingly --- request/request-tests.ts | 438 ++++++++++++++++++++++++++++++++++++++- request/request.d.ts | 146 ++++++++----- 2 files changed, 517 insertions(+), 67 deletions(-) diff --git a/request/request-tests.ts b/request/request-tests.ts index 9d7cbf3bc4..7f04be26ac 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -4,6 +4,7 @@ import request = require('request'); import http = require('http'); import stream = require('stream'); import formData = require('form-data'); +import fs = require('fs'); var value: any; var str: string; @@ -20,7 +21,7 @@ var headers: {[key: string]: string}; var agent: http.Agent; var write: stream.Writable; var req: request.Request; -var form: formData.FormData; +var form1: formData.FormData; var bodyArr: request.RequestPart[] = [{ body: value @@ -125,8 +126,6 @@ req.destroy(); // --- --- --- --- --- --- --- --- --- --- --- --- -var callback: (error: any, response: any, body: any) => void; - value = request.initParams; req = request(uri); @@ -136,13 +135,6 @@ req = request(uri, callback); req = request(options); req = request(options, callback); -req = request.request(uri); -req = request.request(uri, options); -req = request.request(uri, options, callback); -req = request.request(uri, callback); -req = request.request(options); -req = request.request(options, callback); - req = request.get(uri); req = request.get(uri, options); req = request.get(uri, options, callback); @@ -204,3 +196,429 @@ request // check response }) .pipe(request.put('http://another.com/another.png')); + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request/request.d.ts b/request/request.d.ts index 4827bc7a66..f3a2741fb7 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -13,50 +13,50 @@ declare module 'request' { import http = require('http'); import FormData = require('form-data'); import url = require('url'); + import fs = require('fs'); - export = RequestAPI; - - function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request; - - module RequestAPI { - export function defaults(options: Options): typeof RequestAPI; - - export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - - export function forever(agentOptions: any, optionsArg: any): Request; - export function jar(): CookieJar; - export function cookie(str: string): Cookie; - - export var initParams: any; - + namespace request { + export interface RequestAPI { + defaults(options: Options): RequestAPI; + (uri: string, + options?: Options, + callback?: (error: any, response: http.IncomingMessage, body: any) => void) + : Request; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + + forever(agentOptions: any, optionsArg: any): Request; + jar(): CookieJar; + cookie(str: string): Cookie; + + initParams: any; + debug: boolean; + } + export interface Options { url?: string; uri?: string; @@ -70,7 +70,7 @@ declare module 'request' { hawk ?: HawkOptions; qs?: any; json?: any; - multipart?: RequestPart[]; + multipart?: RequestPart[] | Multipart; agentOptions?: any; agentClass?: any; forever?: any; @@ -88,17 +88,47 @@ declare module 'request' { proxy?: any; strictSSL?: boolean; gzip?: boolean; + preambleCRLF?: boolean; + postambleCRLF?: boolean; + key?: Buffer; + cert?: Buffer; + passphrase?: string; + ca?: Buffer; + har?: HttpArchiveRequest; } + + export interface HttpArchiveRequest { + url?: string; + method?: string; + headers?: NameValuePair[]; + postData?: { + mimeType?: string; + params?: NameValuePair[]; + } + } + export interface NameValuePair { + name: string; + value: string; + } + + export interface Multipart { + chunked?: boolean; + data?: { + 'content-type'?: string, + body: string + }[]; + } + export interface RequestPart { headers?: Headers; body: any; } - + export interface Request extends stream.Stream { readable: boolean; writable: boolean; - + getAgent(): http.Agent; //start(): void; //abort(): void; @@ -114,9 +144,9 @@ declare module 'request' { auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; oauth(oauth: OAuthOptions): Request; jar(jar: CookieJar): Request; - + on(event: string, listener: Function): Request; - + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding: string, cb?: Function): boolean; @@ -131,11 +161,11 @@ declare module 'request' { destroy(): void; toJSON(): string; } - + export interface Headers { [key: string]: any; } - + export interface AuthOptions { user?: string; username?: string; @@ -144,7 +174,7 @@ declare module 'request' { sendImmediately?: boolean; bearer?: string; } - + export interface OAuthOptions { callback?: string; consumer_key?: string; @@ -153,28 +183,28 @@ declare module 'request' { token_secret?: string; verifier?: string; } - + export interface HawkOptions { credentials: any; } - + export interface AWSOptions { secret: string; bucket?: string; } - + export interface CookieJar { setCookie(cookie: Cookie, uri: string|url.Url, options?: any): void getCookieString(uri: string|url.Url): string getCookies(uri: string|url.Url): Cookie[] } - + export interface CookieValue { name: string; value: any; httpOnly: boolean; } - + export interface Cookie extends Array { constructor(name: string, req: Request): void; str: string; @@ -182,5 +212,7 @@ declare module 'request' { path: string; toString(): string; } - } + } + var request: request.RequestAPI; + export = request; } From 31d1cc43cd5f828fec19f35c286396f859fa47cc Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 09:41:45 -0600 Subject: [PATCH 0031/1680] Change request-promise to use full 'request' API --- request-promise/request-promise-tests.ts | 453 ++++++++++++++++++++++- request-promise/request-promise.d.ts | 25 +- request/request-tests.ts | 2 +- request/request.d.ts | 54 +-- 4 files changed, 486 insertions(+), 48 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index 41a5eb80d3..ad2f8f61f9 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -1,17 +1,466 @@ /// import rp = require('request-promise'); +import nodeRequest = require('request'); rp('http://www.google.com') .then(console.dir) .catch(console.error); -var options: rp.Options = { +var options: nodeRequest.Options = { uri : 'http://posttestserver.com/post.php', - method : 'POST' + method : 'POST', + json: true, + body: { some: 'payload' } }; rp(options) .then(console.dir) .catch(console.error); +// --> Displays length of response from server after post + +// Get full response after DELETE +options = { + method: 'DELETE', + uri: 'http://my-server/path/to/resource/1234' +}; + +rp(options) + .then(function (response) { + console.log("DELETE succeeded with status %d", response.statusCode); + }) + .catch(console.error); + +//The following examples from https://github.com/request/request +import fs = require('fs'); +import http = require('http'); +var request = rp; + +//The following examples from https://github.com/request/request +request('http://www.google.com', function (error, response, body) { + if (!error && response.statusCode == 200) { + console.log(body); // Show the HTML for the Google homepage. + } +}); + +request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')); + +fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json')); + +request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://google.com/img.png') + .on('response', function(response) { + console.log(response.statusCode); // 200 + console.log(response.headers['content-type']); // 'image/png' + }) + .pipe(request.put('http://mysite.com/img.png')); + +request + .get('http://mysite.com/doodle.png') + .on('error', function(err) { + console.log(err); + }) + .pipe(fs.createWriteStream('doodle.png')); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + if (req.method === 'PUT') { + req.pipe(request.put('http://mysite.com/doodle.png')); + } else if (req.method === 'GET' || req.method === 'HEAD') { + request.get('http://mysite.com/doodle.png').pipe(resp); + } + } +}); + +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + var x = request('http://mysite.com/doodle.png'); + req.pipe(x); + x.pipe(resp); + } +}); + +var resp: http.ServerResponse; +var req: nodeRequest.Request; +req.pipe(request('http://mysite.com/doodle.png')).pipe(resp); + +var r = request; +http.createServer(function (req, resp) { + if (req.url === '/doodle.png') { + r.get('http://google.com/doodle.png').pipe(resp); + } +}); + +request.post('http://service.com/upload', {form:{key:'value'}}); +// or +request.post('http://service.com/upload').form({key:'value'}); +// or +request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ }); + +var data = { + // Pass a simple key-value pair + my_field: 'my_value', + // Pass data via Buffers + my_buffer: new Buffer([1, 2, 3]), + // Pass data via Streams + my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), + // Pass multiple values /w an Array + attachments: [ + fs.createReadStream(__dirname + '/attachment1.jpg'), + fs.createReadStream(__dirname + '/attachment2.jpg') + ], + // Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS} + // Use case: for some types of streams, you'll need to provide "file"-related information manually. + // See the `form-data` README for more information about options: https://github.com/felixge/node-form-data + custom_file: { + value: fs.createReadStream('/dev/urandom'), + options: { + filename: 'topsecret.jpg', + contentType: 'image/jpg' + } + } +}; +request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) { + if (err) { + return console.error('upload failed:', err); + } + console.log('Upload successful! Server responded with:', body); +}); + +var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {}); +var form = requestMultipart.form(); +form.append('my_field', 'my_value'); +form.append('my_buffer', new Buffer([1, 2, 3])); +form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'}); + +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: { + chunked: false, + data: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' } + ] + } + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); +request({ + method: 'PUT', + preambleCRLF: true, + postambleCRLF: true, + uri: 'http://service.com/upload', + multipart: [ + { + 'content-type': 'application/json', + body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + }, + { body: 'I am an attachment' }, + { body: fs.createReadStream('image.png') } + ] + }, + function (error, response, body) { + if (error) { + return console.error('upload failed:', error); + } + console.log('Upload successful! Server responded with:', body); + }); + +request.get('http://some.server.com/').auth('username', 'password', false); +// or +request.get('http://some.server.com/', { + 'auth': { + 'user': 'username', + 'pass': 'password', + 'sendImmediately': false + } +}); +// or +request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); +// or +request.get('http://some.server.com/', { + 'auth': { + 'bearer': 'bearerToken' + } +}); + +var username = 'username', + password = 'password', + url = 'http://' + username + ':' + password + '@some.server.com'; + +request({url: url}, function (error, response, body) { + // Do more stuff with 'body' here +}); + +options = { + url: 'https://api.github.com/repos/request/request', + headers: { + 'User-Agent': 'request' + } +}; + +function callback(error, response, body) { + if (!error && response.statusCode == 200) { + var info = JSON.parse(body); + console.log(info.stargazers_count + " Stars"); + console.log(info.forks_count + " Forks"); + } +} + +request(options, callback); + +// OAuth1.0 - 3-legged server side flow (Twitter example) +// step 1 +import qs = require('querystring'); +const CONSUMER_KEY = 'key'; +const CONSUMER_SECRET = 'secret'; +var oauth = + { callback: 'http://mysite.com/callback/' + , consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + } + , url = 'https://api.twitter.com/oauth/request_token' + ; +request.post({url:url, oauth:oauth}, function (e, r, body) { + // Ideally, you would take the body in the response + // and construct a URL that a user clicks on (like a sign in button). + // The verifier is only available in the response after a user has + // verified with twitter that they are authorizing your app. + + // step 2 + var req_data = qs.parse(body); + var uri = 'https://api.twitter.com/oauth/authenticate' + + '?' + qs.stringify({oauth_token: req_data.oauth_token}); + // redirect the user to the authorize uri + + // step 3 + // after the user is redirected back to your server + var auth_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: auth_data.oauth_token + , token_secret: req_data.oauth_token_secret + , verifier: auth_data.oauth_verifier + } + , url = 'https://api.twitter.com/oauth/access_token' + ; + request.post({url:url, oauth:oauth}, function (e, r, body) { + // ready to make signed requests on behalf of the user + var perm_data = qs.parse(body) + , oauth = + { consumer_key: CONSUMER_KEY + , consumer_secret: CONSUMER_SECRET + , token: perm_data.oauth_token + , token_secret: perm_data.oauth_token_secret + } + , url = 'https://api.twitter.com/1.1/users/show.json' + , qs = + { screen_name: perm_data.screen_name + , user_id: perm_data.user_id + } + ; + request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + console.log(user); + }); + }); +}); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key') + , caFile = path.resolve(__dirname, 'ssl/ca.cert.pem'); + +options = { + url: 'https://api.some-server.com/', + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + passphrase: 'password', + ca: fs.readFileSync(caFile) +}; + +request.get(options); + +var path = require('path') + , certFile = path.resolve(__dirname, 'ssl/client.crt') + , keyFile = path.resolve(__dirname, 'ssl/client.key'); + +options = { + url: 'https://api.some-server.com/', + agentOptions: { + cert: fs.readFileSync(certFile), + key: fs.readFileSync(keyFile), + // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: + // pfx: fs.readFileSync(pfxFilePath), + passphrase: 'password', + securityOptions: 'SSL_OP_NO_SSLv3' + } +}; + +request.get(options); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + secureProtocol: 'SSLv3_method' + } +}); + +request.get({ + url: 'https://api.some-server.com/', + agentOptions: { + ca: fs.readFileSync('ca.cert.pem') + } +}); + + +request({ + // will be ignored + method: 'GET', + uri: 'http://www.google.com', + + // HTTP Archive Request Object + har: { + url: 'http://www.mockbin.com/har', + method: 'POST', + headers: [ + { + name: 'content-type', + value: 'application/x-www-form-urlencoded' + } + ], + postData: { + mimeType: 'application/x-www-form-urlencoded', + params: [ + { + name: 'foo', + value: 'bar' + }, + { + name: 'hello', + value: 'world' + } + ] + } + } + }); + +//requests using baseRequest() will set the 'x-token' header +var baseRequest = request.defaults({ + headers: {'x-token': 'my-token'} +}); + +//requests using specialRequest() will include the 'x-token' header set in +//baseRequest and will also include the 'special' header +var specialRequest = baseRequest.defaults({ + headers: {special: 'special value'} +}); + +request.put(url); +request.patch(url); +request.post(url); +request.head(url); +request.del(url); +request.get(url); +request.cookie('key1=value1'); +request.jar(); +request.debug = true; + +request.get('http://10.255.255.1', {timeout: 1500}, function(err) { + console.log(err.code === 'ETIMEDOUT'); + // Set to `true` if the timeout was a connection timeout, `false` or + // `undefined` otherwise. + console.log(err.connect === true); + process.exit(0); +}); + +var rand = Math.floor(Math.random()*100000000).toString(); + request( + { method: 'PUT' + , uri: 'http://mikeal.iriscouch.com/testjs/' + rand + , multipart: + [ { 'content-type': 'application/json' + , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}}) + } + , { body: 'I am an attachment' } + ] + } + , function (error, response, body) { + if(response.statusCode == 201){ + console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand) + } else { + console.log('error: '+ response.statusCode) + console.log(body) + } + } + ); + +request( + { method: 'GET' + , uri: 'http://www.google.com' + , gzip: true + } + , function (error, response, body) { + // body is the decompressed response body + console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) + console.log('the decoded data is: ' + body) + } + ).on('data', function(data) { + // decompressed data as it is received + console.log('decoded chunk: ' + data) + }) + .on('response', function(response) { + // unmodified http.IncomingMessage object + response.on('data', function(data) { + // compressed data as it is received + console.log('received ' + data.length + ' bytes of compressed data') + }) + }); + +var requestWithJar = request.defaults({jar: true}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar() +requestWithJar = request.defaults({jar:j}) +requestWithJar('http://www.google.com', function () { + requestWithJar('http://images.google.com'); +}); + +var j = request.jar(); +var cookie = request.cookie('key1=value1'); +var url = 'http://www.google.com'; +j.setCookie(cookie, url); +request({url: url, jar: j}, function () { + request('http://images.google.com'); +}); + +//TODO: add definitions for tough-cookie-filestore +//var FileCookieStore = require('tough-cookie-filestore'); +// NOTE - currently the 'cookies.json' file must already exist! +//var j = request.jar(new FileCookieStore('cookies.json')); +requestWithJar = request.defaults({ jar : j }) +request('http://www.google.com', function() { + request('http://images.google.com'); +}); + +var j = request.jar() +request({url: 'http://www.google.com', jar: j}, function () { + var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..." + var cookies = j.getCookies(url); + // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...] +}); diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 246f1e5d9d..67b82ebd8e 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -1,31 +1,20 @@ // Type definitions for request-promise v0.4.2 // Project: https://www.npmjs.com/package/request-promise -// Definitions by: Christopher Glantschnig +// Definitions by: Christopher Glantschnig , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Change [0]: 2015/08/20 - Aya Morisawa -/// -/// /// /// declare module 'request-promise' { import request = require('request'); - import stream = require('stream'); - import http = require('http'); - import FormData = require('form-data'); - - export = RequestPromiseAPI; - - function RequestPromiseAPI(options: RequestPromiseAPI.Options): Promise; - function RequestPromiseAPI(uri: string): Promise; - - module RequestPromiseAPI { - export interface Options extends request.Options { - simple?: boolean; - transform?: (body: any, response: http.IncomingMessage) => any; - resolveWithFullResponse?: boolean; - } + import http = require('http'); + + interface RequestPromise extends request.Request, Promise { } + + var requestPromise: request.RequestAPI; + export = requestPromise; } diff --git a/request/request-tests.ts b/request/request-tests.ts index 7f04be26ac..99c7f566c2 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -33,7 +33,7 @@ var bodyArr: request.RequestPart[] = [{ // --- --- --- --- --- --- --- --- --- --- --- --- -str = req.toJSON(); +obj = req.toJSON(); var cookieValue: request.CookieValue; str = cookieValue.name; diff --git a/request/request.d.ts b/request/request.d.ts index f3a2741fb7..202adf9552 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -1,6 +1,6 @@ // Type definitions for request // Project: https://github.com/mikeal/request -// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor +// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor , Joe Skeen // Definitions: https://github.com/borisyankov/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts @@ -16,40 +16,40 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : Request; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + : TRequest; + (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request; + del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - forever(agentOptions: any, optionsArg: any): Request; + forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; cookie(str: string): Cookie; @@ -159,7 +159,7 @@ declare module 'request' { resume(): void; abort(): void; destroy(): void; - toJSON(): string; + toJSON(): Object; } export interface Headers { @@ -213,6 +213,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From b06d25ff7a01af49ca934962021de73f4d292818 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:01:23 -0600 Subject: [PATCH 0032/1680] Fix implicit any issues --- request-promise/request-promise-tests.ts | 34 ++++++++-------- request/request-tests.ts | 33 ++++++++-------- request/request.d.ts | 49 ++++++++++++------------ 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index ad2f8f61f9..a4d28a8f44 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -37,7 +37,6 @@ import fs = require('fs'); import http = require('http'); var request = rp; -//The following examples from https://github.com/request/request request('http://www.google.com', function (error, response, body) { if (!error && response.statusCode == 200) { console.log(body); // Show the HTML for the Google homepage. @@ -52,7 +51,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -60,7 +59,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -212,7 +211,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -248,7 +247,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -260,20 +259,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -418,13 +416,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request-tests.ts b/request/request-tests.ts index 99c7f566c2..2e878893b3 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -212,7 +212,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img request .get('http://google.com/img.png') - .on('response', function(response) { + .on('response', function(response: any) { console.log(response.statusCode); // 200 console.log(response.headers['content-type']); // 'image/png' }) @@ -220,7 +220,7 @@ request request .get('http://mysite.com/doodle.png') - .on('error', function(err) { + .on('error', function(err: any) { console.log(err); }) .pipe(fs.createWriteStream('doodle.png')); @@ -370,7 +370,7 @@ options = { } }; -function callback(error, response, body) { +function callback(error: any, response: http.IncomingMessage, body: string) { if (!error && response.statusCode == 200) { var info = JSON.parse(body); console.log(info.stargazers_count + " Stars"); @@ -406,7 +406,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { // step 3 // after the user is redirected back to your server - var auth_data = qs.parse(body) + var auth_data: any = qs.parse(body) , oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET @@ -418,20 +418,19 @@ request.post({url:url, oauth:oauth}, function (e, r, body) { ; request.post({url:url, oauth:oauth}, function (e, r, body) { // ready to make signed requests on behalf of the user - var perm_data = qs.parse(body) - , oauth = + var perm_data: any = qs.parse(body); + var oauth = { consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET , token: perm_data.oauth_token , token_secret: perm_data.oauth_token_secret - } - , url = 'https://api.twitter.com/1.1/users/show.json' - , qs = - { screen_name: perm_data.screen_name - , user_id: perm_data.user_id - } - ; - request.get({url:url, oauth:oauth, qs:qs, json:true}, function (e, r, user) { + }; + var url = 'https://api.twitter.com/1.1/users/show.json'; + var query = { + screen_name: perm_data.screen_name, + user_id: perm_data.user_id + }; + request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) { console.log(user); }); }); @@ -576,13 +575,13 @@ request( console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity')) console.log('the decoded data is: ' + body) } - ).on('data', function(data) { + ).on('data', function(data: any) { // decompressed data as it is received console.log('decoded chunk: ' + data) }) - .on('response', function(response) { + .on('response', function(response: http.IncomingMessage) { // unmodified http.IncomingMessage object - response.on('data', function(data) { + response.on('data', function(data: any[]) { // compressed data as it is received console.log('received ' + data.length + ' bytes of compressed data') }) diff --git a/request/request.d.ts b/request/request.d.ts index 202adf9552..711b3d3c16 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -18,36 +18,33 @@ declare module 'request' { namespace request { export interface RequestAPI { defaults(options: Options): RequestAPI; - (uri: string, - options?: Options, - callback?: (error: any, response: http.IncomingMessage, body: any) => void) - : TRequest; - (uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - (options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + (uri: string, options?: Options, callback?: RequestCallback): TRequest; + (uri: string, callback?: RequestCallback): TRequest; + (options?: Options, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, callback?: RequestCallback): TRequest; + get(options: Options, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, callback?: RequestCallback): TRequest; + post(options: Options, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, callback?: RequestCallback): TRequest; + put(options: Options, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, callback?: RequestCallback): TRequest; + head(options: Options, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, callback?: RequestCallback): TRequest; + patch(options: Options, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; - del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): TRequest; + del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, callback?: RequestCallback): TRequest; + del(options: Options, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; @@ -97,6 +94,10 @@ declare module 'request' { har?: HttpArchiveRequest; } + export interface RequestCallback { + (error: any, response: http.IncomingMessage, body: any): void; + } + export interface HttpArchiveRequest { url?: string; method?: string; From 98184ee41d3848d537e04d0414323e73cb2dbe47 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:51:29 -0600 Subject: [PATCH 0033/1680] Added back missing options and fixed promise exposure --- request-promise/request-promise.d.ts | 14 ++++++++++++-- request/request.d.ts | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 67b82ebd8e..7a94ce5967 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -12,9 +12,19 @@ declare module 'request-promise' { import request = require('request'); import http = require('http'); - interface RequestPromise extends request.Request, Promise { + interface RequestPromise extends request.Request { + then(onFulfilled: Function, onRejected: Function): Promise; + catch(onRejected: Function): Promise; + finally(onFinished: Function): Promise; + promise(): Promise; } - var requestPromise: request.RequestAPI; + interface RequestPromiseOptions extends request.Options { + simple?: boolean; + transform?: (body: any, response: http.IncomingMessage) => any; + resolveWithFullResponse?: boolean; + } + + var requestPromise: request.RequestAPI; export = requestPromise; } diff --git a/request/request.d.ts b/request/request.d.ts index 711b3d3c16..f0ec40f3bc 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -16,8 +16,8 @@ declare module 'request' { import fs = require('fs'); namespace request { - export interface RequestAPI { - defaults(options: Options): RequestAPI; + export interface RequestAPI { + defaults(options: Options): RequestAPI; (uri: string, options?: Options, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; (options?: Options, callback?: RequestCallback): TRequest; @@ -214,6 +214,6 @@ declare module 'request' { toString(): string; } } - var request: request.RequestAPI; + var request: request.RequestAPI; export = request; } From 1a9a1665fb7f72239ca3e3b0b5024ff7c0963c36 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:55:24 -0600 Subject: [PATCH 0034/1680] fix tests --- request-promise/request-promise.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 7a94ce5967..1832787be5 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -13,7 +13,7 @@ declare module 'request-promise' { import http = require('http'); interface RequestPromise extends request.Request { - then(onFulfilled: Function, onRejected: Function): Promise; + then(onFulfilled: Function, onRejected?: Function): Promise; catch(onRejected: Function): Promise; finally(onFinished: Function): Promise; promise(): Promise; From 6c9b4cf0248de82bc63dee6af72fe8dfb9d2501b Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 10:58:20 -0600 Subject: [PATCH 0035/1680] fix implicit any --- request-promise/request-promise-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-promise/request-promise-tests.ts b/request-promise/request-promise-tests.ts index a4d28a8f44..347cca818d 100644 --- a/request-promise/request-promise-tests.ts +++ b/request-promise/request-promise-tests.ts @@ -27,7 +27,7 @@ options = { }; rp(options) - .then(function (response) { + .then(function (response: http.IncomingMessage) { console.log("DELETE succeeded with status %d", response.statusCode); }) .catch(console.error); From 2d23048aa0c96acfa7d2c667484029acdd446896 Mon Sep 17 00:00:00 2001 From: Joe Skeen Date: Wed, 7 Oct 2015 11:12:48 -0600 Subject: [PATCH 0036/1680] Use generic Options to allow for custom options from request-promise --- request/request.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/request/request.d.ts b/request/request.d.ts index f0ec40f3bc..db8ca8c7d3 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -17,34 +17,34 @@ declare module 'request' { namespace request { export interface RequestAPI { - defaults(options: Options): RequestAPI; - (uri: string, options?: Options, callback?: RequestCallback): TRequest; + defaults(options: TOptions): RequestAPI; + (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; (uri: string, callback?: RequestCallback): TRequest; - (options?: Options, callback?: RequestCallback): TRequest; + (options?: TOptions, callback?: RequestCallback): TRequest; - get(uri: string, options?: Options, callback?: RequestCallback): TRequest; + get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; get(uri: string, callback?: RequestCallback): TRequest; - get(options: Options, callback?: RequestCallback): TRequest; + get(options: TOptions, callback?: RequestCallback): TRequest; - post(uri: string, options?: Options, callback?: RequestCallback): TRequest; + post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; post(uri: string, callback?: RequestCallback): TRequest; - post(options: Options, callback?: RequestCallback): TRequest; + post(options: TOptions, callback?: RequestCallback): TRequest; - put(uri: string, options?: Options, callback?: RequestCallback): TRequest; + put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; put(uri: string, callback?: RequestCallback): TRequest; - put(options: Options, callback?: RequestCallback): TRequest; + put(options: TOptions, callback?: RequestCallback): TRequest; - head(uri: string, options?: Options, callback?: RequestCallback): TRequest; + head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; head(uri: string, callback?: RequestCallback): TRequest; - head(options: Options, callback?: RequestCallback): TRequest; + head(options: TOptions, callback?: RequestCallback): TRequest; - patch(uri: string, options?: Options, callback?: RequestCallback): TRequest; + patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; patch(uri: string, callback?: RequestCallback): TRequest; - patch(options: Options, callback?: RequestCallback): TRequest; + patch(options: TOptions, callback?: RequestCallback): TRequest; - del(uri: string, options?: Options, callback?: RequestCallback): TRequest; + del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; del(uri: string, callback?: RequestCallback): TRequest; - del(options: Options, callback?: RequestCallback): TRequest; + del(options: TOptions, callback?: RequestCallback): TRequest; forever(agentOptions: any, optionsArg: any): TRequest; jar(): CookieJar; From 71b6e0f1fdbc2d43e0e2423505932a14b14081f1 Mon Sep 17 00:00:00 2001 From: ashwin027 Date: Wed, 7 Oct 2015 18:47:15 -0700 Subject: [PATCH 0037/1680] Added missing options to IGridoptions Added missing options enableGridMenu and useExternalFiltering. --- ui-grid/ui-grid.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ece964280f..47a2452f8b 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -600,6 +600,13 @@ declare module uiGrid { * @default false */ enableFiltering?: boolean; + /** + * False by default. When enabled, this adds a settings icon in the top right of the grid, + * which floats above the column header. The menu by default gives access to show/hide columns, + * but can be customized to show additional actions. + * @default false + */ + enableGridMenu?: boolean; /** * uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid. * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER @@ -791,6 +798,12 @@ declare module uiGrid { * @default 20 */ virtualizationThreshold?: number; + /** + * Disables client side filtering. When true, handle the filterChanged event and set data, + * defaults to false + * @default false + */ + useExternalFiltering?: boolean; /** * Default time in milliseconds to throttle scroll events to, defaults to 70ms * @default 70 From 16d09d28c0ee49edc10be758bbc2da35bdff4e71 Mon Sep 17 00:00:00 2001 From: ibrahimuludag Date: Fri, 9 Oct 2015 14:58:12 +0300 Subject: [PATCH 0038/1680] Update knockout.d.ts Added after? option to KnockoutBindingHandler --- knockout/knockout.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index edb510b6db..c2020c418e 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -142,6 +142,7 @@ interface KnockoutAllBindingsAccessor { } interface KnockoutBindingHandler { + after?: Array; init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; }; update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void; options?: any; From 6166ce3c5e4b23634c89435ad165bee3ebea24ce Mon Sep 17 00:00:00 2001 From: Luuk Date: Sat, 10 Oct 2015 16:40:33 +0200 Subject: [PATCH 0039/1680] Renamed files and folders for safari-extension definitions --- .../safari-extension-content-tests.ts | 0 .../safari-extension-content.d.ts | 0 .../safari-tests.ts => safari-extension/safari-extension-tests.ts | 0 safari/safari.d.ts => safari-extension/safari-extension.d.ts | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename safari/safari-content-tests.ts => safari-extension/safari-extension-content-tests.ts (100%) rename safari/safari-content.d.ts => safari-extension/safari-extension-content.d.ts (100%) rename safari/safari-tests.ts => safari-extension/safari-extension-tests.ts (100%) rename safari/safari.d.ts => safari-extension/safari-extension.d.ts (100%) diff --git a/safari/safari-content-tests.ts b/safari-extension/safari-extension-content-tests.ts similarity index 100% rename from safari/safari-content-tests.ts rename to safari-extension/safari-extension-content-tests.ts diff --git a/safari/safari-content.d.ts b/safari-extension/safari-extension-content.d.ts similarity index 100% rename from safari/safari-content.d.ts rename to safari-extension/safari-extension-content.d.ts diff --git a/safari/safari-tests.ts b/safari-extension/safari-extension-tests.ts similarity index 100% rename from safari/safari-tests.ts rename to safari-extension/safari-extension-tests.ts diff --git a/safari/safari.d.ts b/safari-extension/safari-extension.d.ts similarity index 100% rename from safari/safari.d.ts rename to safari-extension/safari-extension.d.ts From c88a935bc1fd65957d9355b4408f1cde0c1ba3c5 Mon Sep 17 00:00:00 2001 From: Luuk Date: Sat, 10 Oct 2015 16:43:55 +0200 Subject: [PATCH 0040/1680] Fixed references --- safari-extension/safari-extension-content-tests.ts | 2 +- safari-extension/safari-extension-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/safari-extension/safari-extension-content-tests.ts b/safari-extension/safari-extension-content-tests.ts index b58735b9d0..067e90f054 100644 --- a/safari-extension/safari-extension-content-tests.ts +++ b/safari-extension/safari-extension-content-tests.ts @@ -1,4 +1,4 @@ -/// +/// // https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AddingExtensionToolbars/AddingExtensionToolbars.html#//apple_ref/doc/uid/TP40009977-CH5-SW7 var theBody = document.body; diff --git a/safari-extension/safari-extension-tests.ts b/safari-extension/safari-extension-tests.ts index b4e5cfd603..0336c4411f 100644 --- a/safari-extension/safari-extension-tests.ts +++ b/safari-extension/safari-extension-tests.ts @@ -1,4 +1,4 @@ -/// +/// // https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/AccessingResourcesWithinYourExtensionFolder/AccessingResourcesWithinYourExtensionFolder.html#//apple_ref/doc/uid/TP40009977-CH18-SW2 var img = document.createElement("img"); From da4f02bd35aaac24b62debfac86e054520191af4 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:42:17 +0200 Subject: [PATCH 0041/1680] Typeahead: added missing options, and missing parameters, normalized some comments and code style --- typeahead/typeahead-tests.ts | 64 +++-- typeahead/typeahead.d.ts | 507 +++++++++++++++++------------------ 2 files changed, 281 insertions(+), 290 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 2bcb016c08..3864865c9f 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,14 +6,10 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: any, cb: any) { - var matches: any, substrRegex: any; - - // an array that will be populated with substring matches - matches = []; - + return function findMatches(q: string, syncResults: (x: any) => void) { + var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` - substrRegex = new RegExp(q, 'i'); + var substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array @@ -25,7 +21,7 @@ var substringMatcher = function (strs: any) { } }); - cb(matches); + syncResults(matches); } } @@ -46,14 +42,14 @@ function test_method_names() { $('#the-basics .typeahead').typeahead('open'); $('#the-basics .typeahead').typeahead('close'); $('#the-basics .typeahead').typeahead('val'); - $('#the-basics .typeahead').typeahead('val', 'test value'); + $('#the-basics .typeahead').typeahead('val', 'test value'); } function test_options() { var dataSets: Twitter.Typeahead.Dataset[] = []; - + function with_empty_options() { $('#the-basics .typeahead').typeahead({}, dataSets); } @@ -72,10 +68,10 @@ function test_options() { function with_all_options() { $('#the-basics .typeahead').typeahead({ - hint: true, - highlight: true, - minLength: 1 - }, + hint: true, + highlight: true, + minLength: 1 + }, dataSets ); } @@ -101,33 +97,33 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', - source: substringMatcher(states) - }] + displayKey: 'value', + source: substringMatcher(states) + }] ); } function with_templates_option() { $('#the-basics .typeahead').typeahead(options, [{ - templates: {}, - source: substringMatcher(states) - }] + templates: {}, + source: substringMatcher(states) + }] ); } function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ - name: 'states', - displayKey: 'value', - templates: {}, - source: substringMatcher(states) - }] + name: 'states', + displayKey: 'value', + templates: {}, + source: substringMatcher(states) + }] ); } function with_multiple_datasets() { $('#the-basics .typeahead').typeahead(options, [ - { + { name: 'states', displayKey: 'value', templates: {}, @@ -192,7 +188,7 @@ function test_datasets_objects() { } function with_multiple_objects() { - $('#the-basics .typeahead').typeahead(options, + $('#the-basics .typeahead').typeahead(options, { name: 'states', displayKey: 'value', @@ -231,7 +227,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: function(context: any) { + empty: function (context: any) { return context.name; } } @@ -249,7 +245,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - footer: function(context: any) { + footer: function (context: any) { return context.name; } } @@ -267,7 +263,7 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - header: function(context: any) { + header: function (context: any) { return context.name; } } @@ -277,8 +273,8 @@ function test_dataset_templates() { function with_suggestion_option() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), - templates: { - suggestion: function(context) { + templates: { + suggestion: function (context) { return context.name; } } @@ -289,10 +285,10 @@ function test_dataset_templates() { $('#the-basics .typeahead').typeahead(options, { source: substringMatcher(states), templates: { - empty: 'no results', + empty: 'no results', footer: 'custom footer', header: 'custom header', - suggestion: function(context) { + suggestion: function (context) { return context.name; } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index a8b139937c..cde3a92771 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -10,19 +10,19 @@ interface JQuery { /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. * The menu is only visible when it is open and has content. - * - * @constructor + * + * @constructor * @param methodName Method 'open' - */ + */ typeahead(methodName: 'open'): JQuery; /** @@ -36,10 +36,10 @@ interface JQuery { /** * Returns the current value of the typeahead. * The value is the text the user has entered into the input element. - * - * @constructor + * + * @constructor * @param methodName Method 'val' - */ + */ typeahead(methodName: 'val'): string; /** @@ -87,7 +87,7 @@ interface JQuery { * @param options ('hint' or 'highlight' or 'minLength' all of which are optional) * @param datasets One or more datasets passed in as arguments. */ - typeahead(options: Twitter.Typeahead.Options, ... datasets: Twitter.Typeahead.Dataset[]): JQuery; + typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; } declare module Twitter.Typeahead { @@ -104,8 +104,8 @@ declare module Twitter.Typeahead { * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. * cb can be invoked synchronously or asynchronously. * - */ - source: (query: string, cb: (result: any) => void) => void; + */ + source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); /** * The name of the dataset. @@ -125,32 +125,33 @@ declare module Twitter.Typeahead { /** * A hash of templates to be used when rendering the dataset. * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. - */ + */ templates?: Templates; + async?: boolean; + display?: boolean | ((x: any) => boolean); } interface Templates { - /** * Rendered when 0 suggestions are available for the given query. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query - */ + */ empty?: any; /** * Rendered at the bottom of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ footer?: any; /** * Rendered at the top of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ header?: any; /** @@ -158,273 +159,267 @@ declare module Twitter.Typeahead { * If set, this has to be a precompiled template. * The associated suggestion object will serve as the context. * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. - */ + */ suggestion?: (datum: any) => string; } - /** - * When initializing a typeahead, there are a number of options you can configure. - */ + /** + * When initializing a typeahead, there are a number of options you can configure. + */ interface Options { - /** - * highlight: If true, when suggestions are rendered, - * pattern matches for the current query in text nodes will be wrapped in a strong element. - * Defaults to false. - */ - highlight?: boolean; + /** + * highlight: If true, when suggestions are rendered, + * pattern matches for the current query in text nodes will be wrapped in a strong element. + * Defaults to false. + */ + highlight?: boolean; - /** - * If false, the typeahead will not show a hint. Defaults to true. - */ - hint?: boolean; + /** + * If false, the typeahead will not show a hint. Defaults to true. + */ + hint?: boolean; - /** - * The minimum character length needed before suggestions start getting rendered. Defaults to 1. - */ - minLength?: number; + /** + * The minimum character length needed before suggestions start getting rendered. Defaults to 1. + */ + minLength?: number; } } -declare module Bloodhound -{ - interface BloodhoundOptions - { - /** - * Transforms a datum into an array of string tokens - * - * @constructor - * @param datum individual units that compose the dataset - */ - datumTokenizer?: any; - /** - * Transforms a query into an array of string tokens - * - * @constructor - * @param query tokenizer query - */ - queryTokenizer?: any; - /** - * The max number of suggestions to return from Bloodhound#get. - * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 - */ - limit?: number; - /** - * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. - * If not set, duplicate detection will not be performed. - */ - dupDetector?: (remoteMatch: T, localMatch: T) => boolean; - /** - * A compare function used to sort matched datums for a given query. - */ - sorter?: (a: T, b: T) => number; - /** - *An array of datums or a function that returns an array of datums. - */ - local?: () => T[]; - /** - * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. - */ - prefetch?: PrefetchOptions; - /** - * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. - */ - remote?: RemoteOptions; - } - - /** - * Prefetched data is fetched and processed on initialization. - * If the browser supports localStorage, the processed data will be cached - * there to prevent additional network requests on subsequent page loads. - */ - interface PrefetchOptions - { - /** - * A URL to a JSON file containing an array of datums. Required. - */ - url: string; - /** - * The time (in milliseconds) the prefetched data should be cached - * in localStorage. Defaults to 86400000 (1 day). - */ - ttl?: number; - /** - * A function that transforms the response body into an array of datums. - * - * @param parsedResponse Response body - */ - filter?: (parsedResponse: any) => T[]; - /** The key that data will be stored in local storage under. Defaults to value of url. - * - */ - cacheKey?: string; - /** - * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. - */ - thumbprint?: string; - /** - * The ajax settings object passed to jQuery.ajax. - */ - ajax?: JQueryAjaxSettings; - } - - /** - * Remote data is only used when the data provided by local and prefetch - * is insufficient. In order to prevent an obscene number of requests - * being made to remote endpoint, typeahead.js rate-limits remote requests. - */ - interface RemoteOptions - { - /** - * A URL to make requests to when the data provided by local and - * prefetch is insufficient. Required. - */ - url: string; - /** - * The pattern in url that will be replaced with the user's query - * when a request is made. Defaults to %QUERY. - */ - wildcard?: string; - /** - * Overrides the request URL. If set, no wildcard substitution will - * be performed on url. - * - * @param url Replacement URL - * @param uriEncodedQuery Encoded query - * @returns A valid URL - */ - replace?: (url: string, uriEncodedQuery: string) => string; - /** - * The function used for rate-limiting network requests. - * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. - */ - rateLimitby?: string; - /** - * The time interval in milliseconds that will be used by rateLimitFn. - * Defaults to 300. - */ - rateLimitWait?: number; +declare module Bloodhound { + interface BloodhoundOptions { + /** + * Transforms a datum into an array of string tokens + * + * @constructor + * @param datum individual units that compose the dataset + */ + datumTokenizer?: any; + /** + * Transforms a query into an array of string tokens + * + * @constructor + * @param query tokenizer query + */ + queryTokenizer?: any; + /** + * The max number of suggestions to return from Bloodhound#get. + * If not reached, the data source will attempt to backfill the suggestions from remote. Defaults to 5 + */ + limit?: number; + /** + * If set, this is expected to be a function with the signature (remoteMatch, localMatch) that returns true if the datums are duplicates or false otherwise. + * If not set, duplicate detection will not be performed. + */ + dupDetector?: (remoteMatch: T, localMatch: T) => boolean; + /** + * A compare function used to sort matched datums for a given query. + */ + sorter?: (a: T, b: T) => number; + /** + * An array of datums or a function that returns an array of datums. + */ + local?: () => T[]; + /** + * Can be a URL to a JSON file containing an array of datums or, if more configurability is needed, a prefetch options hash. + */ + prefetch?: PrefetchOptions; + /** + * Can be a URL to fetch suggestions from when the data provided by local and prefetch is insufficient or, if more configurability is needed, a remote options hash. + */ + remote?: RemoteOptions; + } /** - * Transforms the response body into an array of datums. - * - * @param parsedResponse Response body + * Prefetched data is fetched and processed on initialization. + * If the browser supports localStorage, the processed data will be cached + * there to prevent additional network requests on subsequent page loads. */ - filter?: (parsedResponse: any) => T[]; + interface PrefetchOptions { + /** + * A URL to a JSON file containing an array of datums. Required. + */ + url: string; + /** + * The time (in milliseconds) the prefetched data should be cached + * in localStorage. Defaults to 86400000 (1 day). + */ + ttl?: number; + /** + * A function that transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** The key that data will be stored in local storage under. Defaults to value of url. + * + */ + cacheKey?: string; + /** + * A string used for thumbprinting prefetched data. If this doesn't match what's stored in local storage, the data will be refetched. + */ + thumbprint?: string; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; + } + /** - * The ajax settings object passed to jQuery.ajax. + * Remote data is only used when the data provided by local and prefetch + * is insufficient. In order to prevent an obscene number of requests + * being made to remote endpoint, typeahead.js rate-limits remote requests. */ - ajax?: JQueryAjaxSettings; + interface RemoteOptions { + /** + * A URL to make requests to when the data provided by local and + * prefetch is insufficient. Required. + */ + url: string; + /** + * The pattern in url that will be replaced with the user's query + * when a request is made. Defaults to %QUERY. + */ + wildcard?: string; + /** + * Overrides the request URL. If set, no wildcard substitution will + * be performed on url. + * + * @param url Replacement URL + * @param uriEncodedQuery Encoded query + * @returns A valid URL + */ + replace?: (url: string, uriEncodedQuery: string) => string; + /** + * The function used for rate-limiting network requests. + * Can be either 'debounce' or 'throttle'. Defaults to 'debounce'. + */ + rateLimitby?: string; + /** + * The time interval in milliseconds that will be used by rateLimitFn. + * Defaults to 300. + */ + rateLimitWait?: number; + + /** + * Transforms the response body into an array of datums. + * + * @param parsedResponse Response body + */ + filter?: (parsedResponse: any) => T[]; + /** + * The ajax settings object passed to jQuery.ajax. + */ + ajax?: JQueryAjaxSettings; - /** - * A function that provides a hook to allow you to prepare the settings object passed to transport - * when a request is about to be made. The function signature should be prepare(query, settings), - * where query is the query #search was called with and settings is the default settings object - * created internally by the Bloodhound instance. The prepare function should return a settings object. - * [Note: Added in 0.11.1] - * - * @param query The query #search was called with. - * @param settings The default settings object created internally by Bloodhound. - * @returns A JqueryAjaxSettings object. - */ - prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; - } + /** + * A function that provides a hook to allow you to prepare the settings object passed to transport + * when a request is about to be made. The function signature should be prepare(query, settings), + * where query is the query #search was called with and settings is the default settings object + * created internally by the Bloodhound instance. The prepare function should return a settings object. + * [Note: Added in 0.11.1] + * + * @param query The query #search was called with. + * @param settings The default settings object created internally by Bloodhound. + * @returns A JqueryAjaxSettings object. + */ + prepare?: (query: string, settings: JQueryAjaxSettings) => JQueryAjaxSettings; + } - /** - * The most common tokenization methods. - */ - interface Tokenizers - { /** - * Split a given string on whitespace characters. + * The most common tokenization methods. */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; + interface Tokenizers { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; - /** - * Instances of the most common tokenization methods. - */ - obj: ObjTokenizer; - } + /** + * Instances of the most common tokenization methods. + */ + obj: ObjTokenizer; + } - interface ObjTokenizer - { - /** - * Split a given string on whitespace characters. - */ - whitespace(query: string): string[]; - /** - * Split a given string on non-word characters. - */ - nonword(query: string): string[]; - } + interface ObjTokenizer { + /** + * Split a given string on whitespace characters. + */ + whitespace(query: string): string[]; + /** + * Split a given string on non-word characters. + */ + nonword(query: string): string[]; + } } declare class Bloodhound { - constructor(options: Bloodhound.BloodhoundOptions); - /** - * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin - */ - public ttAdapter(): any; - /** - * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. - * Until initialized, all other methods will behave as no-ops. - * Returns a jQuery promise which is resolved when engine has been initialized. - * - * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. - * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. - * If reinitialize is truthy, the method will behave as if it were being called for the first time. - * - * var promise1 = engine.initialize(); - * var promise2 = engine.initialize(); - * var promise3 = engine.initialize(true); - * - * promise1 === promise2; - * promise3 !== promise1 && promise3 !== promise2; - */ - public initialize(reinitialize?: boolean): JQueryPromise; - /** - * Takes one argument, datums, which is expected to be an array of datums. - * The passed in datums will get added to the search index that powers the suggestion engine. - */ - public add(datums: T[]): void; - /** - * Removes all suggestions from the search index. - */ - public clear(): void; - /** - * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. - * clearPrefetchCache offers a way to programmatically clear said cache. - */ - public clearPrefetchCache(): void; - /** - * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. - * clearRemoteCache offers a way to programmatically clear said cache. - */ - public clearRemoteCache(): void; - /** - * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. - */ - public noConflict(): any; + constructor(options: Bloodhound.BloodhoundOptions); + /** + * wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin + */ + public ttAdapter(): any; + /** + * Kicks off the initialization of the suggestion engine. This includes processing the data provided through local and fetching/processing the data provided through prefetch. + * Until initialized, all other methods will behave as no-ops. + * Returns a jQuery promise which is resolved when engine has been initialized. + * + * After the initial call of initialize, how subsequent invocations of the method behave depends on the reinitialize argument. + * If reinitialize is falsy, the method will not execute the initialization logic and will just return the same jQuery promise returned by the initial invocation. + * If reinitialize is truthy, the method will behave as if it were being called for the first time. + * + * var promise1 = engine.initialize(); + * var promise2 = engine.initialize(); + * var promise3 = engine.initialize(true); + * + * promise1 === promise2; + * promise3 !== promise1 && promise3 !== promise2; + */ + public initialize(reinitialize?: boolean): JQueryPromise; + /** + * Takes one argument, datums, which is expected to be an array of datums. + * The passed in datums will get added to the search index that powers the suggestion engine. + */ + public add(datums: T[]): void; + /** + * Removes all suggestions from the search index. + */ + public clear(): void; + /** + * If you're using prefetch, data gets cached in local storage in an effort to cut down on unnecessary network requests. + * clearPrefetchCache offers a way to programmatically clear said cache. + */ + public clearPrefetchCache(): void; + /** + * If you're using remote, Bloodhound will cache the 10 most recent responses in an effort to provide a better user experience. + * clearRemoteCache offers a way to programmatically clear said cache. + */ + public clearRemoteCache(): void; + /** + * Returns a reference to the Bloodhound constructor and reverts window.Bloodhound to its previous value. Can be used to avoid naming collisions. + */ + public noConflict(): any; - /** - * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. - * cb will always be invoked once synchronously with suggestions that were available on the client. - * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. - */ - public get(query: string, cb: (datums: T[]) => void): void; + /** + * Computes a set of suggestions for query. cb will be invoked with an array of datums that represent said set. + * cb will always be invoked once synchronously with suggestions that were available on the client. + * If those suggestions are insufficient (# of suggestions is less than limit) and remote was configured, cb may also be invoked asynchronously with the suggestions available on the client mixed with suggestions from the remote source. + */ + public get(query: string, cb: (datums: T[]) => void): void; - /** - * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. - * Specify how you want datums and queries tokenized. - */ - public static tokenizers: Bloodhound.Tokenizers; + /** + * The Bloodhound suggestion engine is token-based, so how datums and queries are tokenized plays a vital role in the quality of search results. + * Specify how you want datums and queries tokenized. + */ + public static tokenizers: Bloodhound.Tokenizers; } declare module "bloodhound" { - export = Bloodhound; + export = Bloodhound; } From 7d715446377a65c491337c88efec1116507c2436 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:45:35 +0200 Subject: [PATCH 0042/1680] Bootstrap.v3.datetimepicker: referenced moment.js less generic type parameters, updated some functions, added some missing parameters --- .../bootstrap.v3.datetimepicker-tests.ts | 14 +++---- .../bootstrap.v3.datetimepicker.d.ts | 39 ++++++++++++------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 6abf38f946..056c76dd6b 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -6,17 +6,17 @@ function test_cases() { $('#datetimepicker').datetimepicker({ pickDate: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ pickTime: false }); - $('#datetimepicker').datetimepicker({ + $('#datetimepicker').datetimepicker({ minDate: '2012-12-31' }); - - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); - - var startDate = new Date(2012, 1, 20); - var endDate = new Date(2012, 1, 25); + + $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + + var startDate = moment(new Date(2012, 1, 20)); + var endDate = moment(new Date(2012, 1, 25)); $('#datetimepicker2') .datetimepicker() .on("dp.change", function (ev) { diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts index 228b7537f7..0db3f7b3fb 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker.d.ts @@ -10,15 +10,22 @@ */ /// +/// declare module BootstrapV3DatetimePicker { - interface DatetimepickerChangeEventObject extends JQueryEventObject { - date: any; - oldDate: any; + enum ViewMode { + 'days', + 'months', + 'years', + 'decades' + } + + interface DatetimepickerChangeEventObject extends DatetimepickerEventObject { + oldDate: moment.Moment; } interface DatetimepickerEventObject extends JQueryEventObject { - date: any; + date: moment.Moment; } interface DatetimepickerIcons { @@ -35,33 +42,37 @@ declare module BootstrapV3DatetimePicker { useSeconds?: boolean; useCurrent?: boolean; minuteStepping?: number; - minDate?: any; - maxDate?: any; + minDate?: moment.Moment | Date | string; + maxDate?: moment.Moment | Date | string; showToday?: boolean; collapse?: boolean; language?: string; - defaultDate?: string; - disabledDates?: Array; - enabledDates?: Array; + defaultDate?: moment.Moment | Date | string; + disabledDates?: Array; + enabledDates?: Array; icons?: DatetimepickerIcons; useStrict?: boolean; direction?: string; sideBySide?: boolean; - daysOfWeekDisabled?: Array; + daysOfWeekDisabled?: Array; calendarWeeks?: boolean; format?: string | boolean; locale?: string; showTodayButton?: boolean; + viewMode?: string; + inline?: boolean; } interface Datetimepicker { - setDate(date: any): void; - setMinDate(date: any): void; - setMaxDate(date: any): void; + date(date: moment.Moment | Date | string): void; + date(): moment.Moment; + minDate(date: moment.Moment | Date | string): void; + minDate(): moment.Moment | boolean; + maxDate(date: moment.Moment | Date | string): void; + maxDate(): moment.Moment | boolean; show(): void; disable(): void; enable(): void; - getDate(): void; } } From fd6b794520e5258ff59c7501d7d155fad3dad21a Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:49:50 +0200 Subject: [PATCH 0043/1680] FullCalendar: updated to last version, updated some interfaces names to fit documentation, less generic arguments and options, referenced moment.js --- fullCalendar/fullCalendar-tests.ts | 43 ++++----- fullCalendar/fullCalendar.d.ts | 146 +++++++++++++++++------------ 2 files changed, 107 insertions(+), 82 deletions(-) diff --git a/fullCalendar/fullCalendar-tests.ts b/fullCalendar/fullCalendar-tests.ts index 6890cbe422..b3ec7973c5 100644 --- a/fullCalendar/fullCalendar-tests.ts +++ b/fullCalendar/fullCalendar-tests.ts @@ -4,11 +4,10 @@ // All examples from http://arshaw.com/fullcalendar/docs/ -$('#calendar').fullCalendar({ -}) +$('#calendar').fullCalendar({}); $('#calendar').fullCalendar({ - weekends: false + weekends: false }); $('#calendar').fullCalendar({ @@ -67,7 +66,7 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('option', 'aspectRatio', 1.8); $('#calendar').fullCalendar({ - viewRender: function(view) { + viewRender: function (view) { alert('The new title of the view is ' + view.title); } }); @@ -81,22 +80,19 @@ $('#calendar').fullCalendar({ $('#calendar').fullCalendar('render'); $('#calendar').fullCalendar({ - dragOpacity: { - month: .2, - '': .5 - } + dragOpacity: .5 }); var view = $('#calendar').fullCalendar('getView'); alert("The view's title is " + view.title); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -155,12 +151,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -220,12 +216,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -274,12 +270,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ editable: true, header: { @@ -339,12 +335,12 @@ $(document).ready(function () { }); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -715,12 +711,12 @@ $('#draggable1').draggable(); $('#draggable2').draggable(); $(document).ready(function () { - + var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); - + $('#calendar').fullCalendar({ theme: true, header: { @@ -799,11 +795,11 @@ $(document).ready(function () { revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); - + }); /* initialize the calendar -----------------------------------------------------------------*/ - + $('#calendar').fullCalendar({ header: { left: 'prev,next today', @@ -833,9 +829,8 @@ $(document).ready(function () { // if so, remove the element from the "Draggable Events" list $(this).remove(); } - } }); }); -$('#calendar').fullCalendar('refetchEvents') \ No newline at end of file +$('#calendar').fullCalendar('refetchEvents'); diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index f73dc2d8bf..7552d5bfd9 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module FullCalendar { export interface Calendar { @@ -34,7 +35,18 @@ declare module FullCalendar { version: string; } - export interface Options { + export interface BusinessHours { + start: moment.Duration; + end: moment.Duration; + dow: Array; + } + + export interface Timespan { + start: moment.Moment; + end: moment.Moment; + } + + export interface Options extends AgendaOptions, EventDraggingResizingOptions, DroppingExternalElementsOptions, SelectionOptions { // General display - http://arshaw.com/fullcalendar/docs/display/ @@ -55,14 +67,19 @@ declare module FullCalendar { weekMode?: string; weekNumbers?: boolean; weekNumberCalculation?: any; // String/Function + businessHours?: boolean | BusinessHours; height?: number; contentHeight?: number; aspectRatio?: number; handleWindowResize?: boolean; - viewRender?: (view: View, element: JQuery) => void; - viewDestroy?: (view: View, element: JQuery) => void; + viewRender?: (view: ViewObject, element: JQuery) => void; + viewDestroy?: (view: ViewObject, element: JQuery) => void; dayRender?: (date: Date, cell: HTMLTableDataCellElement) => void; - windowResize?: (view: View) => void; + windowResize?: (view: ViewObject) => void; + + // Timezone + timezone?: string | boolean; + now?: moment.Moment | Date | string | (() => moment.Moment) // Views - http://arshaw.com/fullcalendar/docs/views/ @@ -70,6 +87,7 @@ declare module FullCalendar { // Current Date - http://arshaw.com/fullcalendar/docs/current_date/ + defaultDate?: moment.Moment | Date | string; year?: number; month?: number; date?: number; @@ -79,6 +97,7 @@ declare module FullCalendar { timeFormat?: any; // String/ViewOptionHash columnFormat?: any; // String/ViewOptionHash titleFormat?: any; // String/ViewOptionHash + buttonText?: ButtonTextObject; monthNames?: Array; monthNamesShort?: Array; @@ -88,19 +107,10 @@ declare module FullCalendar { // Clicking & Hovering - http://arshaw.com/fullcalendar/docs/mouse/ - dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - eventClick?: (event: EventObject, jsEvent: MouseEvent, view: View) => any; // return type boolean or void - eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; - - // Selection - http://arshaw.com/fullcalendar/docs/selection/ - - selectable?: any; // Boolean/ViewOptionHash - selectHelper?: any; // Boolean/Function - unselectAuto?: boolean; - unselectCancel?: string; - select?: (startDate: Date | string, endDate: Date | string, allDay: boolean, jsEvent: MouseEvent, view: View) => void; - unselect?: (view: View, jsEvent: Event) => void; + dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: ViewObject) => void; + eventClick?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => any; // return type boolean or void + eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; + eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: ViewObject) => void; // Event Data - http://arshaw.com/fullcalendar/docs/event_data/ @@ -129,7 +139,7 @@ declare module FullCalendar { endParam?: string lazyFetching?: boolean; eventDataTransform?: (eventData: any) => EventObject; - loading?: (isLoading: boolean, view: View) => void; + loading?: (isLoading: boolean, view: ViewObject) => void; // Event Rendering - http://arshaw.com/fullcalendar/docs/event_rendering/ @@ -137,37 +147,12 @@ declare module FullCalendar { eventBackgroundColor?: string; eventBorderColor?: string; eventTextColor?: string; - eventRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAfterAllRender?: (view: View) => void; - eventDestroy?: (event: EventObject, element: JQuery, view: View) => void; + eventRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: ViewObject) => void; + eventAfterAllRender?: (view: ViewObject) => void; + eventDestroy?: (event: EventObject, element: JQuery, view: ViewObject) => void; - // Event Dragging & Resizing - editable?: boolean; - eventStartEditable?: boolean; - eventDurationEditable?: boolean; - dragRevertDuration?: number; - dragOpacity?: any; // Float/ViewOptionHash - eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void; - - droppable?: boolean; - dropAccept?: any; // String/Function - drop?: (date: Date, allDay: boolean, jsEvent: MouseEvent, ui: any) => void; - } - - export interface View { - name: string; - title: string; - start: Date | string; - end: Date | string; - visStart: Date; - visEnd: Date; } export interface ViewOptionHash { @@ -189,16 +174,56 @@ declare module FullCalendar { export interface AgendaOptions { allDaySlot?: boolean; allDayText?: string; - axisFormat?: string; - slotMinutes?: number; - snapMinutes?: number; - defaultEventMinutes?: number; - firstHour?: number; - minTime?: any; // Integer/String - maxTime?: any; // Integer/String + slotDuration?: moment.Duration; + slotLabelFormat?: string; + slotLabelInterval?: moment.Duration; + snapDuration?: moment.Duration; + scrollTime?: moment.Duration; + minTime?: moment.Duration; // Integer/String + maxTime?: moment.Duration; // Integer/String slotEventOverlap?: boolean; } + /* + * Event Dragging & Resizing + */ + export interface EventDraggingResizingOptions { + editable?: boolean; + eventStartEditable?: boolean; + eventDurationEditable?: boolean; + dragRevertDuration?: number; // integer, milliseconds + dragOpacity?: number; // float + dragScroll?: boolean; + eventOverlap?: boolean | ((stillEvent: EventObject, movingEvent: EventObject) => boolean); + eventConstraint?: BusinessHours | Timespan; + eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + } + /* + * Selection - http://arshaw.com/fullcalendar/docs/selection/ + */ + export interface SelectionOptions { + selectable?: boolean; + selectHelper?: boolean | ((start: moment.Moment, end: moment.Moment) => HTMLElement); + unselectAuto?: boolean; + unselectCancel?: string; + selectOverlap?: boolean | ((event: EventObject) => boolean); + selectConstraint?: Timespan | BusinessHours; + select?: (start: moment.Moment, end: moment.Moment, jsEvent: MouseEvent, view: ViewObject, resource?: any) => void; + unselect?: (view: ViewObject, jsEvent: Event) => void; + } + + export interface DroppingExternalElementsOptions { + droppable?: boolean; + dropAccept?: string | ((draggable: any) => boolean); + drop?: (date: moment.Moment, jsEvent: MouseEvent, ui: any) => void; + eventReceive?: (event: EventObject) => void + } + export interface ButtonTextObject { prev?: string; next?: string; @@ -210,12 +235,10 @@ declare module FullCalendar { day?: string; } - export interface EventObject { + export interface EventObject extends Timespan { id?: any // String/number title: string; allDay?: boolean; - start: Date | string; - end?: Date | string; url?: string; className?: any; // string/Array editable?: boolean; @@ -226,6 +249,13 @@ declare module FullCalendar { textColor?: string; } + export interface ViewObject extends Timespan { + name: string; + title: string; + intervalStart: moment.Moment; + intervalEnd: moment.Moment; + } + export interface EventSource extends JQueryAjaxSettings { /** @@ -272,7 +302,7 @@ interface JQuery { /** * Returns the View Object for the current view. */ - fullCalendar(method: 'getView'): FullCalendar.View; + fullCalendar(method: 'getView'): FullCalendar.ViewObject; /** * Immediately switches to a different view. From 3eed85776e25068f0234c0827230d05d1bd412bc Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 14:59:22 +0200 Subject: [PATCH 0044/1680] setMaxDate has been changed to getter and setters so it is now maxDate https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/docs/Functions.md#minmaxdate --- .../bootstrap.v3.datetimepicker-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts index 056c76dd6b..e17b7b10cf 100644 --- a/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts +++ b/bootstrap.v3.datetimepicker/bootstrap.v3.datetimepicker-tests.ts @@ -13,7 +13,7 @@ function test_cases() { minDate: '2012-12-31' }); - $('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31'); + $('#datetimepicker').data("DateTimePicker").maxDate('2012-12-31'); var startDate = moment(new Date(2012, 1, 20)); var endDate = moment(new Date(2012, 1, 25)); From d7b3d781a82a3a19fcc9eb7916e247156ab432ee Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 15:36:34 +0200 Subject: [PATCH 0045/1680] Typeahead : DisplayKey is now Display --- typeahead/typeahead-tests.ts | 20 ++++++++++---------- typeahead/typeahead.d.ts | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 3864865c9f..ec2b2e2f3d 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,7 +6,7 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: string, syncResults: (x: any) => void) { + return function findMatches(q: string, syncResults: (x: Array) => void) { var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` var substrRegex = new RegExp(q, 'i'); @@ -97,7 +97,7 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', + display: 'value', source: substringMatcher(states) }] ); @@ -114,7 +114,7 @@ function test_datasets_array() { function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }] @@ -125,13 +125,13 @@ function test_datasets_array() { $('#the-basics .typeahead').typeahead(options, [ { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -161,7 +161,7 @@ function test_datasets_objects() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, { - displayKey: 'value', + display: 'value', source: substringMatcher(states) } ); @@ -180,7 +180,7 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: x => x.value, templates: {}, source: substringMatcher(states) } @@ -191,13 +191,13 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -291,7 +291,7 @@ function test_dataset_templates() { suggestion: function (context) { return context.name; } - } + }, }); } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index cde3a92771..7ffbe5b509 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -105,7 +105,7 @@ declare module Twitter.Typeahead { * cb can be invoked synchronously or asynchronously. * */ - source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); + source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** * The name of the dataset. @@ -120,7 +120,7 @@ declare module Twitter.Typeahead { * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. * Defaults to value. */ - displayKey?: string | ((obj: any) => string); + display?: string | ((obj: any) => string); /** * A hash of templates to be used when rendering the dataset. @@ -128,7 +128,6 @@ declare module Twitter.Typeahead { */ templates?: Templates; async?: boolean; - display?: boolean | ((x: any) => boolean); } From bf24ad882812478d35937c70782624bfe2ac95eb Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:13:45 +0200 Subject: [PATCH 0046/1680] typeahead: Added support for some of the custom events --- typeahead/typeahead.d.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 7ffbe5b509..136f9650bf 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -88,6 +88,41 @@ interface JQuery { * @param datasets One or more datasets passed in as arguments. */ typeahead(options: Twitter.Typeahead.Options, ...datasets: Twitter.Typeahead.Dataset[]): JQuery; + + on(events: "typeahead:active", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:active", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:idle", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:idle", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:open", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:open", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:close", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:close", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:change", selector: string, data: any, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", selector: string, handler: (ev: JQueryEventObject) => any): JQuery; + on(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + off(events: "typeahead:change", handler: (ev: JQueryEventObject) => any): JQuery; + + on(events: "typeahead:render", selector: string, data: any, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", selector: string, handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + on(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + off(events: "typeahead:render", handler: (ev: JQueryEventObject, suggestions: Array, async: boolean, datasetName: string) => any): JQuery; + + on(events: "typeahead:select", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; } declare module Twitter.Typeahead { From b7257e1d4c9eec50396df8d9759123060e5c8d7c Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 20:54:29 +0200 Subject: [PATCH 0047/1680] typeahead: added all the events, tests coming soon --- typeahead/typeahead.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index 136f9650bf..ce401c213b 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -123,6 +123,31 @@ interface JQuery { on(events: "typeahead:select", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; on(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; off(events: "typeahead:select", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:autocomplete", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:autocomplete", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:cursorchange", selector: string, data: any, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", selector: string, handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + on(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + off(events: "typeahead:cursorchange", handler: (ev: JQueryEventObject, suggestion: any) => any): JQuery; + + on(events: "typeahead:asyncrequest", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncrequest", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asynccancel", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asynccancel", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + + on(events: "typeahead:asyncreceive", selector: string, data: any, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", selector: string, handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + on(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; + off(events: "typeahead:asyncreceive", handler: (ev: JQueryEventObject, query: string, datasetName: string) => any): JQuery; } declare module Twitter.Typeahead { From 77b2f7e8d49399d29f751a066ae13da17f46facc Mon Sep 17 00:00:00 2001 From: James Brantly Date: Thu, 8 Oct 2015 00:31:51 -0400 Subject: [PATCH 0048/1680] Initial React v0.14 definitions --- react/README.md | 8 +- react/react-addons-clone-with-props.d.ts | 18 + react/react-addons-create-fragment.d.ts | 16 + react/react-addons-css-transition-group.d.ts | 25 + react/react-addons-linked-state-mixin.d.ts | 24 + react/react-addons-perf.d.ts | 46 + react/react-addons-pure-render-mixin.d.ts | 17 + react/react-addons-test-utils.d.ts | 154 +++ react/react-addons-transition-group.d.ts | 22 + react/react-addons-update.d.ts | 35 + react/react-dom.d.ts | 71 ++ react/react-global.d.ts | 325 +---- react/react.d.ts | 1107 +----------------- 13 files changed, 486 insertions(+), 1382 deletions(-) create mode 100644 react/react-addons-clone-with-props.d.ts create mode 100644 react/react-addons-create-fragment.d.ts create mode 100644 react/react-addons-css-transition-group.d.ts create mode 100644 react/react-addons-linked-state-mixin.d.ts create mode 100644 react/react-addons-perf.d.ts create mode 100644 react/react-addons-pure-render-mixin.d.ts create mode 100644 react/react-addons-test-utils.d.ts create mode 100644 react/react-addons-transition-group.d.ts create mode 100644 react/react-addons-update.d.ts create mode 100644 react/react-dom.d.ts diff --git a/react/README.md b/react/README.md index b7ff4b55e6..eed63fcb32 100644 --- a/react/README.md +++ b/react/README.md @@ -1,5 +1,5 @@ -# React v0.13.3 Type Definitions +# React v0.14 Type Definitions -This folder contains the following `.d.ts` files: -* `react.d.ts` declares the module `"react"` and `"react/addons"` -* `react-global.d.ts` declares the global namespace `React` (only include this if you are actually using the global `React`) +If you are using modules you should use `react.d.ts`, `react-dom.d.ts` and any of the `react-addon-*.d.ts` definition files. + +If you are using the global `React` variable, you should use `react-global.d.ts`. diff --git a/react/react-addons-clone-with-props.d.ts b/react/react-addons-clone-with-props.d.ts new file mode 100644 index 0000000000..137c6650c7 --- /dev/null +++ b/react/react-addons-clone-with-props.d.ts @@ -0,0 +1,18 @@ +// Type definitions for React v0.14 (react-addons-clone-with-props) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function cloneWithProps

(element: __React.DOMElement

, props: P): __React.DOMElement

; + export function cloneWithProps

(element: __React.ClassicElement

, props: P): __React.ClassicElement

; + export function cloneWithProps

(element: __React.ReactElement

, props: P): __React.ReactElement

; + } +} + +declare module "react-addons-clone-with-props" { + export = __React.__Addons.cloneWithProps; +} diff --git a/react/react-addons-create-fragment.d.ts b/react/react-addons-create-fragment.d.ts new file mode 100644 index 0000000000..b2332eae1e --- /dev/null +++ b/react/react-addons-create-fragment.d.ts @@ -0,0 +1,16 @@ +// Type definitions for React v0.14 (react-addons-create-fragment) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + export function createFragment(object: { [key: string]: ReactNode }): ReactFragment; + } +} + +declare module "react-addons-create-fragment" { + export = __React.__Addons.createFragment; +} diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts new file mode 100644 index 0000000000..99db1f4f46 --- /dev/null +++ b/react/react-addons-css-transition-group.d.ts @@ -0,0 +1,25 @@ +// Type definitions for React v0.14 (react-addons-css-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare namespace __React { + namespace __Addons { + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + } +} + +declare module "react-addons-css-transition-group" { + var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + export = CSSTransitionGroup; +} diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts new file mode 100644 index 0000000000..a98caa3847 --- /dev/null +++ b/react/react-addons-linked-state-mixin.d.ts @@ -0,0 +1,24 @@ +// Type definitions for React v0.14 (react-addons-linked-state-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + } +} + +declare module "react-addons-linked-state-mixin" { + var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + export = LinkedStateMixin; +} diff --git a/react/react-addons-perf.d.ts b/react/react-addons-perf.d.ts new file mode 100644 index 0000000000..7ca369db8b --- /dev/null +++ b/react/react-addons-perf.d.ts @@ -0,0 +1,46 @@ +// Type definitions for React v0.14 (react-addons-perf) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + namespace Perf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + } +} + +declare module "react-addons-perf" { + import Perf = __React.__Addons.Perf; + export = Perf; +} diff --git a/react/react-addons-pure-render-mixin.d.ts b/react/react-addons-pure-render-mixin.d.ts new file mode 100644 index 0000000000..741046d907 --- /dev/null +++ b/react/react-addons-pure-render-mixin.d.ts @@ -0,0 +1,17 @@ +// Type definitions for React v0.14 (react-addons-pure-render-mixin) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface PureRenderMixin extends Mixin {} + } +} + +declare module "react-addons-pure-render-mixin" { + var PureRenderMixin: __React.__Addons.PureRenderMixin; + export = PureRenderMixin; +} diff --git a/react/react-addons-test-utils.d.ts b/react/react-addons-test-utils.d.ts new file mode 100644 index 0000000000..13f4336573 --- /dev/null +++ b/react/react-addons-test-utils.d.ts @@ -0,0 +1,154 @@ +// Type definitions for React v0.14 (react-addons-test-utils) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + interface MockedComponentClass { + new(): any; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } + + namespace TestUtils { + namespace Simulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + } +} + +declare module "react-addons-test-utils" { + import TestUtils = __React.__Addons.TestUtils; + export = TestUtils; +} diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts new file mode 100644 index 0000000000..376bebd51b --- /dev/null +++ b/react/react-addons-transition-group.d.ts @@ -0,0 +1,22 @@ +// Type definitions for React v0.14 (react-addons-transition-group) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + type TransitionGroup = ComponentClass; + } +} + +declare module "react-addons-transition-group" { + var TransitionGroup: __React.__Addons.TransitionGroup; + export = TransitionGroup; +} \ No newline at end of file diff --git a/react/react-addons-update.d.ts b/react/react-addons-update.d.ts new file mode 100644 index 0000000000..ece9e87c7a --- /dev/null +++ b/react/react-addons-update.d.ts @@ -0,0 +1,35 @@ +// Type definitions for React v0.14 (react-addons-update) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + namespace __Addons { + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + } +} + +declare module "react-addons-update" { + export = __React.__Addons.update; +} diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts new file mode 100644 index 0000000000..e0d88e04ba --- /dev/null +++ b/react/react-dom.d.ts @@ -0,0 +1,71 @@ +// Type definitions for React v0.14 (react-dom) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare namespace __React { + + module __DOM { + function findDOMNode( + componentOrElement: __React.Component | Element): TElement; + function findDOMNode( + componentOrElement: __React.Component | Element): Element; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + + var version: string; + + function unstable_batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; + function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; + function unstable_batchedUpdates(callback: () => any): void; + + function unstable_renderSubtreeIntoContainer

( + parentComponent: Component, + nextElement: DOMElement

, + container: Element, + callback?: (component: DOMComponent

) => any): DOMComponent

; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ClassicElement

, + container: Element, + callback?: (component: ClassicComponent) => any): ClassicComponent; + function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + nextElement: ReactElement

, + container: Element, + callback?: (component: Component) => any): Component; + + + } + + namespace __DOMServer { + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + var version: string; + } +} + +declare module "react-dom" { + import DOM = __React.__DOM; + export = DOM; +} + +declare module "react-dom/server" { + import DOMServer = __React.__DOMServer; + export = DOMServer; +} diff --git a/react/react-global.d.ts b/react/react-global.d.ts index 1728ba2fc8..4de0a8eed2 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -1,285 +1,66 @@ -// Type definitions for React v0.13.3 (namespace) +// Type definitions for React v0.14 (namespace) // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// import React = __React; +import ReactDOM = __React.__DOM; declare namespace __React { - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; + namespace addons { + export var TransitionGroup: __React.__Addons.TransitionGroup; + export var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + + export var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + export var PureRenderMixin: __React.__Addons.PureRenderMixin; + + export import cloneWithProps = __React.__Addons.cloneWithProps; + export import createFragment = __React.__Addons.createFragment; + export import update = __React.__Addons.update; + + export import Perf = __React.__Addons.Perf; + export import TestUtils = __React.__Addons.TestUtils; } - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- + // TransitionGroup types + export import TransitionGroupProps = __React.__Addons.TransitionGroupProps; + export import TransitionGroup = __React.__Addons.TransitionGroup; + export import CSSTransitionGroupProps = __React.__Addons.CSSTransitionGroupProps; + export import CSSTransitionGroup = __React.__Addons.CSSTransitionGroup; + + // LinkedStateMixin types + export import ReactLink = __React.__Addons.ReactLink; + export import LinkedStateMixin = __React.__Addons.LinkedStateMixin; + + // PureRenderMixin types + export import PureRenderMixin = __React.__Addons.PureRenderMixin; + + // update types + export import UpdateSpecCommand = __React.__Addons.UpdateSpecCommand; + export import UpdateSpecPath = __React.__Addons.UpdateSpecPath; + export import UpdateSpec = __React.__Addons.UpdateSpec; + export import UpdateArraySpec = __React.__Addons.UpdateArraySpec; - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } + // Perf types + export import ComponentPerfContext = __React.__Addons.ComponentPerfContext; + export import NumericPerfContext = __React.__Addons.NumericPerfContext; + export import Measurements = __React.__Addons.Measurements; + + // TestUtil types + export import SyntheticEventData = __React.__Addons.SyntheticEventData; + export import EventSimulator = __React.__Addons.EventSimulator; + export import MockedComponentClass = __React.__Addons.MockedComponentClass; + export import ShallowRenderer = __React.__Addons.ShallowRenderer; } diff --git a/react/react.d.ts b/react/react.d.ts index de8ba67327..b096028382 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React v0.13.3 +// Type definitions for React v0.14 // Project: http://facebook.github.io/react/ // Definitions by: Asana , AssureSign , Microsoft // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -98,29 +98,7 @@ declare namespace __React { props?: P, ...children: ReactNode[]): ReactElement

; - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; var DOM: ReactDOM; var PropTypes: ReactPropTypes; @@ -152,12 +130,8 @@ declare namespace __React { interface ClassicComponent extends Component { replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; isMounted(): boolean; getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; } interface DOMComponent

extends ClassicComponent { @@ -812,1085 +786,6 @@ declare module "react" { export = __React; } -declare module "react/addons" { - // - // React Elements - // ---------------------------------------------------------------------- - - type ReactType = ComponentClass | string; - - interface ReactElement

{ - type: string | ComponentClass

; - props: P; - key: string | number; - ref: string | ((component: Component) => any); - } - - interface ClassicElement

extends ReactElement

{ - type: string | ClassicComponentClass

; - ref: string | ((component: ClassicComponent) => any); - } - - interface DOMElement

extends ClassicElement

{ - type: string; - ref: string | ((component: DOMComponent

) => any); - } - - type HTMLElement = DOMElement; - type SVGElement = DOMElement; - - // - // Factories - // ---------------------------------------------------------------------- - - interface Factory

{ - (props?: P, ...children: ReactNode[]): ReactElement

; - } - - interface ClassicFactory

extends Factory

{ - (props?: P, ...children: ReactNode[]): ClassicElement

; - } - - interface DOMFactory

extends ClassicFactory

{ - (props?: P, ...children: ReactNode[]): DOMElement

; - } - - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; - type SVGElementFactory = DOMFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - type ReactText = string | number; - type ReactChild = ReactElement | ReactText; - - // Should be Array but type aliases cannot be recursive - type ReactFragment = {} | Array; - type ReactNode = ReactChild | ReactFragment | boolean; - - // - // Top Level API - // ---------------------------------------------------------------------- - - function createClass(spec: ComponentSpec): ClassicComponentClass

; - - function createFactory

(type: string): DOMFactory

; - function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; - function createFactory

(type: ComponentClass

): Factory

; - - function createElement

( - type: string, - props?: P, - ...children: ReactNode[]): DOMElement

; - function createElement

( - type: ClassicComponentClass

| string, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function createElement

( - type: ComponentClass

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function cloneElement

( - element: DOMElement

, - props?: P, - ...children: ReactNode[]): DOMElement

; - function cloneElement

( - element: ClassicElement

, - props?: P, - ...children: ReactNode[]): ClassicElement

; - function cloneElement

( - element: ReactElement

, - props?: P, - ...children: ReactNode[]): ReactElement

; - - function render

( - element: DOMElement

, - container: Element, - callback?: () => any): DOMComponent

; - function render( - element: ClassicElement

, - container: Element, - callback?: () => any): ClassicComponent; - function render( - element: ReactElement

, - container: Element, - callback?: () => any): Component; - - function unmountComponentAtNode(container: Element): boolean; - function renderToString(element: ReactElement): string; - function renderToStaticMarkup(element: ReactElement): string; - function isValidElement(object: {}): boolean; - function initializeTouchEvents(shouldUseTouch: boolean): void; - - function findDOMNode( - componentOrElement: Component | Element): TElement; - function findDOMNode( - componentOrElement: Component | Element): Element; - - var DOM: ReactDOM; - var PropTypes: ReactPropTypes; - var Children: ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // Base component for plain JS classes - class Component implements ComponentLifecycle { - static propTypes: ValidationMap; - static contextTypes: ValidationMap; - static childContextTypes: ValidationMap; - static defaultProps: Props; - - constructor(props?: P, context?: any); - setState(f: (prevState: S, props: P) => S, callback?: () => any): void; - setState(state: S, callback?: () => any): void; - forceUpdate(callBack?: () => any): void; - render(): JSX.Element; - props: P; - state: S; - context: {}; - refs: { - [key: string]: Component - }; - } - - interface ClassicComponent extends Component { - replaceState(nextState: S, callback?: () => any): void; - getDOMNode(): TElement; - getDOMNode(): Element; - isMounted(): boolean; - getInitialState?(): S; - setProps(nextProps: P, callback?: () => any): void; - replaceProps(nextProps: P, callback?: () => any): void; - } - - interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - type HTMLComponent = DOMComponent; - type SVGComponent = DOMComponent; - - interface ChildContextProvider { - getChildContext(): CC; - } - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - interface ComponentClass

{ - new(props?: P, context?: any): Component; - propTypes?: ValidationMap

; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap; - defaultProps?: P; - } - - interface ClassicComponentClass

extends ComponentClass

{ - new(props?: P, context?: any): ClassicComponent; - getDefaultProps?(): P; - displayName?: string; - } - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - interface ComponentLifecycle { - componentWillMount?(): void; - componentDidMount?(): void; - componentWillReceiveProps?(nextProps: P, nextContext: any): void; - shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; - componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; - componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; - componentWillUnmount?(): void; - } - - interface Mixin extends ComponentLifecycle { - mixins?: Mixin; - statics?: { - [key: string]: any; - }; - - displayName?: string; - propTypes?: ValidationMap; - contextTypes?: ValidationMap; - childContextTypes?: ValidationMap - - getDefaultProps?(): P; - getInitialState?(): S; - } - - interface ComponentSpec extends Mixin { - render(): ReactElement; - - [propertyName: string]: any; - } - - // - // Event System - // ---------------------------------------------------------------------- - - interface SyntheticEvent { - bubbles: boolean; - cancelable: boolean; - currentTarget: EventTarget; - defaultPrevented: boolean; - eventPhase: number; - isTrusted: boolean; - nativeEvent: Event; - preventDefault(): void; - stopPropagation(): void; - target: EventTarget; - timeStamp: Date; - type: string; - } - - interface DragEvent extends SyntheticEvent { - dataTransfer: DataTransfer; - } - - interface ClipboardEvent extends SyntheticEvent { - clipboardData: DataTransfer; - } - - interface KeyboardEvent extends SyntheticEvent { - altKey: boolean; - charCode: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - key: string; - keyCode: number; - locale: string; - location: number; - metaKey: boolean; - repeat: boolean; - shiftKey: boolean; - which: number; - } - - interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; - } - - interface FormEvent extends SyntheticEvent { - } - - interface MouseEvent extends SyntheticEvent { - altKey: boolean; - button: number; - buttons: number; - clientX: number; - clientY: number; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - pageX: number; - pageY: number; - relatedTarget: EventTarget; - screenX: number; - screenY: number; - shiftKey: boolean; - } - - interface TouchEvent extends SyntheticEvent { - altKey: boolean; - changedTouches: TouchList; - ctrlKey: boolean; - getModifierState(key: string): boolean; - metaKey: boolean; - shiftKey: boolean; - targetTouches: TouchList; - touches: TouchList; - } - - interface UIEvent extends SyntheticEvent { - detail: number; - view: AbstractView; - } - - interface WheelEvent extends SyntheticEvent { - deltaMode: number; - deltaX: number; - deltaY: number; - deltaZ: number; - } - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - interface EventHandler { - (event: E): void; - } - - interface DragEventHandler extends EventHandler {} - interface ClipboardEventHandler extends EventHandler {} - interface KeyboardEventHandler extends EventHandler {} - interface FocusEventHandler extends EventHandler {} - interface FormEventHandler extends EventHandler {} - interface MouseEventHandler extends EventHandler {} - interface TouchEventHandler extends EventHandler {} - interface UIEventHandler extends EventHandler {} - interface WheelEventHandler extends EventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - interface Props { - children?: ReactNode; - key?: string | number; - ref?: string | ((component: T) => any); - } - - interface DOMAttributesBase extends Props { - onCopy?: ClipboardEventHandler; - onCut?: ClipboardEventHandler; - onPaste?: ClipboardEventHandler; - onKeyDown?: KeyboardEventHandler; - onKeyPress?: KeyboardEventHandler; - onKeyUp?: KeyboardEventHandler; - onFocus?: FocusEventHandler; - onBlur?: FocusEventHandler; - onChange?: FormEventHandler; - onInput?: FormEventHandler; - onSubmit?: FormEventHandler; - onClick?: MouseEventHandler; - onDoubleClick?: MouseEventHandler; - onDrag?: DragEventHandler; - onDragEnd?: DragEventHandler; - onDragEnter?: DragEventHandler; - onDragExit?: DragEventHandler; - onDragLeave?: DragEventHandler; - onDragOver?: DragEventHandler; - onDragStart?: DragEventHandler; - onDrop?: DragEventHandler; - onMouseDown?: MouseEventHandler; - onMouseEnter?: MouseEventHandler; - onMouseLeave?: MouseEventHandler; - onMouseMove?: MouseEventHandler; - onMouseOut?: MouseEventHandler; - onMouseOver?: MouseEventHandler; - onMouseUp?: MouseEventHandler; - onTouchCancel?: TouchEventHandler; - onTouchEnd?: TouchEventHandler; - onTouchMove?: TouchEventHandler; - onTouchStart?: TouchEventHandler; - onScroll?: UIEventHandler; - onWheel?: WheelEventHandler; - - className?: string; - id?: string; - - dangerouslySetInnerHTML?: { - __html: string; - }; - } - - interface DOMAttributes extends DOMAttributesBase> { - } - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - interface CSSProperties { - boxFlex?: number; - boxFlexGroup?: number; - columnCount?: number; - flex?: number | string; - flexGrow?: number; - flexShrink?: number; - fontWeight?: number | string; - lineClamp?: number; - lineHeight?: number | string; - opacity?: number; - order?: number; - orphans?: number; - widows?: number; - zIndex?: number; - zoom?: number; - - fontSize?: number | string; - - // SVG-related properties - fillOpacity?: number; - strokeOpacity?: number; - strokeWidth?: number; - - [propertyName: string]: any; - } - - interface HTMLAttributesBase extends DOMAttributesBase { - accept?: string; - acceptCharset?: string; - accessKey?: string; - action?: string; - allowFullScreen?: boolean; - allowTransparency?: boolean; - alt?: string; - async?: boolean; - autoComplete?: boolean; - autoFocus?: boolean; - autoPlay?: boolean; - cellPadding?: number | string; - cellSpacing?: number | string; - charSet?: string; - checked?: boolean; - classID?: string; - cols?: number; - colSpan?: number; - content?: string; - contentEditable?: boolean; - contextMenu?: string; - controls?: any; - coords?: string; - crossOrigin?: string; - data?: string; - dateTime?: string; - defaultChecked?: boolean; - defaultValue?: string; - defer?: boolean; - dir?: string; - disabled?: boolean; - download?: any; - draggable?: boolean; - encType?: string; - form?: string; - formAction?: string; - formEncType?: string; - formMethod?: string; - formNoValidate?: boolean; - formTarget?: string; - frameBorder?: number | string; - headers?: string; - height?: number | string; - hidden?: boolean; - high?: number; - href?: string; - hrefLang?: string; - htmlFor?: string; - httpEquiv?: string; - icon?: string; - label?: string; - lang?: string; - list?: string; - loop?: boolean; - low?: number; - manifest?: string; - marginHeight?: number; - marginWidth?: number; - max?: number | string; - maxLength?: number; - media?: string; - mediaGroup?: string; - method?: string; - min?: number | string; - multiple?: boolean; - muted?: boolean; - name?: string; - noValidate?: boolean; - open?: boolean; - optimum?: number; - pattern?: string; - placeholder?: string; - poster?: string; - preload?: string; - radioGroup?: string; - readOnly?: boolean; - rel?: string; - required?: boolean; - role?: string; - rows?: number; - rowSpan?: number; - sandbox?: string; - scope?: string; - scoped?: boolean; - scrolling?: string; - seamless?: boolean; - selected?: boolean; - shape?: string; - size?: number; - sizes?: string; - span?: number; - spellCheck?: boolean; - src?: string; - srcDoc?: string; - srcSet?: string; - start?: number; - step?: number | string; - style?: CSSProperties; - tabIndex?: number; - target?: string; - title?: string; - type?: string; - useMap?: string; - value?: string; - width?: number | string; - wmode?: string; - - // Non-standard Attributes - autoCapitalize?: boolean; - autoCorrect?: boolean; - property?: string; - itemProp?: string; - itemScope?: boolean; - itemType?: string; - unselectable?: boolean; - } - - interface HTMLAttributes extends HTMLAttributesBase { - } - - interface SVGElementAttributes extends HTMLAttributes { - viewBox?: string; - preserveAspectRatio?: string; - } - - interface SVGAttributes extends DOMAttributes { - ref?: string | ((component: SVGComponent) => void); - - cx?: number | string; - cy?: number | string; - d?: string; - dx?: number | string; - dy?: number | string; - fill?: string; - fillOpacity?: number | string; - fontFamily?: string; - fontSize?: number | string; - fx?: number | string; - fy?: number | string; - gradientTransform?: string; - gradientUnits?: string; - height?: number | string; - markerEnd?: string; - markerMid?: string; - markerStart?: string; - offset?: number | string; - opacity?: number | string; - patternContentUnits?: string; - patternUnits?: string; - points?: string; - preserveAspectRatio?: string; - r?: number | string; - rx?: number | string; - ry?: number | string; - spreadMethod?: string; - stopColor?: string; - stopOpacity?: number | string; - stroke?: string; - strokeDasharray?: string; - strokeLinecap?: string; - strokeMiterlimit?: string; - strokeOpacity?: number | string; - strokeWidth?: number | string; - textAnchor?: string; - transform?: string; - version?: string; - viewBox?: string; - width?: number | string; - x1?: number | string; - x2?: number | string; - x?: number | string; - y1?: number | string; - y2?: number | string - y?: number | string; - } - - // - // React.DOM - // ---------------------------------------------------------------------- - - interface ReactDOM { - // HTML - a: HTMLFactory; - abbr: HTMLFactory; - address: HTMLFactory; - area: HTMLFactory; - article: HTMLFactory; - aside: HTMLFactory; - audio: HTMLFactory; - b: HTMLFactory; - base: HTMLFactory; - bdi: HTMLFactory; - bdo: HTMLFactory; - big: HTMLFactory; - blockquote: HTMLFactory; - body: HTMLFactory; - br: HTMLFactory; - button: HTMLFactory; - canvas: HTMLFactory; - caption: HTMLFactory; - cite: HTMLFactory; - code: HTMLFactory; - col: HTMLFactory; - colgroup: HTMLFactory; - data: HTMLFactory; - datalist: HTMLFactory; - dd: HTMLFactory; - del: HTMLFactory; - details: HTMLFactory; - dfn: HTMLFactory; - dialog: HTMLFactory; - div: HTMLFactory; - dl: HTMLFactory; - dt: HTMLFactory; - em: HTMLFactory; - embed: HTMLFactory; - fieldset: HTMLFactory; - figcaption: HTMLFactory; - figure: HTMLFactory; - footer: HTMLFactory; - form: HTMLFactory; - h1: HTMLFactory; - h2: HTMLFactory; - h3: HTMLFactory; - h4: HTMLFactory; - h5: HTMLFactory; - h6: HTMLFactory; - head: HTMLFactory; - header: HTMLFactory; - hr: HTMLFactory; - html: HTMLFactory; - i: HTMLFactory; - iframe: HTMLFactory; - img: HTMLFactory; - input: HTMLFactory; - ins: HTMLFactory; - kbd: HTMLFactory; - keygen: HTMLFactory; - label: HTMLFactory; - legend: HTMLFactory; - li: HTMLFactory; - link: HTMLFactory; - main: HTMLFactory; - map: HTMLFactory; - mark: HTMLFactory; - menu: HTMLFactory; - menuitem: HTMLFactory; - meta: HTMLFactory; - meter: HTMLFactory; - nav: HTMLFactory; - noscript: HTMLFactory; - object: HTMLFactory; - ol: HTMLFactory; - optgroup: HTMLFactory; - option: HTMLFactory; - output: HTMLFactory; - p: HTMLFactory; - param: HTMLFactory; - picture: HTMLFactory; - pre: HTMLFactory; - progress: HTMLFactory; - q: HTMLFactory; - rp: HTMLFactory; - rt: HTMLFactory; - ruby: HTMLFactory; - s: HTMLFactory; - samp: HTMLFactory; - script: HTMLFactory; - section: HTMLFactory; - select: HTMLFactory; - small: HTMLFactory; - source: HTMLFactory; - span: HTMLFactory; - strong: HTMLFactory; - style: HTMLFactory; - sub: HTMLFactory; - summary: HTMLFactory; - sup: HTMLFactory; - table: HTMLFactory; - tbody: HTMLFactory; - td: HTMLFactory; - textarea: HTMLFactory; - tfoot: HTMLFactory; - th: HTMLFactory; - thead: HTMLFactory; - time: HTMLFactory; - title: HTMLFactory; - tr: HTMLFactory; - track: HTMLFactory; - u: HTMLFactory; - ul: HTMLFactory; - "var": HTMLFactory; - video: HTMLFactory; - wbr: HTMLFactory; - - // SVG - svg: SVGElementFactory; - circle: SVGFactory; - defs: SVGFactory; - ellipse: SVGFactory; - g: SVGFactory; - line: SVGFactory; - linearGradient: SVGFactory; - mask: SVGFactory; - path: SVGFactory; - pattern: SVGFactory; - polygon: SVGFactory; - polyline: SVGFactory; - radialGradient: SVGFactory; - rect: SVGFactory; - stop: SVGFactory; - text: SVGFactory; - tspan: SVGFactory; - } - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - interface Validator { - (object: T, key: string, componentName: string): Error; - } - - interface Requireable extends Validator { - isRequired: Validator; - } - - interface ValidationMap { - [key: string]: Validator; - } - - interface ReactPropTypes { - any: Requireable; - array: Requireable; - bool: Requireable; - func: Requireable; - number: Requireable; - object: Requireable; - string: Requireable; - node: Requireable; - element: Requireable; - instanceOf(expectedClass: {}): Requireable; - oneOf(types: any[]): Requireable; - oneOfType(types: Validator[]): Requireable; - arrayOf(type: Validator): Requireable; - objectOf(type: Validator): Requireable; - shape(type: ValidationMap): Requireable; - } - - // - // React.Children - // ---------------------------------------------------------------------- - - interface ReactChildren { - map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; - forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; - count(children: ReactNode): number; - only(children: ReactNode): ReactChild; - } - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - interface AbstractView { - styleMedia: StyleMedia; - document: Document; - } - - interface Touch { - identifier: number; - target: EventTarget; - screenX: number; - screenY: number; - clientX: number; - clientY: number; - pageX: number; - pageY: number; - } - - interface TouchList { - [index: number]: Touch; - length: number; - item(index: number): Touch; - identifiedTouch(identifier: number): Touch; - } - - // - // React.addons - // ---------------------------------------------------------------------- - - export module addons { - export var CSSTransitionGroup: CSSTransitionGroup; - export var TransitionGroup: TransitionGroup; - - export var LinkedStateMixin: LinkedStateMixin; - export var PureRenderMixin: PureRenderMixin; - - export function batchedUpdates( - callback: (a: A, b: B) => any, a: A, b: B): void; - export function batchedUpdates(callback: (a: A) => any, a: A): void; - export function batchedUpdates(callback: () => any): void; - - // deprecated: use petehunt/react-classset or JedWatson/classnames - export function classSet(cx: { [key: string]: boolean }): string; - export function classSet(...classList: string[]): string; - - export function cloneWithProps

( - element: DOMElement

, props: P): DOMElement

; - export function cloneWithProps

( - element: ClassicElement

, props: P): ClassicElement

; - export function cloneWithProps

( - element: ReactElement

, props: P): ReactElement

; - - export function createFragment( - object: { [key: string]: ReactNode }): ReactFragment; - - export function update(value: any[], spec: UpdateArraySpec): any[]; - export function update(value: {}, spec: UpdateSpec): any; - - // Development tools - export import Perf = ReactPerf; - export import TestUtils = ReactTestUtils; - } - - // - // React.addons (Transitions) - // ---------------------------------------------------------------------- - - interface TransitionGroupProps { - component?: ReactType; - childFactory?: (child: ReactElement) => ReactElement; - } - - interface CSSTransitionGroupProps extends TransitionGroupProps { - transitionName: string; - transitionAppear?: boolean; - transitionEnter?: boolean; - transitionLeave?: boolean; - } - - type CSSTransitionGroup = ComponentClass; - type TransitionGroup = ComponentClass; - - // - // React.addons (Mixins) - // ---------------------------------------------------------------------- - - interface ReactLink { - value: T; - requestChange(newValue: T): void; - } - - interface LinkedStateMixin extends Mixin { - linkState(key: string): ReactLink; - } - - interface PureRenderMixin extends Mixin { - } - - // - // Reat.addons.update - // ---------------------------------------------------------------------- - - interface UpdateSpecCommand { - $set?: any; - $merge?: {}; - $apply?(value: any): any; - } - - interface UpdateSpecPath { - [key: string]: UpdateSpec; - } - - type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; - - interface UpdateArraySpec extends UpdateSpecCommand { - $push?: any[]; - $unshift?: any[]; - $splice?: any[][]; - } - - // - // React.addons.Perf - // ---------------------------------------------------------------------- - - interface ComponentPerfContext { - current: string; - owner: string; - } - - interface NumericPerfContext { - [key: string]: number; - } - - interface Measurements { - exclusive: NumericPerfContext; - inclusive: NumericPerfContext; - render: NumericPerfContext; - counts: NumericPerfContext; - writes: NumericPerfContext; - displayNames: { - [key: string]: ComponentPerfContext; - }; - totalTime: number; - } - - module ReactPerf { - export function start(): void; - export function stop(): void; - export function printInclusive(measurements: Measurements[]): void; - export function printExclusive(measurements: Measurements[]): void; - export function printWasted(measurements: Measurements[]): void; - export function printDOM(measurements: Measurements[]): void; - export function getLastMeasurements(): Measurements[]; - } - - // - // React.addons.TestUtils - // ---------------------------------------------------------------------- - - interface MockedComponentClass { - new(): any; - } - - module ReactTestUtils { - export import Simulate = ReactSimulate; - - export function renderIntoDocument

( - element: ReactElement

): Component; - export function renderIntoDocument>( - element: ReactElement): C; - - export function mockComponent( - mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; - - export function isElementOfType( - element: ReactElement, type: ReactType): boolean; - export function isTextComponent(instance: Component): boolean; - export function isDOMComponent(instance: Component): boolean; - export function isCompositeComponent(instance: Component): boolean; - export function isCompositeComponentWithType( - instance: Component, - type: ComponentClass): boolean; - - export function findAllInRenderedTree( - tree: Component, - fn: (i: Component) => boolean): Component; - - export function scryRenderedDOMComponentsWithClass( - tree: Component, - className: string): DOMComponent[]; - export function findRenderedDOMComponentWithClass( - tree: Component, - className: string): DOMComponent; - - export function scryRenderedDOMComponentsWithTag( - tree: Component, - tagName: string): DOMComponent[]; - export function findRenderedDOMComponentWithTag( - tree: Component, - tagName: string): DOMComponent; - - export function scryRenderedComponentsWithType

( - tree: Component, - type: ComponentClass

): Component[]; - export function scryRenderedComponentsWithType>( - tree: Component, - type: ComponentClass): C[]; - - export function findRenderedComponentWithType

( - tree: Component, - type: ComponentClass

): Component; - export function findRenderedComponentWithType>( - tree: Component, - type: ComponentClass): C; - - export function createRenderer(): ShallowRenderer; - } - - interface SyntheticEventData { - altKey?: boolean; - button?: number; - buttons?: number; - clientX?: number; - clientY?: number; - changedTouches?: TouchList; - charCode?: boolean; - clipboardData?: DataTransfer; - ctrlKey?: boolean; - deltaMode?: number; - deltaX?: number; - deltaY?: number; - deltaZ?: number; - detail?: number; - getModifierState?(key: string): boolean; - key?: string; - keyCode?: number; - locale?: string; - location?: number; - metaKey?: boolean; - pageX?: number; - pageY?: number; - relatedTarget?: EventTarget; - repeat?: boolean; - screenX?: number; - screenY?: number; - shiftKey?: boolean; - targetTouches?: TouchList; - touches?: TouchList; - view?: AbstractView; - which?: number; - } - - interface EventSimulator { - (element: Element, eventData?: SyntheticEventData): void; - (component: Component, eventData?: SyntheticEventData): void; - } - - module ReactSimulate { - export var blur: EventSimulator; - export var change: EventSimulator; - export var click: EventSimulator; - export var cut: EventSimulator; - export var doubleClick: EventSimulator; - export var drag: EventSimulator; - export var dragEnd: EventSimulator; - export var dragEnter: EventSimulator; - export var dragExit: EventSimulator; - export var dragLeave: EventSimulator; - export var dragOver: EventSimulator; - export var dragStart: EventSimulator; - export var drop: EventSimulator; - export var focus: EventSimulator; - export var input: EventSimulator; - export var keyDown: EventSimulator; - export var keyPress: EventSimulator; - export var keyUp: EventSimulator; - export var mouseDown: EventSimulator; - export var mouseEnter: EventSimulator; - export var mouseLeave: EventSimulator; - export var mouseMove: EventSimulator; - export var mouseOut: EventSimulator; - export var mouseOver: EventSimulator; - export var mouseUp: EventSimulator; - export var paste: EventSimulator; - export var scroll: EventSimulator; - export var submit: EventSimulator; - export var touchCancel: EventSimulator; - export var touchEnd: EventSimulator; - export var touchMove: EventSimulator; - export var touchStart: EventSimulator; - export var wheel: EventSimulator; - } - - class ShallowRenderer { - getRenderOutput>(): E; - getRenderOutput(): ReactElement; - render(element: ReactElement, context?: any): void; - unmount(): void; - } -} - declare namespace JSX { import React = __React; From f2ff7464b5cd7f6dc41228f7950f55ece27d1c07 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 19:41:57 -0400 Subject: [PATCH 0049/1680] Remove cloneWithProps since it's deprecated --- react/react-addons-clone-with-props.d.ts | 18 ------------------ react/react-global.d.ts | 2 -- 2 files changed, 20 deletions(-) delete mode 100644 react/react-addons-clone-with-props.d.ts diff --git a/react/react-addons-clone-with-props.d.ts b/react/react-addons-clone-with-props.d.ts deleted file mode 100644 index 137c6650c7..0000000000 --- a/react/react-addons-clone-with-props.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for React v0.14 (react-addons-clone-with-props) -// Project: http://facebook.github.io/react/ -// Definitions by: Asana , AssureSign , Microsoft -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare namespace __React { - namespace __Addons { - export function cloneWithProps

(element: __React.DOMElement

, props: P): __React.DOMElement

; - export function cloneWithProps

(element: __React.ClassicElement

, props: P): __React.ClassicElement

; - export function cloneWithProps

(element: __React.ReactElement

, props: P): __React.ReactElement

; - } -} - -declare module "react-addons-clone-with-props" { - export = __React.__Addons.cloneWithProps; -} diff --git a/react/react-global.d.ts b/react/react-global.d.ts index 4de0a8eed2..3ed029240b 100644 --- a/react/react-global.d.ts +++ b/react/react-global.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// /// /// /// @@ -26,7 +25,6 @@ declare namespace __React { export var LinkedStateMixin: __React.__Addons.LinkedStateMixin; export var PureRenderMixin: __React.__Addons.PureRenderMixin; - export import cloneWithProps = __React.__Addons.cloneWithProps; export import createFragment = __React.__Addons.createFragment; export import update = __React.__Addons.update; From 6186be126ad03fc0c767a962833edfa98239ced7 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:47:57 -0400 Subject: [PATCH 0050/1680] Export types as well as variables for certain addons --- react/react-addons-css-transition-group.d.ts | 1 + react/react-addons-linked-state-mixin.d.ts | 1 + react/react-addons-pure-render-mixin.d.ts | 1 + react/react-addons-transition-group.d.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts index 99db1f4f46..bcc3471243 100644 --- a/react/react-addons-css-transition-group.d.ts +++ b/react/react-addons-css-transition-group.d.ts @@ -21,5 +21,6 @@ declare namespace __React { declare module "react-addons-css-transition-group" { var CSSTransitionGroup: __React.__Addons.CSSTransitionGroup; + type CSSTransitionGroup = __React.__Addons.CSSTransitionGroup; export = CSSTransitionGroup; } diff --git a/react/react-addons-linked-state-mixin.d.ts b/react/react-addons-linked-state-mixin.d.ts index a98caa3847..ce1022cd8a 100644 --- a/react/react-addons-linked-state-mixin.d.ts +++ b/react/react-addons-linked-state-mixin.d.ts @@ -20,5 +20,6 @@ declare namespace __React { declare module "react-addons-linked-state-mixin" { var LinkedStateMixin: __React.__Addons.LinkedStateMixin; + type LinkedStateMixin = __React.__Addons.LinkedStateMixin; export = LinkedStateMixin; } diff --git a/react/react-addons-pure-render-mixin.d.ts b/react/react-addons-pure-render-mixin.d.ts index 741046d907..cc73a714dd 100644 --- a/react/react-addons-pure-render-mixin.d.ts +++ b/react/react-addons-pure-render-mixin.d.ts @@ -13,5 +13,6 @@ declare namespace __React { declare module "react-addons-pure-render-mixin" { var PureRenderMixin: __React.__Addons.PureRenderMixin; + type PureRenderMixin = __React.__Addons.PureRenderMixin; export = PureRenderMixin; } diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts index 376bebd51b..fac2d76bca 100644 --- a/react/react-addons-transition-group.d.ts +++ b/react/react-addons-transition-group.d.ts @@ -18,5 +18,6 @@ declare namespace __React { declare module "react-addons-transition-group" { var TransitionGroup: __React.__Addons.TransitionGroup; + type TransitionGroup = __React.__Addons.TransitionGroup; export = TransitionGroup; } \ No newline at end of file From 8eb584e9cf92d0457ecbbc9980ce6d634a69cba2 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:52:17 -0400 Subject: [PATCH 0051/1680] Add legacy files for v0.13 --- react/react-0.13.3.d.ts | 2038 ++++++++++++++++++++++++++++++++ react/react-global-0.13.3.d.ts | 285 +++++ 2 files changed, 2323 insertions(+) create mode 100644 react/react-0.13.3.d.ts create mode 100644 react/react-global-0.13.3.d.ts diff --git a/react/react-0.13.3.d.ts b/react/react-0.13.3.d.ts new file mode 100644 index 0000000000..de8ba67327 --- /dev/null +++ b/react/react-0.13.3.d.ts @@ -0,0 +1,2038 @@ +// Type definitions for React v0.13.3 +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace __React { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onContextMenu?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } +} + +declare module "react" { + export = __React; +} + +declare module "react/addons" { + // + // React Elements + // ---------------------------------------------------------------------- + + type ReactType = ComponentClass | string; + + interface ReactElement

{ + type: string | ComponentClass

; + props: P; + key: string | number; + ref: string | ((component: Component) => any); + } + + interface ClassicElement

extends ReactElement

{ + type: string | ClassicComponentClass

; + ref: string | ((component: ClassicComponent) => any); + } + + interface DOMElement

extends ClassicElement

{ + type: string; + ref: string | ((component: DOMComponent

) => any); + } + + type HTMLElement = DOMElement; + type SVGElement = DOMElement; + + // + // Factories + // ---------------------------------------------------------------------- + + interface Factory

{ + (props?: P, ...children: ReactNode[]): ReactElement

; + } + + interface ClassicFactory

extends Factory

{ + (props?: P, ...children: ReactNode[]): ClassicElement

; + } + + interface DOMFactory

extends ClassicFactory

{ + (props?: P, ...children: ReactNode[]): DOMElement

; + } + + type HTMLFactory = DOMFactory; + type SVGFactory = DOMFactory; + type SVGElementFactory = DOMFactory; + + // + // React Nodes + // http://facebook.github.io/react/docs/glossary.html + // ---------------------------------------------------------------------- + + type ReactText = string | number; + type ReactChild = ReactElement | ReactText; + + // Should be Array but type aliases cannot be recursive + type ReactFragment = {} | Array; + type ReactNode = ReactChild | ReactFragment | boolean; + + // + // Top Level API + // ---------------------------------------------------------------------- + + function createClass(spec: ComponentSpec): ClassicComponentClass

; + + function createFactory

(type: string): DOMFactory

; + function createFactory

(type: ClassicComponentClass

| string): ClassicFactory

; + function createFactory

(type: ComponentClass

): Factory

; + + function createElement

( + type: string, + props?: P, + ...children: ReactNode[]): DOMElement

; + function createElement

( + type: ClassicComponentClass

| string, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function createElement

( + type: ComponentClass

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function cloneElement

( + element: DOMElement

, + props?: P, + ...children: ReactNode[]): DOMElement

; + function cloneElement

( + element: ClassicElement

, + props?: P, + ...children: ReactNode[]): ClassicElement

; + function cloneElement

( + element: ReactElement

, + props?: P, + ...children: ReactNode[]): ReactElement

; + + function render

( + element: DOMElement

, + container: Element, + callback?: () => any): DOMComponent

; + function render( + element: ClassicElement

, + container: Element, + callback?: () => any): ClassicComponent; + function render( + element: ReactElement

, + container: Element, + callback?: () => any): Component; + + function unmountComponentAtNode(container: Element): boolean; + function renderToString(element: ReactElement): string; + function renderToStaticMarkup(element: ReactElement): string; + function isValidElement(object: {}): boolean; + function initializeTouchEvents(shouldUseTouch: boolean): void; + + function findDOMNode( + componentOrElement: Component | Element): TElement; + function findDOMNode( + componentOrElement: Component | Element): Element; + + var DOM: ReactDOM; + var PropTypes: ReactPropTypes; + var Children: ReactChildren; + + // + // Component API + // ---------------------------------------------------------------------- + + // Base component for plain JS classes + class Component implements ComponentLifecycle { + static propTypes: ValidationMap; + static contextTypes: ValidationMap; + static childContextTypes: ValidationMap; + static defaultProps: Props; + + constructor(props?: P, context?: any); + setState(f: (prevState: S, props: P) => S, callback?: () => any): void; + setState(state: S, callback?: () => any): void; + forceUpdate(callBack?: () => any): void; + render(): JSX.Element; + props: P; + state: S; + context: {}; + refs: { + [key: string]: Component + }; + } + + interface ClassicComponent extends Component { + replaceState(nextState: S, callback?: () => any): void; + getDOMNode(): TElement; + getDOMNode(): Element; + isMounted(): boolean; + getInitialState?(): S; + setProps(nextProps: P, callback?: () => any): void; + replaceProps(nextProps: P, callback?: () => any): void; + } + + interface DOMComponent

extends ClassicComponent { + tagName: string; + } + + type HTMLComponent = DOMComponent; + type SVGComponent = DOMComponent; + + interface ChildContextProvider { + getChildContext(): CC; + } + + // + // Class Interfaces + // ---------------------------------------------------------------------- + + interface ComponentClass

{ + new(props?: P, context?: any): Component; + propTypes?: ValidationMap

; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap; + defaultProps?: P; + } + + interface ClassicComponentClass

extends ComponentClass

{ + new(props?: P, context?: any): ClassicComponent; + getDefaultProps?(): P; + displayName?: string; + } + + // + // Component Specs and Lifecycle + // ---------------------------------------------------------------------- + + interface ComponentLifecycle { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P, nextContext: any): void; + shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean; + componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void; + componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void; + componentWillUnmount?(): void; + } + + interface Mixin extends ComponentLifecycle { + mixins?: Mixin; + statics?: { + [key: string]: any; + }; + + displayName?: string; + propTypes?: ValidationMap; + contextTypes?: ValidationMap; + childContextTypes?: ValidationMap + + getDefaultProps?(): P; + getInitialState?(): S; + } + + interface ComponentSpec extends Mixin { + render(): ReactElement; + + [propertyName: string]: any; + } + + // + // Event System + // ---------------------------------------------------------------------- + + interface SyntheticEvent { + bubbles: boolean; + cancelable: boolean; + currentTarget: EventTarget; + defaultPrevented: boolean; + eventPhase: number; + isTrusted: boolean; + nativeEvent: Event; + preventDefault(): void; + stopPropagation(): void; + target: EventTarget; + timeStamp: Date; + type: string; + } + + interface DragEvent extends SyntheticEvent { + dataTransfer: DataTransfer; + } + + interface ClipboardEvent extends SyntheticEvent { + clipboardData: DataTransfer; + } + + interface KeyboardEvent extends SyntheticEvent { + altKey: boolean; + charCode: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + key: string; + keyCode: number; + locale: string; + location: number; + metaKey: boolean; + repeat: boolean; + shiftKey: boolean; + which: number; + } + + interface FocusEvent extends SyntheticEvent { + relatedTarget: EventTarget; + } + + interface FormEvent extends SyntheticEvent { + } + + interface MouseEvent extends SyntheticEvent { + altKey: boolean; + button: number; + buttons: number; + clientX: number; + clientY: number; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + pageX: number; + pageY: number; + relatedTarget: EventTarget; + screenX: number; + screenY: number; + shiftKey: boolean; + } + + interface TouchEvent extends SyntheticEvent { + altKey: boolean; + changedTouches: TouchList; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + targetTouches: TouchList; + touches: TouchList; + } + + interface UIEvent extends SyntheticEvent { + detail: number; + view: AbstractView; + } + + interface WheelEvent extends SyntheticEvent { + deltaMode: number; + deltaX: number; + deltaY: number; + deltaZ: number; + } + + // + // Event Handler Types + // ---------------------------------------------------------------------- + + interface EventHandler { + (event: E): void; + } + + interface DragEventHandler extends EventHandler {} + interface ClipboardEventHandler extends EventHandler {} + interface KeyboardEventHandler extends EventHandler {} + interface FocusEventHandler extends EventHandler {} + interface FormEventHandler extends EventHandler {} + interface MouseEventHandler extends EventHandler {} + interface TouchEventHandler extends EventHandler {} + interface UIEventHandler extends EventHandler {} + interface WheelEventHandler extends EventHandler {} + + // + // Props / DOM Attributes + // ---------------------------------------------------------------------- + + interface Props { + children?: ReactNode; + key?: string | number; + ref?: string | ((component: T) => any); + } + + interface DOMAttributesBase extends Props { + onCopy?: ClipboardEventHandler; + onCut?: ClipboardEventHandler; + onPaste?: ClipboardEventHandler; + onKeyDown?: KeyboardEventHandler; + onKeyPress?: KeyboardEventHandler; + onKeyUp?: KeyboardEventHandler; + onFocus?: FocusEventHandler; + onBlur?: FocusEventHandler; + onChange?: FormEventHandler; + onInput?: FormEventHandler; + onSubmit?: FormEventHandler; + onClick?: MouseEventHandler; + onDoubleClick?: MouseEventHandler; + onDrag?: DragEventHandler; + onDragEnd?: DragEventHandler; + onDragEnter?: DragEventHandler; + onDragExit?: DragEventHandler; + onDragLeave?: DragEventHandler; + onDragOver?: DragEventHandler; + onDragStart?: DragEventHandler; + onDrop?: DragEventHandler; + onMouseDown?: MouseEventHandler; + onMouseEnter?: MouseEventHandler; + onMouseLeave?: MouseEventHandler; + onMouseMove?: MouseEventHandler; + onMouseOut?: MouseEventHandler; + onMouseOver?: MouseEventHandler; + onMouseUp?: MouseEventHandler; + onTouchCancel?: TouchEventHandler; + onTouchEnd?: TouchEventHandler; + onTouchMove?: TouchEventHandler; + onTouchStart?: TouchEventHandler; + onScroll?: UIEventHandler; + onWheel?: WheelEventHandler; + + className?: string; + id?: string; + + dangerouslySetInnerHTML?: { + __html: string; + }; + } + + interface DOMAttributes extends DOMAttributesBase> { + } + + // This interface is not complete. Only properties accepting + // unitless numbers are listed here (see CSSProperty.js in React) + interface CSSProperties { + boxFlex?: number; + boxFlexGroup?: number; + columnCount?: number; + flex?: number | string; + flexGrow?: number; + flexShrink?: number; + fontWeight?: number | string; + lineClamp?: number; + lineHeight?: number | string; + opacity?: number; + order?: number; + orphans?: number; + widows?: number; + zIndex?: number; + zoom?: number; + + fontSize?: number | string; + + // SVG-related properties + fillOpacity?: number; + strokeOpacity?: number; + strokeWidth?: number; + + [propertyName: string]: any; + } + + interface HTMLAttributesBase extends DOMAttributesBase { + accept?: string; + acceptCharset?: string; + accessKey?: string; + action?: string; + allowFullScreen?: boolean; + allowTransparency?: boolean; + alt?: string; + async?: boolean; + autoComplete?: boolean; + autoFocus?: boolean; + autoPlay?: boolean; + cellPadding?: number | string; + cellSpacing?: number | string; + charSet?: string; + checked?: boolean; + classID?: string; + cols?: number; + colSpan?: number; + content?: string; + contentEditable?: boolean; + contextMenu?: string; + controls?: any; + coords?: string; + crossOrigin?: string; + data?: string; + dateTime?: string; + defaultChecked?: boolean; + defaultValue?: string; + defer?: boolean; + dir?: string; + disabled?: boolean; + download?: any; + draggable?: boolean; + encType?: string; + form?: string; + formAction?: string; + formEncType?: string; + formMethod?: string; + formNoValidate?: boolean; + formTarget?: string; + frameBorder?: number | string; + headers?: string; + height?: number | string; + hidden?: boolean; + high?: number; + href?: string; + hrefLang?: string; + htmlFor?: string; + httpEquiv?: string; + icon?: string; + label?: string; + lang?: string; + list?: string; + loop?: boolean; + low?: number; + manifest?: string; + marginHeight?: number; + marginWidth?: number; + max?: number | string; + maxLength?: number; + media?: string; + mediaGroup?: string; + method?: string; + min?: number | string; + multiple?: boolean; + muted?: boolean; + name?: string; + noValidate?: boolean; + open?: boolean; + optimum?: number; + pattern?: string; + placeholder?: string; + poster?: string; + preload?: string; + radioGroup?: string; + readOnly?: boolean; + rel?: string; + required?: boolean; + role?: string; + rows?: number; + rowSpan?: number; + sandbox?: string; + scope?: string; + scoped?: boolean; + scrolling?: string; + seamless?: boolean; + selected?: boolean; + shape?: string; + size?: number; + sizes?: string; + span?: number; + spellCheck?: boolean; + src?: string; + srcDoc?: string; + srcSet?: string; + start?: number; + step?: number | string; + style?: CSSProperties; + tabIndex?: number; + target?: string; + title?: string; + type?: string; + useMap?: string; + value?: string; + width?: number | string; + wmode?: string; + + // Non-standard Attributes + autoCapitalize?: boolean; + autoCorrect?: boolean; + property?: string; + itemProp?: string; + itemScope?: boolean; + itemType?: string; + unselectable?: boolean; + } + + interface HTMLAttributes extends HTMLAttributesBase { + } + + interface SVGElementAttributes extends HTMLAttributes { + viewBox?: string; + preserveAspectRatio?: string; + } + + interface SVGAttributes extends DOMAttributes { + ref?: string | ((component: SVGComponent) => void); + + cx?: number | string; + cy?: number | string; + d?: string; + dx?: number | string; + dy?: number | string; + fill?: string; + fillOpacity?: number | string; + fontFamily?: string; + fontSize?: number | string; + fx?: number | string; + fy?: number | string; + gradientTransform?: string; + gradientUnits?: string; + height?: number | string; + markerEnd?: string; + markerMid?: string; + markerStart?: string; + offset?: number | string; + opacity?: number | string; + patternContentUnits?: string; + patternUnits?: string; + points?: string; + preserveAspectRatio?: string; + r?: number | string; + rx?: number | string; + ry?: number | string; + spreadMethod?: string; + stopColor?: string; + stopOpacity?: number | string; + stroke?: string; + strokeDasharray?: string; + strokeLinecap?: string; + strokeMiterlimit?: string; + strokeOpacity?: number | string; + strokeWidth?: number | string; + textAnchor?: string; + transform?: string; + version?: string; + viewBox?: string; + width?: number | string; + x1?: number | string; + x2?: number | string; + x?: number | string; + y1?: number | string; + y2?: number | string + y?: number | string; + } + + // + // React.DOM + // ---------------------------------------------------------------------- + + interface ReactDOM { + // HTML + a: HTMLFactory; + abbr: HTMLFactory; + address: HTMLFactory; + area: HTMLFactory; + article: HTMLFactory; + aside: HTMLFactory; + audio: HTMLFactory; + b: HTMLFactory; + base: HTMLFactory; + bdi: HTMLFactory; + bdo: HTMLFactory; + big: HTMLFactory; + blockquote: HTMLFactory; + body: HTMLFactory; + br: HTMLFactory; + button: HTMLFactory; + canvas: HTMLFactory; + caption: HTMLFactory; + cite: HTMLFactory; + code: HTMLFactory; + col: HTMLFactory; + colgroup: HTMLFactory; + data: HTMLFactory; + datalist: HTMLFactory; + dd: HTMLFactory; + del: HTMLFactory; + details: HTMLFactory; + dfn: HTMLFactory; + dialog: HTMLFactory; + div: HTMLFactory; + dl: HTMLFactory; + dt: HTMLFactory; + em: HTMLFactory; + embed: HTMLFactory; + fieldset: HTMLFactory; + figcaption: HTMLFactory; + figure: HTMLFactory; + footer: HTMLFactory; + form: HTMLFactory; + h1: HTMLFactory; + h2: HTMLFactory; + h3: HTMLFactory; + h4: HTMLFactory; + h5: HTMLFactory; + h6: HTMLFactory; + head: HTMLFactory; + header: HTMLFactory; + hr: HTMLFactory; + html: HTMLFactory; + i: HTMLFactory; + iframe: HTMLFactory; + img: HTMLFactory; + input: HTMLFactory; + ins: HTMLFactory; + kbd: HTMLFactory; + keygen: HTMLFactory; + label: HTMLFactory; + legend: HTMLFactory; + li: HTMLFactory; + link: HTMLFactory; + main: HTMLFactory; + map: HTMLFactory; + mark: HTMLFactory; + menu: HTMLFactory; + menuitem: HTMLFactory; + meta: HTMLFactory; + meter: HTMLFactory; + nav: HTMLFactory; + noscript: HTMLFactory; + object: HTMLFactory; + ol: HTMLFactory; + optgroup: HTMLFactory; + option: HTMLFactory; + output: HTMLFactory; + p: HTMLFactory; + param: HTMLFactory; + picture: HTMLFactory; + pre: HTMLFactory; + progress: HTMLFactory; + q: HTMLFactory; + rp: HTMLFactory; + rt: HTMLFactory; + ruby: HTMLFactory; + s: HTMLFactory; + samp: HTMLFactory; + script: HTMLFactory; + section: HTMLFactory; + select: HTMLFactory; + small: HTMLFactory; + source: HTMLFactory; + span: HTMLFactory; + strong: HTMLFactory; + style: HTMLFactory; + sub: HTMLFactory; + summary: HTMLFactory; + sup: HTMLFactory; + table: HTMLFactory; + tbody: HTMLFactory; + td: HTMLFactory; + textarea: HTMLFactory; + tfoot: HTMLFactory; + th: HTMLFactory; + thead: HTMLFactory; + time: HTMLFactory; + title: HTMLFactory; + tr: HTMLFactory; + track: HTMLFactory; + u: HTMLFactory; + ul: HTMLFactory; + "var": HTMLFactory; + video: HTMLFactory; + wbr: HTMLFactory; + + // SVG + svg: SVGElementFactory; + circle: SVGFactory; + defs: SVGFactory; + ellipse: SVGFactory; + g: SVGFactory; + line: SVGFactory; + linearGradient: SVGFactory; + mask: SVGFactory; + path: SVGFactory; + pattern: SVGFactory; + polygon: SVGFactory; + polyline: SVGFactory; + radialGradient: SVGFactory; + rect: SVGFactory; + stop: SVGFactory; + text: SVGFactory; + tspan: SVGFactory; + } + + // + // React.PropTypes + // ---------------------------------------------------------------------- + + interface Validator { + (object: T, key: string, componentName: string): Error; + } + + interface Requireable extends Validator { + isRequired: Validator; + } + + interface ValidationMap { + [key: string]: Validator; + } + + interface ReactPropTypes { + any: Requireable; + array: Requireable; + bool: Requireable; + func: Requireable; + number: Requireable; + object: Requireable; + string: Requireable; + node: Requireable; + element: Requireable; + instanceOf(expectedClass: {}): Requireable; + oneOf(types: any[]): Requireable; + oneOfType(types: Validator[]): Requireable; + arrayOf(type: Validator): Requireable; + objectOf(type: Validator): Requireable; + shape(type: ValidationMap): Requireable; + } + + // + // React.Children + // ---------------------------------------------------------------------- + + interface ReactChildren { + map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T }; + forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void; + count(children: ReactNode): number; + only(children: ReactNode): ReactChild; + } + + // + // Browser Interfaces + // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts + // ---------------------------------------------------------------------- + + interface AbstractView { + styleMedia: StyleMedia; + document: Document; + } + + interface Touch { + identifier: number; + target: EventTarget; + screenX: number; + screenY: number; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + } + + interface TouchList { + [index: number]: Touch; + length: number; + item(index: number): Touch; + identifiedTouch(identifier: number): Touch; + } + + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} + +declare namespace JSX { + import React = __React; + + interface Element extends React.ReactElement { } + interface ElementClass extends React.Component { + render(): JSX.Element; + } + interface ElementAttributesProperty { props: {}; } + + interface IntrinsicElements { + // HTML + a: React.HTMLAttributes; + abbr: React.HTMLAttributes; + address: React.HTMLAttributes; + area: React.HTMLAttributes; + article: React.HTMLAttributes; + aside: React.HTMLAttributes; + audio: React.HTMLAttributes; + b: React.HTMLAttributes; + base: React.HTMLAttributes; + bdi: React.HTMLAttributes; + bdo: React.HTMLAttributes; + big: React.HTMLAttributes; + blockquote: React.HTMLAttributes; + body: React.HTMLAttributes; + br: React.HTMLAttributes; + button: React.HTMLAttributes; + canvas: React.HTMLAttributes; + caption: React.HTMLAttributes; + cite: React.HTMLAttributes; + code: React.HTMLAttributes; + col: React.HTMLAttributes; + colgroup: React.HTMLAttributes; + data: React.HTMLAttributes; + datalist: React.HTMLAttributes; + dd: React.HTMLAttributes; + del: React.HTMLAttributes; + details: React.HTMLAttributes; + dfn: React.HTMLAttributes; + dialog: React.HTMLAttributes; + div: React.HTMLAttributes; + dl: React.HTMLAttributes; + dt: React.HTMLAttributes; + em: React.HTMLAttributes; + embed: React.HTMLAttributes; + fieldset: React.HTMLAttributes; + figcaption: React.HTMLAttributes; + figure: React.HTMLAttributes; + footer: React.HTMLAttributes; + form: React.HTMLAttributes; + h1: React.HTMLAttributes; + h2: React.HTMLAttributes; + h3: React.HTMLAttributes; + h4: React.HTMLAttributes; + h5: React.HTMLAttributes; + h6: React.HTMLAttributes; + head: React.HTMLAttributes; + header: React.HTMLAttributes; + hr: React.HTMLAttributes; + html: React.HTMLAttributes; + i: React.HTMLAttributes; + iframe: React.HTMLAttributes; + img: React.HTMLAttributes; + input: React.HTMLAttributes; + ins: React.HTMLAttributes; + kbd: React.HTMLAttributes; + keygen: React.HTMLAttributes; + label: React.HTMLAttributes; + legend: React.HTMLAttributes; + li: React.HTMLAttributes; + link: React.HTMLAttributes; + main: React.HTMLAttributes; + map: React.HTMLAttributes; + mark: React.HTMLAttributes; + menu: React.HTMLAttributes; + menuitem: React.HTMLAttributes; + meta: React.HTMLAttributes; + meter: React.HTMLAttributes; + nav: React.HTMLAttributes; + noscript: React.HTMLAttributes; + object: React.HTMLAttributes; + ol: React.HTMLAttributes; + optgroup: React.HTMLAttributes; + option: React.HTMLAttributes; + output: React.HTMLAttributes; + p: React.HTMLAttributes; + param: React.HTMLAttributes; + picture: React.HTMLAttributes; + pre: React.HTMLAttributes; + progress: React.HTMLAttributes; + q: React.HTMLAttributes; + rp: React.HTMLAttributes; + rt: React.HTMLAttributes; + ruby: React.HTMLAttributes; + s: React.HTMLAttributes; + samp: React.HTMLAttributes; + script: React.HTMLAttributes; + section: React.HTMLAttributes; + select: React.HTMLAttributes; + small: React.HTMLAttributes; + source: React.HTMLAttributes; + span: React.HTMLAttributes; + strong: React.HTMLAttributes; + style: React.HTMLAttributes; + sub: React.HTMLAttributes; + summary: React.HTMLAttributes; + sup: React.HTMLAttributes; + table: React.HTMLAttributes; + tbody: React.HTMLAttributes; + td: React.HTMLAttributes; + textarea: React.HTMLAttributes; + tfoot: React.HTMLAttributes; + th: React.HTMLAttributes; + thead: React.HTMLAttributes; + time: React.HTMLAttributes; + title: React.HTMLAttributes; + tr: React.HTMLAttributes; + track: React.HTMLAttributes; + u: React.HTMLAttributes; + ul: React.HTMLAttributes; + "var": React.HTMLAttributes; + video: React.HTMLAttributes; + wbr: React.HTMLAttributes; + + // SVG + svg: React.SVGElementAttributes; + + circle: React.SVGAttributes; + defs: React.SVGAttributes; + ellipse: React.SVGAttributes; + g: React.SVGAttributes; + line: React.SVGAttributes; + linearGradient: React.SVGAttributes; + mask: React.SVGAttributes; + path: React.SVGAttributes; + pattern: React.SVGAttributes; + polygon: React.SVGAttributes; + polyline: React.SVGAttributes; + radialGradient: React.SVGAttributes; + rect: React.SVGAttributes; + stop: React.SVGAttributes; + text: React.SVGAttributes; + tspan: React.SVGAttributes; + } +} diff --git a/react/react-global-0.13.3.d.ts b/react/react-global-0.13.3.d.ts new file mode 100644 index 0000000000..1728ba2fc8 --- /dev/null +++ b/react/react-global-0.13.3.d.ts @@ -0,0 +1,285 @@ +// Type definitions for React v0.13.3 (namespace) +// Project: http://facebook.github.io/react/ +// Definitions by: Asana , AssureSign , Microsoft +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import React = __React; + +declare namespace __React { + // + // React.addons + // ---------------------------------------------------------------------- + + export module addons { + export var CSSTransitionGroup: CSSTransitionGroup; + export var TransitionGroup: TransitionGroup; + + export var LinkedStateMixin: LinkedStateMixin; + export var PureRenderMixin: PureRenderMixin; + + export function batchedUpdates( + callback: (a: A, b: B) => any, a: A, b: B): void; + export function batchedUpdates(callback: (a: A) => any, a: A): void; + export function batchedUpdates(callback: () => any): void; + + // deprecated: use petehunt/react-classset or JedWatson/classnames + export function classSet(cx: { [key: string]: boolean }): string; + export function classSet(...classList: string[]): string; + + export function cloneWithProps

( + element: DOMElement

, props: P): DOMElement

; + export function cloneWithProps

( + element: ClassicElement

, props: P): ClassicElement

; + export function cloneWithProps

( + element: ReactElement

, props: P): ReactElement

; + + export function createFragment( + object: { [key: string]: ReactNode }): ReactFragment; + + export function update(value: any[], spec: UpdateArraySpec): any[]; + export function update(value: {}, spec: UpdateSpec): any; + + // Development tools + export import Perf = ReactPerf; + export import TestUtils = ReactTestUtils; + } + + // + // React.addons (Transitions) + // ---------------------------------------------------------------------- + + interface TransitionGroupProps { + component?: ReactType; + childFactory?: (child: ReactElement) => ReactElement; + } + + interface CSSTransitionGroupProps extends TransitionGroupProps { + transitionName: string; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + } + + type CSSTransitionGroup = ComponentClass; + type TransitionGroup = ComponentClass; + + // + // React.addons (Mixins) + // ---------------------------------------------------------------------- + + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + interface LinkedStateMixin extends Mixin { + linkState(key: string): ReactLink; + } + + interface PureRenderMixin extends Mixin { + } + + // + // Reat.addons.update + // ---------------------------------------------------------------------- + + interface UpdateSpecCommand { + $set?: any; + $merge?: {}; + $apply?(value: any): any; + } + + interface UpdateSpecPath { + [key: string]: UpdateSpec; + } + + type UpdateSpec = UpdateSpecCommand | UpdateSpecPath; + + interface UpdateArraySpec extends UpdateSpecCommand { + $push?: any[]; + $unshift?: any[]; + $splice?: any[][]; + } + + // + // React.addons.Perf + // ---------------------------------------------------------------------- + + interface ComponentPerfContext { + current: string; + owner: string; + } + + interface NumericPerfContext { + [key: string]: number; + } + + interface Measurements { + exclusive: NumericPerfContext; + inclusive: NumericPerfContext; + render: NumericPerfContext; + counts: NumericPerfContext; + writes: NumericPerfContext; + displayNames: { + [key: string]: ComponentPerfContext; + }; + totalTime: number; + } + + module ReactPerf { + export function start(): void; + export function stop(): void; + export function printInclusive(measurements: Measurements[]): void; + export function printExclusive(measurements: Measurements[]): void; + export function printWasted(measurements: Measurements[]): void; + export function printDOM(measurements: Measurements[]): void; + export function getLastMeasurements(): Measurements[]; + } + + // + // React.addons.TestUtils + // ---------------------------------------------------------------------- + + interface MockedComponentClass { + new(): any; + } + + module ReactTestUtils { + export import Simulate = ReactSimulate; + + export function renderIntoDocument

( + element: ReactElement

): Component; + export function renderIntoDocument>( + element: ReactElement): C; + + export function mockComponent( + mocked: MockedComponentClass, mockTagName?: string): typeof ReactTestUtils; + + export function isElementOfType( + element: ReactElement, type: ReactType): boolean; + export function isTextComponent(instance: Component): boolean; + export function isDOMComponent(instance: Component): boolean; + export function isCompositeComponent(instance: Component): boolean; + export function isCompositeComponentWithType( + instance: Component, + type: ComponentClass): boolean; + + export function findAllInRenderedTree( + tree: Component, + fn: (i: Component) => boolean): Component; + + export function scryRenderedDOMComponentsWithClass( + tree: Component, + className: string): DOMComponent[]; + export function findRenderedDOMComponentWithClass( + tree: Component, + className: string): DOMComponent; + + export function scryRenderedDOMComponentsWithTag( + tree: Component, + tagName: string): DOMComponent[]; + export function findRenderedDOMComponentWithTag( + tree: Component, + tagName: string): DOMComponent; + + export function scryRenderedComponentsWithType

( + tree: Component, + type: ComponentClass

): Component[]; + export function scryRenderedComponentsWithType>( + tree: Component, + type: ComponentClass): C[]; + + export function findRenderedComponentWithType

( + tree: Component, + type: ComponentClass

): Component; + export function findRenderedComponentWithType>( + tree: Component, + type: ComponentClass): C; + + export function createRenderer(): ShallowRenderer; + } + + interface SyntheticEventData { + altKey?: boolean; + button?: number; + buttons?: number; + clientX?: number; + clientY?: number; + changedTouches?: TouchList; + charCode?: boolean; + clipboardData?: DataTransfer; + ctrlKey?: boolean; + deltaMode?: number; + deltaX?: number; + deltaY?: number; + deltaZ?: number; + detail?: number; + getModifierState?(key: string): boolean; + key?: string; + keyCode?: number; + locale?: string; + location?: number; + metaKey?: boolean; + pageX?: number; + pageY?: number; + relatedTarget?: EventTarget; + repeat?: boolean; + screenX?: number; + screenY?: number; + shiftKey?: boolean; + targetTouches?: TouchList; + touches?: TouchList; + view?: AbstractView; + which?: number; + } + + interface EventSimulator { + (element: Element, eventData?: SyntheticEventData): void; + (component: Component, eventData?: SyntheticEventData): void; + } + + module ReactSimulate { + export var blur: EventSimulator; + export var change: EventSimulator; + export var click: EventSimulator; + export var cut: EventSimulator; + export var doubleClick: EventSimulator; + export var drag: EventSimulator; + export var dragEnd: EventSimulator; + export var dragEnter: EventSimulator; + export var dragExit: EventSimulator; + export var dragLeave: EventSimulator; + export var dragOver: EventSimulator; + export var dragStart: EventSimulator; + export var drop: EventSimulator; + export var focus: EventSimulator; + export var input: EventSimulator; + export var keyDown: EventSimulator; + export var keyPress: EventSimulator; + export var keyUp: EventSimulator; + export var mouseDown: EventSimulator; + export var mouseEnter: EventSimulator; + export var mouseLeave: EventSimulator; + export var mouseMove: EventSimulator; + export var mouseOut: EventSimulator; + export var mouseOver: EventSimulator; + export var mouseUp: EventSimulator; + export var paste: EventSimulator; + export var scroll: EventSimulator; + export var submit: EventSimulator; + export var touchCancel: EventSimulator; + export var touchEnd: EventSimulator; + export var touchMove: EventSimulator; + export var touchStart: EventSimulator; + export var wheel: EventSimulator; + } + + class ShallowRenderer { + getRenderOutput>(): E; + getRenderOutput(): ReactElement; + render(element: ReactElement, context?: any): void; + unmount(): void; + } +} From f9e6e567f4da28108dd99317203251565eb325e3 Mon Sep 17 00:00:00 2001 From: James Brantly Date: Wed, 14 Oct 2015 20:55:48 -0400 Subject: [PATCH 0052/1680] Fix `module` => `namespace` --- react/react-dom.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts index e0d88e04ba..a2183b7eab 100644 --- a/react/react-dom.d.ts +++ b/react/react-dom.d.ts @@ -7,7 +7,7 @@ declare namespace __React { - module __DOM { + namespace __DOM { function findDOMNode( componentOrElement: __React.Component | Element): TElement; function findDOMNode( From 99fe3fa43b31bea4a9a3137b748e6474cc936e63 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Thu, 15 Oct 2015 11:56:18 +0200 Subject: [PATCH 0053/1680] Fullcalendar: Fixed callback parameters on eventDrop and eventResize --- fullCalendar/fullCalendar.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index 7552d5bfd9..6400dba7e0 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -198,10 +198,10 @@ declare module FullCalendar { eventConstraint?: BusinessHours | Timespan; eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventDrop?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: ViewObject) => void; - eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; + eventResize?: (event: EventObject, delta: moment.Duration, revertFunc: Function, jsEvent: Event, ui: any, view: ViewObject) => void; } /* * Selection - http://arshaw.com/fullcalendar/docs/selection/ From 640536586ae4f3a7db43b041a44caf64021c7610 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Thu, 15 Oct 2015 15:17:03 +0300 Subject: [PATCH 0054/1680] flux-utils definitions added. --- flux/flux-utils.d.ts | 130 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 flux/flux-utils.d.ts diff --git a/flux/flux-utils.d.ts b/flux/flux-utils.d.ts new file mode 100644 index 0000000000..8437f9d4b5 --- /dev/null +++ b/flux/flux-utils.d.ts @@ -0,0 +1,130 @@ +// Type definitions for Flux/utils +// Project: http://facebook.github.io/flux/ +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module FluxUtils { + + export class Container { + /** + * Create is used to transform a react class into a container + * that updates its state when relevant stores change. + * The provided base class must have static methods getStores() and calculateState(). + */ + static create(base: React.ComponentClass, options?: Object): React.ComponentClass; + } + + /** + * This class extends ReduceStore and defines the state as an immutable map. + */ + export class MapStore extends ReduceStore> { + + /** + * Access the value at the given key. + * Throws an error if the key does not exist in the cache. + */ + at(key: K): V; + + /** + * Check if the cache has a particular key + */ + has(key: K): boolean; + + /** + * Get the value of a particular key. + * Returns undefined if the key does not exist in the cache. + */ + get(key: K): V; + + /** + * Gets an array of keys and puts the values in a map if they exist, + * it allows providing a previous result to update instead of generating a new map. + * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. + */ + getAll(keys: Iterable, prev?: Immutable.Map): Immutable.Map; + } + + export class ReduceStore extends Store { + /** + * Getter that exposes the entire state of this store. + * If your state is not immutable you should override this and not expose state directly. + */ + getState(): T; + + /** + * Constructs the initial state for this store. + * This is called once during construction of the store. + */ + getInitialState(): T; + + /** + * Reduces the current state, and an action to the new state of this store. + * All subclasses must implement this method. + * This method should be pure and have no side-effects. + */ + reduce(state: T, action: Object): T; + + /** + * Checks if two versions of state are the same. + * You do not need to override this if your state is immutable. + */ + areEqual(one: T, two: T): boolean; + + } + + export class Store { + + /** + * Constructs and registers an instance of this store with the given dispatcher. + */ + constructor(dispatcher: Flux.Dispatcher); + + /** + * Adds a listener to the store, when the store changes the given callback will be called. + * A token is returned that can be used to remove the listener. + * Calling the remove() function on the returned token will remove the listener. + */ + addListener(callback: Function): { remove: Function }; + + /** + * Returns the dispatcher this store is registered with. + */ + getDispatcher(): Flux.Dispatcher; + + /** + * Returns the dispatch token that the dispatcher recognizes this store by. + * Can be used to waitFor() this store. + */ + getDispatchToken(): string; + + /** + * Ask if a store has changed during the current dispatch. + * Can only be invoked while dispatching. + * This can be used for constructing derived stores that depend on data from other stores. + */ + hasChanged(): boolean; + + /** + *Emit an event notifying all listeners that this store has changed. + * This can only be invoked when dispatching. + * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. + */ + __emitChange(): void; + + /** + * Subclasses must override this method. + * This is how the store receives actions from the dispatcher. + * All state mutation logic must be done during this method. + */ + __onDispatch(payload: Object): void; + } + + + +} + +declare module 'flux/utils' { + export = FluxUtils; +} From d28dd90af5a7ba2b4f18b107ddba3321a5a1f629 Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Sat, 17 Oct 2015 12:14:39 +0200 Subject: [PATCH 0055/1680] Typeahead: Received an update through nuget, incorporated the differences --- typeahead/typeahead.d.ts | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index ce401c213b..e01e0d509a 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -10,19 +10,19 @@ interface JQuery { /** * Destroys previously initialized typeaheads. This entails reverting * DOM modifications and removing event handlers. - * - * @constructor + * + * @constructor * @param methodName Method 'destroy' - */ + */ typeahead(methodName: 'destroy'): JQuery; /** * Opens the dropdown menu of typeahead. Note that being open does not mean that the menu is visible. * The menu is only visible when it is open and has content. - * - * @constructor + * + * @constructor * @param methodName Method 'open' - */ + */ typeahead(methodName: 'open'): JQuery; /** @@ -36,10 +36,10 @@ interface JQuery { /** * Returns the current value of the typeahead. * The value is the text the user has entered into the input element. - * - * @constructor + * + * @constructor * @param methodName Method 'val' - */ + */ typeahead(methodName: 'val'): string; /** @@ -164,7 +164,7 @@ declare module Twitter.Typeahead { * It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. * cb can be invoked synchronously or asynchronously. * - */ + */ source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** @@ -185,7 +185,7 @@ declare module Twitter.Typeahead { /** * A hash of templates to be used when rendering the dataset. * Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string. - */ + */ templates?: Templates; async?: boolean; } @@ -196,29 +196,43 @@ declare module Twitter.Typeahead { * Rendered when 0 suggestions are available for the given query. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query - */ + */ empty?: any; /** * Rendered at the bottom of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ footer?: any; /** * Rendered at the top of the dataset. * Can be either a HTML string or a precompiled template. * If it's a precompiled template, the passed in context will contain query and isEmpty. - */ + */ header?: any; + + /** + * Rendered when 0 suggestions are available for the given query. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + notFound?: (query: string) => string; + + /** + * Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected. + * Can be either a HTML string or a precompiled template. + * If it's a precompiled template, the passed in context will contain query. + */ + pending?: (query: string) => string; /** * Used to render a single suggestion. * If set, this has to be a precompiled template. * The associated suggestion object will serve as the context. * Defaults to the value of displayKey wrapped in a p tag i.e.

{{value}}

. - */ + */ suggestion?: (datum: any) => string; } From 438f5535c7f5cc7653cceb91d1d3a7f85b82a507 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Mon, 19 Oct 2015 18:55:20 +0300 Subject: [PATCH 0056/1680] Delete flux-utils.d.ts --- flux/flux-utils.d.ts | 130 ------------------------------------------- 1 file changed, 130 deletions(-) delete mode 100644 flux/flux-utils.d.ts diff --git a/flux/flux-utils.d.ts b/flux/flux-utils.d.ts deleted file mode 100644 index 8437f9d4b5..0000000000 --- a/flux/flux-utils.d.ts +++ /dev/null @@ -1,130 +0,0 @@ -// Type definitions for Flux/utils -// Project: http://facebook.github.io/flux/ -// Definitions by: Giedrius Grabauskas -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module FluxUtils { - - export class Container { - /** - * Create is used to transform a react class into a container - * that updates its state when relevant stores change. - * The provided base class must have static methods getStores() and calculateState(). - */ - static create(base: React.ComponentClass, options?: Object): React.ComponentClass; - } - - /** - * This class extends ReduceStore and defines the state as an immutable map. - */ - export class MapStore extends ReduceStore> { - - /** - * Access the value at the given key. - * Throws an error if the key does not exist in the cache. - */ - at(key: K): V; - - /** - * Check if the cache has a particular key - */ - has(key: K): boolean; - - /** - * Get the value of a particular key. - * Returns undefined if the key does not exist in the cache. - */ - get(key: K): V; - - /** - * Gets an array of keys and puts the values in a map if they exist, - * it allows providing a previous result to update instead of generating a new map. - * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. - */ - getAll(keys: Iterable, prev?: Immutable.Map): Immutable.Map; - } - - export class ReduceStore extends Store { - /** - * Getter that exposes the entire state of this store. - * If your state is not immutable you should override this and not expose state directly. - */ - getState(): T; - - /** - * Constructs the initial state for this store. - * This is called once during construction of the store. - */ - getInitialState(): T; - - /** - * Reduces the current state, and an action to the new state of this store. - * All subclasses must implement this method. - * This method should be pure and have no side-effects. - */ - reduce(state: T, action: Object): T; - - /** - * Checks if two versions of state are the same. - * You do not need to override this if your state is immutable. - */ - areEqual(one: T, two: T): boolean; - - } - - export class Store { - - /** - * Constructs and registers an instance of this store with the given dispatcher. - */ - constructor(dispatcher: Flux.Dispatcher); - - /** - * Adds a listener to the store, when the store changes the given callback will be called. - * A token is returned that can be used to remove the listener. - * Calling the remove() function on the returned token will remove the listener. - */ - addListener(callback: Function): { remove: Function }; - - /** - * Returns the dispatcher this store is registered with. - */ - getDispatcher(): Flux.Dispatcher; - - /** - * Returns the dispatch token that the dispatcher recognizes this store by. - * Can be used to waitFor() this store. - */ - getDispatchToken(): string; - - /** - * Ask if a store has changed during the current dispatch. - * Can only be invoked while dispatching. - * This can be used for constructing derived stores that depend on data from other stores. - */ - hasChanged(): boolean; - - /** - *Emit an event notifying all listeners that this store has changed. - * This can only be invoked when dispatching. - * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. - */ - __emitChange(): void; - - /** - * Subclasses must override this method. - * This is how the store receives actions from the dispatcher. - * All state mutation logic must be done during this method. - */ - __onDispatch(payload: Object): void; - } - - - -} - -declare module 'flux/utils' { - export = FluxUtils; -} From 3d4207f11f34df6bcc5cdbece92b69fffed8fde6 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Mon, 19 Oct 2015 18:56:13 +0300 Subject: [PATCH 0057/1680] Update flux.d.ts Content moved from flux-utils.d.ts --- flux/flux.d.ts | 122 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/flux/flux.d.ts b/flux/flux.d.ts index bf5bafac4b..8a00eb1e1f 100644 --- a/flux/flux.d.ts +++ b/flux/flux.d.ts @@ -65,3 +65,125 @@ declare module Flux { declare module "flux" { export = Flux; } + +declare module FluxUtils { + + export class Container { + constructor(); + /** + * Create is used to transform a react class into a container + * that updates its state when relevant stores change. + * The provided base class must have static methods getStores() and calculateState(). + */ + static create(base: React.ComponentClass, options?: Object): React.ComponentClass; + } + + /** + * This class extends ReduceStore and defines the state as an immutable map. + */ + export class MapStore extends ReduceStore> { + + /** + * Access the value at the given key. + * Throws an error if the key does not exist in the cache. + */ + at(key: K): V; + + /** + * Check if the cache has a particular key + */ + has(key: K): boolean; + + /** + * Get the value of a particular key. + * Returns undefined if the key does not exist in the cache. + */ + get(key: K): V; + + /** + * Gets an array of keys and puts the values in a map if they exist, + * it allows providing a previous result to update instead of generating a new map. + * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. + */ + getAll(keys: Immutable.IndexedIterable, prev?: Immutable.Map): Immutable.Map; + } + + export class ReduceStore extends Store { + /** + * Getter that exposes the entire state of this store. + * If your state is not immutable you should override this and not expose state directly. + */ + getState(): T; + + /** + * Constructs the initial state for this store. + * This is called once during construction of the store. + */ + getInitialState(): T; + + /** + * Reduces the current state, and an action to the new state of this store. + * All subclasses must implement this method. + * This method should be pure and have no side-effects. + */ + reduce(state: T, action: Object): T; + + /** + * Checks if two versions of state are the same. + * You do not need to override this if your state is immutable. + */ + areEqual(one: T, two: T): boolean; + + } + + export class Store { + + /** + * Constructs and registers an instance of this store with the given dispatcher. + */ + constructor(dispatcher: Flux.Dispatcher); + + /** + * Adds a listener to the store, when the store changes the given callback will be called. + * A token is returned that can be used to remove the listener. + * Calling the remove() function on the returned token will remove the listener. + */ + addListener(callback: Function): { remove: Function }; + + /** + * Returns the dispatcher this store is registered with. + */ + getDispatcher(): Flux.Dispatcher; + + /** + * Returns the dispatch token that the dispatcher recognizes this store by. + * Can be used to waitFor() this store. + */ + getDispatchToken(): string; + + /** + * Ask if a store has changed during the current dispatch. + * Can only be invoked while dispatching. + * This can be used for constructing derived stores that depend on data from other stores. + */ + hasChanged(): boolean; + + /** + *Emit an event notifying all listeners that this store has changed. + * This can only be invoked when dispatching. + * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. + */ + __emitChange(): void; + + /** + * Subclasses must override this method. + * This is how the store receives actions from the dispatcher. + * All state mutation logic must be done during this method. + */ + __onDispatch(payload: Object): void; + } +} + +declare module 'flux/utils' { + export = FluxUtils; +} From 96173498302aeab1a726f8927bc7314d0b42db85 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Mon, 19 Oct 2015 19:06:19 +0300 Subject: [PATCH 0058/1680] Added references Added immutable and react references. --- flux/flux.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flux/flux.d.ts b/flux/flux.d.ts index 8a00eb1e1f..5b6079d50b 100644 --- a/flux/flux.d.ts +++ b/flux/flux.d.ts @@ -1,8 +1,11 @@ // Type definitions for Flux // Project: http://facebook.github.io/flux/ -// Definitions by: Steve Baker +// Definitions by: Steve Baker , Giedrius Grabauskas // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// +/// + declare module Flux { /** From 7652e924ff0971f817916b8dd8823b085073e1a2 Mon Sep 17 00:00:00 2001 From: vpham6 Date: Wed, 21 Oct 2015 11:45:23 -0700 Subject: [PATCH 0059/1680] Update type for ngModelAttrs with key String --- angular-formly/angular-formly.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index 8f76b3ccf9..9917d217f4 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -297,6 +297,7 @@ declare module AngularFormly { bound?: any; expression?: any; value?: any; + [key: string]: any; }; From 8864681db077703f359e779c1d65135d25edbccb Mon Sep 17 00:00:00 2001 From: MatejQ Date: Fri, 23 Oct 2015 15:34:53 +0200 Subject: [PATCH 0060/1680] Fixed CellClassGetter interfaces according to ui-grid JS code --- ui-grid/ui-grid.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index ef013fdf18..bcf6efe7e0 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -3752,7 +3752,7 @@ declare module uiGrid { } export interface ICellClassGetter { - (gridRow?: IGridRowOf, gridCol?: IGridColumnOf, colRenderIndex?: number): string; + (grid?: IGridInstanceOf, gridRow?: IGridRowOf, gridCol?: IGridColumnOf, rowRenderIndex?: number, colRenderIndex?: number): string; } export interface ICellTooltipGetter { @@ -3762,7 +3762,7 @@ declare module uiGrid { (gridCol: IGridColumnOf): string; } export interface IHeaderFooterCellClassGetter { - (gridRow: IGridRowOf, rowRenderIndex: number, gridCol: IGridColumnOf, colRenderIndex: number) + (grid: IGridInstanceOf, gridRow: IGridRowOf, gridCol: IGridColumnOf, rowRenderIndex: number, colRenderIndex: number) : string; } export interface IMenuItem { From 19e1e0847b972660738b2720a0bca867ffd399c1 Mon Sep 17 00:00:00 2001 From: MatejQ Date: Fri, 23 Oct 2015 15:56:04 +0200 Subject: [PATCH 0061/1680] Attempt to fix failing tests. --- ui-grid/ui-grid-tests.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ui-grid/ui-grid-tests.ts b/ui-grid/ui-grid-tests.ts index 95c81298a7..fe88fec4f2 100644 --- a/ui-grid/ui-grid-tests.ts +++ b/ui-grid/ui-grid-tests.ts @@ -12,9 +12,9 @@ columnDef.aggregationHideLabel = false; columnDef.aggregationType = 1; columnDef.aggregationType = function () { return 1; }; columnDef.cellClass = 'test'; -columnDef.cellClass = (gridRow, gridCol, index) => { - //types of gridRow, gridCol, and index are flowed in correctly - return `${gridRow.entity.name}-${gridCol.field}-${index + 1}`; +columnDef.cellClass = (grid, gridRow, gridCol, rowIndex, colIndex) => { + //types of grid, gridRow, gridCol, rowIndex and colIndex are flowed in correctly + return `${grid.footerHeight}-${gridRow.entity.name}-${gridCol.field}-${rowIndex + 1}-${colIndex + 1}`; }; columnDef.cellFilter = 'date'; columnDef.cellTemplate = '
hello
'; @@ -44,17 +44,17 @@ columnDef.filter = { columnDef.filterCellFiltered = false; columnDef.filterHeaderTemplate = '
'; columnDef.filters = [columnDef.filter]; -columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { - //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly - return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; +columnDef.footerCellClass = (grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => { + //types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly + return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.footerCellClass = 'theClass'; columnDef.footerCellFilter = 'currency:$'; columnDef.footerCellTemplate = '
'; columnDef.headerCellClass = - (gridRow, rowRenderIndex, gridCol, colRenderIndex) => { - //types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly - return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; + (grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => { + //types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly + return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`; }; columnDef.headerCellClass = 'classy'; columnDef.headerCellFilter = 'currency:$'; From af731ff9f1a1e33e4c80e9b75b529fa6507ad9a0 Mon Sep 17 00:00:00 2001 From: Wayne Maurer Date: Fri, 23 Oct 2015 20:22:50 +0200 Subject: [PATCH 0062/1680] Update change-case.d.ts Add missing definitions, sorted functions for readability --- change-case/change-case.d.ts | 42 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/change-case/change-case.d.ts b/change-case/change-case.d.ts index e61d70de64..22c1652862 100644 --- a/change-case/change-case.d.ts +++ b/change-case/change-case.d.ts @@ -4,34 +4,36 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "change-case" { - function dot(s: string): string; - function dotCase(s: string): string; - function swap(s: string): string; - function swapCase(s: string): string; - function path(s: string): string; - function pathCase(s: string): string; - function upper(s: string): string; - function upperCase(s: string): string; - function lower(s: string): string; - function lowerCase(s: string): string; function camel(s: string): string; function camelCase(s: string): string; - function snake(s: string): string; - function snakeCase(s: string): string; - function title(s: string): string; - function titleCase(s: string): string; + function constant(s: string): string; + function constantCase(s: string): string; + function dot(s: string): string; + function dotCase(s: string): string; + function isLower(s: string): boolean; + function isLowerCase(s: string): boolean; + function isUpper(s: string): boolean; + function isUpperCase(s: string): boolean; + function lcFirst(s: string): string; + function lower(s: string): string; + function lowerCase(s: string): string; + function lowerCaseFirst(s: string): string; function param(s: string): string; function paramCase(s: string): string; function pascal(s: string): string; function pascalCase(s: string): string; - function constant(s: string): string; - function constantCase(s: string): string; + function path(s: string): string; + function pathCase(s: string): string; function sentence(s: string): string; function sentenceCase(s: string): string; - function isUpper(s: string): boolean; - function isUpperCase(s: string): boolean; - function isLower(s: string): boolean; - function isLowerCase(s: string): boolean; + function snake(s: string): string; + function snakeCase(s: string): string; + function swap(s: string): string; + function swapCase(s: string): string; + function title(s: string): string; + function titleCase(s: string): string; function ucFirst(s: string): string; + function upper(s: string): string; + function upperCase(s: string): string; function upperCaseFirst(s: string): string; } From 54f6c166ae1721dab0d948024f67f15f82e63d13 Mon Sep 17 00:00:00 2001 From: Wayne Maurer Date: Fri, 23 Oct 2015 20:26:54 +0200 Subject: [PATCH 0063/1680] Update change-case-tests.ts added missing tests for missing functions, sorted for readability --- change-case/change-case-tests.ts | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/change-case/change-case-tests.ts b/change-case/change-case-tests.ts index 24276654c6..837ecc3a7d 100644 --- a/change-case/change-case-tests.ts +++ b/change-case/change-case-tests.ts @@ -5,33 +5,35 @@ import changeCase = require("change-case"); var s: string; var b: boolean; -s = changeCase.dot(s); -s = changeCase.dotCase(s); -s = changeCase.swap(s); -s = changeCase.swapCase(s); -s = changeCase.path(s); -s = changeCase.pathCase(s); -s = changeCase.upper(s); -s = changeCase.upperCase(s); -s = changeCase.lower(s); -s = changeCase.lowerCase(s); +b = changeCase.isLower(s); +b = changeCase.isLowerCase(s); +b = changeCase.isUpper(s); +b = changeCase.isUpperCase(s); s = changeCase.camel(s); s = changeCase.camelCase(s); -s = changeCase.snake(s); -s = changeCase.snakeCase(s); -s = changeCase.title(s); -s = changeCase.titleCase(s); +s = changeCase.constant(s); +s = changeCase.constantCase(s); +s = changeCase.dot(s); +s = changeCase.dotCase(s); +s = changeCase.lcFirst(s); +s = changeCase.lower(s); +s = changeCase.lowerCase(s); +s = changeCase.lowerCaseFirst(s); s = changeCase.param(s); s = changeCase.paramCase(s); s = changeCase.pascal(s); s = changeCase.pascalCase(s); -s = changeCase.constant(s); -s = changeCase.constantCase(s); +s = changeCase.path(s); +s = changeCase.pathCase(s); s = changeCase.sentence(s); s = changeCase.sentenceCase(s); -b = changeCase.isUpper(s); -b = changeCase.isUpperCase(s); -b = changeCase.isLower(s); -b = changeCase.isLowerCase(s); +s = changeCase.snake(s); +s = changeCase.snakeCase(s); +s = changeCase.swap(s); +s = changeCase.swapCase(s); +s = changeCase.title(s); +s = changeCase.titleCase(s); s = changeCase.ucFirst(s); +s = changeCase.upper(s); +s = changeCase.upperCase(s); s = changeCase.upperCaseFirst(s); From 392f2699d0aee7ef7da3227614e641600c1e1af1 Mon Sep 17 00:00:00 2001 From: Maxime LUCE Date: Sun, 25 Oct 2015 01:01:01 +0200 Subject: [PATCH 0064/1680] Update opn typings for version 3.0.2 --- opn/opn-tests.ts | 18 ++++++++--- opn/opn.d.ts | 84 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 11 deletions(-) diff --git a/opn/opn-tests.ts b/opn/opn-tests.ts index 361725970d..2b39f1950c 100644 --- a/opn/opn-tests.ts +++ b/opn/opn-tests.ts @@ -1,10 +1,18 @@ /// -import opn = require('opn'); +import * as opn from "opn"; var errorCallback: (err: Error) => void; -opn('foo'); -opn('foo', 'bar'); -opn('foo', errorCallback); -opn('foo', 'bar', errorCallback); +opn("foo"); +opn("foo", errorCallback); + +opn("foo", { app: "bar" }); +opn("foo", { app: ["bar", "--arg"] }); +opn("foo", { app: "bar", wait: false }); +opn("foo", { app: ["bar", "--arg"] , wait: false}); + +opn("foo", { app: "bar" }, errorCallback); +opn("foo", { app: ["bar", "--arg"] }, errorCallback); +opn("foo", { app: "bar", wait: false }, errorCallback); +opn("foo", { app: ["bar", "--arg"], wait: false }, errorCallback); diff --git a/opn/opn.d.ts b/opn/opn.d.ts index 10a34ce60c..6e6a5a1788 100644 --- a/opn/opn.d.ts +++ b/opn/opn.d.ts @@ -1,10 +1,82 @@ -// Type definitions for opn 1.0.0 +// Type definitions for opn 3.0.2 // Project: https://github.com/sindresorhus/opn -// Definitions by: Shinnosuke Watanabe +// Definitions by: Shinnosuke Watanabe , +// Maxime LUCE // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module 'opn' { - function opn(target: string, callback?: (err: Error) => void): void; - function opn(target: string, app: string, callback?: (err: Error) => void): void; - export = opn; +/// + +declare namespace Opn { + export interface Options { + /** + * Wait for the opened app to exit before calling the `callback`. + * If `false` it's called immediately when opening the app. + * On Windows you have to explicitly specify an app for it to be able to wait. + */ + wait?: boolean; + + /** + * Specify the app to open the target with, or an array with the app and app arguments. + * The app name is platform dependent. Don't hard code it in reusable modules. + * Eg. Chrome is `google chrome` on OS X, `google-chrome` on Linux and `chrome` on Windows. + */ + app?: string | string[]; + } +} + +declare module "opn" { + import * as cp from "child_process"; + + interface DefaultFunction { + /** + * Uses the command open on OS X, start on Windows and xdg-open on other platforms. + * + * Returns the spawned child process. + * You'd normally not need to use this for anything, but it can be useful if you'd like + * to attach custom event listeners or perform other operations directly on the spawned process. + * + * @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. Eg. URLs opens in your default browser. + */ + (target: string): cp.ChildProcess; + + /** + * Uses the command open on OS X, start on Windows and xdg-open on other platforms. + * + * Returns the spawned child process. + * You'd normally not need to use this for anything, but it can be useful if you'd like + * to attach custom event listeners or perform other operations directly on the spawned process. + * + * @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. Eg. URLs opens in your default browser. + * @param callback- Called when the opened app exits, or if `wait: false`, immediately when opening. + */ + (target: string, callback: (err: Error) => void): cp.ChildProcess; + + /** + * Uses the command open on OS X, start on Windows and xdg-open on other platforms. + * + * Returns the spawned child process. + * You'd normally not need to use this for anything, but it can be useful if you'd like + * to attach custom event listeners or perform other operations directly on the spawned process. + * + * @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. Eg. URLs opens in your default browser. + * @param options - Options to be passed to opn. + */ + (target: string, options: Opn.Options): cp.ChildProcess; + + /** + * Uses the command open on OS X, start on Windows and xdg-open on other platforms. + * + * Returns the spawned child process. + * You'd normally not need to use this for anything, but it can be useful if you'd like + * to attach custom event listeners or perform other operations directly on the spawned process. + * + * @param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. Eg. URLs opens in your default browser. + * @param options - Options to be passed to opn. + * @param callback- Called when the opened app exits, or if `wait: false`, immediately when opening. + */ + (target: string, options: Opn.Options, callback: (err: Error) => void): cp.ChildProcess; + } + + const opn: DefaultFunction; + export = opn; } From 59f9108f4e913a8933ab7c1c1914536df8f2c97c Mon Sep 17 00:00:00 2001 From: Kristian Tryggestad Date: Tue, 27 Oct 2015 16:33:46 +0100 Subject: [PATCH 0065/1680] Add transport property to SignalR's HubConnection --- signalr/signalr.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index aa17d1e579..e890c8f425 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -90,6 +90,7 @@ interface HubConnectionSettings { interface HubConnection extends SignalR { //(url?: string, queryString?: any, logging?: boolean): HubConnection; proxies: any; + transport: { name: string, supportsKeepAlive: () => boolean }; received(callback: (data: { Id: any; Method: any; Hub: any; State: any; Args: any; }) => void ): HubConnection; createHubProxy(hubName: string): HubProxy; } From 34b2fc23d8d72d11ff1a77bd9436a76816ba1acd Mon Sep 17 00:00:00 2001 From: Martin D Date: Tue, 27 Oct 2015 16:43:24 -0400 Subject: [PATCH 0066/1680] IconOptions to accept arrays and point objects All Leaflet methods and options that accept Point objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent: http://leafletjs.com/reference.html#point --- leaflet/leaflet.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 110bdd6f75..04f2da4094 100755 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -1088,7 +1088,7 @@ declare namespace L { /** * Size of the icon image in pixels. */ - iconSize?: Point; + iconSize?: Point|number[]; /** * The coordinates of the "tip" of the icon (relative to its top left corner). @@ -1096,7 +1096,7 @@ declare namespace L { * location. Centered by default if size is specified, also can be set in CSS * with negative margins. */ - iconAnchor?: Point; + iconAnchor?: Point|number[]; /** * The URL to the icon shadow image. If not specified, no shadow image will be @@ -1113,19 +1113,19 @@ declare namespace L { /** * Size of the shadow image in pixels. */ - shadowSize?: Point; + shadowSize?: Point|number[]; /** * The coordinates of the "tip" of the shadow (relative to its top left corner) * (the same as iconAnchor if not specified). */ - shadowAnchor?: Point; + shadowAnchor?: Point|number[]; /** * The coordinates of the point from which popups will "open", relative to the * icon anchor. */ - popupAnchor?: Point; + popupAnchor?: Point|number[]; /** * A custom class name to assign to both icon and shadow images. Empty by default. From 1d7d9e514e1978b74979cdfbc29a0b2ea8337cfc Mon Sep 17 00:00:00 2001 From: Jacob Eggers Date: Wed, 28 Oct 2015 00:05:07 -0700 Subject: [PATCH 0067/1680] Fixes #6489 --- request-promise/request-promise.d.ts | 3 ++- request/request.d.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/request-promise/request-promise.d.ts b/request-promise/request-promise.d.ts index 246f1e5d9d..1bc357dd13 100644 --- a/request-promise/request-promise.d.ts +++ b/request-promise/request-promise.d.ts @@ -22,10 +22,11 @@ declare module 'request-promise' { function RequestPromiseAPI(uri: string): Promise; module RequestPromiseAPI { - export interface Options extends request.Options { + interface AdditionalOptions { simple?: boolean; transform?: (body: any, response: http.IncomingMessage) => any; resolveWithFullResponse?: boolean; } + export type Options = AdditionalOptions & request.Options; } } diff --git a/request/request.d.ts b/request/request.d.ts index d3bbd57047..49c41f8fc0 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -57,9 +57,15 @@ declare module 'request' { export var initParams: any; - export interface Options { - url?: string; - uri?: string; + interface UriOptions { + uri: string; + } + + interface UrlOptions { + url: string; + } + + interface OptionalOptions { callback?: (error: any, response: http.IncomingMessage, body: any) => void; jar?: any; // CookieJar formData?: any; // Object @@ -90,6 +96,8 @@ declare module 'request' { gzip?: boolean; } + export type Options = (UriOptions|UrlOptions)&OptionalOptions; + export interface RequestPart { headers?: Headers; body: any; From f58cfb989f00ec880d4b4acad0f52bc5bf7aba0b Mon Sep 17 00:00:00 2001 From: Zhiyuan Wang Date: Wed, 28 Oct 2015 15:20:34 +0800 Subject: [PATCH 0068/1680] add definition and test for merge-descriptor --- merge-descriptors/merge-descriptors-tests.ts | 35 +++++++++++++++++++ .../merge-descriptors-tests.ts.tscparams | 1 + merge-descriptors/merge-descriptors.d.ts | 13 +++++++ 3 files changed, 49 insertions(+) create mode 100644 merge-descriptors/merge-descriptors-tests.ts create mode 100644 merge-descriptors/merge-descriptors-tests.ts.tscparams create mode 100644 merge-descriptors/merge-descriptors.d.ts diff --git a/merge-descriptors/merge-descriptors-tests.ts b/merge-descriptors/merge-descriptors-tests.ts new file mode 100644 index 0000000000..81376320ff --- /dev/null +++ b/merge-descriptors/merge-descriptors-tests.ts @@ -0,0 +1,35 @@ +/// +import mixin = require('merge-descriptors'); + +function testAssertion(condition: boolean, errorMessage: string) { + if (!condition) { + throw new Error(errorMessage); + } +} + +interface IMergedObject { + InSrc?: string; + name: string; + InTarget: string; +} + +var src = { + InSrc: 'src', + get name(): string { + return 'from src name'; + } +} + +var target: IMergedObject = { name: 'my target name', InTarget: 'target' }; + +var target2 = mixin(target, src, true); + +console.log(JSON.stringify(target)); + +testAssertion(target2 === target, "Returned object should refer to input [destination] object"); +testAssertion(target.name === 'from src name', "[redfine]=true, source member will overwrite destination member"); +testAssertion(target.InTarget === 'target', "overwrite do not affect members only in [destination]"); +testAssertion(target['InSrc'] === 'src', "members from [source] must be copied to [destination]"); + +var nameProperty:PropertyDescriptor = Object.getOwnPropertyDescriptor(target, "name"); +testAssertion(nameProperty.set === undefined, "member descriptor must be overwritten"); \ No newline at end of file diff --git a/merge-descriptors/merge-descriptors-tests.ts.tscparams b/merge-descriptors/merge-descriptors-tests.ts.tscparams new file mode 100644 index 0000000000..4169d3605f --- /dev/null +++ b/merge-descriptors/merge-descriptors-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 \ No newline at end of file diff --git a/merge-descriptors/merge-descriptors.d.ts b/merge-descriptors/merge-descriptors.d.ts new file mode 100644 index 0000000000..8e3212edda --- /dev/null +++ b/merge-descriptors/merge-descriptors.d.ts @@ -0,0 +1,13 @@ +// Type definitions for merge-descriptors +// Project: https://github.com/component/merge-descriptors +// Definitions by: Zhiyuan Wang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'merge-descriptors' { + + function merge(destination: Object, source: Object): Object; + + function merge(destination: Object, source: Object, redefine: boolean): Object; + + export = merge; +} \ No newline at end of file From d42c7e25f743c928986821fa555015bce87e2ba1 Mon Sep 17 00:00:00 2001 From: John Alfaro Date: Wed, 28 Oct 2015 13:58:48 -0400 Subject: [PATCH 0069/1680] #6487 - gridfs-stream.d.ts - Support for findOne and curCol Added declarat --- gridfs-stream/gridfs-stream.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gridfs-stream/gridfs-stream.d.ts b/gridfs-stream/gridfs-stream.d.ts index a8ad5f9ed3..7dc355dafd 100644 --- a/gridfs-stream/gridfs-stream.d.ts +++ b/gridfs-stream/gridfs-stream.d.ts @@ -52,6 +52,7 @@ declare module "gridfs-stream" { files: mongo.Collection; collection(name?: string): mongo.Collection; + curCol: string; createWriteStream(options?: GridFSStream.Options): GridFSStream.WriteStream; createReadStream(options?: GridFSStream.Options): GridFSStream.ReadStream; @@ -60,6 +61,7 @@ declare module "gridfs-stream" { remove(options: GridFSStream.Options, callback: (err: Error) => void): void; exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void): void; + findOne(options: GridFSStream.Options, callback: (err: Error, record: any)=>void):void; } } From 3637fe5a062c4a1ab987a22960c4c12f61296ef0 Mon Sep 17 00:00:00 2001 From: Kapil Sachdeva Date: Wed, 28 Oct 2015 19:01:23 -0500 Subject: [PATCH 0070/1680] Add the ngCordova type definitions This changeset add the bindings for $cordovaDevice & $cordovaToast services --- ngCordova/device-tests.ts | 42 +++++++++++++++++++++ ngCordova/device.d.ts | 77 +++++++++++++++++++++++++++++++++++++++ ngCordova/toast-tests.ts | 51 ++++++++++++++++++++++++++ ngCordova/toast.d.ts | 21 +++++++++++ ngCordova/tsd.d.ts | 2 + 5 files changed, 193 insertions(+) create mode 100644 ngCordova/device-tests.ts create mode 100644 ngCordova/device.d.ts create mode 100644 ngCordova/toast-tests.ts create mode 100644 ngCordova/toast.d.ts create mode 100644 ngCordova/tsd.d.ts diff --git a/ngCordova/device-tests.ts b/ngCordova/device-tests.ts new file mode 100644 index 0000000000..c5f761326d --- /dev/null +++ b/ngCordova/device-tests.ts @@ -0,0 +1,42 @@ +/// +/// +/// + +// For the full application demo please see follow repo : +// https://github.com/ksachdeva/ngCordova-typescript-demo + +namespace demo.device { + 'use strict'; + + interface IDeviceViewModel { + available:boolean; + cordova:string; + model:string; + platform:string; + uuid:string; + version:string; + } + + export class DeviceController { + + public vm:IDeviceViewModel; + + static $inject:Array = ["$ionicPlatform", "$cordovaDevice"]; + constructor($ionicPlatform:ionic.platform.IonicPlatformService, $cordovaDevice:ngCordova.IDeviceService) { + + $ionicPlatform.ready(() => { + this.vm = { + available : $cordovaDevice.getDevice().available, + cordova : $cordovaDevice.getCordova(), + model : $cordovaDevice.getModel(), + platform : $cordovaDevice.getPlatform(), + uuid : $cordovaDevice.getUUID(), + version : $cordovaDevice.getVersion() + }; + }); + } + + } + + angular.module("demo.device").controller("DeviceController", DeviceController); +} \ No newline at end of file diff --git a/ngCordova/device.d.ts b/ngCordova/device.d.ts new file mode 100644 index 0000000000..760b37cefe --- /dev/null +++ b/ngCordova/device.d.ts @@ -0,0 +1,77 @@ +// Type definitions for ngCordova device plugin +// Project: https://github.com/driftyco/ng-cordova +// Definitions by: Kapil Sachdeva + +declare module ngCordova { + + interface IDeviceInfo { + available:boolean; + platform:string; + version:string; + uuid:string; + cordova:string; + model:string; + manufacturer:string; + isVirtual:boolean; + serial:string; + } + + interface IDeviceService { + + /** + * Returns the whole device object. + * @see https://github.com/apache/cordova-plugin-device + * @returns {Object} The device object. + */ + getDevice():IDeviceInfo; + + /** + * Returns the Cordova version. + * @see https://github.com/apache/cordova-plugin-device#devicecordova + * @returns {String} The Cordova version. + */ + getCordova():string; + + /** + * Returns the name of the device's model or product. + * @see https://github.com/apache/cordova-plugin-device#devicemodel + * @returns {String} The name of the device's model or product. + */ + getModel():string; + + + /** + * @deprecated device.name is deprecated as of version 2.3.0. Use device.model instead. + * @returns {String} + */ + getName():string; + + /** + * Returns the device's operating system name. + * @see https://github.com/apache/cordova-plugin-device#deviceplatform + * @returns {String} The device's operating system name. + */ + getPlatform():string; + + + /** + * Returns the device's Universally Unique Identifier. + * @see https://github.com/apache/cordova-plugin-device#deviceuuid + * @returns {String} The device's Universally Unique Identifier + */ + getUUID():string; + + /** + * Returns the operating system version. + * @see https://github.com/apache/cordova-plugin-device#deviceversion + * @returns {String} + */ + getVersion():string; + + /** + * Returns the device manufacturer. + * @returns {String} + */ + getManufacturer():string; + } +} \ No newline at end of file diff --git a/ngCordova/toast-tests.ts b/ngCordova/toast-tests.ts new file mode 100644 index 0000000000..1d067a92b7 --- /dev/null +++ b/ngCordova/toast-tests.ts @@ -0,0 +1,51 @@ +/// +/// +/// + +// For the full application demo please see follow repo : +// https://github.com/ksachdeva/ngCordova-typescript-demo + +namespace demo.toast { + 'use strict'; + + export class ToastController { + + toastMessage:string = 'enter a message'; + msg:string; + + static $inject:Array = ["$cordovaToast"]; + constructor(private $cordovaToast:ngCordova.IToastService) { + + } + + center() { + this.$cordovaToast.show(this.toastMessage, 'long', 'center') + .then((success) => { + console.log("center msg displayed"); + }, (error) => { + this.msg = error.message; + }); + } + + top() { + this.$cordovaToast.showShortTop(this.toastMessage) + .then((success) => { + console.log("short top msg displayed"); + }, (error) => { + this.msg = error.message; + }); + } + + bottom() { + this.$cordovaToast.showLongBottom(this.toastMessage) + .then((success) => { + console.log("long bottom msg displayed"); + }, (error) => { + this.msg = error.message; + }); + } + + } + + angular.module("demo.toast").controller("ToastController", ToastController); +} \ No newline at end of file diff --git a/ngCordova/toast.d.ts b/ngCordova/toast.d.ts new file mode 100644 index 0000000000..c7dd6a9803 --- /dev/null +++ b/ngCordova/toast.d.ts @@ -0,0 +1,21 @@ +// Type definitions for ngCordova toast plugin +// Project: https://github.com/driftyco/ng-cordova +// Definitions by: Kapil Sachdeva + +/// + +declare module ngCordova { + + interface IToastService { + + showShortTop(message:string):angular.IPromise; + showShortCenter(message:string):angular.IPromise; + showShortBottom(message:string):angular.IPromise; + + showLongTop(message:string):angular.IPromise; + showLongCenter(message:string):angular.IPromise; + showLongBottom(message:string):angular.IPromise; + + show(message:string, duration:string, position:string):angular.IPromise; + } +} \ No newline at end of file diff --git a/ngCordova/tsd.d.ts b/ngCordova/tsd.d.ts new file mode 100644 index 0000000000..13cbd0f26c --- /dev/null +++ b/ngCordova/tsd.d.ts @@ -0,0 +1,2 @@ +/// +/// From ac7ddea017ca3e61975da263c29f9e20cbe6af8c Mon Sep 17 00:00:00 2001 From: Kapil Sachdeva Date: Wed, 28 Oct 2015 19:09:33 -0500 Subject: [PATCH 0071/1680] Corrections for the conventions for the file headers --- ngCordova/device-tests.ts | 2 +- ngCordova/device.d.ts | 3 ++- ngCordova/toast-tests.ts | 2 +- ngCordova/toast.d.ts | 3 ++- ngCordova/tsd.d.ts | 5 +++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ngCordova/device-tests.ts b/ngCordova/device-tests.ts index c5f761326d..37a30bf663 100644 --- a/ngCordova/device-tests.ts +++ b/ngCordova/device-tests.ts @@ -2,7 +2,7 @@ /// /// -// For the full application demo please see follow repo : +// For the full application demo please see following repo : // https://github.com/ksachdeva/ngCordova-typescript-demo namespace demo.device { diff --git a/ngCordova/device.d.ts b/ngCordova/device.d.ts index 760b37cefe..8171fb3fc0 100644 --- a/ngCordova/device.d.ts +++ b/ngCordova/device.d.ts @@ -1,6 +1,7 @@ // Type definitions for ngCordova device plugin // Project: https://github.com/driftyco/ng-cordova -// Definitions by: Kapil Sachdeva +// Definitions by: Kapil Sachdeva +// Definitions: https://github.com/ksachdeva/DefinitelyTyped declare module ngCordova { diff --git a/ngCordova/toast-tests.ts b/ngCordova/toast-tests.ts index 1d067a92b7..43ed529e5d 100644 --- a/ngCordova/toast-tests.ts +++ b/ngCordova/toast-tests.ts @@ -2,7 +2,7 @@ /// /// -// For the full application demo please see follow repo : +// For the full application demo please see following repo : // https://github.com/ksachdeva/ngCordova-typescript-demo namespace demo.toast { diff --git a/ngCordova/toast.d.ts b/ngCordova/toast.d.ts index c7dd6a9803..8e5c6ba0c1 100644 --- a/ngCordova/toast.d.ts +++ b/ngCordova/toast.d.ts @@ -1,6 +1,7 @@ // Type definitions for ngCordova toast plugin // Project: https://github.com/driftyco/ng-cordova -// Definitions by: Kapil Sachdeva +// Definitions by: Kapil Sachdeva +// Definitions: https://github.com/ksachdeva/DefinitelyTyped /// diff --git a/ngCordova/tsd.d.ts b/ngCordova/tsd.d.ts index 13cbd0f26c..726ea99e6e 100644 --- a/ngCordova/tsd.d.ts +++ b/ngCordova/tsd.d.ts @@ -1,2 +1,7 @@ +// Type definitions for ngCordova plugins +// Project: https://github.com/driftyco/ng-cordova +// Definitions by: Kapil Sachdeva +// Definitions: https://github.com/ksachdeva/DefinitelyTyped + /// /// From 7464746d91f97560fc0975abc497bf745fd7cd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 29 Oct 2015 12:31:11 +0100 Subject: [PATCH 0072/1680] Create three-FirstPersonControls.d.ts --- threejs/three-FirstPersonControls.d.ts | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 threejs/three-FirstPersonControls.d.ts diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts new file mode 100644 index 0000000000..355ce1e69d --- /dev/null +++ b/threejs/three-FirstPersonControls.d.ts @@ -0,0 +1,33 @@ +Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts + +interface IFirstPersonControls { + object: IObject3D; + target: IVector3; + domElement: HTMLCanvasElement; + movementSpeed: number; + lookSpeed: number; + noFly: bool; + lookVertical: bool; + autoForward: bool; + activeLook: bool; + heightSpeed: bool; + heightCoef: number; + heightMin: number; + constrainVertical: bool; + verticalMin: number; + verticalMax: number; + autoSpeedFactor: number; + mouseX: number; + mouseY: number; + lat: number; + lon: number; + phi: number; + theta: number; + moveForward: bool; + moveBackward: bool; + moveLeft: bool; + moveRight: bool; + freeze: bool; + mouseDragOn: bool; + update(delta?: number): void; +} From f55e5666a28ecee6941dda592a903b1ff5aa0c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 29 Oct 2015 12:38:34 +0100 Subject: [PATCH 0073/1680] fixed build errors from copied source --- threejs/three-FirstPersonControls.d.ts | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index 355ce1e69d..b5c1f7e1e7 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -1,19 +1,22 @@ -Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts +//Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// interface IFirstPersonControls { - object: IObject3D; - target: IVector3; + object: Object3D; + target: Vector3; domElement: HTMLCanvasElement; movementSpeed: number; lookSpeed: number; - noFly: bool; - lookVertical: bool; - autoForward: bool; - activeLook: bool; - heightSpeed: bool; - heightCoef: number; - heightMin: number; - constrainVertical: bool; + noFly: boolean; + lookVertical: boolean; + autoForward: boolean; + activeLook: boolean; + heightSpeed: boolean; + heightCoef: boolean; + heightMin: boolean; + constrainVertical: boolean; verticalMin: number; verticalMax: number; autoSpeedFactor: number; @@ -23,11 +26,11 @@ interface IFirstPersonControls { lon: number; phi: number; theta: number; - moveForward: bool; - moveBackward: bool; - moveLeft: bool; - moveRight: bool; - freeze: bool; - mouseDragOn: bool; + moveForward: boolean; + moveBackward: boolean; + moveLeft: boolean; + moveRight: boolean; + freeze: boolean; + mouseDragOn: boolean; update(delta?: number): void; } From 1df845d46b911d23abde00af0ebe5de3e181a93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 29 Oct 2015 12:54:38 +0100 Subject: [PATCH 0074/1680] changed interface to class declaration --- threejs/three-FirstPersonControls.d.ts | 67 ++++++++++++++------------ 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index b5c1f7e1e7..32d9b6791e 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -1,36 +1,39 @@ -//Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts +// Type definitions for three.js // Definitions: https://github.com/borisyankov/DefinitelyTyped +//Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts /// - -interface IFirstPersonControls { - object: Object3D; - target: Vector3; - domElement: HTMLCanvasElement; - movementSpeed: number; - lookSpeed: number; - noFly: boolean; - lookVertical: boolean; - autoForward: boolean; - activeLook: boolean; - heightSpeed: boolean; - heightCoef: boolean; - heightMin: boolean; - constrainVertical: boolean; - verticalMin: number; - verticalMax: number; - autoSpeedFactor: number; - mouseX: number; - mouseY: number; - lat: number; - lon: number; - phi: number; - theta: number; - moveForward: boolean; - moveBackward: boolean; - moveLeft: boolean; - moveRight: boolean; - freeze: boolean; - mouseDragOn: boolean; - update(delta?: number): void; +declare module THREE { + class FirstPersonControls { + constructor(object: Camera, domElement?: HTMLElement); + object: THREE.Object3D; + target: THREE.Vector3; + domElement: HTMLCanvasElement; + movementSpeed: number; + lookSpeed: number; + noFly: boolean; + lookVertical: boolean; + autoForward: boolean; + activeLook: boolean; + heightSpeed: boolean; + heightCoef: boolean; + heightMin: boolean; + constrainVertical: boolean; + verticalMin: number; + verticalMax: number; + autoSpeedFactor: number; + mouseX: number; + mouseY: number; + lat: number; + lon: number; + phi: number; + theta: number; + moveForward: boolean; + moveBackward: boolean; + moveLeft: boolean; + moveRight: boolean; + freeze: boolean; + mouseDragOn: boolean; + update(delta?: number): void; + } } From 37dc9544a2afc14bb76745d61a7903125c3696d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 29 Oct 2015 14:21:50 +0100 Subject: [PATCH 0075/1680] fixed header --- threejs/three-FirstPersonControls.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index 32d9b6791e..d59fd3459f 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -1,4 +1,6 @@ // Type definitions for three.js +// Project: http://mrdoob.github.com/three.js/ +// Definitions by: Poul Kjeldager Sørensen // Definitions: https://github.com/borisyankov/DefinitelyTyped //Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts From 5fa991766aa3b0d7ca3ead189993252ff7231ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 29 Oct 2015 14:26:40 +0100 Subject: [PATCH 0076/1680] fixed name --- threejs/three-FirstPersonControls.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index d59fd3459f..3e34b9e45c 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -1,6 +1,6 @@ // Type definitions for three.js // Project: http://mrdoob.github.com/three.js/ -// Definitions by: Poul Kjeldager Sørensen +// Definitions by: Poul Kjeldager Sørensen // Definitions: https://github.com/borisyankov/DefinitelyTyped //Source : https://github.com/NTaylorMullen/CycleR/blob/master/CycleR/CycleR.Game.Client/Client/Interfaces/ThreeJS/Cameras/FirstPersonControls.d.ts From b5f4a47c028a5cee5b38389eddb46f75d73c1e98 Mon Sep 17 00:00:00 2001 From: Eric Nicholson Date: Thu, 29 Oct 2015 09:54:55 -0400 Subject: [PATCH 0077/1680] Fixed existing definitions for SQS and added missing definitions --- aws-sdk/aws-sdk-tests.ts | 253 ++++++++++++++++++++++++++++- aws-sdk/aws-sdk-tests.ts.tscparams | 1 + aws-sdk/aws-sdk.d.ts | 211 +++++++++++++++++------- 3 files changed, 405 insertions(+), 60 deletions(-) create mode 100644 aws-sdk/aws-sdk-tests.ts.tscparams diff --git a/aws-sdk/aws-sdk-tests.ts b/aws-sdk/aws-sdk-tests.ts index 8a3464a6df..7411beb930 100644 --- a/aws-sdk/aws-sdk-tests.ts +++ b/aws-sdk/aws-sdk-tests.ts @@ -1,13 +1,256 @@ /// -import awsSdk = require('aws-sdk'); +import AWS = require('aws-sdk'); var str: string; -var creds: awsSdk.Credentials; +var creds: AWS.Credentials; -creds = new awsSdk.Credentials(str, str); -creds = new awsSdk.Credentials(str, str, str); +creds = new AWS.Credentials(str, str); +creds = new AWS.Credentials(str, str, str); str = creds.accessKeyId; -// more + +/* + * SQS + */ +var sqs:AWS.SQS + +//Default constructor +sqs = new AWS.SQS(); + +//Locking the API Version +sqs = new AWS.SQS({apiVersion: '2012-11-05'}); + +// Locking the API Version Globally +AWS.config.apiVersions = { + sqs: '2012-11-05', + // other service API versions +}; + +sqs.addPermission({ + AWSAccountIds: [ /* required */ + 'STRING_VALUE', + /* more items */ + ], + Actions: [ /* required */ + 'STRING_VALUE', + /* more items */ + ], + Label: 'STRING_VALUE', /* required */ + QueueUrl: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.changeMessageVisibility({ + QueueUrl: 'STRING_VALUE', /* required */ + ReceiptHandle: 'STRING_VALUE', /* required */ + VisibilityTimeout: 0 /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.changeMessageVisibilityBatch({ + Entries: [ /* required */ + { + Id: 'STRING_VALUE', /* required */ + ReceiptHandle: 'STRING_VALUE', /* required */ + VisibilityTimeout: 0 + }, + /* more items */ + ], + QueueUrl: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.createQueue({ + QueueName: 'STRING_VALUE', /* required */ + Attributes: { + someKey: 'STRING_VALUE', + /* anotherKey: ... */ + } + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.deleteMessage({ + QueueUrl: 'STRING_VALUE', /* required */ + ReceiptHandle: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.deleteMessageBatch({ + Entries: [ /* required */ + { + Id: 'STRING_VALUE', /* required */ + ReceiptHandle: 'STRING_VALUE' /* required */ + }, + /* more items */ + ], + QueueUrl: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.deleteQueue({ + QueueUrl: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.getQueueAttributes({ + QueueUrl: 'STRING_VALUE', /* required */ + AttributeNames: [ + 'Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy', + /* more items */ + ] + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.getQueueUrl({ + QueueName: 'STRING_VALUE', /* required */ + QueueOwnerAWSAccountId: 'STRING_VALUE' + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.listDeadLetterSourceQueues({ + QueueUrl: 'STRING_VALUE' /* required */ + }, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.listQueues({ + QueueNamePrefix: 'STRING_VALUE' + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.purgeQueue({ + QueueUrl: 'STRING_VALUE' /* required */ + }, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.receiveMessage({ + QueueUrl: 'STRING_VALUE', /* required */ + AttributeNames: [ + 'Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy', + /* more items */ + ], + MaxNumberOfMessages: 0, + MessageAttributeNames: [ + 'STRING_VALUE', + /* more items */ + ], + VisibilityTimeout: 0, + WaitTimeSeconds: 0 + }, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.removePermission({ + Label: 'STRING_VALUE', /* required */ + QueueUrl: 'STRING_VALUE' /* required */ + }, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.sendMessage({ + MessageBody: 'STRING_VALUE', /* required */ + QueueUrl: 'STRING_VALUE', /* required */ + DelaySeconds: 0, + MessageAttributes: { + someKey: { + DataType: 'STRING_VALUE', /* required */ + BinaryListValues: [ + new Buffer('...') || 'STRING_VALUE', + /* more items */ + ], + BinaryValue: new Buffer('...') || 'STRING_VALUE', + StringListValues: [ + 'STRING_VALUE', + /* more items */ + ], + StringValue: 'STRING_VALUE' + }, + /* anotherKey: ... */ + } + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.sendMessageBatch({ + Entries: [ /* required */ + { + Id: 'STRING_VALUE', /* required */ + MessageBody: 'STRING_VALUE', /* required */ + DelaySeconds: 0, + MessageAttributes: { + someKey: { + DataType: 'STRING_VALUE', /* required */ + BinaryListValues: [ + new Buffer('...') , + /* more items */ + ], + BinaryValue: new Buffer('...'), + StringListValues: [ + 'STRING_VALUE', + /* more items */ + ], + StringValue: 'STRING_VALUE' + }, + /* anotherKey: ... */ + } + }, + /* more items */ + ], + QueueUrl: 'STRING_VALUE' /* required */ + }, + function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + +sqs.setQueueAttributes({ + Attributes: { /* required */ + someKey: 'STRING_VALUE', + /* anotherKey: ... */ + }, + QueueUrl: 'STRING_VALUE' /* required */ + }, function(err, data) { + if (err) console.log(err, err.stack); // an error occurred + else console.log(data); // successful response + }); + + \ No newline at end of file diff --git a/aws-sdk/aws-sdk-tests.ts.tscparams b/aws-sdk/aws-sdk-tests.ts.tscparams new file mode 100644 index 0000000000..70401a77ee --- /dev/null +++ b/aws-sdk/aws-sdk-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 \ No newline at end of file diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts index 3a500bbbb4..128341729d 100644 --- a/aws-sdk/aws-sdk.d.ts +++ b/aws-sdk/aws-sdk.d.ts @@ -30,6 +30,16 @@ declare module "aws-sdk" { xhrAsync?: boolean; xhrWithCredentials?: boolean; } + + export class Endpoint { + constructor(endpoint:string); + + host:string; + hostname:string; + href:string; + port:number; + protocol:string; + } export interface Services { autoscaling?: any; @@ -99,7 +109,25 @@ declare module "aws-sdk" { export class SQS { constructor(options?: any); - public client: Sqs.Client; + endpoint:Endpoint; + + addPermission(params: SQS.AddPermissionParams, callback: (err:Error, data:any) => void): void; + changeMessageVisibility(params: SQS.ChangeMessageVisibilityParams, callback: (err:Error, data:any) => void): void; + changeMessageVisibilityBatch(params: SQS.ChangeMessageVisibilityBatchParams, callback: (err:Error, data:SQS.ChangeMessageVisibilityBatchResponse) => void): void; + createQueue(params: SQS.CreateQueueParams, callback: (err: Error, data: SQS.CreateQueueResult) => void): void; + deleteMessage(params: SQS.DeleteMessageParams, callback: (err: Error, data: any) => void): void; + deleteMessageBatch(params: SQS.DeleteMessageBatchParams, callback: (err: Error, data: SQS.DeleteMessageBatchResult) => void): void; + deleteQueue(params: { QueueUrl: string; }, callback: (err: Error, data: any) => void): void; + getQueueAttributes(params: SQS.GetQueueAttributesParams, callback: (err: Error, data: SQS.GetQueueAttributesResult) => void): void; + getQueueUrl(params: SQS.GetQueueUrlParams, callback: (err: Error, data: { QueueUrl: string; }) => void): void; + listDeadLetterSourceQueues(params: {QueueUrl:string}, callback: (err: Error, data: {queueUrls: string[]}) => void): void; + listQueues(params: {QueueNamePrefix?:string}, callback: (err: Error, data: {QueueUrls: string[]}) => void): void; + purgeQueue(params: {QueueUrl: string}, callback: (err: Error, data: any) => void): void; + receiveMessage(params: SQS.ReceiveMessageParams, callback: (err: Error, data: SQS.ReceiveMessageResult) => void): void; + removePermission(params: {QueueUrl: string, Label: string}, callback: (err: Error, data: any) => void): void; + sendMessage(params: SQS.SendMessageParams, callback: (err: Error, data: SQS.SendMessageResult) => void): void; + sendMessageBatch(params: SQS.SendMessageBatchParams, callback: (err: Error, data: SQS.SendMessageBatchResult) => void): void; + setQueueAttributes(params: SQS.SetQueueAttributesParams, callback: (err: Error, data: any) => void): void; } export class SES { @@ -126,36 +154,77 @@ declare module "aws-sdk" { constructor(options?: any); } - export module Sqs { - - export interface Client { - config: ClientConfig; - - sendMessage(params: SendMessageRequest, callback: (err: any, data: SendMessageResult) => void): void; - sendMessageBatch(params: SendMessageBatchRequest, callback: (err: any, data: SendMessageBatchResult) => void): void; - receiveMessage(params: ReceiveMessageRequest, callback: (err: any, data: ReceiveMessageResult) => void): void; - deleteMessage(params: DeleteMessageRequest, callback: (err: any, data: any) => void): void; - deleteMessageBatch(params: DeleteMessageBatchRequest, callback: (err: any, data: DeleteMessageBatchResult) => void): void; - createQueue(params: CreateQueueRequest, callback: (err: any, data: CreateQueueResult) => void): void; - deleteQueue(params: DeleteQueueRequest, callback: (err: any, data: any) => void): void; + export module SQS { + + export interface SqsOptions { + params?: any; + endpoint?: string; + accessKeyId?: string; + secretAccessKey?: string; + sessionToken?: Credentials; + credentials?: Credentials; + credentialProvider?: any; + region?: string; + maxRetries?: number; + maxRedirects?: number; + sslEnabled?: boolean; + paramValidation?: boolean; + computeChecksums?: boolean; + convertResponseTypes?: boolean; + correctClockSkew?: boolean; + s3ForcePathStyle?: boolean; + s3BucketEndpoint?: boolean; + httpOptions?: HttpOptions; + apiVersion?: string; + apiVersions?: { [serviceName:string]: string}; + logger?: Logger; + systemClockOffset?: number; + signatureVersion?: string; + signatureCache?: boolean; + } + + export interface AddPermissionParams { + QueueUrl: string; + Label: string; + AWSAccountIds:string[]; + Actions:string[]; + } + + export interface ChangeMessageVisibilityParams { + QueueUrl: string, + ReceiptHandle: string, + VisibilityTimeout: number + } + + export interface ChangeMessageVisibilityBatchParams { + QueueUrl: string, + Entries: { Id: string; ReceiptHandle: string; VisibilityTimeout?: number; }[] + } + + export interface ChangeMessageVisibilityBatchResponse { + Successful: { Id:string }[]; + Failed: BatchResultErrorEntry[]; } - export interface SendMessageRequest { - QueueUrl?: string; - MessageBody?: string; + export interface SendMessageParams { + QueueUrl: string; + MessageBody: string; DelaySeconds?: number; + MessageAttributes?: { [name:string]: MessageAttribute; } } - export interface ReceiveMessageRequest { - QueueUrl?: string; + export interface ReceiveMessageParams { + QueueUrl: string; MaxNumberOfMessages?: number; VisibilityTimeout?: number; AttributeNames?: string[]; + MessageAttributeNames?: string[]; + WaitTimeSeconds?:number; } - export interface DeleteMessageBatchRequest { - QueueUrl?: string; - Entries?: DeleteMessageBatchRequestEntry[]; + export interface DeleteMessageBatchParams { + QueueUrl: string; + Entries: DeleteMessageBatchRequestEntry[]; } export interface DeleteMessageBatchRequestEntry { @@ -163,85 +232,117 @@ declare module "aws-sdk" { ReceiptHandle: string; } - export interface DeleteMessageRequest { - QueueUrl?: string; - ReceiptHandle?: string; + export interface DeleteMessageParams { + QueueUrl: string; + ReceiptHandle: string; } - export class Attribute { - Name: string; - Value: string; + export interface SendMessageBatchParams { + QueueUrl: string; + Entries: SendMessageBatchRequestEntry[]; } - export interface SendMessageBatchRequest { - QueueUrl?: string; - Entries?: SendMessageBatchRequestEntry[]; - } - - export class SendMessageBatchRequestEntry { + export interface SendMessageBatchRequestEntry { Id: string; MessageBody: string; - DelaySeconds: number; - } - - export interface CreateQueueRequest { - QueueName?: string; - DefaultVisibilityTimeout?: number; DelaySeconds?: number; - Attributes?: Attribute[]; + MessageAttributes?: { [name:string]: MessageAttribute; } } - export interface DeleteQueueRequest { - QueueUrl?: string; + export interface CreateQueueParams { + QueueName: string; + Attributes: QueueAttributes; } - - export class SendMessageResult { + + export interface QueueAttributes { + [name:string]: any; + DelaySeconds?: number; + MaximumMessageSize?: number; + MessageRetentionPeriod?: number; + Policy?: any; + ReceiveMessageWaitTimeSeconds?: number; + VisibilityTimeout?: number; + RedrivePolicy?: any; + } + + export interface GetQueueAttributesParams { + QueueUrl: string; + AttributeNames: string[]; + } + + export interface GetQueueAttributesResult { + Attributes: {[name:string]: string}; + } + + export interface GetQueueUrlParams { + QueueName: string; + QueueOwnerAWSAccountId?: string; + } + + export interface SendMessageResult { MessageId: string; MD5OfMessageBody: string; + MD5OfMessageAttributes: string; } - export class ReceiveMessageResult { + export interface ReceiveMessageResult { Messages: Message[]; } - export class Message { + export interface Message { MessageId: string; ReceiptHandle: string; MD5OfBody: string; Body: string; - Attributes: Attribute[]; + Attributes: { [name:string]:any }; + MD5OfMessageAttributes:string; + MessageAttributes: { [name:string]: MessageAttribute; } } - export class DeleteMessageBatchResult { + export interface MessageAttribute { + StringValue?: string; + BinaryValue?: any; //(Buffer, Typed Array, Blob, String) + StringListValues?: string[]; + BinaryListValues?: any[]; + DataType: string; + } + + export interface DeleteMessageBatchResult { Successful: DeleteMessageBatchResultEntry[]; Failed: BatchResultErrorEntry[]; } - export class DeleteMessageBatchResultEntry { + export interface DeleteMessageBatchResultEntry { Id: string; } - export class BatchResultErrorEntry { + export interface BatchResultErrorEntry { Id: string; Code: string; - Message: string; - SenderFault: string; + Message?: string; + SenderFault: boolean; } - export class SendMessageBatchResult { + export interface SendMessageBatchResult { Successful: SendMessageBatchResultEntry[]; Failed: BatchResultErrorEntry[]; } - export class SendMessageBatchResultEntry { + export interface SendMessageBatchResultEntry { Id: string; MessageId: string; MD5OfMessageBody: string; + MD5OfMessageAttributes:string; } - export class CreateQueueResult { + export interface CreateQueueResult { QueueUrl: string; } + + export interface SetQueueAttributesParams { + QueueUrl: string; + Attributes: QueueAttributes; + } } From ee5dffce66ae102783f3c23cfc836696110fdf62 Mon Sep 17 00:00:00 2001 From: Zhiyuan Wang Date: Fri, 30 Oct 2015 08:28:47 +0800 Subject: [PATCH 0078/1680] Add definitions and tests for NodeJs package [depd] --- depd/depd-tests.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++ depd/depd.d.ts | 17 +++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 depd/depd-tests.ts create mode 100644 depd/depd.d.ts diff --git a/depd/depd-tests.ts b/depd/depd-tests.ts new file mode 100644 index 0000000000..14dfbe72c4 --- /dev/null +++ b/depd/depd-tests.ts @@ -0,0 +1,54 @@ +/// + +import depd = require('depd'); + +var deprecate = depd("depd-tests"); + +function assert(condition: boolean, message: string): void { + if (!condition) { + throw new Error(message); + } +} + +function testDepdMessage(...args: string[]): boolean { + if (arguments.length < 1) { + deprecate('testDepdMessage argument.lenth<1'); + return true; + } else { + console.log('normal logic'); + return false; + } +} + +assert(testDepdMessage() === true, "Deprecated code must be triggered!"); +assert(testDepdMessage('a') === false, "Deprecated code must be triggered!"); + +interface ITestObject { + p1: string; + p2: string; +} + +var obj = { p1: 'deprecated property', p2: 'normal property' }; +deprecate.property(obj, 'p1', 'property [p1] is deprecated!'); + +console.log(obj.p1); + +interface ITestDeprecatedFunction { + func1?: Function; + func2?: Function; +} + +var obj2 = {}; + +// message automatically derived from function name +obj2.func1 = deprecate.function(function func1() { + console.log('all calls to [func1] are deprecated '); +}); + +// specific message +obj2.func2 = deprecate.function(function () { + console.log('all calls to [func2] are deprecated '); +}, 'func2'); + +obj2.func1(); +obj2.func2(); \ No newline at end of file diff --git a/depd/depd.d.ts b/depd/depd.d.ts new file mode 100644 index 0000000000..33f7b72a04 --- /dev/null +++ b/depd/depd.d.ts @@ -0,0 +1,17 @@ +// Type definitions for nodejs package depd 1.1.0 +// Project: https://github.com/dougwilson/nodejs-depd +// Definitions by: Zhiyuan Wang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module 'depd' { + function depd(namespace: string): Deprecate; + + interface Deprecate { + (message: string): void; + function(fn: Function, message?: string): Function; + property(obj: Object, prop: string, message: string): void; + } + + export = depd; +} \ No newline at end of file From cb16d9359e8bfd91dc92bcbb1a58a3964c21dd30 Mon Sep 17 00:00:00 2001 From: Zhiyuan Wang Date: Fri, 30 Oct 2015 08:39:23 +0800 Subject: [PATCH 0079/1680] adjust definition header since validation failure in PR --- depd/depd.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depd/depd.d.ts b/depd/depd.d.ts index 33f7b72a04..1af4eaa8da 100644 --- a/depd/depd.d.ts +++ b/depd/depd.d.ts @@ -1,4 +1,4 @@ -// Type definitions for nodejs package depd 1.1.0 +// Type definitions for depd 1.1.0 // Project: https://github.com/dougwilson/nodejs-depd // Definitions by: Zhiyuan Wang // Definitions: https://github.com/borisyankov/DefinitelyTyped From 147380f9d1255f779806270d80eea85e2c1af55f Mon Sep 17 00:00:00 2001 From: edvin Date: Fri, 30 Oct 2015 13:38:06 +0100 Subject: [PATCH 0080/1680] Support global sprintf and vsprintf for use in browser. --- sprintf-js/sprintf-js.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sprintf-js/sprintf-js.d.ts b/sprintf-js/sprintf-js.d.ts index fba1925b6c..89377b83d2 100644 --- a/sprintf-js/sprintf-js.d.ts +++ b/sprintf-js/sprintf-js.d.ts @@ -10,7 +10,7 @@ Its prototype is simple: string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]]) */ -declare module "sprintf-js" { +declare module sprintf_js { /** sprintf.js is a complete open source JavaScript sprintf implementation for the browser and node.js. Its prototype is simple: string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]]) @@ -69,3 +69,10 @@ X - yields an integer as a hexadecimal number (upper-case) */ export function vsprintf(fmt: string, args: any[]): string; } + +declare module "sprintf-js" { + export =sprintf_js; +} + +declare var sprintf: typeof sprintf_js.sprintf; +declare var vsprintf: typeof sprintf_js.vsprintf; From b1956785d638d352d4045bae2b35dca7c19b0b41 Mon Sep 17 00:00:00 2001 From: Zhiyuan Wang Date: Fri, 30 Oct 2015 21:24:22 +0800 Subject: [PATCH 0081/1680] Add definitions and tests for NodeJs package bytes v2.1.0 --- bytes/bytes-tests.ts | 16 +++++++++++ bytes/bytes.d.ts | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 bytes/bytes-tests.ts create mode 100644 bytes/bytes.d.ts diff --git a/bytes/bytes-tests.ts b/bytes/bytes-tests.ts new file mode 100644 index 0000000000..4a981aee47 --- /dev/null +++ b/bytes/bytes-tests.ts @@ -0,0 +1,16 @@ +/// + +import bytes = require('bytes'); + +// 1024*1024 = 1048576 +console.log(bytes(104857)); +console.log(bytes(104857, { thousandsSeparator: ' ' })); + +console.log(bytes.format(104857)); +console.log(bytes.format(104857, { thousandsSeparator: ' ' })); + +console.log(bytes('1024kb')); +console.log(bytes(1024)); + +console.log(bytes.parse('1024kb')); +console.log(bytes.parse(1024)); \ No newline at end of file diff --git a/bytes/bytes.d.ts b/bytes/bytes.d.ts new file mode 100644 index 0000000000..d9946edf2f --- /dev/null +++ b/bytes/bytes.d.ts @@ -0,0 +1,66 @@ +// Type definitions for bytes v2.1.0 +// Project: https://github.com/visionmedia/bytes.js +// Definitions by: Zhiyuan Wang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'bytes' { + + interface IBytesFormatOptions { + thousandsSeparator: string + } + + /** + *Convert the given value in bytes into a string. + * + * @param {number} value + * @param {{ + * thousandsSeparator: [string] + * }} [options] bytes options. + * + * @returns {string} + */ + function bytes(value: number, options?: IBytesFormatOptions): string; + + /** + *Parse string to an integer in bytes. + * + * @param {string} value + * @returns {number} + */ + function bytes(value: string): number; + + module bytes { + + /** + * Format the given value in bytes into a string. + * + * If the value is negative, take Math.abs(). If it is a float, + * it is rounded. + * + * @param {number} value + * @param {IBytesFormatOptions} [options] + */ + + function format(value: number, options?: IBytesFormatOptions): string; + + /** + * Just return the input number value. + * + * @param {number} value + * @return {number} + */ + function parse(value: number): number; + + /** + * Parse the string value into an integer in bytes. + * + * If no unit is given, it is assumed the value is in bytes. + * + * @param {string} value + * @return {number} + */ + function parse(value: string): number; + } + + export = bytes; +} \ No newline at end of file From 4331a333df4e8d47f3f221bbe797fc7dd989457b Mon Sep 17 00:00:00 2001 From: Zhiyuan Wang Date: Sat, 31 Oct 2015 20:04:55 +0800 Subject: [PATCH 0082/1680] add definitions and tests for NodeJs package ms v0.7.1 --- ms/ms-tests.ts | 14 ++++++++++++++ ms/ms.d.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 ms/ms-tests.ts create mode 100644 ms/ms.d.ts diff --git a/ms/ms-tests.ts b/ms/ms-tests.ts new file mode 100644 index 0000000000..75312e9277 --- /dev/null +++ b/ms/ms-tests.ts @@ -0,0 +1,14 @@ +/// + +import ms = require('ms'); + +ms('2 days') // 172800000 +ms('1d') // 86400000 + +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(ms('10 hours')) // "10h" + +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" \ No newline at end of file diff --git a/ms/ms.d.ts b/ms/ms.d.ts new file mode 100644 index 0000000000..5a7c67add2 --- /dev/null +++ b/ms/ms.d.ts @@ -0,0 +1,30 @@ +// Type definitions for ms v0.7.1 +// Project: https://github.com/guille/ms.js +// Definitions by: Zhiyuan Wang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'ms' { + + interface IMSOptions { + long: boolean + } + + /** + * Short/Long format for `value`. + * + * @param {Number} value + * @param {{long: boolean}} options + * @return {String} + */ + function ms(value: number, options?: IMSOptions): string; + + /** + * Parse the given `value` and return milliseconds. + * + * @param {String} value + * @return {Number} + */ + function ms(value: string): number; + + export = ms; +} \ No newline at end of file From a809e347c94f642cdffae40c42b1ea45f84ad9ad Mon Sep 17 00:00:00 2001 From: floriantopf Date: Sun, 1 Nov 2015 01:22:54 +0100 Subject: [PATCH 0083/1680] react-onLoad-event --- react/react.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/react/react.d.ts b/react/react.d.ts index ba86c4690b..25a3a30b9f 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -313,6 +313,8 @@ declare namespace __React { deltaZ: number; } + interface LoadEvent extends SyntheticEvent {} + // // Event Handler Types // ---------------------------------------------------------------------- @@ -330,6 +332,7 @@ declare namespace __React { interface TouchEventHandler extends EventHandler {} interface UIEventHandler extends EventHandler {} interface WheelEventHandler extends EventHandler {} + interface LoadEventHandler extends EventHandler {} // // Props / DOM Attributes @@ -377,6 +380,7 @@ declare namespace __React { onTouchStart?: TouchEventHandler; onScroll?: UIEventHandler; onWheel?: WheelEventHandler; + onLoad?: LoadEventHandler; className?: string; id?: string; From 124f32ed3cc9c46b666232527a9d2a753d4c6b0f Mon Sep 17 00:00:00 2001 From: tkqubo Date: Sun, 1 Nov 2015 11:39:18 +0900 Subject: [PATCH 0084/1680] webpack: add HMR --- webpack/webpack-env-tests.ts | 27 +++++++ webpack/webpack-env.d.ts | 135 +++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/webpack/webpack-env-tests.ts b/webpack/webpack-env-tests.ts index b4a9693ecf..25ec177d69 100644 --- a/webpack/webpack-env-tests.ts +++ b/webpack/webpack-env-tests.ts @@ -13,3 +13,30 @@ let contextModule = context('./someModule'); require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => { }); + +// check if HMR is enabled +if(module.hot) { + // accept update of dependency + module.hot.accept("./handler.js", function() { + //... + }); +} + +module.exports = null; + +// check if HMR is enabled +if(module.hot) { + + // accept itself + module.hot.accept(); + + // dispose handler + module.hot.dispose(function() { + // revoke the side effect + //... + }); +} + + +var status: string = module.hot.status(); + diff --git a/webpack/webpack-env.d.ts b/webpack/webpack-env.d.ts index f67b9c5d6a..07f160c5ec 100644 --- a/webpack/webpack-env.d.ts +++ b/webpack/webpack-env.d.ts @@ -5,6 +5,7 @@ /** * Webpack module API - variables and global functions available inside modules + * https://webpack.github.io/docs/api-in-modules.html */ declare namespace __WebpackModuleApi { @@ -101,3 +102,137 @@ declare var __non_webpack_require__: any; * Equals the config option debug */ declare var DEBUG: boolean; + +/** + * Webpack Hot Module Replacement + * https://webpack.github.io/docs/hot-module-replacement.html + */ +declare namespace __WebpackHotModuleReplacement { + interface Module { + exports: any; + require(id: string): any; + id: string; + filename: string; + loaded: boolean; + parent: any; + children: any[]; + hot: Hot; + } + + interface Hot { + /** + * Accept code updates for the specified dependencies. The callback is called when dependencies were replaced. + * @param dependencies + * @param callback + */ + accept(dependencies: string[], callback: (updatedDependencies: string[]) => void): void; + /** + * Accept code updates for the specified dependencies. The callback is called when dependencies were replaced. + * @param dependency + * @param callback + */ + accept(dependency: string, callback: () => void): void; + /** + * Accept code updates for this module without notification of parents. + * This should only be used if the module doesn’t export anything. + * The errHandler can be used to handle errors that occur while loading the updated module. + * @param errHandler + */ + accept(errHandler?: Function): void; + /** + * Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline". + */ + decline(dependencies: string[]): void; + /** + * Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline". + */ + decline(dependency: string): void; + /** + * Flag the current module as not update-able. If updated the update code would fail with code "decline". + */ + decline(): void; + /** + * Add a one time handler, which is executed when the current module code is replaced. + * Here you should destroy/remove any persistent resource you have claimed/created. + * If you want to transfer state to the new module, add it to data object. + * The data will be available at module.hot.data on the new module. + * @param callback + */ + dispose(callback: (data: any) => void): void; + /** + * Add a one time handler, which is executed when the current module code is replaced. + * Here you should destroy/remove any persistent resource you have claimed/created. + * If you want to transfer state to the new module, add it to data object. + * The data will be available at module.hot.data on the new module. + * @param callback + */ + addDisposeHandler(callback: (data: any) => void): void; + /** + * Remove a handler. + * This can useful to add a temporary dispose handler. You could i. e. replace code while in the middle of a multi-step async function. + * @param callback + */ + removeDisposeHandler(callback: (data: any) => void): void; + /** + * Throws an exceptions if status() is not idle. + * Check all currently loaded modules for updates and apply updates if found. + * If no update was found, the callback is called with null. + * If autoApply is truthy the callback will be called with all modules that were disposed. + * apply() is automatically called with autoApply as options parameter. + * If autoApply is not set the callback will be called with all modules that will be disposed on apply(). + * @param autoApply + * @param callback + */ + check(autoApply: boolean, callback: (err: Error, outdatedModules: any[]) => void): void; + /** + * Throws an exceptions if status() is not idle. + * Check all currently loaded modules for updates and apply updates if found. + * If no update was found, the callback is called with null. + * The callback will be called with all modules that will be disposed on apply(). + * @param callback + */ + check(callback: (err: Error, outdatedModules: any[]) => void): void; + /** + * If status() != "ready" it throws an error. + * Continue the update process. + * @param options + * @param callback + */ + apply(options: AcceptOptions, callback: (err: Error, outdatedModules: any[]) => void): void; + /** + * If status() != "ready" it throws an error. + * Continue the update process. + * @param callback + */ + apply(callback: (err: Error, outdatedModules: any[]) => void): void; + /** + * Return one of idle, check, watch, watch-delay, prepare, ready, dispose, apply, abort or fail. + */ + status(): string; + /** Register a callback on status change. */ + status(callback: (status: string) => void): void; + /** Register a callback on status change. */ + addStatusHandler(callback: (status: string) => void): void; + /** + * Remove a registered status change handler. + * @param callback + */ + removeStatusHandler(callback: (status: string) => void): void; + + active: boolean; + data: any; + } + + interface AcceptOptions { + /** + * If true the update process continues even if some modules are not accepted (and would bubble to the entry point). + */ + ignoreUnaccepted: boolean; + /** + * Indicates that apply() is automatically called by check function + */ + autoApply: boolean; + } +} + +declare var module: __WebpackHotModuleReplacement.Module; From 19a046ce14527ae0922226655924660f3fa63255 Mon Sep 17 00:00:00 2001 From: Ali Taheri Date: Sun, 1 Nov 2015 11:09:06 +0330 Subject: [PATCH 0085/1680] [jest] improved typings. --- jest/jest-tests.ts | 2 +- jest/jest.d.ts | 59 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index 764daf142a..da141ef9e5 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -47,7 +47,7 @@ describe('displayUser', function() { '