From 75e8c438092a15804594e46bc82973b86bed3e22 Mon Sep 17 00:00:00 2001 From: AllBogs Date: Wed, 4 Nov 2015 10:10:29 +0100 Subject: [PATCH 001/128] Update snapsvg.d.ts Seemed to be some confusion between the functions "Matrix()" (argument-less constructor function) and "matrix()" (utility function that takes arguments and returns a Matrix object). --- snapsvg/snapsvg.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index aff964a6d..6543eaa90 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -15,7 +15,7 @@ declare module mina { } export interface AnimationDescriptor { - id: string; + id: string; start: number; end: number; b: number; @@ -35,7 +35,7 @@ declare module mina { pause(): void; resume(): void; update(): void; - } + } export function backin(n:number):number; export function backout(n:number):number; @@ -57,8 +57,9 @@ declare module Snap { export var filter:Filter; export var path:Path; - export function Matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; - export function Matrix(svgMatrix:SVGMatrix):Matrix; + export function Matrix():void; + export function matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; + export function matrix(svgMatrix:SVGMatrix):Matrix; export function ajax(url:string,postData:string,callback:Function,scope?:Object):XMLHttpRequest; export function ajax(url:string,postData:Object,callback:Function,scope?:Object):XMLHttpRequest; From 344ad0763e4fd64c431b2169bdc93ea045dfdb63 Mon Sep 17 00:00:00 2001 From: AllBogs Date: Wed, 4 Nov 2015 10:23:57 +0100 Subject: [PATCH 002/128] Update snapsvg.d.ts --- snapsvg/snapsvg.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapsvg/snapsvg.d.ts b/snapsvg/snapsvg.d.ts index 6543eaa90..6a941f3d7 100644 --- a/snapsvg/snapsvg.d.ts +++ b/snapsvg/snapsvg.d.ts @@ -57,7 +57,7 @@ declare module Snap { export var filter:Filter; export var path:Path; - export function Matrix():void; + export function Matrix():void; export function matrix(a:number,b:number,c:number,d:number,e:number,f:number):Matrix; export function matrix(svgMatrix:SVGMatrix):Matrix; From 63e48f4210cf95d7a8ddc93480eaa1a10cbf02a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Tue, 10 Nov 2015 17:04:33 +0100 Subject: [PATCH 003/128] three: Update comment for WebGLRenderer.clear --- threejs/three.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index fd165f936..dd1521d84 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4686,7 +4686,7 @@ declare module THREE { /** * Tells the renderer to clear its color, depth or stencil drawing buffer(s). - * If no parameters are passed, no buffer will be cleared. + * Arguments default to true */ clear(color?: boolean, depth?: boolean, stencil?: boolean): void; From 3c032bd7f68ace09840c363cdbd0fc8bc3106a1f Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 12:28:49 +0100 Subject: [PATCH 004/128] First commit: add type definitions for slick 1.5.8 --- jquery.slick/slick-tests.ts | 232 ++++++++++++++++++++++ jquery.slick/slick.d.ts | 381 ++++++++++++++++++++++++++++++++++++ 2 files changed, 613 insertions(+) create mode 100644 jquery.slick/slick-tests.ts create mode 100644 jquery.slick/slick.d.ts diff --git a/jquery.slick/slick-tests.ts b/jquery.slick/slick-tests.ts new file mode 100644 index 000000000..499e6974c --- /dev/null +++ b/jquery.slick/slick-tests.ts @@ -0,0 +1,232 @@ +/// +/// + + +// -------------------------------------------------------- +// ------------------- WEBSITE EXAMPLE -------------------- +// ---------- http://kenwheeler.github.io/slick/ ---------- +// -------------------------------------------------------- + +$('.single-item').slick(); + +$('.multiple-items').slick({ + infinite: true, + slidesToShow: 3, + slidesToScroll: 3 +}); + +$('.responsive').slick({ + dots: true, + infinite: false, + speed: 300, + slidesToShow: 4, + slidesToScroll: 4, + responsive: [ + { + breakpoint: 1024, + settings: { + slidesToShow: 3, + slidesToScroll: 3, + infinite: true, + dots: true + } + }, + { + breakpoint: 600, + settings: { + slidesToShow: 2, + slidesToScroll: 2 + } + }, + { + breakpoint: 480, + settings: { + slidesToShow: 1, + slidesToScroll: 1 + } + } + // You can unslick at a given breakpoint now by adding: + // settings: "unslick" + // instead of a settings object + ] +}); + +$('.variable-width').slick({ + dots: true, + infinite: true, + speed: 300, + slidesToShow: 1, + centerMode: true, + variableWidth: true +}); + +$('.one-time').slick({ + dots: true, + infinite: true, + speed: 300, + slidesToShow: 1, + adaptiveHeight: true +}); + +$('.center').slick({ + centerMode: true, + centerPadding: '60px', + slidesToShow: 3, + responsive: [ + { + breakpoint: 768, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 3 + } + }, + { + breakpoint: 480, + settings: { + arrows: false, + centerMode: true, + centerPadding: '40px', + slidesToShow: 1 + } + } + ] +}); + +// To use lazy loading, set a data-lazy attribute +// on your img tags and leave off the src +// + +$('.lazy').slick({ + lazyLoad: 'ondemand', + slidesToShow: 3, + slidesToScroll: 1 +}); + +$('.autoplay').slick({ + slidesToShow: 3, + slidesToScroll: 1, + autoplay: true, + autoplaySpeed: 2000, +}); + +$('.fade').slick({ + dots: true, + infinite: true, + speed: 500, + fade: true, + cssEase: 'linear' +}); + +var slideIndex = 1; +$('.add-remove').slick({ + slidesToShow: 3, + slidesToScroll: 3 +}); +$('.js-add-slide').on('click', function() { + slideIndex++; + $('.add-remove').slick('slickAdd','

' + slideIndex + '

'); +}); + +$('.js-remove-slide').on('click', function() { + $('.add-remove').slick('slickRemove', slideIndex - 1); + if (slideIndex !== 0){ + slideIndex--; + } +}); + +$('.filtering').slick({ + slidesToShow: 4, + slidesToScroll: 4 +}); + +var filtered = false; + +$('.js-filter').on('click', function(){ + if (filtered === false) { + $('.filtering').slick('slickFilter',':even'); + $(this).text('Unfilter Slides'); + filtered = true; + } else { + $('.filtering').slick('slickUnfilter'); + $(this).text('Filter Slides'); + filtered = false; + } +}); + +$('.your-slider').slick('unslick'); + +$('.slider-for').slick({ + slidesToShow: 1, + slidesToScroll: 1, + arrows: false, + fade: true, + asNavFor: '.slider-nav' +}); +$('.slider-nav').slick({ + slidesToShow: 3, + slidesToScroll: 1, + asNavFor: '.slider-for', + dots: true, + centerMode: true, + focusOnSelect: true +}); + +$('.single-item-rtl').slick({ + rtl: true +}); + + + +// -------------------------------------------------------- +// ---------------- TEST DEFAULT OPTIONS ------------------ +// -------------------------------------------------------- + +$("#diaporama").slick({ + accessibility: true, + adaptiveHeight: false, + autoplay: false, + autoplaySpeed: 3000, + arrows: true, + asNavFor: "#slideshow", + appendArrows: "", + prevArrow: "", + nextArrow: "", + centerMode: false, + centerPadding: "50px", + cssEase: "ease", + customPaging: (slider, i: number) => { + console.log("customPaging slider", slider); + console.log("customPaging index", i); + }, + dots: false, + draggable: true, + fade: false, + focusOnSelect: false, + easing: "linear", + edgeFriction: 0.15, + infinite: true, + initialSlide: 0, + lazyLoad: "ondemand", + mobileFirst: false, + pauseOnHover: true, + pauseOnDotsHover: false, + respondTo: "window", + responsive: null, + rows: 1, + slide: "div", + slidesPerRow: 1, + slidesToShow: 1, + slidesToScroll: 1, + speed: 300, + swipe: true, + swipeToSlide: false, + touchMove: true, + touchThreshold: 5, + useCSS: true, + variableWidth: false, + vertical: false, + verticalSwiping: false, + rtl: false +}); diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts new file mode 100644 index 000000000..cc9aa626b --- /dev/null +++ b/jquery.slick/slick.d.ts @@ -0,0 +1,381 @@ +// Type definitions for stick 1.5.8 +// Project: http://kenwheeler.github.io/slick/ +// Definitions by: John Gouigouix +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface JQuerySlickOptions { + + /** + * Enables tabbing and arrow key navigation + * Default: true + */ + accessibility?: boolean; + + /** + * Enables adaptive height for single slide horizontal carousels. + * Default: false + */ + adaptiveHeight?: boolean; + + /** + * Enables Autoplay + * Default: false + */ + autoplay?: boolean; + + /** + * Autoplay Speed in milliseconds + * Default: 3000 + */ + autoplaySpeed?: number; + + /** + * Prev/Next Arrows + * Default: true + */ + arrows?: boolean; + + /** + * Set the slider to be the navigation of other slider (Class or ID Name) + * Default: null + */ + asNavFor?: string; + + /** + * Change where the navigation arrows are attached (Selector, htmlString, Array, Element, jQuery object) + * Default: $(element) + */ + appendArrows?: any; + + /** + * Allows you to select a node or customize the HTML for the "Previous" arrow. + * Default: + */ + prevArrow?: string | Object; + + /** + * Allows you to select a node or customize the HTML for the "Next" arrow. + * Default: + */ + nextArrow?: string | Object; + + /** + * Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts. + * Default: false + */ + centerMode?: boolean; + + /** + * Side padding when in center mode (px or %) + * Default: '50px' + */ + centerPadding?: string; + + /** + * CSS3 Animation Easing + * Default: 'ease' + */ + cssEase?: string; + + /** + * Custom paging templates. See source for use example. + * Default: n/a + */ + customPaging?: (slider, i: number) => string; + + /** + * Show dot indicators + * Default: false + */ + dots?: boolean; + + /** + * Enable mouse dragging + * Default: true + */ + draggable?: boolean; + + /** + * Enable fade + * Default: false + */ + fade?: boolean; + + /** + * Enable focus on selected element (click) + * Default: false + */ + focusOnSelect?: boolean; + + /** + * Add easing for jQuery animate. Use with easing libraries or default easing methods + * Default: 'linear' + */ + easing?: string; + + /** + * Resistance when swiping edges of non-infinite carousels + * Default: 0.15 + */ + edgeFriction?: number; + + /** + * Infinite loop sliding + * Default: true + */ + infinite?: boolean; + + /** + * Slide to start on + * Default: 0 + */ + initialSlide?: number; + + /** + * Set lazy loading technique. Accepts 'ondemand' or 'progressive'. + * Default: 'ondemand' + */ + lazyLoad?: string; + + /** + * Responsive settings use mobile first calculation + * Default: false + */ + mobileFirst?: boolean; + + /** + * Pause Autoplay On Hover + * Default: true + */ + pauseOnHover?: boolean; + + /** + * Pause Autoplay when a dot is hovered + * Default: false + */ + pauseOnDotsHover?: boolean; + + /** + * Width that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two) + * Default: 'window' + */ + respondTo?: string; + + /** + * Object containing breakpoints and settings objects (see demo). + * Enables settings sets at given screen width. + * Set settings to "unslick" instead of an object to disable slick at a given breakpoint. + * Default: none + */ + responsive?: Object; + + /** + * Setting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row. + * Default: 1 + */ + rows?: number; + + /** + * Element query to use as slide + * Default: 'div' + */ + slide?: string; + + /** + * With grid mode intialized via the rows option, this sets how many slides are in each grid row. + * Default: 1 + */ + slidesPerRow?: number; + + /** + * # of slides to show + * Default: 1 + */ + slidesToShow?: number; + + /** + * # of slides to scroll + * Default: 1 + */ + slidesToScroll?: number; + + /** + * Slide/Fade animation speed (ms) + * Default: 300 + */ + speed?: number; + + /** + * Enable swiping + * Default: true + */ + swipe?: boolean; + + /** + * Allow users to drag or swipe directly to a slide irrespective of slidesToScroll. + * Default: false + */ + swipeToSlide?: boolean; + + /** + * Enable slide motion with touch + * Default: true + */ + touchMove?: boolean; + + /** + * To advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider. + * Default: 5 + */ + touchThreshold?: number; + + /** + * Enable/Disable CSS Transitions + * Default: true + */ + useCSS?: boolean; + + /** + * Variable width slides. + * Default: false + */ + variableWidth?: boolean; + + /** + * Vertical slide mode + * Default: false + */ + vertical?: boolean; + + /** + * Vertical swipe mode + * Default: false + */ + verticalSwiping?: boolean; + + /** + * Change the slider's direction to become right-to-left + * Default: false + */ + rtl?: boolean; + +} + + +interface JQuery { + + /** + * Create slick component + */ + slick(): JQuery; + slick(options: JQuerySlickOptions): JQuery; + + /** + * Returns the current slide index + * @param methodName The name of the method + */ + slick(methodName: "slickCurrentSlide"): number; + + /** + * Navigates to a slide by index + * @param methodName The name of the method + * @param slide + * @param animate + */ + slick(methodName: "slickGoTo", slide: number, animate?: boolean): JQuery; + + /** + * Navigates to the next slide + * @param methodName The name of the method + */ + slick(methodName: "slickNext"): JQuery; + + /** + * Navigates to the previous slide + * @param methodName The name of the method + */ + slick(methodName: "slickPrev"): JQuery; + + /** + * Pauses autoplay + * @param methodName The name of the method + */ + slick(methodName: "slickPause"): JQuery; + + /** + * Starts autoplay + * @param methodName The name of the method + */ + slick(methodName: "slickPlay"): JQuery; + + /** + * Add a slide. If an index is provided, will add at that index, or before if addBefore is set. If no index is provided, + * add to the end or to the beginning if addBefore is set. Accepts HTML String || Object + * @param methodName The name of the method + * @param html + * @param index/div> + * @param addBefore + */ + slick(methodName: "slickAdd", html: string | Object, index?: number, addBefore?: number): JQuery; + + /** + * Remove slide by index. If removeBefore is set true, remove slide preceding index, or the first slide if no index is specified. + * If removeBefore is set to false, remove the slide following index, or the last slide if no index is set. + * @param methodName The name of the method + * @param index + * @param removeBefore + */ + slick(methodName: "slickRemove", index: number, removeBefore?: number): JQuery; + + /** + * Filters slides using jQuery .filter() + * @param methodName The name of the method + * @param selector + */ + slick(methodName : "slickFilter", selector: string): JQuery; + + /** + * Filters slides using jQuery .filter() + * @param methodName The name of the method + * @param func + */ + slick(methodName : "slickFilter", func: (index: number, element: Element) => any): JQuery; + + /** + * Removes applied filtering + * @param methodName The name of the method + * @param index + */ + slick(methodName: "slickUnfilter", index: number): JQuery; + + /** + * Sets an individual value live. Set refresh to true if it's a UI update. + * @param methodName The name of the method + * @param option The option name + */ + slick(methodName: "slickGetOption", option: any): JQuerySlickOptions; + + /** + * Sets an individual value live. Set refresh to true if it's a UI update. + * @param methodName The name of the method + * @param option The option name + * @param value depends on option + * @param refresh + */ + slick(methodName: "slickSetOption", option: string, value: JQuerySlickOptions, refresh?: boolean): JQuery; + + /** + * Deconstructs slick + * @param methodName The name of the method + */ + slick(methodName: "unslick"): JQuery; + + /** + * Get Slick Object + * @param methodName "getSlick" + */ + slick(methodName: "getSlick"): Object; + +} From 366488bc0c33117797b3725905d0ddae8dd1c708 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 14:16:45 +0100 Subject: [PATCH 005/128] Fixed error name --- jquery.slick/slick.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts index cc9aa626b..949f21736 100644 --- a/jquery.slick/slick.d.ts +++ b/jquery.slick/slick.d.ts @@ -374,7 +374,7 @@ interface JQuery { /** * Get Slick Object - * @param methodName "getSlick" + * @param methodName The name of the method */ slick(methodName: "getSlick"): Object; From 9545151e70db4d285c5f7bcfaf41b5fb879cebb8 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Fri, 13 Nov 2015 16:25:13 +0100 Subject: [PATCH 006/128] First commit: add type definitions for mmenu 5.5.3 --- jquery.mmenu/jquery.mmenu-tests.ts | 85 +++++++++++ jquery.mmenu/jquery.mmenu.d.ts | 229 +++++++++++++++++++++++++++++ 2 files changed, 314 insertions(+) create mode 100644 jquery.mmenu/jquery.mmenu-tests.ts create mode 100644 jquery.mmenu/jquery.mmenu.d.ts diff --git a/jquery.mmenu/jquery.mmenu-tests.ts b/jquery.mmenu/jquery.mmenu-tests.ts new file mode 100644 index 000000000..9fbb9b776 --- /dev/null +++ b/jquery.mmenu/jquery.mmenu-tests.ts @@ -0,0 +1,85 @@ +/// +/// + + +// -------------------------------------------------------- +// ---------------- TEST DEFAULT OPTIONS ------------------ +// -------------------------------------------------------- + +var menu: JQuery = $("#my-menu"); +menu.mmenu( + // options + { + extensions: [], + navbar: { + add: true, + title: "Menu", + titleLink: "parent" + }, + onClick: { + close: true, + preventDefault: false, + setSelected: false + }, + slidingSubmenus: true + }, + // configurations + { + classNames: { + divider: "Divider", + inset: "Inset", + panel: "Panel", + selected: "Selected", + vertical: "vertical" + }, + clone: false, + openingInterval: 25, + panelNodetype: "div, ul, ol", + transitionDuration: 400 + } +); + + +// -------------------------------------------------------- +// ------------------- TEST MMENU API --------------------- +// -------------------------------------------------------- + +var api: JQueryMmenu.API = menu.data("mmenu"); +var myPanel: JQuery = $("#panel"); +var listItem: JQuery = $(".list-item"); + +api.closeAllPanels(); +api.bind("closeAllPanels", function() { + console.log("close all opened panels and go back to the first panel."); +}); + +api.closePanel(myPanel); +api.bind("closePanel", function(panel) { + console.log("close this ", panel); +}); + +api.getInstance(); +api.bind("getInstance", function() { + console.log("get the class instance for the menu."); +}); + +api.init(myPanel); +api.bind("init", function(panel) { + console.log("method to (re)initialize a newly added ", panel); +}); + +api.openPanel(myPanel); +api.bind("openPanel", function(panel) { + console.log("This panel is now opened ", panel); +}); + +api.setSelected(listItem, true); +api.bind("setSelected", function(listItem, selected) { + console.log("set or unset a list item as selected ", listItem); + console.log("has selected ", selected); +}); + +api.update(); +api.bind("update", function() { + console.log("update the appearance for the menu"); +}); diff --git a/jquery.mmenu/jquery.mmenu.d.ts b/jquery.mmenu/jquery.mmenu.d.ts new file mode 100644 index 000000000..97874f8f0 --- /dev/null +++ b/jquery.mmenu/jquery.mmenu.d.ts @@ -0,0 +1,229 @@ +// Type definitions for jQuery mmenu v5.5.3 +// Project: http://mmenu.frebsite.nl/ +// Definitions by: John Gouigouix +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JQueryMmenu { + + interface NavbarOptions { + + /** + * Whether or not to add a navbar above the panels. + * Default: true + */ + add?: boolean; + + /** + * The title above the main panel. + * Default: "Menu" + */ + title?: string; + + /** + * The type of link to set for the title. + * Possible values: "parent", "anchor" or "none". + * Default: "parent" + */ + titleLink?: string; + + } + + interface OnclickOptions { + + /** + * Whether or not the menu should close after clicking a link inside it. + * The default value varies per link: true if the default behavior for + * the clicked link is prevented, false otherwise. + * Default: null + */ + close?: boolean | any; + + /** + * Whether or not to prevent the default behavior for the clicked link. + * The default value varies per link: true if its href is equal to + * or starts with a hash (#), false otherwise. + * Default: null + */ + preventDefault?: boolean | any; + + /** + * Whether or not the clicked link should be visibly "selected". + * Default: true + */ + setSelected?: boolean | any; + + } + + interface Options { + + /** + * A collection of extension names to enable for the menu. + * You'll need this option when using the extensions. + * Default: [] + */ + extensions?: Array; + + /** + * navbar options + */ + navbar?: NavbarOptions; + + /** + * onClick options + */ + onClick?: OnclickOptions; + + /** + * Whether or not submenus should come sliding in from the right. + * If false, submenus expand below their parent. + * To expand a single submenu below its parent item, add the class "Vertical" to it. + * Default: true + */ + slidingSubmenus?: boolean; + + } + + interface ClassnamesConfigurations { + + /** + * The classname on a LI that should be displayed as a divider. + * Default: "Divider" + */ + divider?: string; + + /** + * The classname on a submenu (a nested UL) that should be displayed as a default list. + * Default: "Inset" + */ + inset?: string; + + /** + * The classname on an element (for example a DIV) that should be considered to be a panel. + * Only applies if the "isMenu" option is set to false. + * Default: "Panel" + */ + panel?: string; + + /** + * The classname on the LI that should be displayed as selected. + * Default: "Selected" + */ + selected?: string; + + /** + * The classname on a submenu (a nested UL) that should expand below + * their parent instead of slide in from the right. + * Default: "vertical" + */ + vertical?: string; + + } + + interface Configurations { + + /** + * the CSS class names object + */ + classNames?: ClassnamesConfigurations; + + /** + * Whether or not the menu should be cloned (and the original menu kept intact). + * Default: false + */ + clone?: boolean; + + /** + * The number of milliseconds between opening/closing the menu and panels, + * needed to force CSS transitions. + * Default: 25 + */ + openingInterval?: number; + + /** + * jQuery selector containing the node-type of panels. + * Default: "div, ul, ol" + */ + panelNodetype?: string; + + /** + * The number of milliseconds used in the CSS transitions. + * Default: 400 (The value should match the associated CSS value.) + */ + transitionDuration?: number; + + } + + interface API { + + /** + * Trigger this method to close all opened panels and go back to the first panel. + */ + closeAllPanels(): JQuery; + /** @see closeAllPanels() */ + bind(methodName: "closeAllPanels", callback: () => void): JQuery; + + /** + * Trigger this method to close a panel + * (only available if the "slidingSubmenus" option is set to false). + * @param panel + */ + closePanel(panel: JQuery); + /** @see closePanel() */ + bind(methodName: "closePanel", callback: (panel: JQuery) => void); + + /** + * Trigger this method to get the class instance for the menu. + */ + getInstance(); + /** @see getInstance() */ + bind(methodName: "getInstance", callback: () => void); + + /** + * Trigger this method to (re)initialize a newly added panel. + * @param panel The panel to (re)initialize. + */ + init(panel: JQuery); + /** @see init() */ + bind(methodName: "init", callback: (panel: JQuery) => void); + + /** + * Trigger this method to open a panel. + * @param panel The panel to open. + */ + openPanel(panel: JQuery); + /** @see openPanel() */ + bind(methodName: "openPanel", callback: (panel: JQuery) => void); + + /** + * Trigger this method to set or unset a list item as "selected". + * @param li The list item to set or unset as "selected". + * @param selected Whether to set or unset the list item as "selected". Default: true + */ + setSelected(li: JQuery, selected?: boolean); + /** @see setSelected() */ + bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void); + + /** + * Trigger this method to update the appearance for the menu. + */ + update(); + /** @see update() */ + bind(methodName: "update", callback: () => void); + + } + +} + + +interface JQuery { + + /** + * Create mmenu component + */ + mmenu(): JQuery; + mmenu(options: JQueryMmenu.Options): JQuery; + mmenu(options: JQueryMmenu.Options, configurations: JQueryMmenu.Configurations): JQuery; + +} From 47441e47c0e3ef775e27e9a73ebd4392f7951e96 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 16 Nov 2015 11:29:52 +0100 Subject: [PATCH 007/128] Fix test error for mmenu 5.5.3 --- jquery.mmenu/jquery.mmenu-tests.ts | 4 ++-- jquery.mmenu/jquery.mmenu.d.ts | 37 ++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/jquery.mmenu/jquery.mmenu-tests.ts b/jquery.mmenu/jquery.mmenu-tests.ts index 9fbb9b776..ae52793d6 100644 --- a/jquery.mmenu/jquery.mmenu-tests.ts +++ b/jquery.mmenu/jquery.mmenu-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- @@ -44,7 +44,7 @@ menu.mmenu( // ------------------- TEST MMENU API --------------------- // -------------------------------------------------------- -var api: JQueryMmenu.API = menu.data("mmenu"); +var api = menu.data("mmenu"); var myPanel: JQuery = $("#panel"); var listItem: JQuery = $(".list-item"); diff --git a/jquery.mmenu/jquery.mmenu.d.ts b/jquery.mmenu/jquery.mmenu.d.ts index 97874f8f0..a502c37cd 100644 --- a/jquery.mmenu/jquery.mmenu.d.ts +++ b/jquery.mmenu/jquery.mmenu.d.ts @@ -157,6 +157,13 @@ declare module JQueryMmenu { interface API { + /** + * Trigger non-specialized signature method + * @param methodName + * @param callback + */ + bind(methodName: string, callback: (...args: any[]) => void): any; + /** * Trigger this method to close all opened panels and go back to the first panel. */ @@ -169,48 +176,48 @@ declare module JQueryMmenu { * (only available if the "slidingSubmenus" option is set to false). * @param panel */ - closePanel(panel: JQuery); + closePanel(panel: JQuery): void; /** @see closePanel() */ - bind(methodName: "closePanel", callback: (panel: JQuery) => void); + bind(methodName: "closePanel", callback: (panel: JQuery) => void): void; /** * Trigger this method to get the class instance for the menu. */ - getInstance(); + getInstance(): void; /** @see getInstance() */ - bind(methodName: "getInstance", callback: () => void); + bind(methodName: "getInstance", callback: () => void): void; /** * Trigger this method to (re)initialize a newly added panel. * @param panel The panel to (re)initialize. */ - init(panel: JQuery); + init(panel: JQuery): void; /** @see init() */ - bind(methodName: "init", callback: (panel: JQuery) => void); + bind(methodName: "init", callback: (panel: JQuery) => void): void; /** * Trigger this method to open a panel. * @param panel The panel to open. */ - openPanel(panel: JQuery); + openPanel(panel: JQuery): void; /** @see openPanel() */ - bind(methodName: "openPanel", callback: (panel: JQuery) => void); + bind(methodName: "openPanel", callback: (panel: JQuery) => void): void; /** * Trigger this method to set or unset a list item as "selected". * @param li The list item to set or unset as "selected". * @param selected Whether to set or unset the list item as "selected". Default: true */ - setSelected(li: JQuery, selected?: boolean); + setSelected(li: JQuery, selected?: boolean): void; /** @see setSelected() */ - bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void); + bind(methodName: "setSelected", callback: (li: JQuery, selected?: boolean) => void): void; /** * Trigger this method to update the appearance for the menu. */ - update(); + update(): void; /** @see update() */ - bind(methodName: "update", callback: () => void); + bind(methodName: "update", callback: () => void): void; } @@ -226,4 +233,10 @@ interface JQuery { mmenu(options: JQueryMmenu.Options): JQuery; mmenu(options: JQueryMmenu.Options, configurations: JQueryMmenu.Configurations): JQuery; + /** + * Return the mmenu object + * @param element + */ + data(element: "mmenu"): JQueryMmenu.API; + } From 38eb9eab293520f4902c5cec93528508777fd699 Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 16 Nov 2015 11:30:34 +0100 Subject: [PATCH 008/128] Fix test error for slick 1.5.8 --- jquery.slick/slick-tests.ts | 7 +++---- jquery.slick/slick.d.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jquery.slick/slick-tests.ts b/jquery.slick/slick-tests.ts index 499e6974c..90f61ca67 100644 --- a/jquery.slick/slick-tests.ts +++ b/jquery.slick/slick-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- @@ -196,9 +196,8 @@ $("#diaporama").slick({ centerMode: false, centerPadding: "50px", cssEase: "ease", - customPaging: (slider, i: number) => { - console.log("customPaging slider", slider); - console.log("customPaging index", i); + customPaging: (slider, i) => { + return "customPaging slider " + slider + " customPaging index " + i; }, dots: false, draggable: true, diff --git a/jquery.slick/slick.d.ts b/jquery.slick/slick.d.ts index 949f21736..d75090bb2 100644 --- a/jquery.slick/slick.d.ts +++ b/jquery.slick/slick.d.ts @@ -83,7 +83,7 @@ interface JQuerySlickOptions { * Custom paging templates. See source for use example. * Default: n/a */ - customPaging?: (slider, i: number) => string; + customPaging?: (slider: any, i: number) => string; /** * Show dot indicators @@ -272,6 +272,13 @@ interface JQuery { slick(): JQuery; slick(options: JQuerySlickOptions): JQuery; + /** + * Trigger non-specialized signature method + * @param methodName + * @param arg + */ + slick(methodName: string, ...arg: any[]): any; + /** * Returns the current slide index * @param methodName The name of the method From d8184977b0d72cce7fb5e03591de83b9424f6d0b Mon Sep 17 00:00:00 2001 From: emmanuel Date: Mon, 23 Nov 2015 14:35:47 +0100 Subject: [PATCH 009/128] Rename jquery.slick to slick-carousel --- .../slick-tests.ts => slick-carousel/slick-carousel-tests.ts | 2 +- jquery.slick/slick.d.ts => slick-carousel/slick-carousel.d.ts | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename jquery.slick/slick-tests.ts => slick-carousel/slick-carousel-tests.ts (98%) rename jquery.slick/slick.d.ts => slick-carousel/slick-carousel.d.ts (100%) diff --git a/jquery.slick/slick-tests.ts b/slick-carousel/slick-carousel-tests.ts similarity index 98% rename from jquery.slick/slick-tests.ts rename to slick-carousel/slick-carousel-tests.ts index 90f61ca67..0279f5131 100644 --- a/jquery.slick/slick-tests.ts +++ b/slick-carousel/slick-carousel-tests.ts @@ -1,5 +1,5 @@ /// -/// +/// // -------------------------------------------------------- diff --git a/jquery.slick/slick.d.ts b/slick-carousel/slick-carousel.d.ts similarity index 100% rename from jquery.slick/slick.d.ts rename to slick-carousel/slick-carousel.d.ts From d84ba2d2c36776b81a954ad2b84cefb560dc2cd9 Mon Sep 17 00:00:00 2001 From: stunaz Date: Thu, 10 Dec 2015 19:55:49 -0500 Subject: [PATCH 010/128] =?UTF-8?q?-=20Added=20namespace=20=E2=80=98Loadin?= =?UTF-8?q?gBar=E2=80=99=20-=20Added=20loadingBar=20interface=20Definition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../angular-loading-bar-tests.ts | 10 +++++++ angular-loading-bar/angular-loading-bar.d.ts | 26 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/angular-loading-bar/angular-loading-bar-tests.ts b/angular-loading-bar/angular-loading-bar-tests.ts index b7ca2894e..6acdfa6d5 100644 --- a/angular-loading-bar/angular-loading-bar-tests.ts +++ b/angular-loading-bar/angular-loading-bar-tests.ts @@ -13,3 +13,13 @@ class TestController { } app.controller('TestController', TestController); + + + +var barConfig: angular.loadingBar.ILoadingBarProvider[] = []; +barConfig.push({ + includeSpinner: true, + includeBar: true, + spinnerTemplate: 'template', + latencyThreshold: 100 +}); diff --git a/angular-loading-bar/angular-loading-bar.d.ts b/angular-loading-bar/angular-loading-bar.d.ts index b1a8cd55d..d026db098 100644 --- a/angular-loading-bar/angular-loading-bar.d.ts +++ b/angular-loading-bar/angular-loading-bar.d.ts @@ -6,7 +6,7 @@ /// -declare module angular { +declare module angular.loadingBar { interface IRequestShortcutConfig { /** @@ -15,4 +15,26 @@ declare module angular { ignoreLoadingBar?: boolean; } -} \ No newline at end of file + interface ILoadingBarProvider{ + /** + * Turn the spinner on or off + */ + includeSpinner?: boolean; + + /** + * Turn the loading bar on or off + */ + includeBar?: boolean; + + /** + * HTML template + */ + spinnerTemplate?: string; + + /** + * Latency Threshold + */ + latencyThreshold?: number; + } + +} From f9d722838776698c634a9af179d10eb3a7858c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Sojo?= Date: Fri, 11 Dec 2015 09:12:43 +0100 Subject: [PATCH 011/128] Fix position type, string to any, in jQueryui autocompleteOptions https://api.jqueryui.com/autocomplete/#option-position --- jqueryui/jqueryui.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 9dd576e1a..ade8eb735 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -49,7 +49,7 @@ declare module JQueryUI { delay?: number; disabled?: boolean; minLength?: number; - position?: string; + position?: any; // object source?: any; // [], string or () } From f7ba60bb1434c6d538a03bb5338fafa9ef2646c9 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 11 Dec 2015 12:16:01 +0100 Subject: [PATCH 012/128] Update definition of ITemplateOptions --- angular-formly/angular-formly.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index 2bf75af7d..d52df5e48 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -70,6 +70,11 @@ declare module AngularFormly { postWrapper?: ITemplateManipulator[]; } + interface ISelectOption { + name: string; + value: string; + group?: string; + } /** * see http://docs.angular-formly.com/docs/ngmodelattrstemplatemanipulator @@ -104,6 +109,12 @@ declare module AngularFormly { description?: string; [key: string]: any; + // types for select/radio fields + options?: ISelectOption | any; + groupProp?: string; // default: group + valueProp?: string; // default: value + labelProp?: string; // default: name + } From 1bd11135c8be706a519b46753f477e3e3c4029fa Mon Sep 17 00:00:00 2001 From: hinamiyagk Date: Mon, 14 Dec 2015 12:09:18 +0900 Subject: [PATCH 013/128] Add electron.hideInternalModules() --- github-electron/github-electron-main-tests.ts | 4 ++- github-electron/github-electron.d.ts | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/github-electron/github-electron-main-tests.ts b/github-electron/github-electron-main-tests.ts index ef9c21e52..8a0d4125f 100644 --- a/github-electron/github-electron-main-tests.ts +++ b/github-electron/github-electron-main-tests.ts @@ -19,6 +19,8 @@ import { shell } from 'electron'; +require('electron').hideInternalModules(); + import path = require('path'); // Quick start @@ -201,7 +203,7 @@ ipcMain.on('online-status-changed', (event: any, status: any) => { app.on('ready', () => { window = new BrowserWindow({ width: 800, - height: 600, + height: 600, titleBarStyle: 'hidden-inset', }); window.loadURL('https://github.com'); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7c5fa8b4d..5dcaba2ff 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1312,7 +1312,7 @@ declare module GitHubElectron { */ read(format: string, type?: string): any; } - + interface CrashReporterStartOptions { /** * Default: Electron @@ -1343,7 +1343,7 @@ declare module GitHubElectron { */ extra?: {} } - + interface CrashReporterPayload extends Object { /** * E.g., "electron-crash-service". @@ -1383,17 +1383,17 @@ declare module GitHubElectron { */ upload_file_minidump: File; } - + interface CrashReporter { start(options?: CrashReporterStartOptions): void; - + /** * @returns The date and ID of the last crash report. When there was no crash report * sent or the crash reporter is not started, null will be returned. */ getLastCrashReport(): CrashReporterPayload; } - + interface Shell{ /** * Show the given file in a file manager. If possible, select the file. @@ -1469,7 +1469,7 @@ declare module GitHubElectron { */ process: any; } - + interface WebFrame { /** * Changes the zoom factor to the specified factor, zoom factor is @@ -1588,7 +1588,7 @@ declare module GitHubElectron { ENABLE_SAMPLING: number; RECORD_CONTINUOUSLY: number; } - + interface Dialog { /** * @param callback If supplied, the API call will be asynchronous. @@ -1608,7 +1608,7 @@ declare module GitHubElectron { * @returns The index of the clicked button. */ showMessageBox: typeof GitHubElectron.Dialog.showMessageBox; - + /** * Runs a modal dialog that shows an error message. This API can be called safely * before the ready event of app module emits, it is usually used to report errors @@ -1616,7 +1616,7 @@ declare module GitHubElectron { */ showErrorBox(title: string, content: string): void; } - + interface GlobalShortcut { /** * Registers a global shortcut of accelerator. @@ -1643,14 +1643,14 @@ declare module GitHubElectron { */ unregisterAll(): void; } - + class RequestFileJob { /** * Create a request job which would query a file of path and set corresponding mime types. */ constructor(path: string); } - + class RequestStringJob { /** * Create a request job which sends a string as response. @@ -1667,7 +1667,7 @@ declare module GitHubElectron { data?: string; }); } - + class RequestBufferJob { /** * Create a request job which accepts a buffer and sends a string as response. @@ -1684,7 +1684,7 @@ declare module GitHubElectron { data?: Buffer; }); } - + interface Protocol { registerProtocol(scheme: string, handler: (request: any) => void): void; unregisterProtocol(scheme: string): void; @@ -1718,6 +1718,7 @@ declare module GitHubElectron { powerMonitor: NodeJS.EventEmitter; protocol: GitHubElectron.Protocol; Tray: typeof GitHubElectron.Tray; + hideInternalModules(): any; } } From a77e03f09222a03e3ba25c485de29f6bdf2aebb6 Mon Sep 17 00:00:00 2001 From: Rafal Witczak Date: Tue, 1 Dec 2015 19:35:07 -0800 Subject: [PATCH 014/128] TSD definitions for cordova-plugin-mapsforge --- .../cordova-plugin-mapsforge-tests.ts | 73 +++++ .../cordova-plugin-mapsforge.d.ts | 249 ++++++++++++++++++ 2 files changed, 322 insertions(+) create mode 100644 cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts create mode 100644 cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts diff --git a/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts b/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts new file mode 100644 index 000000000..52ef78700 --- /dev/null +++ b/cordova-plugin-mapsforge/cordova-plugin-mapsforge-tests.ts @@ -0,0 +1,73 @@ +/// + + +mapsforge.embedded.initialize(["/mnt/sdcard/spain.map",0,0]); //Creates the view +mapsforge.embedded.setCenter(43.360056,-5.845757); //Sets the center of the view +mapsforge.embedded.setMaxZoom(18); +mapsforge.embedded.setZoom(15); + +//Adding a marker +var markerKey: number; +mapsforge.embedded.addMarker([mapsforge.embedded.MARKER_YELLOW,43.360056,-5.845757],function(key){markerKey = key;}); + +//Adding a polyline +var points = [43.360056,-5.845757, 43.160056,-5.645757,43.560056,-5.895757]; +var polylineKey: number; +mapsforge.embedded.addPolyline([mapsforge.embedded.COLOR_GREEN,10,points], function(key){polylineKey = key;}, function(error){alert(error);}); + + + +mapsforge.cache.initialize("/mnt/sdcard/spain.map"); //Initializes the renderer with the offline map + +/*Now you can use the Leaflet code seen before*/ + +mapsforge.cache.setExternalCache(false); //Sets the cache to internal for faster performance + +//Now we set the cache size to 50 MB. This will increase the time between cleanings, but +//it will also make those cleanings slower, since there are a lot more of images to +//delete...so be careful when you choose the cache size +mapsforge.cache.setMaxCacheSize(50); + + + +var L: any; + +interface TilePoint { + x: number; + y: number; + z: number; +} + +interface Tile { + src: string; + _layer: any; + onload: any; + onerror: any; +} + +L.OfflineTileLayer = L.TileLayer.extend({ + getTileUrl : function(tilePoint: TilePoint, tile: Tile) { + var zoom = tilePoint.z, x = tilePoint.x, y = tilePoint.y; + + if (mapsforge.cache) { + mapsforge.cache.getTile([x,y,zoom], function(result) {tile.src=result;}, + function() {tile.src = "path to an error image";}); + }else{ + tile.src = "path to an error image"; + } + }, + + _loadTile: function (tile: Tile, tilePoint: TilePoint) { + tile._layer = this; + tile.onload = this._tileOnLoad; + tile.onerror = this._tileOnError; + + this._adjustTilePoint(tilePoint); + this.getTileUrl(tilePoint, tile); + + this.fire('tileloadstart', { + tile: tile, + url: tile.src + }); + } +}); diff --git a/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts b/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts new file mode 100644 index 000000000..6314a09fb --- /dev/null +++ b/cordova-plugin-mapsforge/cordova-plugin-mapsforge.d.ts @@ -0,0 +1,249 @@ +// Type definitions for cordova-plugin-mapsforge +// Project: https://github.com/afsuarez/mapsforge-cordova-plugin +// Definitions by: rafw87 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Window { + mapsforge: MapsforgePlugin; +} + +declare var mapsforge: MapsforgePlugin; + +interface MapsforgePlugin { + embedded: MapsforgeEmbeddedPlugin; + cache: MapsforgeCachePlugin; +} + +interface MapsforgeEmbeddedPlugin { + + COLOR_DKGRAY: number|string; + COLOR_CYAN: number|string; + COLOR_BLACK: number|string; + COLOR_BLUE: number|string; + COLOR_GREEN: number|string; + COLOR_RED: number|string; + COLOR_WHITE: number|string; + COLOR_TRANSPARENT: number|string; + COLOR_YELLOW: number|string; + + MARKER_RED: number|string; + MARKER_GREEN: number|string; + MARKER_BLUE: number|string; + MARKER_YELLOW: number|string; + MARKER_BLACK: number|string; + MARKER_WHITE: number|string; + + /** + * The map file path provided must be the absolute file path. You can specify the width and height values for the view that will be added, + * or you can set them to 0 for set the value to MATCH_PARENT. You must call this method before any other method. + * @param args Array in the following form: [String mapFilePath, int viewWidth, int viewHeight]. + * @param success Success callback. + * @param error Error callback + */ + initialize(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * To show the map view. + * @param success Success callback. + * @param error Error callback + */ + show(success?: () => void, error?: (message: string) => void): void; + + /** + * To hide the map view. + * @param success Success callback. + * @param error Error callback + */ + hide(success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the center of the map to the given coordinates. + * @param lat Latitude of the new center. + * @param lng Longitude of the new center. + * @param success Success callback. + * @param error Error callback + */ + setCenter(lat: number, lng: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the zoom to the specified value (if it is between the zoom limits). + * @param zoomLevel New zoom level. + * @param success Success callback. + * @param error Error callback + */ + setZoom(zoomLevel: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the maximum zoom level. + * @param maxZoom New maximum zoom level. + * @param success Success callback. + * @param error Error callback + */ + setMaxZoom(maxZoom: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the minimum zoom level. + * @param minZoom New minimum zoom level. + * @param success Success callback. + * @param error Error callback + */ + setMinZoom(minZoom: number, success?: () => void, error?: (message: string) => void): void; + + /** + * The path to the map ile is required, and the path to the render theme may be null in order to apply the default render theme. + * @param args Array in the following form: [String mapFilePath, String renderThemePath] + * @param success Success callback. + * @param error Error callback + */ + setOfflineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * + * @param args Array in the following form: [String providerName, String host, String baseUrl, String extension, int port] + * @param success Success callback. + * @param error Error callback + */ + setOnlineTileLayer(args: any[], success?: () => void, error?: (message: string) => void): void; + + /** + * Adds a marker to the map in the specified coordinates and returns the key for that marker to the success function. + * @param arg Array in the following form: [String marker_color, double lat, double lng]. + * The color of the marker should be one of the constants from mapsforge.embedded object; if the marker doesn't exist a green marker will be used instead. + * @param success Success callback. Gets the key of created marker. That key is the one you have to use if you want to delete it. + * @param error Error callback + */ + addMarker(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void; + + /** + * + * @param arg Array in the following form: [int color, int strokeWidth,[double points]]. + * The color can be one of the constants specified before, or the new color you want. + * This function will use the odd positions of the array of points for the latitudes and the even positions for the longitudes. + * Example: [lat1, lng1, lat2, lng2, lat3, lng3]. + * If the length of the array is not even, the function will throw an exception and return the error message to the error function. + * @param success Success callback. Gets the key of created polyline. + * @param error Error callback + */ + addPolyline(arg: any[], success?: (key: number) => void, error?: (message: string) => void): void; + + /** + * Deletes the layer(markers or polylines) with the specified key from the map. + * @param key Key of marker or polyline. + * @param success Success callback. + * @param error Error callback + */ + deleteLayer(key: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Initializes again the map if the onStop method was called. + * @param success Success callback. + * @param error Error callback + */ + onStart(success?: () => void, error?: (message: string) => void): void; + + + /** + * Stops the rendering. Useful for when the app goes to the background. You have to call the onStart method to restart it. + * @param success Success callback. + * @param error Error callback + */ + onStop(success?: () => void, error?: (message: string) => void): void; + + /** + * Stops and cleans the resources that have been used. + * @param success Success callback. + * @param error Error callback + */ + onDestroy(success?: () => void, error?: (message: string) => void): void; +} + +interface MapsforgeCachePlugin { + + /** + * You should call this method before any other one, and provide it with the absolute map file path. + * @param mapFilePath Absolute map file path. + * @param success Success callback. + * @param error Error callback + */ + initialize(mapFilePath: string, success?: () => void, error?: (message: string) => void): void; + + /** + * This method is the one that provides the tiles, generating them if their are not in the cache. + * @param args Array in the following form: [double lat, double lng, byte zoom] + * @param success Success callback. Gets the tile path. + * @param error Error callback + */ + getTile(args: any[], success?: (tilePath: string) => void, error?: (message: string) => void): void; + + /** + * Enables or disables the cache. If disabled, the plugin will generate the tiles always from scratch. Cache is enabled by default. + * @param enabled Cache enabled or disabled. + * @param success Success callback. + * @param error Error callback + */ + setCacheEnabled(enabled: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets whether or not the cache should be placed in the internal memory or in the SD card. + * By default it is placed in SD card, so devices with not too much memory have a better performance. + * @param external Cache external or internal. + * @param success Success callback. + * @param error Error callback + */ + setExternalCache(external: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the map file to be used for rendering to the map specified by its absolute path. + * @param absolutePath Absolute map file path. + * @param success Success callback. + * @param error Error callback + */ + setMapFile(absolutePath: string, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the age for the generated images. This means that when the cache is being cleaned, all images younger than the specified value will be kept in the cache in order to avoid deleting images that are being used at the moment. + * @param milliseconds Max cache age in milliseconds. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheAge(milliseconds: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the maximum size for the cache. This size must be specified in megabytes. If there is not that space available, the cache will fit the maximum size. + * @param sizeInMB Max cache size in megabytes. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheSize(sizeInMB: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets the tile size. By default the tile size is set to 256. + * @param size Tile size. + * @param success Success callback. + * @param error Error callback + */ + setMaxCacheSize(size: number, success?: () => void, error?: (message: string) => void): void; + + /** + * This method sets the size in megabytes that will remain always available in memory in order to avoid that the application uses all space available. + * @param sizeInMB Size in megabytes that will remain always available in memory. + * @param success Success callback. + * @param error Error callback + */ + setCacheCleaningTrigger(sizeInMB: number, success?: () => void, error?: (message: string) => void): void; + + /** + * Sets a flag to destroy the cache when the onDestroy method is called. + * @param destroy If true, cache will be destroyed when the onDestroy method will be called. + * @param success Success callback. + * @param error Error callback + */ + destroyCacheOnExit(destroy: boolean, success?: () => void, error?: (message: string) => void): void; + + /** + * Deletes the cache depending on the flag state. + * @param success Success callback. + * @param error Error callback + */ + onDestroy(success?: () => void, error?: (message: string) => void): void; +} From d220aeca45e917dd5237fabd997cbeb13bbce849 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sat, 12 Dec 2015 17:06:39 +0200 Subject: [PATCH 015/128] Added definitions for scrypt-async v1.2.0. --- scrypt-async/scrypt-async-tests.ts | 25 +++++++++++++++++++ scrypt-async/scrypt-async.d.ts | 39 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 scrypt-async/scrypt-async-tests.ts create mode 100644 scrypt-async/scrypt-async.d.ts diff --git a/scrypt-async/scrypt-async-tests.ts b/scrypt-async/scrypt-async-tests.ts new file mode 100644 index 000000000..745d3ae62 --- /dev/null +++ b/scrypt-async/scrypt-async-tests.ts @@ -0,0 +1,25 @@ +// Tests by: Kaur Kuut + +/// + +var callback = function(key: string | number[]) { }; + +scrypt("abc", "def", 10, 8, 32, 1000, callback, "base64"); +scrypt("abc", [4,5,6], 10, 8, 32, 1000, callback, "base64"); +scrypt([1,2,3], "def", 10, 8, 32, 1000, callback, "base64"); +scrypt([1,2,3], [4,5,6], 10, 8, 32, 1000, callback, "base64"); + +scrypt("abc", "def", 10, 8, 32, 1000, callback); +scrypt("abc", [4,5,6], 10, 8, 32, 1000, callback); +scrypt([1,2,3], "def", 10, 8, 32, 1000, callback); +scrypt([1,2,3], [4,5,6], 10, 8, 32, 1000, callback); + +scrypt("abc", "def", 10, 8, 32, callback, "base64"); +scrypt("abc", [4,5,6], 10, 8, 32, callback, "base64"); +scrypt([1,2,3], "def", 10, 8, 32, callback, "base64"); +scrypt([1,2,3], [4,5,6], 10, 8, 32, callback, "base64"); + +scrypt("abc", "def", 10, 8, 32, callback); +scrypt("abc", [4,5,6], 10, 8, 32, callback); +scrypt([1,2,3], "def", 10, 8, 32, callback); +scrypt([1,2,3], [4,5,6], 10, 8, 32, callback); \ No newline at end of file diff --git a/scrypt-async/scrypt-async.d.ts b/scrypt-async/scrypt-async.d.ts new file mode 100644 index 000000000..618d49e8a --- /dev/null +++ b/scrypt-async/scrypt-async.d.ts @@ -0,0 +1,39 @@ +// Type definitions for scrypt-async v1.2.0 +// Project: https://github.com/dchest/scrypt-async-js +// Definitions by: Kaur Kuut +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module ScryptAsync { + interface CallbackFunc { + (key: string): any; + (key: number[]): any; + } + + interface ScryptStatic { + (password: string, salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc, encoding: string): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, interruptStep: number, callback: CallbackFunc): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc, encoding: string): void; + + (password: string, salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: string, salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: number[], salt: string, logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + (password: number[], salt: number[], logN: number, r: number, dkLen: number, callback: CallbackFunc): void; + } +} + +declare var scrypt: ScryptAsync.ScryptStatic; + +declare module "scrypt-async" { + export = scrypt; +} \ No newline at end of file From 8adab1a506255d3c821401e1afcf2708156831dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn?= Date: Mon, 14 Dec 2015 22:59:12 +0100 Subject: [PATCH 016/128] Added definitions for protractor-http-mock. --- .../protractor-http-mock-tests.ts | 211 ++++++++++++++++++ .../protractor-http-mock.d.ts | 202 +++++++++++++++++ 2 files changed, 413 insertions(+) create mode 100644 protractor-http-mock/protractor-http-mock-tests.ts create mode 100644 protractor-http-mock/protractor-http-mock.d.ts diff --git a/protractor-http-mock/protractor-http-mock-tests.ts b/protractor-http-mock/protractor-http-mock-tests.ts new file mode 100644 index 000000000..9fdf0695a --- /dev/null +++ b/protractor-http-mock/protractor-http-mock-tests.ts @@ -0,0 +1,211 @@ +/// + +function TestConfig() { + mock.config = { + rootDirectory: 'root', + protractorConfig: 'protractor.conf.js' + }; +} + +function TestCtorOverloads() { + let noParam: mock.ProtractorHttpMock = mock(); + let emptyArray: mock.ProtractorHttpMock = mock([]); + let skipDefaults: mock.ProtractorHttpMock = mock([], true); + + let del: mock.requests.Delete = { + request: { + path: 'path', + method: 'DELETE' + }, + response: { + status: 400, + data: 1 + } + }; + let put: mock.requests.Put = { + request: { + path: 'path', + method: 'PUT' + }, + response: { + status: 400, + data: 1 + } + }; + let mocks: mock.ProtractorHttpMock = mock([del, put]); +} + +function TestTeardown() { + mock.teardown(); +} + +function TestRequestsMade() { + let values: Array; + mock.requestsMade().then(v => values = v); +} + +function TestClearRequests() { + let promiseValue: boolean; + mock.clearRequests().then(value => { + promiseValue = value; + }); +} + +function TestGetRequestDefinitions() { + let getMinium: mock.requests.Get = { + request: { + path: 'path', + method: 'GET' + }, + response: { + data: 1, + status: 500 + } + }; + + let getParams: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + params: { + param1: 'param1', + param2: 2 + } + }, + response: { + data: 1, + status: 500 + } + }; + + let post: mock.requests.Post = { + request: { + path: 'path', + method: 'POST' + }, + response: { + data: 1, + status: 500 + } + }; + + let getQueryString: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + queryString: { + query1: 'query1', + query2: 2 + } + }, + response: { + data: 1, + status: 500 + } + }; + + let getHeaders: mock.requests.Get = { + request: { + path: 'path', + method: 'GET', + headers: { + head1: 'head1', + head2: 'head2' + } + }, + response: { + data: 1, + status: 500 + } + }; +} + +function TestPostRequestDefinitions() { + let post: mock.requests.Post = { + request: { + path: 'path', + method: 'POST' + }, + response: { + data: 1, + status: 500 + } + }; + + let postData: mock.requests.PostData = { + request: { + path: 'path', + method: 'POST', + data: 'data' + }, + response: { + data: 1, + status: 500 + } + }; +} + +function TestHeadRequestDefinitions() { + let head: mock.requests.Head = { + request: { + path: 'path', + method: 'HEAD' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestDeleteRequestDefinitions() { + let del: mock.requests.Delete = { + request: { + path: 'path', + method: 'DELETE' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestPutRequestDefinitions() { + let put: mock.requests.Put = { + request: { + path: 'path', + method: 'PUT' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestPatchRequestDefinitions() { + let patch: mock.requests.Patch = { + request: { + path: 'path', + method: 'PATCH' + }, + response: { + status: 500, + data: 1 + } + }; +} + +function TestJsonpRequestDefinitions() { + let jsonp: mock.requests.Jsonp = { + request: { + path: 'path', + method: 'JSONP' + }, + response: { + status: 500, + data: 1 + } + }; +} diff --git a/protractor-http-mock/protractor-http-mock.d.ts b/protractor-http-mock/protractor-http-mock.d.ts new file mode 100644 index 000000000..446c7b3e9 --- /dev/null +++ b/protractor-http-mock/protractor-http-mock.d.ts @@ -0,0 +1,202 @@ +// Type definitions for protractor-http-mock +// Project: https://github.com/atecarlos/protractor-http-mock +// Definitions by: Crevil +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module mock { + interface ProtractorHttpMock { + /** + * Instantiate mock module. This must be done before the browser connects. + * + * @param mocks An array of mock modules to load into the application. + * @param skipDefaults Set true to skip loading of default mocks. + */ + (mocks?: Array>, skipDefaults?: boolean): ProtractorHttpMock; + + /** + * Clean up. + * Typically done in the afterEach call to ensure the teardown + * is executed regardless of what happens in the test execution. + */ + teardown(): void; + + /** + * Returns a promise that will be resolved with an array of + * all matched HTTP requests. + */ + requestsMade(): webdriver.promise.Promise>; + + /** + * Returns a promise that will be resolved with a true boolean + * when all matched HTTP requests are cleared. + */ + clearRequests(): webdriver.promise.Promise; + + /** + * Module configuration to setup + */ + config: { + /** + * Mocks directory where mock files are located. + * Default: process.cwd() + */ + rootDirectory?: string; + + /** + * Path to protractor configuration file. + * Default: protractor.conf + */ + protractorConfig?: string; + }; + } + + /** + * Matched request. + */ + interface ReceivedRequest { + url: string; + method: string; + } + + module requests { + /** + * Base request mock used for all mocks. + */ + interface BaseRequest { + request: { + method: string; + path: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * GET request mock. + */ + interface Get extends BaseRequest { + request: { + method: string; + path: string; + params?: Object; + queryString?: Object; + headers?: Object; + interceptedRequest?: boolean; + interceptedAnonymousRequest?: boolean; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * POST request mock with payload. + */ + interface PostData extends BaseRequest { + request: { + path: string; + method: string; + data: TPayload; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * POST request mock. + */ + interface Post extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * HEAD request mock. + */ + interface Head extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * HTTP Delete request mock. + */ + interface Delete extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * PUT request mock. + */ + interface Put extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * PATCH request mock. + */ + interface Patch extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + + /** + * JSONP request mock. + */ + interface Jsonp extends BaseRequest { + request: { + path: string; + method: string; + }; + response: { + status: number; + data: TResponse; + }; + } + } +} + +declare var mock: mock.ProtractorHttpMock; + +declare module 'protractor-http-mock' { + export = mock; +} From 2a90bb4dd66299e1b4d1e1512cedf8932689260a Mon Sep 17 00:00:00 2001 From: ravishivt Date: Mon, 14 Dec 2015 17:42:49 -0800 Subject: [PATCH 017/128] Added definitions for protractor.ExpectedConditions Added definitions and tests for ExpectedConditions documented at https://angular.github.io/protractor/#/api?view=ExpectedConditions. --- .../angular-protractor-tests.ts | 21 +++ angular-protractor/angular-protractor.d.ts | 139 ++++++++++++++++++ 2 files changed, 160 insertions(+) diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts index 45a5d7edc..0f98aead1 100644 --- a/angular-protractor/angular-protractor-tests.ts +++ b/angular-protractor/angular-protractor-tests.ts @@ -196,6 +196,27 @@ function TestWebDriverUntilModule() { conditionWebElements = protractor.until.elementsLocated(by.className('class')); } +function TestWebDriverExpectedConditionsModule() { + var conditionB: protractor.until.Condition; + var el: protractor.ElementFinder = element(by.id('id')); + + conditionB = protractor.ExpectedConditions.alertIsPresent(); + conditionB = protractor.ExpectedConditions.elementToBeClickable(el); + conditionB = protractor.ExpectedConditions.textToBePresentInElement(el, 'text'); + conditionB = protractor.ExpectedConditions.textToBePresentInElementValue(el, 'text'); + conditionB = protractor.ExpectedConditions.titleContains('text'); + conditionB = protractor.ExpectedConditions.titleIs('text'); + conditionB = protractor.ExpectedConditions.presenceOf(el); + conditionB = protractor.ExpectedConditions.stalenessOf(el); + conditionB = protractor.ExpectedConditions.visibilityOf(el); + conditionB = protractor.ExpectedConditions.invisibilityOf(el); + conditionB = protractor.ExpectedConditions.elementToBeSelected(el); + + conditionB = protractor.ExpectedConditions.not(protractor.ExpectedConditions.alertIsPresent()); + conditionB = protractor.ExpectedConditions.and(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el)); + conditionB = protractor.ExpectedConditions.or(protractor.ExpectedConditions.alertIsPresent(), protractor.ExpectedConditions.elementToBeClickable(el)); +} + function TestProtractor() { var ptor: protractor.Protractor; var driver: webdriver.WebDriver = new webdriver.Builder(). diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts index ff8324238..dc969927e 100644 --- a/angular-protractor/angular-protractor.d.ts +++ b/angular-protractor/angular-protractor.d.ts @@ -501,6 +501,145 @@ declare module protractor { function titleMatches(regex: RegExp): webdriver.until.Condition; } + module ExpectedConditions { + /** + * Negates the result of a promise. + * + * @param {webdriver.until.Condition} expectedCondition + * @return {!webdriver.until.Condition} An expected condition that returns the negated value. + */ + function not(expectedCondition: webdriver.until.Condition): webdriver.until.Condition; + + /** + * Chain a number of expected conditions using logical_and, short circuiting at the + * first expected condition that evaluates to false. + * + * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'and' together. + * @return {!webdriver.until.Condition} An expected condition that returns a promise which evaluates + * to the result of the logical and. + */ + function and(...fns: webdriver.until.Condition[]): webdriver.until.Condition; + + /** + * Chain a number of expected conditions using logical_or, short circuiting at the + * first expected condition that evaluates to true. + * + * @param {...webdriver.until.Condition[]} fns An array of expected conditions to 'or' together. + * @return {!webdriver.until.Condition} An expected condition that returns a promise which + * evaluates to the result of the logical or. + */ + function or(...fns: webdriver.until.Condition[]): webdriver.until.Condition; + + /** + * Expect an alert to be present. + * + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether an alert is present. + */ + function alertIsPresent(): webdriver.until.Condition; + + /** + * An Expectation for checking an element is visible and enabled such that you can click it. + * + * @param {ElementFinder} element The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is clickable. + */ + function elementToBeClickable(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking if the given text is present in the element. + * Returns false if the elementFinder does not find an element. + * + * @param {ElementFinder} element The element to check + * @param {string} text The text to verify against + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the text is present in the element. + */ + function textToBePresentInElement(element: ElementFinder, text: string): webdriver.until.Condition; + + /** + * An expectation for checking if the given text is present in the element’s value. + * Returns false if the elementFinder does not find an element. + * + * @param {ElementFinder} element The element to check + * @param {string} text The text to verify against + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the text is present in the element's value. + */ + function textToBePresentInElementValue( + element: ElementFinder, text: string + ): webdriver.until.Condition; + + /** + * An expectation for checking that the title contains a case-sensitive substring. + * + * @param {string} title The fragment of title expected + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the title contains the string. + */ + function titleContains(title: string): webdriver.until.Condition; + + /** + * An expectation for checking the title of a page. + * + * @param {string} title The expected title, which must be an exact match. + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the title equals the string. + */ + function titleIs(title: string): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page. This does not necessarily + * mean that the element is visible. This is the opposite of 'stalenessOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise + * representing whether the element is present. + */ + function presenceOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is not attached to the DOM of a page. + * This is the opposite of 'presenceOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is stale. + */ + function stalenessOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page and visible. + * Visibility means that the element is not only displayed but also has a height and width that is + * greater than 0. This is the opposite of 'invisibilityOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is visible. + */ + function visibilityOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking that an element is present on the DOM of a page. This does not necessarily + * mean that the element is visible. This is the opposite of 'stalenessOf'. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is invisible. + */ + function invisibilityOf(element: ElementFinder): webdriver.until.Condition; + + /** + * An expectation for checking the selection is selected. + * + * @param {ElementFinder} elementFinder The element to check + * @return {!webdriver.until.Condition} An expected condition that returns a promise representing + * whether the element is selected. + */ + function elementToBeSelected(element: ElementFinder): webdriver.until.Condition; + } + //endregion /** From cf172aab99c3139a718aa8e65398a22c53dd7ead Mon Sep 17 00:00:00 2001 From: Sagar Vadodaria Date: Tue, 15 Dec 2015 14:39:20 +0530 Subject: [PATCH 018/128] added missing property As per AngularJs Documentation, (https://docs.angularjs.org/api/ngRoute/provider/$routeProvider) , $routeProvider has a property as well. caseInsensitiveMatch , which can be used to turn off the case sensitive match globally. --- angularjs/angular-route.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts index 5f426d51c..eafdf714c 100644 --- a/angularjs/angular-route.d.ts +++ b/angularjs/angular-route.d.ts @@ -128,6 +128,12 @@ declare module angular.route { } interface IRouteProvider extends IServiceProvider { + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ + caseInsensitiveMatch?: boolean; /** * Sets route definition that will be used on route change when no other route definition is matched. * From 911b32f0cee09a9f34a7aeb778fae9dba90d9241 Mon Sep 17 00:00:00 2001 From: BSO Date: Tue, 15 Dec 2015 10:14:58 +0100 Subject: [PATCH 019/128] Added constructor using mock files. --- .../protractor-http-mock-tests.ts | 3 ++- protractor-http-mock/protractor-http-mock.d.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/protractor-http-mock/protractor-http-mock-tests.ts b/protractor-http-mock/protractor-http-mock-tests.ts index 9fdf0695a..6c39f1401 100644 --- a/protractor-http-mock/protractor-http-mock-tests.ts +++ b/protractor-http-mock/protractor-http-mock-tests.ts @@ -9,7 +9,8 @@ function TestConfig() { function TestCtorOverloads() { let noParam: mock.ProtractorHttpMock = mock(); - let emptyArray: mock.ProtractorHttpMock = mock([]); + let emptyArray: mock.ProtractorHttpMock = mock([]); + let mockFiles: mock.ProtractorHttpMock = mock(['mock1', 'mock2']); let skipDefaults: mock.ProtractorHttpMock = mock([], true); let del: mock.requests.Delete = { diff --git a/protractor-http-mock/protractor-http-mock.d.ts b/protractor-http-mock/protractor-http-mock.d.ts index 446c7b3e9..41c4ef41f 100644 --- a/protractor-http-mock/protractor-http-mock.d.ts +++ b/protractor-http-mock/protractor-http-mock.d.ts @@ -9,15 +9,22 @@ declare module mock { interface ProtractorHttpMock { /** * Instantiate mock module. This must be done before the browser connects. - * + * * @param mocks An array of mock modules to load into the application. * @param skipDefaults Set true to skip loading of default mocks. */ (mocks?: Array>, skipDefaults?: boolean): ProtractorHttpMock; + /** + * Instantiate mock modules from files. This must be done before the browser connects. + * + * @param mocks An array of mock module names relative to the rootDirectory configuration. + */ + (mocks: Array): ProtractorHttpMock; + /** * Clean up. - * Typically done in the afterEach call to ensure the teardown + * Typically done in the afterEach call to ensure the teardown * is executed regardless of what happens in the test execution. */ teardown(): void; @@ -35,7 +42,7 @@ declare module mock { clearRequests(): webdriver.promise.Promise; /** - * Module configuration to setup + * Module configuration to setup */ config: { /** @@ -51,7 +58,7 @@ declare module mock { protractorConfig?: string; }; } - + /** * Matched request. */ From 5dc8ee8dce912a84449a8024d34ef0609cf86824 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Tue, 15 Dec 2015 11:29:13 +0100 Subject: [PATCH 020/128] fixed es6 imports to have types properly exported instead of string --- angular-translate/angular-translate.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts index e4f69c688..0d4048b0a 100644 --- a/angular-translate/angular-translate.d.ts +++ b/angular-translate/angular-translate.d.ts @@ -6,8 +6,8 @@ /// declare module "angular-translate" { - var _: string; - export = _; + import ngt = angular.translate; + export = ngt; } declare module angular.translate { From 09fa17a56f4d1e7318b5d2ab105950d0add62826 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Tue, 15 Dec 2015 10:40:04 +0000 Subject: [PATCH 021/128] Add commonJS support to angular-resource --- angularjs/angular-resource.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 76930196b..030ddd0c4 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -5,6 +5,10 @@ /// +declare module 'angular-resource' { + var _: string; + export = _; +} /////////////////////////////////////////////////////////////////////////////// // ngResource module (angular-resource.js) From 77e5ef281cd7b71713b32382c63dcc4c75e3c127 Mon Sep 17 00:00:00 2001 From: Laurence C Date: Tue, 15 Dec 2015 11:42:25 +0000 Subject: [PATCH 022/128] Add definitions for SwiftClick --- swiftclick/swiftclick-tests.ts | 7 +++++++ swiftclick/swiftclick.d.ts | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 swiftclick/swiftclick-tests.ts create mode 100644 swiftclick/swiftclick.d.ts diff --git a/swiftclick/swiftclick-tests.ts b/swiftclick/swiftclick-tests.ts new file mode 100644 index 000000000..237978996 --- /dev/null +++ b/swiftclick/swiftclick-tests.ts @@ -0,0 +1,7 @@ +/// + +var swiftClick = SwiftClick.attach(document.body); + +swiftClick.replaceNodeNamesToTrack(["a", "div", "h1"]); +swiftClick.addNodeNamesToTrack(["li"]); +swiftClick.useCssParser(true); \ No newline at end of file diff --git a/swiftclick/swiftclick.d.ts b/swiftclick/swiftclick.d.ts new file mode 100644 index 000000000..d00e9f761 --- /dev/null +++ b/swiftclick/swiftclick.d.ts @@ -0,0 +1,20 @@ +// Type definitions for SwiftClick v1.2.0 +// Project: https://github.com/munkychop/swiftclick +// Definitions by: Laurence C +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface SwiftClickObject { + addNodeNamesToTrack(nodeNamesArray: string[]): void; + replaceNodeNamesToTrack(nodeNamesArray: string[]): void; + useCssParser(useParser: boolean): void; +} + +interface SwiftClickStatic { + attach(contextEl: Element): SwiftClickObject; +} + +declare module "swiftclick" { + export = SwiftClick; +} + +declare var SwiftClick: SwiftClickStatic; From f3917c6c0bff6f5c2db8d44a90f4fe19c928224c Mon Sep 17 00:00:00 2001 From: lgrignon Date: Tue, 15 Dec 2015 15:48:20 +0100 Subject: [PATCH 023/128] backbone definitions (splitted PR) --- .../backbone.localstorage-tests.ts | 6 +++ .../backbone.localstorage.d.ts | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 backbone.localstorage/backbone.localstorage-tests.ts create mode 100644 backbone.localstorage/backbone.localstorage.d.ts diff --git a/backbone.localstorage/backbone.localstorage-tests.ts b/backbone.localstorage/backbone.localstorage-tests.ts new file mode 100644 index 000000000..0d44897a8 --- /dev/null +++ b/backbone.localstorage/backbone.localstorage-tests.ts @@ -0,0 +1,6 @@ +/// + +var store: Store = new Store('testStore'); +store.findAll(); + +store.save(); diff --git a/backbone.localstorage/backbone.localstorage.d.ts b/backbone.localstorage/backbone.localstorage.d.ts new file mode 100644 index 000000000..122c47587 --- /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 c92a91b9eb4e669bb9c5b9a3d3288647acc75c8a Mon Sep 17 00:00:00 2001 From: Julien Renaux Date: Tue, 15 Dec 2015 10:03:54 -0600 Subject: [PATCH 024/128] Change Connections to string Connections are strings not numbers --- cordova/plugins/NetworkInformation.d.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cordova/plugins/NetworkInformation.d.ts b/cordova/plugins/NetworkInformation.d.ts index 53093284f..1ba2ae9e0 100644 --- a/cordova/plugins/NetworkInformation.d.ts +++ b/cordova/plugins/NetworkInformation.d.ts @@ -45,16 +45,16 @@ interface Connection { * Connection.CELL * Connection.NONE */ - type: number + type: string } declare var Connection: { - UNKNOWN: number; - ETHERNET: number; - WIFI: number; - CELL_2G: number; - CELL_3G: number; - CELL_4G: number; - CELL: number; - NONE: number; -} \ No newline at end of file + UNKNOWN: string; + ETHERNET: string; + WIFI: string; + CELL_2G: string; + CELL_3G: string; + CELL_4G: string; + CELL: string; + NONE: string; +} From a04c6d2afafb44fb6ecb77d48f503df720568725 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 22:02:23 +0500 Subject: [PATCH 025/128] lodash: signatures of _.some have been changed --- lodash/lodash-tests.ts | 40 +++++++++++++++++++++++++++++++++ lodash/lodash.d.ts | 50 ++++++++++++++++++++++++++++++++---------- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2398b8d43..010e24480 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2694,9 +2694,11 @@ module TestAny { let array: TResult[]; let list: _.List; let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; let listIterator: (value: TResult, index: number, collection: _.List) => boolean; let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => boolean; { let result: boolean; @@ -2719,6 +2721,12 @@ module TestAny { result = _.any(dictionary, ''); result = _.any<{a: number}, TResult>(dictionary, {a: 42}); + result = _.any(numericDictionary); + result = _.any(numericDictionary, numericDictionaryIterator); + result = _.any(numericDictionary, numericDictionaryIterator, any); + result = _.any(numericDictionary, ''); + result = _.any<{a: number}, TResult>(numericDictionary, {a: 42}); + result = _(array).any(); result = _(array).any(listIterator); result = _(array).any(listIterator, any); @@ -2736,6 +2744,12 @@ module TestAny { result = _(dictionary).any(dictionaryIterator, any); result = _(dictionary).any(''); result = _(dictionary).any<{a: number}>({a: 42}); + + result = _(numericDictionary).any(); + result = _(numericDictionary).any(numericDictionaryIterator); + result = _(numericDictionary).any(numericDictionaryIterator, any); + result = _(numericDictionary).any(''); + result = _(numericDictionary).any<{a: number}>({a: 42}); } { @@ -2758,6 +2772,12 @@ module TestAny { result = _(dictionary).chain().any(dictionaryIterator, any); result = _(dictionary).chain().any(''); result = _(dictionary).chain().any<{a: number}>({a: 42}); + + result = _(numericDictionary).chain().any(); + result = _(numericDictionary).chain().any(numericDictionaryIterator); + result = _(numericDictionary).chain().any(numericDictionaryIterator, any); + result = _(numericDictionary).chain().any(''); + result = _(numericDictionary).chain().any<{a: number}>({a: 42}); } } @@ -4378,9 +4398,11 @@ module TestSome { let array: TResult[]; let list: _.List; let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; let listIterator: (value: TResult, index: number, collection: _.List) => boolean; let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => boolean; { let result: boolean; @@ -4403,6 +4425,12 @@ module TestSome { result = _.some(dictionary, ''); result = _.some<{a: number}, TResult>(dictionary, {a: 42}); + result = _.some(numericDictionary); + result = _.some(numericDictionary, numericDictionaryIterator); + result = _.some(numericDictionary, numericDictionaryIterator, any); + result = _.some(numericDictionary, ''); + result = _.some<{a: number}, TResult>(numericDictionary, {a: 42}); + result = _(array).some(); result = _(array).some(listIterator); result = _(array).some(listIterator, any); @@ -4420,6 +4448,12 @@ module TestSome { result = _(dictionary).some(dictionaryIterator, any); result = _(dictionary).some(''); result = _(dictionary).some<{a: number}>({a: 42}); + + result = _(numericDictionary).some(); + result = _(numericDictionary).some(numericDictionaryIterator); + result = _(numericDictionary).some(numericDictionaryIterator, any); + result = _(numericDictionary).some(''); + result = _(numericDictionary).some<{a: number}>({a: 42}); } { @@ -4442,6 +4476,12 @@ module TestSome { result = _(dictionary).chain().some(dictionaryIterator, any); result = _(dictionary).chain().some(''); result = _(dictionary).chain().some<{a: number}>({a: 42}); + + result = _(numericDictionary).chain().some(); + result = _(numericDictionary).chain().some(numericDictionaryIterator); + result = _(numericDictionary).chain().some(numericDictionaryIterator, any); + result = _(numericDictionary).chain().some(''); + result = _(numericDictionary).chain().some<{a: number}>({a: 42}); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 64b4da950..bdaa88c83 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4062,7 +4062,16 @@ declare module _ { * @see _.some */ any( - collection: List|Dictionary, + collection: NumericDictionary, + predicate?: NumericDictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.some + */ + any( + collection: List|Dictionary|NumericDictionary, predicate?: string, thisArg?: any ): boolean; @@ -4071,7 +4080,7 @@ declare module _ { * @see _.some */ any( - collection: List|Dictionary, + collection: List|Dictionary|NumericDictionary, predicate?: TObject ): boolean; } @@ -4081,7 +4090,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -4106,7 +4115,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -4131,7 +4140,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -4156,7 +4165,7 @@ declare module _ { * @see _.some */ any( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -7477,7 +7486,16 @@ declare module _ { * @see _.some */ some( - collection: List|Dictionary, + collection: NumericDictionary, + predicate?: NumericDictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.some + */ + some( + collection: List|Dictionary|NumericDictionary, predicate?: string, thisArg?: any ): boolean; @@ -7486,7 +7504,7 @@ declare module _ { * @see _.some */ some( - collection: List|Dictionary, + collection: List|Dictionary|NumericDictionary, predicate?: TObject ): boolean; } @@ -7496,7 +7514,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -7521,7 +7539,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): boolean; @@ -7546,7 +7564,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator, + predicate?: ListIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -7571,7 +7589,7 @@ declare module _ { * @see _.some */ some( - predicate?: ListIterator|DictionaryIterator, + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator, thisArg?: any ): LoDashExplicitWrapper; @@ -13743,6 +13761,10 @@ declare module _ { (value: T, key?: string, collection?: Dictionary): TResult; } + interface NumericDictionaryIterator { + (value: T, key?: number, collection?: Dictionary): TResult; + } + interface ObjectIterator { (element: T, key?: string, collection?: any): TResult; } @@ -13777,6 +13799,10 @@ declare module _ { [index: string]: T; } + interface NumericDictionary { + [index: number]: T; + } + interface StringRepresentable { toString(): string; } From c7f2c236186e7da6b3711bcafc0469786622ffc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Junges?= Date: Tue, 15 Dec 2015 23:00:36 -0200 Subject: [PATCH 026/128] Add support to .component from Angularjs 1.5 --- angularjs/angular.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a489141d5..713e6681d 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -181,6 +181,13 @@ declare module angular { animation(name: string, animationFactory: Function): IModule; animation(name: string, inlineAnnotatedFunction: any[]): IModule; animation(object: Object): IModule; + /** + * Use this method to register a component. + * + * @param name The name of the component. + * @param options A definition object passed into the component. + */ + component(name: string, options: IComponentOptions): IModule; /** * Use this method to register work which needs to be performed on module loading. * @@ -1619,6 +1626,23 @@ declare module angular { */ totalPendingRequests: number; } + + /////////////////////////////////////////////////////////////////////////// + // Component + // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html + // and http://toddmotto.com/exploring-the-angular-1-5-component-method/ + /////////////////////////////////////////////////////////////////////////// + + interface IComponentOptions { + bindings?: Object, + controller: Function|string, + controllerAs?: string, + isolate?: boolean, + restrict?: string, + template?: Array|Function, + templateUrl?: string, + transclude?: boolean + } /////////////////////////////////////////////////////////////////////////// // Directive From 3746eb32840de17c1f4eb306047c505639194644 Mon Sep 17 00:00:00 2001 From: hinamiyagk Date: Wed, 16 Dec 2015 10:50:52 +0900 Subject: [PATCH 027/128] Fix wrong returning type of electron.hideInternalModules --- github-electron/github-electron.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 5dcaba2ff..7334d04ae 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1718,7 +1718,7 @@ declare module GitHubElectron { powerMonitor: NodeJS.EventEmitter; protocol: GitHubElectron.Protocol; Tray: typeof GitHubElectron.Tray; - hideInternalModules(): any; + hideInternalModules(): void; } } From 07b87e60644a79da813e44e8dd7c8ade85f1ce06 Mon Sep 17 00:00:00 2001 From: f111fei Date: Wed, 16 Dec 2015 09:50:54 +0800 Subject: [PATCH 028/128] #7152 [node] parameter type of "signal" in process.kill --- node/node-0.10.d.ts | 2 +- node/node-0.11.d.ts | 2 +- node/node-0.12.d.ts | 2 +- node/node-0.8.8.d.ts | 2 +- node/node.d.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/node/node-0.10.d.ts b/node/node-0.10.d.ts index a4cd5b1a6..ba170e864 100644 --- a/node/node-0.10.d.ts +++ b/node/node-0.10.d.ts @@ -176,7 +176,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index 05aee911d..b05e53494 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -176,7 +176,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.12.d.ts b/node/node-0.12.d.ts index 11fd92d24..39f0aa37a 100644 --- a/node/node-0.12.d.ts +++ b/node/node-0.12.d.ts @@ -256,7 +256,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 1972e0cdc..ea56c7306 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -150,7 +150,7 @@ interface NodeProcess extends EventEmitter { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; diff --git a/node/node.d.ts b/node/node.d.ts index 06c4bb960..449583a30 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -256,7 +256,7 @@ declare module NodeJS { visibility: string; }; }; - kill(pid: number, signal?: string): void; + kill(pid:number, signal?: string|number): void; pid: number; title: string; arch: string; From 9b6a4f0c872faa9b2bd768965e61a2e7ad1ce912 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Dec 2015 11:48:44 +0500 Subject: [PATCH 029/128] node: signatures of module "readline" have been changed --- node/node-tests.ts | 102 ++++++++++++++++++++++++++++++++++++++++----- node/node.d.ts | 39 ++++++++++++++--- 2 files changed, 124 insertions(+), 17 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..e21b5d981 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -421,21 +421,101 @@ module path_tests { } //////////////////////////////////////////////////// -///ReadLine tests : https://nodejs.org/api/readline.html +/// readline tests : https://nodejs.org/api/readline.html //////////////////////////////////////////////////// -var rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}); +module readline_tests { + let rl: readline.ReadLine; -rl.setPrompt("$>"); -rl.prompt(); -rl.prompt(true); + { + let options: readline.ReadLineOptions; + let input: NodeJS.ReadableStream; + let output: NodeJS.WritableStream; + let completer: readline.Completer; + let terminal: boolean; -rl.question("do you like typescript?", function(answer: string) { - rl.close(); -}); + let result: readline.ReadLine; + + result = readline.createInterface(options); + result = readline.createInterface(input); + result = readline.createInterface(input, output); + result = readline.createInterface(input, output, completer); + result = readline.createInterface(input, output, completer, terminal); + } + + { + let prompt: string; + + rl.setPrompt(prompt); + } + + { + let preserveCursor: boolean; + + rl.prompt(); + rl.prompt(preserveCursor); + } + + { + let query: string; + let callback: (answer: string) => void; + + rl.question(query, callback); + } + + { + let result: readline.ReadLine; + + result = rl.pause(); + } + + { + let result: readline.ReadLine; + + result = rl.resume(); + } + + { + rl.close(); + } + + { + let data: string|Buffer; + let key: readline.Key; + + rl.write(data); + rl.write(null, key); + } + + { + let stream: NodeJS.WritableStream; + let x: number; + let y: number; + + readline.cursorTo(stream, x, y); + } + + { + let stream: NodeJS.WritableStream; + let dx: number|string; + let dy: number|string; + + readline.moveCursor(stream, dx, dy); + } + + { + let stream: NodeJS.WritableStream; + let dir: number; + + readline.clearLine(stream, dir); + } + + { + let stream: NodeJS.WritableStream; + + readline.clearScreenDown(stream); + } +} ////////////////////////////////////////////////////////////////////// /// Child Process tests: https://nodejs.org/api/child_process.html /// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..63478c451 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -826,22 +826,49 @@ declare module "readline" { import * as events from "events"; import * as stream from "stream"; + export interface Key { + sequence?: string; + name?: string; + ctrl?: boolean; + meta?: boolean; + shift?: boolean; + } + export interface ReadLine extends events.EventEmitter { setPrompt(prompt: string): void; prompt(preserveCursor?: boolean): void; - question(query: string, callback: Function): void; - pause(): void; - resume(): void; + question(query: string, callback: (answer: string) => void): void; + pause(): ReadLine; + resume(): ReadLine; close(): void; - write(data: any, key?: any): void; + write(data: string|Buffer, key?: Key): void; } + + export interface Completer { + (line: string): CompleterResult; + (line: string, callback: (err: any, result: CompleterResult) => void): any; + } + + export interface CompleterResult { + completions: string[]; + line: string; + } + export interface ReadLineOptions { input: NodeJS.ReadableStream; - output: NodeJS.WritableStream; - completer?: Function; + output?: NodeJS.WritableStream; + completer?: Completer; terminal?: boolean; + historySize?: number; } + + export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine; export function createInterface(options: ReadLineOptions): ReadLine; + + export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void; + export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void; + export function clearLine(stream: NodeJS.WritableStream, dir: number): void; + export function clearScreenDown(stream: NodeJS.WritableStream): void; } declare module "vm" { From 5d78b33357dde02151413b63ffa569246cab0b2f Mon Sep 17 00:00:00 2001 From: LAN Xingcan Date: Wed, 16 Dec 2015 19:01:52 +0800 Subject: [PATCH 030/128] Allow pass buffer argument for pbkdf2 function --- node/node-0.10.d.ts | 4 ++-- node/node-0.11.d.ts | 4 ++-- node/node-0.12.d.ts | 4 ++-- node/node-0.8.8.d.ts | 4 ++-- node/node.d.ts | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/node/node-0.10.d.ts b/node/node-0.10.d.ts index a4cd5b1a6..f6aff4f70 100644 --- a/node/node-0.10.d.ts +++ b/node/node-0.10.d.ts @@ -1191,8 +1191,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; diff --git a/node/node-0.11.d.ts b/node/node-0.11.d.ts index 05aee911d..8c8959ecd 100644 --- a/node/node-0.11.d.ts +++ b/node/node-0.11.d.ts @@ -1099,8 +1099,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; diff --git a/node/node-0.12.d.ts b/node/node-0.12.d.ts index 11fd92d24..2c411c4a9 100644 --- a/node/node-0.12.d.ts +++ b/node/node-0.12.d.ts @@ -1654,8 +1654,8 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; export function randomBytes(size: number): Buffer; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 1972e0cdc..c6b2acf50 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -326,7 +326,7 @@ declare module "cluster" { export function disconnect(callback?: Function): void; export var workers: any; - // Event emitter + // Event emitter export function addListener(event: string, listener: Function): void; export function on(event: string, listener: Function): any; export function once(event: string, listener: Function): void; @@ -970,7 +970,7 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; export function randomBytes(size: number, callback?: (err: Error, buf: Buffer) =>void ); } diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..e031cbf74 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1694,10 +1694,10 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer; + export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; export function pseudoRandomBytes(size: number): Buffer; From 793ee5fa00b4c78fb7619e1137085aa376eade11 Mon Sep 17 00:00:00 2001 From: Eric Nicholson Date: Wed, 16 Dec 2015 09:20:08 -0500 Subject: [PATCH 031/128] Added bluebird mapSeries definitions --- bluebird/bluebird-tests.ts | 97 +++++++++++++++++++++++++++++++++++--- bluebird/bluebird.d.ts | 25 ++++++++++ 2 files changed, 116 insertions(+), 6 deletions(-) diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index bd4f46fc4..5f96d28ef 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -607,19 +607,19 @@ Promise.all([fooProm, barProm, fooProm]).then(result => { //TODO fix collection inference -barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.map((item: Foo, index: number, arrayLength: number) => { return bar; }); -barArrProm = fooProm.map((item: Foo) => { +barArrProm = fooArrProm.map((item: Foo) => { return bar; }); -barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.map((item: Foo, index: number, arrayLength: number) => { return bar; }, { concurrency: 1 }); -barArrProm = fooProm.map((item: Foo) => { +barArrProm = fooArrProm.map((item: Foo) => { return bar; }, { concurrency: 1 @@ -627,10 +627,20 @@ barArrProm = fooProm.map((item: Foo) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -barProm = fooProm.reduce((memo: Bar, item: Foo, index: number, arrayLength: number) => { +barArrProm = fooArrProm.mapSeries((item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = fooArrProm.mapSeries((item: Foo) => { + return bar; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +barProm = fooArrProm.reduce((memo: Bar, item: Foo, index: number, arrayLength: number) => { return memo; }); -barProm = fooProm.reduce((memo: Bar, item: Foo) => { +barProm = fooArrProm.reduce((memo: Bar, item: Foo) => { return memo; }, bar); @@ -1008,6 +1018,81 @@ barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) concurrency: 1 }); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// mapSeries() + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArrThen + +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArrThen + +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArrThen, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArr + +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooThenArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArr + +barArrProm = Promise.mapSeries(fooArr, (item: Foo) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo) => { + return barThen; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => { + return bar; +}); +barArrProm = Promise.mapSeries(fooArr, (item: Foo, index: number, arrayLength: number) => { + return barThen; +}); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // reduce() diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index f3420957a..3d205f2ed 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -315,6 +315,12 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { map(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; map(mapper: (item: Q, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; + /** + * Same as `Promise.mapSeries(thisPromise, mapper)`. + */ + // TODO type inference from array-resolving promise? + mapSeries(mapper: (item: Q, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + /** * Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ @@ -573,6 +579,25 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; static map(values: R[], mapper: (item: R, index: number, arrayLength: number) => U, options?: Promise.ConcurrencyOption): Promise; + /** + * Similar to `map` with concurrency set to 1 but guaranteed to execute in sequential order + * + * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. + * + * *The original array is not modified.* + */ + // promise of array with promises of value + static mapSeries(values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // promise of array with values + static mapSeries(values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // array with promises of value + static mapSeries(values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + + // array with values + static mapSeries(values: R[], mapper: (item: R, index: number, arrayLength: number) => U|Promise.Thenable): Promise; + /** * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. * From f2a49a691651e4fcd3a8d14be5c9bdcde9c374b7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 16 Dec 2015 09:55:29 -0800 Subject: [PATCH 032/128] Add schemeNumber part of javascript-bignum library --- javascript-bignum/javascript-bignum-tests.ts | 21 ++++++++ javascript-bignum/javascript-bignum.d.ts | 53 ++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 javascript-bignum/javascript-bignum-tests.ts create mode 100644 javascript-bignum/javascript-bignum.d.ts diff --git a/javascript-bignum/javascript-bignum-tests.ts b/javascript-bignum/javascript-bignum-tests.ts new file mode 100644 index 000000000..57555fcce --- /dev/null +++ b/javascript-bignum/javascript-bignum-tests.ts @@ -0,0 +1,21 @@ +/// +let m = SchemeNumber("1"); +let n = SchemeNumber(2); + +let sum: SchemeNumber = SchemeNumber.fn["+"](m, n); +sum = SchemeNumber.fn["+"](m, 1); +sum = SchemeNumber.fn["+"](m, "12"); +sum = SchemeNumber.fn["+"]("12", "25"); + +let floored: SchemeNumber = SchemeNumber.fn.floor(m); + +let str: string = floored.toString(16); +str = floored.toExponential(2); +str = floored.toPrecision(2); +str = floored.toFixed(2); + +let num: number = maxIntegerDigits; +num = VERSION[0]; +num = VERSION.length; + +raise("fake error", "This is not really an error", m); diff --git a/javascript-bignum/javascript-bignum.d.ts b/javascript-bignum/javascript-bignum.d.ts new file mode 100644 index 000000000..a088837d1 --- /dev/null +++ b/javascript-bignum/javascript-bignum.d.ts @@ -0,0 +1,53 @@ +// Type definitions for javascript-bignum +// Project: https://github.com/jtobey/javascript-bignum +// Definitions by: Nathan Shively-Sanders +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Documentation: http://john-edwin-tobey.org/Scheme/javascript-bignum/docs/files/schemeNumber-js.html + +// This version only includes typing for schemeNumber, not the full library +declare type SchemeOperator = (...args: (string | SchemeNumber | number)[]) => SchemeNumber; +declare var VERSION: number[]; +declare function raise(conditionType: string, message: string, ...irritants: any[]): void; +declare var maxIntegerDigits: number; +declare interface SchemeFn { + [opname: string]: SchemeOperator; + inexact: SchemeOperator; + exact: SchemeOperator; + max: SchemeOperator; + min: SchemeOperator; + abs: SchemeOperator; + div: SchemeOperator; + mod: SchemeOperator; + div0: SchemeOperator; + mod0: SchemeOperator; + gcd: SchemeOperator; + lcm: SchemeOperator; + numerator: SchemeOperator; + denominator: SchemeOperator; + floor: SchemeOperator; + ceiling: SchemeOperator; + truncate: SchemeOperator; + round: SchemeOperator; + rationalize: SchemeOperator; + exp: SchemeOperator; + log: SchemeOperator; + sin: SchemeOperator; + cos: SchemeOperator; + tan: SchemeOperator; + asin: SchemeOperator; + acos: SchemeOperator; + atan: SchemeOperator; + sqrt: SchemeOperator; + expt: SchemeOperator; + magnitude: SchemeOperator; + angle: SchemeOperator; +} +declare interface SchemeNumber { + (value: string | number): SchemeNumber; + toString(radix: number): string; + toFixed(fractionDigits: number): string; + toExponential(fractionDigits: number): string; + toPrecision(precision: number): string; + fn: SchemeFn; +} +declare var SchemeNumber: SchemeNumber; From 223687fd0d9f082e0be46589967acb09c327c4cf Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Wed, 16 Dec 2015 22:55:03 +0100 Subject: [PATCH 033/128] BUGFIX in ITemplateOptions definition --- angular-formly/angular-formly.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts index d52df5e48..fce793e7e 100644 --- a/angular-formly/angular-formly.d.ts +++ b/angular-formly/angular-formly.d.ts @@ -72,7 +72,7 @@ declare module AngularFormly { interface ISelectOption { name: string; - value: string; + value?: string; group?: string; } @@ -110,7 +110,7 @@ declare module AngularFormly { [key: string]: any; // types for select/radio fields - options?: ISelectOption | any; + options?: Array; groupProp?: string; // default: group valueProp?: string; // default: value labelProp?: string; // default: name From ea6787006265bcfbb7a051f85dfd2f74506a0a01 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 15:25:21 -0800 Subject: [PATCH 034/128] Updated stripe.d.ts Added bank account methods for managed accounts. --- stripe/stripe.d.ts | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 96d8758bc..f18dff0ee 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -1,6 +1,6 @@ // Type definitions for stripe // Project: https://stripe.com/ -// Definitions by: Andy Hawkins , Eric J. Smith +// Definitions by: Andy Hawkins , Eric J. Smith , Amrit Kahlon // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StripeStatic { @@ -11,7 +11,8 @@ interface StripeStatic { cardType(cardNumber: string): string; getToken(token: string, responseHandler: (status: number, response: StripeTokenResponse) => void): void; card: StripeCardData; - createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; + createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void; + bankAccount: StripeBankAccount; } interface StripeTokenData { @@ -40,7 +41,10 @@ interface StripeTokenResponse { } interface StripeError { + type: string; + code: string; message: string; + param?: string; } interface StripeCardData { @@ -60,7 +64,45 @@ interface StripeCardData { address_country?: string; } +interface StripeBankAccount +{ + createToken(params: StripeBankTokenParams, stripeResponseHandler: (response: StripeBankTokenResponse) => void): void; + validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; + validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; +} + +interface StripeBankTokenParams +{ + country: string; + currency: string; + routing_number?: number | string; + account_number?: number | string; + transit_number?: number | string; + institution_number?: number | string; + bsb?: number | string; + sort_code?: string; + iban?: string; +} + +interface StripeBankTokenResponse +{ + id: string; + bank_account: { + country: string; + bank_name: string; + last4: number; + validated: boolean; + object: string; + }; + created: number; + livemode: boolean; + type: string; + object: string; + used: boolean; + error: StripeError; +} + declare var Stripe: StripeStatic; declare module "Stripe" { - export = StripeStatic; + export = StripeStatic; } From b6f9544291b2fc44e33771c699158a3a0543a331 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 15:33:27 -0800 Subject: [PATCH 035/128] update stripe.d.ts Added status to bank token creation response --- stripe/stripe.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index f18dff0ee..3fcf771e3 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -66,7 +66,7 @@ interface StripeCardData { interface StripeBankAccount { - createToken(params: StripeBankTokenParams, stripeResponseHandler: (response: StripeBankTokenResponse) => void): void; + createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void; validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean; validateAccountNumber(accountNumber: number | string, countryCode: string): boolean; } From 8907ae9ff9c1b62b1883190871aafbe0f5574203 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 16:26:17 -0800 Subject: [PATCH 036/128] update stripe.d.ts All those extra bank fields are passed as routing number. --- stripe/stripe.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 3fcf771e3..06901ee9f 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -75,13 +75,8 @@ interface StripeBankTokenParams { country: string; currency: string; + account_number: number | string; routing_number?: number | string; - account_number?: number | string; - transit_number?: number | string; - institution_number?: number | string; - bsb?: number | string; - sort_code?: string; - iban?: string; } interface StripeBankTokenResponse From a30d1017ee9f822c332eaba3d128dd0af5f00816 Mon Sep 17 00:00:00 2001 From: amritk Date: Wed, 16 Dec 2015 18:32:12 -0800 Subject: [PATCH 037/128] Update stripe.d.ts --- stripe/stripe.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/stripe/stripe.d.ts b/stripe/stripe.d.ts index 06901ee9f..27d60d961 100644 --- a/stripe/stripe.d.ts +++ b/stripe/stripe.d.ts @@ -83,6 +83,7 @@ interface StripeBankTokenResponse { id: string; bank_account: { + id: string; country: string; bank_name: string; last4: number; From 4f03ef7344e97760125f45950a870b09fc3e3081 Mon Sep 17 00:00:00 2001 From: Sven Reglitzki Date: Thu, 17 Dec 2015 10:08:48 +0100 Subject: [PATCH 038/128] Add sandboxed-module definitions --- sandboxed-module/sandboxed-module.d.ts | 103 +++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 sandboxed-module/sandboxed-module.d.ts diff --git a/sandboxed-module/sandboxed-module.d.ts b/sandboxed-module/sandboxed-module.d.ts new file mode 100644 index 000000000..94fb37450 --- /dev/null +++ b/sandboxed-module/sandboxed-module.d.ts @@ -0,0 +1,103 @@ +// Type definitions for sandboxed-module v2.0.3 +// Project: https://github.com/felixge/node-sandboxed-module +// Definitions by: Sven Reglitzki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "sandboxed-module" { + + interface SandboxOptions { + /** + * An object containing moduleIds and the values to inject for them when required by the sandboxed module. + * This does not affect children of the sandboxed module. + */ + requires?: Object; + /** + * An object of global variables to inject into the sandboxed module. + */ + globals?: Object; + /** + * An object of local variables to inject into the sandboxed module. + */ + locals?: Object; + /** + * An object of named functions which will transform the source code required with SandboxedModule.require. + * For example, CoffeeScript & istanbul support is implemented with built-in sourceTransformer functions + * (see #registerBuiltInSourceTransformer). + * + * A source transformer receives the source (as it's been transformed thus far) and must return the transformed + * source (whether it's changed or unchanged). + * + * An example source transformer to change all instances of the number "3" to "5" would look like this: + * + * SandboxedModule.require('../fixture/baz', { + * sourceTransformers: { + * turn3sInto5s: function(source) { + * return source.replace(/3/g,'5'); + * } + * } + * }) + */ + sourceTransformers?: Object; + /** + * If false, modules that are required by the sandboxed module will not be sandboxed. By default all modules + * required by the sandboxedModule will be sandboxed using the same options that were used for the original + * sandboxed module. + */ + singleOnly?: boolean; + /** + * If false, the source transformers will not be run against modules required by the sandboxed module. + * By default it will take the same value as {@link SandboxOptions.singleOnly}. + */ + sourceTransformersSingleOnly?: boolean; + } + + class SandboxedModule { + /** + * See {@link SandboxOptions.requires} + */ + required:Object; + /** + * See {@link SandboxOptions.globals} + */ + globals:Object; + /** + * See {@link SandboxOptions.locals} + */ + locals:Object; + /** + * See {@link SandboxOptions.sourceTransformers}. + */ + sourceTransformers:Object; + /** + * The full path to the module. + */ + filename:string; + /** + * The underlaying node.js Module instance. + */ + module:string; + /** + * A getter returning the sandboxedModule.module.exports object. + */ + exports:any; + /** + * Returns a new SandboxedModule where moduleId is a regular module path / id as you would normally pass into + * require(). The new module will be loaded in its own v8 context, but otherwise have access to the normal + * node.js environment. + * + * @param moduleId the ID of the module to load + * @param options the loading options + */ + static load(moduleId:string, options?:SandboxOptions):SandboxedModule + + /** + * Identical to {@link SandboxedModule.load()}, but returns sandboxedModule.exports directly. + * + * @param moduleId the ID of the module to require + * @param options the requiring options + */ + static require(moduleId:string, options?:SandboxOptions):any + } + + export = SandboxedModule; +} From 725408f13522c67f3393be1fc51d1c311fb3ebfb Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:04:10 +0100 Subject: [PATCH 039/128] Add host and port to TlsOptions --- node/node-tests.ts | 7 +++++++ node/node.d.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..717220afc 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -198,6 +198,13 @@ var ctx: tls.SecureContext = tls.createSecureContext({ }); var blah = ctx.context; +var tlsOpts: tls.TlsOptions = { + host: "127.0.0.1", + port: 55 +}; +var tlsSocket = tls.connect(tlsOpts); + + //////////////////////////////////////////////////// // Make sure .listen() and .close() retuern a Server instance diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..2b7c2a10d 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1535,6 +1535,8 @@ declare module "tls" { var CLIENT_RENEG_WINDOW: number; export interface TlsOptions { + host?: string; + port?: number; pfx?: any; //string or buffer key?: any; //string or buffer passphrase?: string; From 1ebf010a1eecb2025777b44e5c0387a4c9f0472c Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:31:43 +0100 Subject: [PATCH 040/128] http.RequestOptions.agent can also be a boolean https://nodejs.org/api/http.html#http_http_request_options_callback --- node/node-tests.ts | 10 ++++++++++ node/node.d.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..021517169 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -226,6 +226,16 @@ module http_tests { }); var agent: http.Agent = http.globalAgent; + + http.request({ + agent: false + }); + http.request({ + agent: agent + }); + http.request({ + agent: undefined + }); } //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..f937b53eb 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -453,7 +453,7 @@ declare module "http" { path?: string; headers?: { [key: string]: any }; auth?: string; - agent?: Agent; + agent?: Agent|boolean; } export interface Server extends events.EventEmitter { From 22997bee704f7d14033b5a1972d3811ad65e576c Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 17 Dec 2015 11:40:40 +0100 Subject: [PATCH 041/128] Add all options to child_process.fork() https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options --- node/node.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..dfc3cff11 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -907,7 +907,11 @@ declare module "child_process" { export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; - encoding?: string; + execPath?: string; + execArgv?: string[]; + silent?: boolean; + uid?: number; + gid?: number; }): ChildProcess; export function spawnSync(command: string, args?: string[], options?: { cwd?: string; From 96a1146cdab67999add011ce79611b8544a9dcb2 Mon Sep 17 00:00:00 2001 From: Sven Reglitzki Date: Thu, 17 Dec 2015 12:23:50 +0100 Subject: [PATCH 042/128] Add some tests to sandboxed-module --- sandboxed-module/sandboxed-module-tests.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sandboxed-module/sandboxed-module-tests.ts diff --git a/sandboxed-module/sandboxed-module-tests.ts b/sandboxed-module/sandboxed-module-tests.ts new file mode 100644 index 000000000..a2e6ff2c4 --- /dev/null +++ b/sandboxed-module/sandboxed-module-tests.ts @@ -0,0 +1,28 @@ +// Type definitions for sandboxed-module v2.0.3 +// Project: https://github.com/felixge/node-sandboxed-module +// Definitions by: Sven Reglitzki +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import SandboxedModule = require("sandboxed-module"); + +var sandboxedModule:SandboxedModule = SandboxedModule.load("foo"); +var sandboxedModuleExports:any = SandboxedModule.require("foo"); + +var sandboxedModuleExportsWithOptions:any = SandboxedModule.require("foo", { + requires: { + someDep: {} + }, + globals: { + theAnswer: 42 + }, + locals: { + someLocal: 1 + }, + sourceTransformers: { + identity: (src:string) => src + }, + singleOnly: true, + sourceTransformersSingleOnly: true +}); From 90a746fd3b9f1afb19453ceb3764d7978f3dd14f Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 17 Dec 2015 16:03:22 +0500 Subject: [PATCH 043/128] lodash: signatures of _.uniq have been changed --- lodash/lodash-tests.ts | 348 ++++++++++++-- lodash/lodash.d.ts | 1011 +++++++++++++++++++++++++++++----------- 2 files changed, 1059 insertions(+), 300 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d5..efdc7ecdc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1671,37 +1671,329 @@ module TestUnion { } } -result = _.uniq([1, 2, 1, 3, 1]); -result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +// _.uniq +module TestUniq { + type SampleObject = {a: number; b: string; c: boolean}; -result = _.unique([1, 2, 1, 3, 1]); -result = _.unique([1, 1, 2, 2, 3], true); -result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + let array: SampleObject[]; + let list: _.List; -result = _([1, 2, 1, 3, 1]).uniq().value(); -result = _([1, 1, 2, 2, 3]).uniq(true).value(); -result = _(['A', 'b', 'C', 'a', 'B', 'c']).uniq(function (letter) { - return letter.toLowerCase(); -}).value(); -result = _([1, 2.5, 3, 1.5, 2, 3.5]).uniq(function (num) { return this.floor(num); }, Math).value(); -result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).uniq('x').value(); + let stringIterator: (value: string, index: number, collection: string) => string; + let listIterator: (value: SampleObject, index: number, collection: _.List) => number; -result = _([1, 2, 1, 3, 1]).unique().value(); -result = _([1, 1, 2, 2, 3]).unique(true).value(); -result = _(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) { - return letter.toLowerCase(); -}).value(); -result = _([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value(); -result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value(); + { + let result: string[]; + + result = _.uniq('abc'); + result = _.uniq('abc', true); + result = _.uniq('abc', true, stringIterator); + result = _.uniq('abc', true, stringIterator, any); + result = _.uniq('abc', true, stringIterator); + result = _.uniq('abc', true, stringIterator, any); + result = _.uniq('abc', stringIterator); + result = _.uniq('abc', stringIterator, any); + result = _.uniq('abc', stringIterator); + result = _.uniq('abc', stringIterator, any); + } + + { + let result: SampleObject[]; + + result = _.uniq(array); + result = _.uniq(array, true); + result = _.uniq(array, true, listIterator); + result = _.uniq(array, true, listIterator, any); + result = _.uniq(array, true, listIterator); + result = _.uniq(array, true, listIterator, any); + result = _.uniq(array, listIterator); + result = _.uniq(array, listIterator, any); + result = _.uniq(array, listIterator); + result = _.uniq(array, listIterator, any); + result = _.uniq(array, true, 'a'); + result = _.uniq(array, true, 'a', any); + result = _.uniq(array, 'a'); + result = _.uniq(array, 'a', any); + result = _.uniq(array, true, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(array, true, {a: 42}); + result = _.uniq(array, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(array, {a: 42}); + + result = _.uniq(list); + result = _.uniq(list, true); + result = _.uniq(list, true, listIterator); + result = _.uniq(list, true, listIterator, any); + result = _.uniq(list, true, listIterator); + result = _.uniq(list, true, listIterator, any); + result = _.uniq(list, listIterator); + result = _.uniq(list, listIterator, any); + result = _.uniq(list, listIterator); + result = _.uniq(list, listIterator, any); + result = _.uniq(list, true, 'a'); + result = _.uniq(list, true, 'a', any); + result = _.uniq(list, 'a'); + result = _.uniq(list, 'a', any); + result = _.uniq(list, true, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(list, true, {a: 42}); + result = _.uniq(list, {a: 42}); + result = _.uniq<{a: number}, SampleObject>(list, {a: 42}); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _('abc').uniq(); + result = _('abc').uniq(true); + result = _('abc').uniq(true, stringIterator); + result = _('abc').uniq(true, stringIterator, any); + result = _('abc').uniq(stringIterator); + result = _('abc').uniq(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).uniq(); + result = _(array).uniq(true); + result = _(array).uniq(true, listIterator); + result = _(array).uniq(true, listIterator, any); + result = _(array).uniq(listIterator); + result = _(array).uniq(listIterator, any); + result = _(array).uniq(true, 'a'); + result = _(array).uniq(true, 'a', any); + result = _(array).uniq('a'); + result = _(array).uniq('a', any); + result = _(array).uniq<{a: number}>(true, {a: 42}); + result = _(array).uniq<{a: number}>({a: 42}); + + result = _(list).uniq(); + result = _(list).uniq(true); + result = _(list).uniq(true, listIterator); + result = _(list).uniq(true, listIterator, any); + result = _(list).uniq(true, listIterator); + result = _(list).uniq(true, listIterator, any); + result = _(list).uniq(listIterator); + result = _(list).uniq(listIterator, any); + result = _(list).uniq(listIterator); + result = _(list).uniq(listIterator, any); + result = _(list).uniq(true, 'a'); + result = _(list).uniq(true, 'a', any); + result = _(list).uniq('a'); + result = _(list).uniq('a', any); + result = _(list).uniq(true, {a: 42}); + result = _(list).uniq<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).uniq({a: 42}); + result = _(list).uniq<{a: number}, SampleObject>({a: 42}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('abc').chain().uniq(); + result = _('abc').chain().uniq(true); + result = _('abc').chain().uniq(true, stringIterator); + result = _('abc').chain().uniq(true, stringIterator, any); + result = _('abc').chain().uniq(stringIterator); + result = _('abc').chain().uniq(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().uniq(); + result = _(array).chain().uniq(true); + result = _(array).chain().uniq(true, listIterator); + result = _(array).chain().uniq(true, listIterator, any); + result = _(array).chain().uniq(listIterator); + result = _(array).chain().uniq(listIterator, any); + result = _(array).chain().uniq(true, 'a'); + result = _(array).chain().uniq(true, 'a', any); + result = _(array).chain().uniq('a'); + result = _(array).chain().uniq('a', any); + result = _(array).chain().uniq<{a: number}>(true, {a: 42}); + result = _(array).chain().uniq<{a: number}>({a: 42}); + + result = _(list).chain().uniq(); + result = _(list).chain().uniq(true); + result = _(list).chain().uniq(true, listIterator); + result = _(list).chain().uniq(true, listIterator, any); + result = _(list).chain().uniq(true, listIterator); + result = _(list).chain().uniq(true, listIterator, any); + result = _(list).chain().uniq(listIterator); + result = _(list).chain().uniq(listIterator, any); + result = _(list).chain().uniq(listIterator); + result = _(list).chain().uniq(listIterator, any); + result = _(list).chain().uniq(true, 'a'); + result = _(list).chain().uniq(true, 'a', any); + result = _(list).chain().uniq('a'); + result = _(list).chain().uniq('a', any); + result = _(list).chain().uniq(true, {a: 42}); + result = _(list).chain().uniq<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).chain().uniq({a: 42}); + result = _(list).chain().uniq<{a: number}, SampleObject>({a: 42}); + } +} + +// _.unique +module TestUnique { + type SampleObject = {a: number; b: string; c: boolean}; + + let array: SampleObject[]; + let list: _.List; + + let stringIterator: (value: string, index: number, collection: string) => string; + let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + + { + let result: string[]; + + result = _.unique('abc'); + result = _.unique('abc', true); + result = _.unique('abc', true, stringIterator); + result = _.unique('abc', true, stringIterator, any); + result = _.unique('abc', true, stringIterator); + result = _.unique('abc', true, stringIterator, any); + result = _.unique('abc', stringIterator); + result = _.unique('abc', stringIterator, any); + result = _.unique('abc', stringIterator); + result = _.unique('abc', stringIterator, any); + } + + { + let result: SampleObject[]; + + result = _.unique(array); + result = _.unique(array, true); + result = _.unique(array, true, listIterator); + result = _.unique(array, true, listIterator, any); + result = _.unique(array, true, listIterator); + result = _.unique(array, true, listIterator, any); + result = _.unique(array, listIterator); + result = _.unique(array, listIterator, any); + result = _.unique(array, listIterator); + result = _.unique(array, listIterator, any); + result = _.unique(array, true, 'a'); + result = _.unique(array, true, 'a', any); + result = _.unique(array, 'a'); + result = _.unique(array, 'a', any); + result = _.unique(array, true, {a: 42}); + result = _.unique<{a: number}, SampleObject>(array, true, {a: 42}); + result = _.unique(array, {a: 42}); + result = _.unique<{a: number}, SampleObject>(array, {a: 42}); + + result = _.unique(list); + result = _.unique(list, true); + result = _.unique(list, true, listIterator); + result = _.unique(list, true, listIterator, any); + result = _.unique(list, true, listIterator); + result = _.unique(list, true, listIterator, any); + result = _.unique(list, listIterator); + result = _.unique(list, listIterator, any); + result = _.unique(list, listIterator); + result = _.unique(list, listIterator, any); + result = _.unique(list, true, 'a'); + result = _.unique(list, true, 'a', any); + result = _.unique(list, 'a'); + result = _.unique(list, 'a', any); + result = _.unique(list, true, {a: 42}); + result = _.unique<{a: number}, SampleObject>(list, true, {a: 42}); + result = _.unique(list, {a: 42}); + result = _.unique<{a: number}, SampleObject>(list, {a: 42}); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _('abc').unique(); + result = _('abc').unique(true); + result = _('abc').unique(true, stringIterator); + result = _('abc').unique(true, stringIterator, any); + result = _('abc').unique(stringIterator); + result = _('abc').unique(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).unique(); + result = _(array).unique(true); + result = _(array).unique(true, listIterator); + result = _(array).unique(true, listIterator, any); + result = _(array).unique(listIterator); + result = _(array).unique(listIterator, any); + result = _(array).unique(true, 'a'); + result = _(array).unique(true, 'a', any); + result = _(array).unique('a'); + result = _(array).unique('a', any); + result = _(array).unique<{a: number}>(true, {a: 42}); + result = _(array).unique<{a: number}>({a: 42}); + + result = _(list).unique(); + result = _(list).unique(true); + result = _(list).unique(true, listIterator); + result = _(list).unique(true, listIterator, any); + result = _(list).unique(true, listIterator); + result = _(list).unique(true, listIterator, any); + result = _(list).unique(listIterator); + result = _(list).unique(listIterator, any); + result = _(list).unique(listIterator); + result = _(list).unique(listIterator, any); + result = _(list).unique(true, 'a'); + result = _(list).unique(true, 'a', any); + result = _(list).unique('a'); + result = _(list).unique('a', any); + result = _(list).unique(true, {a: 42}); + result = _(list).unique<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).unique({a: 42}); + result = _(list).unique<{a: number}, SampleObject>({a: 42}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('abc').chain().unique(); + result = _('abc').chain().unique(true); + result = _('abc').chain().unique(true, stringIterator); + result = _('abc').chain().unique(true, stringIterator, any); + result = _('abc').chain().unique(stringIterator); + result = _('abc').chain().unique(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().unique(); + result = _(array).chain().unique(true); + result = _(array).chain().unique(true, listIterator); + result = _(array).chain().unique(true, listIterator, any); + result = _(array).chain().unique(listIterator); + result = _(array).chain().unique(listIterator, any); + result = _(array).chain().unique(true, 'a'); + result = _(array).chain().unique(true, 'a', any); + result = _(array).chain().unique('a'); + result = _(array).chain().unique('a', any); + result = _(array).chain().unique<{a: number}>(true, {a: 42}); + result = _(array).chain().unique<{a: number}>({a: 42}); + + result = _(list).chain().unique(); + result = _(list).chain().unique(true); + result = _(list).chain().unique(true, listIterator); + result = _(list).chain().unique(true, listIterator, any); + result = _(list).chain().unique(true, listIterator); + result = _(list).chain().unique(true, listIterator, any); + result = _(list).chain().unique(listIterator); + result = _(list).chain().unique(listIterator, any); + result = _(list).chain().unique(listIterator); + result = _(list).chain().unique(listIterator, any); + result = _(list).chain().unique(true, 'a'); + result = _(list).chain().unique(true, 'a', any); + result = _(list).chain().unique('a'); + result = _(list).chain().unique('a', any); + result = _(list).chain().unique(true, {a: 42}); + result = _(list).chain().unique<{a: number}, SampleObject>(true, {a: 42}); + result = _(list).chain().unique({a: 42}); + result = _(list).chain().unique<{a: number}, SampleObject>({a: 42}); + } +} // _.upzip module TestUnzip { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4e86afb66..d53fa00d2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2837,343 +2837,810 @@ declare module _ { //_.uniq interface LoDashStatic { /** - * Creates a duplicate-value-free version of an array using strict equality for comparisons, - * i.e. ===. If the array is sorted, providing true for isSorted will use a faster algorithm. - * If a callback is provided each element of array is passed through the callback before - * uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; - * (value, index, array). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param array Array to remove duplicates from. - * @param isSorted True if `array` is already sorted, optiona, default = false. - * @param iterator Transform the elements of `array` before comparisons for uniqueness. - * @param context 'this' object in `iterator`, optional. - * @return Copy of `array` where all elements are unique. - **/ - uniq(array: Array, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - uniq(array: List, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: Array, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: List, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq( - array: Array, - isSorted: boolean, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, in which only + * the first occurrence of each element is kept. Providing true for isSorted performs a faster search + * algorithm for sorted arrays. If an iteratee function is provided it’s invoked for each element in the + * array to generate the criterion by which uniqueness is computed. The iteratee is bound to thisArg and + * invoked with three arguments: (value, index, array). + * + * If a property name is provided for iteratee the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for iteratee the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @alias _.unique + * + * @param array The array to inspect. + * @param isSorted Specify the array is sorted. + * @param iteratee The function invoked per iteration. + * @param thisArg iteratee + * @return Returns the new duplicate-value-free array. + */ uniq( array: List, - isSorted: boolean, - pluckValue: string): T[]; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq( - array: Array, - pluckValue: string): T[]; + * @see _.uniq + */ + uniq( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ uniq( array: List, - pluckValue: string): T[]; + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - array: Array, - isSorted: boolean, - whereValue: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - whereValue: W): T[]; + iteratee?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - array: Array, - whereValue: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( + * @see _.uniq + */ + uniq( array: List, - whereValue: W): T[]; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): T[]; /** - * @see _.uniq - **/ - unique(array: Array, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - unique(array: List, isSorted?: boolean): T[]; - - /** - * @see _.uniq - **/ - unique( - array: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - callback: ListIterator, - thisArg?: any): T[]; + iteratee?: string, + thisArg?: any + ): T[]; /** - * @see _.uniq - **/ - unique( - array: Array, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.uniq - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; + isSorted?: boolean, + iteratee?: Object + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: Array, - isSorted: boolean, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - isSorted: boolean, - pluckValue: string): T[]; + isSorted?: boolean, + iteratee?: TWhere + ): T[]; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: Array, - pluckValue: string): T[]; - - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - pluckValue: string): T[]; + iteratee?: Object + ): T[]; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: Array, - whereValue?: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( + * @see _.uniq + */ + uniq( array: List, - whereValue?: W): T[]; + iteratee?: TWhere + ): T[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: Array, - isSorted: boolean, - whereValue?: W): T[]; - - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: List, - isSorted: boolean, - whereValue?: W): T[]; + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; } interface LoDashImplicitArrayWrapper { /** - * @see _.uniq - **/ - uniq(isSorted?: boolean): LoDashImplicitArrayWrapper; - - /** - * @see _.uniq - **/ + * @see _.uniq + */ uniq( - isSorted: boolean, - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ uniq( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ uniq( - isSorted: boolean, - pluckValue: string): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - uniq(pluckValue: string): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - isSorted: boolean, - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - uniq( - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ - unique(isSorted?: boolean): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + uniq( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + //_.unique + interface LoDashStatic { + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: string, + thisArg?: any + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: Object + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + isSorted?: boolean, + iteratee?: TWhere + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: Object + ): T[]; + + /** + * @see _.uniq + */ + unique( + array: List, + iteratee?: TWhere + ): T[]; + } + + interface LoDashImplicitWrapper { + /** + * @see _.uniq + */ unique( - isSorted: boolean, - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - **/ + * @see _.uniq + */ unique( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ unique( - isSorted: boolean, - pluckValue: string): LoDashImplicitArrayWrapper; + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique(pluckValue: string): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - isSorted: boolean, - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - whereValue: W): LoDashImplicitArrayWrapper; + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: Object + ): LoDashImplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + isSorted?: boolean, + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: Object + ): LoDashExplicitArrayWrapper; + + /** + * @see _.uniq + */ + unique( + iteratee?: TWhere + ): LoDashExplicitArrayWrapper; } //_.unzip From 331d30c38ced4d10efb77d67f3afbdab438411ac Mon Sep 17 00:00:00 2001 From: John Grimsey Date: Thu, 17 Dec 2015 11:42:08 +0000 Subject: [PATCH 044/128] Return type fix --- email-addresses/email-addresses.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/email-addresses/email-addresses.d.ts b/email-addresses/email-addresses.d.ts index a0c4ffb2c..c8cd74d1a 100644 --- a/email-addresses/email-addresses.d.ts +++ b/email-addresses/email-addresses.d.ts @@ -4,6 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "email-addresses" { - function parseOneAddress(opts: any): Object; - function parseAddressList(opts: any): Object; + function parseOneAddress(opts: any): any; + function parseAddressList(opts: any): any; } From 4f245aafeb6c138804f25e20b03e10f8f9754038 Mon Sep 17 00:00:00 2001 From: Marcel Ernst Date: Thu, 17 Dec 2015 15:54:50 +0100 Subject: [PATCH 045/128] Fix type for DatePickerProps formatDate --- material-ui/material-ui.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 2c59d5416..4b46cee7b 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -319,7 +319,7 @@ declare namespace __MaterialUI { interface DatePickerProps extends React.Props { autoOk?: boolean; defaultDate?: Date; - formatDate?: string; + formatDate?: (date:Date) => string; hintText?: string; floatingLabelText?: string; hideToolbarYearChange?: boolean; From 76352a94c6e4a51e7f382aebaf0b63d9ac06ae12 Mon Sep 17 00:00:00 2001 From: cither1 Date: Fri, 18 Dec 2015 00:14:39 +0900 Subject: [PATCH 046/128] Modified a method name. --- onsenui/onsenui-tests.ts | 2 +- onsenui/onsenui.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/onsenui/onsenui-tests.ts b/onsenui/onsenui-tests.ts index 58b72da6e..f0918dc62 100644 --- a/onsenui/onsenui-tests.ts +++ b/onsenui/onsenui-tests.ts @@ -191,7 +191,7 @@ function onsTabbar(tabBar: TabbarView): void { keepPage: true }; tabBar.setActiveTab(2, options); - var activeTab: number = tabBar.getActiveTab(); + var activeTab: number = tabBar.getActiveTabIndex(); tabBar.loadPage('myPage.html'); tabBar.on('eventName', null); tabBar.once('eventName', null); diff --git a/onsenui/onsenui.d.ts b/onsenui/onsenui.d.ts index 287c8e2f5..9eed8c020 100644 --- a/onsenui/onsenui.d.ts +++ b/onsenui/onsenui.d.ts @@ -634,7 +634,7 @@ interface TabbarView { * @return {Number} The index of the currently active tab * @description Returns tab index on current active tab. If active tab is not found, returns -1 */ - getActiveTab(): number; + getActiveTabIndex(): number; /** * @param {String} url Page URL. Can be either an HTML document or an <ons-template> * @description Displays a new page without changing the active index From 34034aaf69c018354769b0cf68d02f51d580920f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alain=20B=C3=A9arez?= Date: Thu, 17 Dec 2015 18:24:38 +0100 Subject: [PATCH 047/128] Add beforeClose option and isOpened() function --- drop/drop.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drop/drop.d.ts b/drop/drop.d.ts index a48cb8fb3..1b994c9a1 100644 --- a/drop/drop.d.ts +++ b/drop/drop.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Drop v0.5.7 +// Type definitions for Drop v1.3.0 // Project: http://github.hubspot.com/drop/ // Definitions by: Adi Dahiya // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -26,6 +26,7 @@ declare module drop { constrainToWindow?: boolean; constrainToScrollParent?: boolean; remove?: boolean; + beforeClose?: () => boolean; tetherOptions?: tether.ITetherOptions; } @@ -37,6 +38,7 @@ declare module drop { close(): void; remove(): void; toggle(): void; + isOpened(): boolean; position(): void; destroy(): void; /* From f83d1a72867c72e1a1b38f11727fed41cb11222e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 17 Dec 2015 10:25:55 -0800 Subject: [PATCH 048/128] Fix casing for 'mkdir', return type of 'path', optionality of 'track' parameter. --- temp/temp-tests.ts | 21 +++++++++++++++------ temp/temp.d.ts | 14 +++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/temp/temp-tests.ts b/temp/temp-tests.ts index eddf870a4..be25d357b 100644 --- a/temp/temp-tests.ts +++ b/temp/temp-tests.ts @@ -11,6 +11,8 @@ function testCleanup() { } else { const { files, dirs } = result; + files.toPrecision(4); + files.toPrecision(4); } }); } @@ -22,16 +24,22 @@ function testCleanupSync() { } else { const { dirs, files } = cleanupResult + dirs.toPrecision(4); + files.toPrecision(4); } } function testOpen() { temp.open({ dir: "tempDir", prefix: "pref", suffix: "suff" }, (err, result) => { const { path, fd } = result; + path.length; + fd.toPrecision(5); }); temp.open("strPrefix", (err, result) => { const { path, fd } = result; + path.length; + fd.toPrecision(5); }); } @@ -45,23 +53,24 @@ function testCreateWriteStream() { stream.write("data"); } -function testMkDir() { - temp.mkDir("prefix", (err, dirPath) => { +function testMkdir() { + temp.mkdir("prefix", (err, dirPath) => { dirPath.length; }); } -function testMkDirSync() { - const result = temp.mkDirSync("prefix"); +function testMkdirSync() { + const result = temp.mkdirSync("prefix"); result.length; } function testPath() { - temp.path({ suffix: "justSuffix" }, "defaultPrefix"); + const p = temp.path({ suffix: "justSuffix" }, "defaultPrefix"); + p.length; } function testTrack() { - const tempChained = temp.track(true).track(false); + const tempChained = temp.track().track(true).track(false); tempChained.dir; tempChained.cleanupSync(); } \ No newline at end of file diff --git a/temp/temp.d.ts b/temp/temp.d.ts index 3d37bf0c5..7cd51d2be 100644 --- a/temp/temp.d.ts +++ b/temp/temp.d.ts @@ -17,13 +17,13 @@ declare module "temp" { export var dir: string; - export function track(value: boolean): typeof temp; + export function track(value?: boolean): typeof temp; - export function mkDir(affixes: string, callback?: (err: any, dirPath: string) => void): void; - export function mkDir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void; + export function mkdir(affixes: string, callback?: (err: any, dirPath: string) => void): void; + export function mkdir(affixes: AffixOptions, callback?: (err: any, dirPath: string) => void): void; - export function mkDirSync(affixes: string): string; - export function mkDirSync(affixes: AffixOptions): string; + export function mkdirSync(affixes: string): string; + export function mkdirSync(affixes: AffixOptions): string; export function open(affixes: string, callback?: (err: any, result: {path: string, fd: number}) => void): void; export function open(affixes: AffixOptions, callback?: (err: any, result: {path: string, fd: number}) => void): void; @@ -31,8 +31,8 @@ declare module "temp" { export function openSync(affixes: string): { path: string, fd: number }; export function openSync(affixes: AffixOptions): { path: string, fd: number }; - export function path(affixes: string, defaultPrefix: string): void; - export function path(affixes: AffixOptions, defaultPrefix: string): void; + export function path(affixes: string, defaultPrefix: string): string; + export function path(affixes: AffixOptions, defaultPrefix: string): string; export function cleanup(callback?: (result: boolean | {files: number, dirs?: number}) => void): void; From 5b31421af0081615210b2fda42582c933b484733 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 17 Dec 2015 20:17:01 +0100 Subject: [PATCH 049/128] Add create-error.js, see https://github.com/tgriesser/create-error --- create-error/create-error-tests.ts | 149 +++++++++++++++++++++++++++++ create-error/create-error.d.ts | 21 ++++ 2 files changed, 170 insertions(+) create mode 100644 create-error/create-error-tests.ts create mode 100644 create-error/create-error.d.ts diff --git a/create-error/create-error-tests.ts b/create-error/create-error-tests.ts new file mode 100644 index 000000000..76b66adf2 --- /dev/null +++ b/create-error/create-error-tests.ts @@ -0,0 +1,149 @@ +/// +/// +/// + +import * as createError from 'create-error'; +import * as assert from 'assert'; + +// Example taken from https://github.com/tgriesser/create-error/blob/0.3.1/README.md#use + +interface MyCustomError extends createError.Error { + messages: string[]; + someVal: string; +} +var MyCustomError = createError('MyCustomError'); + +interface SubCustomError extends MyCustomError { +} +var SubCustomError = createError(MyCustomError, 'CoolSubError', {messages: []}); + +var sub = new SubCustomError('My Message', {someVal: 'value'}); + +sub instanceof SubCustomError // true +sub instanceof MyCustomError // true +sub instanceof Error // true + +assert.deepEqual(sub.messages, []) // true +assert.equal(sub.someVal, 'value') // true + + +// Taken and adapted from https://github.com/tgriesser/create-error/blob/0.3.1/test/index.js + +var equal = assert.equal; +var deepEqual = assert.deepEqual; + +describe('create-error', function() { + + describe('error creation', function() { + + it('should create a new error', function() { + var TestingError = createError('TestingError'); + var a = new TestingError('msgA'); + var b = new TestingError('msgB'); + equal((a instanceof TestingError), true); + equal((a instanceof Error), true); + equal(a.message, 'msgA'); + equal(b.message, 'msgB'); + equal((a.stack.length > 0), true); + }); + + it('should attach properties in the second argument', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', {anArray: []}); + var a = new TestingError('Test the array'); + deepEqual(a.anArray, []); + }); + + it('should give the name "CustomError" if the name is omitted', function() { + var TestingError = createError(); + var a = new TestingError("msg"); + equal(a.name, 'CustomError'); + }); + + it('should not reference the same property in subsequent errors', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', {anArray: []}); + var a = new TestingError('Test the array'); + a.anArray.push('a'); + var b = new TestingError(''); + deepEqual(b.anArray, []); + }); + + it('should allow for empty objects on the cloned hash', function() { + interface TestingError extends createError.Error { + anEmptyObj: Object; + } + var TestingError = createError('TestingError', {anEmptyObj: Object.create(null)}); + var a = new TestingError('Test the array'); + deepEqual(a.anEmptyObj, Object.create(null)); + }); + + it('attaches attrs in the second arg of the error ctor, #3', function() { + interface RequestError extends createError.Error { + status: number; + } + var RequestError = createError('RequestError', {status: 400}); + var reqErr = new RequestError('404 Error', {status: 404}); + equal(reqErr.status, 404); + equal(reqErr.message, '404 Error'); + equal(reqErr.name, 'RequestError'); + }); + + }); + + describe('subclassing errors', function() { + + it('takes an object in the first argument', function() { + var TestingError = createError('TestingError'); + var SubTestingError = createError(TestingError, 'SubTestingError'); + var x = new SubTestingError(); + equal((x instanceof SubTestingError), true); + equal((x instanceof TestingError), true); + equal((x instanceof Error), true); + }); + + it('attaches the properties appropriately.', function() { + interface SubTestingError extends createError.Error { + key: string[]; + } + var TestingError = createError('TestingError'); + var SubTestingError = createError(TestingError, 'SubTestingError', {key: []}); + var x = new SubTestingError(); + deepEqual(x.key, []); + }); + + it('allows for a default message, #4', function() { + var TestingError = createError('TestingError', {message: 'Error with testing'}); + var x = new TestingError(); + equal(x.message, 'Error with testing'); + }); + + }); + + describe('invalid values sent to the second argument', function() { + + it('should ignore falsy values', function() { + var TestingError = createError('TestingError', ''); + var TestingError2 = createError('TestingError', null); + var TestingError3 = createError('TestingError', void 0); + var a = new TestingError('Test the array'); + var b = new TestingError2('Test the array'); + var c = new TestingError3('Test the array'); + }); + + it('should ignore arrays', function() { + interface TestingError extends createError.Error { + anArray: string[]; + } + var TestingError = createError('TestingError', [{anArray: []}]); + var a = new TestingError('Test the array'); + equal(a.anArray, void 0); + }); + + }); + +}); diff --git a/create-error/create-error.d.ts b/create-error/create-error.d.ts new file mode 100644 index 000000000..5db02e474 --- /dev/null +++ b/create-error/create-error.d.ts @@ -0,0 +1,21 @@ +// Type definitions for create-error.js 0.3.1 +// Project: https://github.com/tgriesser/create-error +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'create-error' { + // FIXME See Global type references https://github.com/Microsoft/TypeScript/issues/983 + type Err = Error; + + namespace createError { + interface Error extends Err { + new (message?: string, obj?: any): T; + } + } + + function createError(): createError.Error; + function createError>(name: string, properties?: any): T; + function createError>(Target: createError.Error, name?: string, properties?: any): T; + + export = createError; +} From f05f79fd5836003f29930c96f2a3c6e77bfb81df Mon Sep 17 00:00:00 2001 From: Arthur Cinader Date: Thu, 17 Dec 2015 10:34:51 -0800 Subject: [PATCH 050/128] Add remove() to ionic.modal.IonicModalController Per api: http://ionicframework.com/docs/api/controller/ionicModal/ note the note in the ionic source code: "Be sure to call [remove()](#remove) when you are done with each modal to clean it up and avoid memory leaks." https://github.com/driftyco/ionic/blob/af1bfef327e685585244c6051c4d38b98aa6c62a/js/angular/service/modal.js#L87 --- ionic/ionic-tests.ts | 1 + ionic/ionic.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index 9c5cfdad0..bad5f9d9f 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -149,6 +149,7 @@ class IonicTestController { ionicModalController.initialize(modalOptions); ionicModalController.show().then(() => console.log("shown modal")) ionicModalController.hide().then(() => console.log("hid modal")) + ionicModalController.remove().then(() => console.log("removed modal")) var isShown: boolean = ionicModalController.isShown(); this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions) diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index ce097a226..a3781f26d 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -174,6 +174,7 @@ declare module ionic { initialize(options: IonicModalOptions): void; show(): ng.IPromise; hide(): ng.IPromise; + remove(): ng.IPromise; isShown(): boolean; } From 742aa93d860391a1cfe03a2338c3dd45f5dd2a26 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 00:31:05 +0500 Subject: [PATCH 051/128] node: signatures of module "events" have been changed --- node/node-tests.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++ node/node.d.ts | 14 ++++++++++---- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index aa0f55bb6..741dd3f48 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -32,6 +32,54 @@ assert.doesNotThrow(() => { if (false) { throw "a hammer at your face"; } }, undefined, "What the...*crunch*"); +//////////////////////////////////////////////////// +/// Events tests : http://nodejs.org/api/events.html +//////////////////////////////////////////////////// + +module events_tests { + let emitter: events.EventEmitter; + let event: string; + let listener: Function; + let any: any; + + { + let result: events.EventEmitter; + + result = emitter.addListener(event, listener); + result = emitter.on(event, listener); + result = emitter.once(event, listener); + result = emitter.removeListener(event, listener); + result = emitter.removeAllListeners(); + result = emitter.removeAllListeners(event); + result = emitter.setMaxListeners(42); + } + + { + let result: number; + + result = events.EventEmitter.defaultMaxListeners; + result = events.EventEmitter.listenerCount(emitter, event); // deprecated + + result = emitter.getMaxListeners(); + result = emitter.listenerCount(event); + } + + { + let result: Function[]; + + result = emitter.listeners(event); + } + + { + let result: boolean; + + result = emitter.emit(event); + result = emitter.emit(event, any); + result = emitter.emit(event, any, any); + result = emitter.emit(event, any, any, any); + } +} + //////////////////////////////////////////////////// /// File system tests : http://nodejs.org/api/fs.html //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index 879b20d89..1d5722496 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -173,9 +173,11 @@ declare module NodeJS { once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } export interface ReadableStream extends EventEmitter { @@ -423,17 +425,21 @@ declare module "querystring" { declare module "events" { export class EventEmitter implements NodeJS.EventEmitter { - static listenerCount(emitter: EventEmitter, event: string): number; + static EventEmitter: EventEmitter; + static listenerCount(emitter: EventEmitter, event: string): number; // deprecated + static defaultMaxListeners: number; addListener(event: string, listener: Function): EventEmitter; on(event: string, listener: Function): EventEmitter; once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; - } + listenerCount(type: string): number; + } } declare module "http" { From f8b59970de238982359ca96a0f7a548dd94b0c74 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Dec 2015 02:25:57 +0500 Subject: [PATCH 052/128] node: implementations of the interface "EventEmitter" in other modules have been fixed --- eventemitter3/eventemitter3-tests.ts | 5 ++++- github-electron/github-electron.d.ts | 28 +++++++++++++++++++------- imap/imap.d.ts | 4 +++- jake/jake.d.ts | 4 +++- mailparser/mailparser.d.ts | 4 +++- pty.js/pty.js.d.ts | 4 +++- steam/steam.d.ts | 4 +++- stylus/stylus.d.ts | 4 +++- yeoman-generator/yeoman-generator.d.ts | 4 +++- 9 files changed, 46 insertions(+), 15 deletions(-) diff --git a/eventemitter3/eventemitter3-tests.ts b/eventemitter3/eventemitter3-tests.ts index 4fa378bc2..49ae0a24d 100644 --- a/eventemitter3/eventemitter3-tests.ts +++ b/eventemitter3/eventemitter3-tests.ts @@ -35,7 +35,10 @@ class EventEmitterTest { constructor() { this.v = new EventEmitter(); this.v = new EventEmitter3ImportedAsES6Module(); - var n: NodeJS.EventEmitter = this.v; + + // Some methods are missing or incompatible with current implementation (v4.2.x) of NodeJS.EventEmitter + // (e.g. getMaxListenters or listeners) + // var n: NodeJS.EventEmitter = this.v; } listeners() { diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index a9b83b7dc..ae59a7538 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -70,9 +70,11 @@ declare module GitHubElectron { once(event: string, listener: Function): Screen; removeListener(event: string, listener: Function): Screen; removeAllListeners(event?: string): Screen; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Screen; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * @returns The current absolute position of the mouse pointer. */ @@ -108,9 +110,11 @@ declare module GitHubElectron { once(event: string, listener: Function): WebContents; removeListener(event: string, listener: Function): WebContents; removeAllListeners(event?: string): WebContents; - setMaxListeners(n: number): void; + setMaxListeners(n: number): WebContents; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; constructor(options?: BrowserWindowOptions); /** * @returns All opened browser windows. @@ -522,9 +526,11 @@ declare module GitHubElectron { once(event: string, listener: Function): WebContents; removeListener(event: string, listener: Function): WebContents; removeAllListeners(event?: string): WebContents; - setMaxListeners(n: number): void; + setMaxListeners(n: number): WebContents; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Loads the url in the window. * @param url Must contain the protocol prefix (e.g., the http:// or file://). @@ -930,9 +936,11 @@ declare module GitHubElectron { once(event: string, listener: Function): App; removeListener(event: string, listener: Function): App; removeAllListeners(event?: string): App; - setMaxListeners(n: number): void; + setMaxListeners(n: number): App; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Try to close all windows. The before-quit event will first be emitted. * If all windows are successfully closed, the will-quit event will be emitted @@ -1122,9 +1130,11 @@ declare module GitHubElectron { once(event: string, listener: Function): AutoUpdater; removeListener(event: string, listener: Function): AutoUpdater; removeAllListeners(event?: string): AutoUpdater; - setMaxListeners(n: number): void; + setMaxListeners(n: number): AutoUpdater; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Set the url and initialize the auto updater. * The url cannot be changed once it is set. @@ -1232,9 +1242,11 @@ declare module GitHubElectron { once(event: string, listener: Function): Tray; removeListener(event: string, listener: Function): Tray; removeAllListeners(event?: string): Tray; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Tray; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Creates a new tray icon associated with the image. */ @@ -1426,9 +1438,11 @@ declare module GitHubElectron { once(event: string, listener: Function): IpcRenderer; removeListener(event: string, listener: Function): IpcRenderer; removeAllListeners(event?: string): IpcRenderer; - setMaxListeners(n: number): void; + setMaxListeners(n: number): IpcRenderer; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; /** * Send ...args to the renderer via channel in asynchronous message, the main * process can handle it by listening to the channel event of ipc module. diff --git a/imap/imap.d.ts b/imap/imap.d.ts index 105e64c85..4b88279ae 100644 --- a/imap/imap.d.ts +++ b/imap/imap.d.ts @@ -246,9 +246,11 @@ declare module IMAP { once(event: string, listener: Function): this; removeListener(event: string, listener: Function): this; removeAllListeners(event?: string): this; - setMaxListeners(n: number): void; + setMaxListeners(n: number): this; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; // from MessageFunctions /** Searches the currently open mailbox for messages using given criteria. criteria is a list describing what you want to find. For criteria types that require arguments, use an array instead of just the string criteria type name (e.g. ['FROM', 'foo@bar.com']). Prefix criteria types with an "!" to negate. */ diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 95614374c..84d5c5079 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -231,9 +231,11 @@ declare module jake{ once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; value: any; } diff --git a/mailparser/mailparser.d.ts b/mailparser/mailparser.d.ts index 9e67cc78a..b45ce05d9 100644 --- a/mailparser/mailparser.d.ts +++ b/mailparser/mailparser.d.ts @@ -78,9 +78,11 @@ declare module 'mailparser' { once(event: string, listener: Function): EventEmitter; removeListener(event: string, listener: Function): EventEmitter; removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } } diff --git a/pty.js/pty.js.d.ts b/pty.js/pty.js.d.ts index 937dff0c0..ab874a574 100644 --- a/pty.js/pty.js.d.ts +++ b/pty.js/pty.js.d.ts @@ -85,9 +85,11 @@ declare module 'pty.js' { removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; // NOTE: this method is not actually defined in pty.js - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } /** diff --git a/steam/steam.d.ts b/steam/steam.d.ts index 3f31aef3f..5f9773512 100644 --- a/steam/steam.d.ts +++ b/steam/steam.d.ts @@ -52,9 +52,11 @@ declare module Steam { once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; } } diff --git a/stylus/stylus.d.ts b/stylus/stylus.d.ts index 5809570b9..b0c8db62f 100644 --- a/stylus/stylus.d.ts +++ b/stylus/stylus.d.ts @@ -698,9 +698,11 @@ declare module Stylus { once(event: string, listener: Function): Renderer; removeListener(event: string, listener: Function): Renderer; removeAllListeners(event?: string): Renderer; - setMaxListeners(n: number): void; + setMaxListeners(n: number): Renderer; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; //#endregion } diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 4ccd98e44..760450952 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -42,9 +42,11 @@ declare module yo { once(event: string, listener: Function): NodeJS.EventEmitter; removeListener(event: string, listener: Function): NodeJS.EventEmitter; removeAllListeners(event?: string): NodeJS.EventEmitter; - setMaxListeners(n: number): void; + setMaxListeners(n: number): NodeJS.EventEmitter; + getMaxListeners(): number; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; async(): any; prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; From a78ed230cdd65f906696480288b7350ffdb1332e Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:04:14 -0300 Subject: [PATCH 053/128] New definition for ngWYSIWYG Interface definitions for an AngularJS wysiwyg component, developed by https://github.com/psergus. I'm not sure what kind of tests can be created for interface definitions. Let me know if more is needed. --- ngwysiwyg/ngwysiwyg-tests.ts | 16 ++++++++++++++++ ngwysiwyg/ngwysiwyg.d.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ngwysiwyg/ngwysiwyg-tests.ts create mode 100644 ngwysiwyg/ngwysiwyg.d.ts diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts new file mode 100644 index 000000000..92f33c87f --- /dev/null +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -0,0 +1,16 @@ +/// + +//import ngWYSIWYG = require("ngWYSIWYG"); + +var options: ngWYSIWYGConfig = { + sanitize: false, + toolbar: [ + { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, + { name: "paragraph", items: ["orderedList", "unorderedList", "outdent", "indent", "-"] }, + { name: "doers", items: ["removeFormatting", "undo", "redo", "-"] }, + { name: "colors", items: ["fontColor", "backgroundColor", "-"] }, + { name: "links", items: ["image", "hr", "symbols", "link", "unlink", "-"] }, + { name: "tools", items: ["print", "-"] }, + { name: "styling", items: ["font", "size", "format"] }, + ] +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts new file mode 100644 index 000000000..0289df60e --- /dev/null +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -0,0 +1,14 @@ +// Type definitions for Marked +// Project: https://github.com/psergus/ngWYSIWYG +// Definitions by: Patrick Mac Kay +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface ngWYSIWYGToolbar { + name: string; + items: string[]; +} + +interface ngWYSIWYGConfig { + sanitize: boolean; + toolbar: ngWYSIWYGToolbar[] +} From 7ca98f443216e1de7fca8d49f2602e1b6b7affbb Mon Sep 17 00:00:00 2001 From: patrick-mackay Date: Thu, 17 Dec 2015 20:36:32 -0300 Subject: [PATCH 054/128] Organization and minor fix Added a module to organize the interfaces. Fix a problem with an optional parameter. Previously was marked as required. --- ngwysiwyg/ngwysiwyg-tests.ts | 6 +++++- ngwysiwyg/ngwysiwyg.d.ts | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ngwysiwyg/ngwysiwyg-tests.ts b/ngwysiwyg/ngwysiwyg-tests.ts index 92f33c87f..c779e918e 100644 --- a/ngwysiwyg/ngwysiwyg-tests.ts +++ b/ngwysiwyg/ngwysiwyg-tests.ts @@ -2,7 +2,7 @@ //import ngWYSIWYG = require("ngWYSIWYG"); -var options: ngWYSIWYGConfig = { +var complete: ngWYSIWYG.Config = { sanitize: false, toolbar: [ { name: "basicStyling", items: ["bold", "italic", "underline", "strikethrough", "subscript", "superscript", "-", "leftAlign", "centerAlign", "rightAlign", "blockJustify", "-"] }, @@ -14,3 +14,7 @@ var options: ngWYSIWYGConfig = { { name: "styling", items: ["font", "size", "format"] }, ] }; + +var partial: ngWYSIWYG.Config = { + sanitize: false +}; diff --git a/ngwysiwyg/ngwysiwyg.d.ts b/ngwysiwyg/ngwysiwyg.d.ts index 0289df60e..9f5ba18ca 100644 --- a/ngwysiwyg/ngwysiwyg.d.ts +++ b/ngwysiwyg/ngwysiwyg.d.ts @@ -3,12 +3,14 @@ // Definitions by: Patrick Mac Kay // Definitions: https://github.com/borisyankov/DefinitelyTyped -interface ngWYSIWYGToolbar { - name: string; - items: string[]; -} +declare module ngWYSIWYG { + export interface Toolbar { + name: string; + items: string[]; + } -interface ngWYSIWYGConfig { - sanitize: boolean; - toolbar: ngWYSIWYGToolbar[] -} + export interface Config { + sanitize: boolean; + toolbar?: Toolbar[]; + } +} \ No newline at end of file From d2dd0dbfc70f5bd50aab635156620b3a2578a48d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 05:09:35 +0100 Subject: [PATCH 055/128] Improve jasmine.d.ts - Remove toContainHtml() and toContainText(): they are not part of Jasmine API - Avoid the use of any for toMatch(), toBeLessThan(), toBeGreaterThan(), toBeCloseTo() and toThrowError() --- jasmine-jquery/jasmine-jquery.d.ts | 8 ++++---- jasmine/jasmine.d.ts | 13 ++++++------- knockout/tests/jasmine.extensions.d.ts | 10 ++++++++++ .../tests/knockout-templatingBehaviors-tests.ts | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 knockout/tests/jasmine.extensions.d.ts diff --git a/jasmine-jquery/jasmine-jquery.d.ts b/jasmine-jquery/jasmine-jquery.d.ts index 903e3f7e2..0e1f2b82b 100644 --- a/jasmine-jquery/jasmine-jquery.d.ts +++ b/jasmine-jquery/jasmine-jquery.d.ts @@ -195,8 +195,8 @@ declare module jasmine { * // returns true * expect($('

    header

    ')).toContainHtml('
      ') */ - //toContainHtml(html: string): boolean; - + toContainHtml(html: string): boolean; + /** * Check if DOM element has the given Text. * @param text Accepts a string or regular expression @@ -213,8 +213,8 @@ declare module jasmine { * // returns true * expect($('

        header

        ')).toContainText('header') */ - //toContainText(text: string): boolean; - + toContainText(text: string): boolean; + /** * Check if DOM element has the given value. * This can only be applied for element on with jQuery val() can be called. diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index ed8591488..46a1937f4 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -281,7 +281,7 @@ declare module jasmine { toBe(expected: any, expectationFailOutput?: any): boolean; toEqual(expected: any, expectationFailOutput?: any): boolean; - toMatch(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; toBeDefined(expectationFailOutput?: any): boolean; toBeUndefined(expectationFailOutput?: any): boolean; toBeNull(expectationFailOutput?: any): boolean; @@ -291,13 +291,12 @@ declare module jasmine { toHaveBeenCalled(): boolean; toHaveBeenCalledWith(...params: any[]): boolean; toContain(expected: any, expectationFailOutput?: any): boolean; - toBeLessThan(expected: any, expectationFailOutput?: any): boolean; - toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean; - toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean; - toContainHtml(expected: string): boolean; - toContainText(expected: string): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; toThrow(expected?: any): boolean; - toThrowError(expected?: any, message?: string): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: Error, message?: string | RegExp): boolean; not: Matchers; Any: Any; diff --git a/knockout/tests/jasmine.extensions.d.ts b/knockout/tests/jasmine.extensions.d.ts new file mode 100644 index 000000000..c3b12213f --- /dev/null +++ b/knockout/tests/jasmine.extensions.d.ts @@ -0,0 +1,10 @@ +// Knockout specs depend on custom Jasmine matchers +// See https://github.com/knockout/knockout/blob/v3.4.0/spec/lib/jasmine.extensions.js +// FYI jasmine-jquery.d.ts (https://github.com/velesin/jasmine-jquery) also defines toContainHtml() and toContainText() + +declare module jasmine { + interface Matchers { + toContainHtml(expected: string): boolean; + toContainText(expected: string): boolean; + } +} diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/tests/knockout-templatingBehaviors-tests.ts index 50ec27572..cd86465b2 100644 --- a/knockout/tests/knockout-templatingBehaviors-tests.ts +++ b/knockout/tests/knockout-templatingBehaviors-tests.ts @@ -1,4 +1,5 @@ /// +/// /// /// From 35801ddb4a4f058eb1611164b91d053993bb175e Mon Sep 17 00:00:00 2001 From: PSHollenberg Date: Fri, 18 Dec 2015 13:26:00 +0100 Subject: [PATCH 056/128] Missing axisOptions mode and monthNames --- flot/jquery.flot.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flot/jquery.flot.d.ts b/flot/jquery.flot.d.ts index 027330eee..c45558b87 100644 --- a/flot/jquery.flot.d.ts +++ b/flot/jquery.flot.d.ts @@ -92,6 +92,8 @@ declare module jquery.flot { interface axisOptions { show?: boolean; // null or true/false position?: string; // "bottom" or "top" or "left" or "right" + mode?: string; // "time" + monthNames?: string[]; // array of month names color?: any; // null or color spec tickColor?: any; // null or color spec From fec3ea4268b1853f2555f9a018593a79eb9229c5 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 13:28:36 +0100 Subject: [PATCH 057/128] Add some missing yeoman methods and fix some wrong ones --- yeoman-generator/yeoman-generator.d.ts | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 4ccd98e44..8ebc4da89 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -28,6 +28,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; + destinationPath(file: string): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -37,6 +38,7 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; + templatePath(file: string): string; addListener(event: string, listener: Function): NodeJS.EventEmitter; on(event: string, listener: Function): NodeJS.EventEmitter; once(event: string, listener: Function): NodeJS.EventEmitter; @@ -49,18 +51,30 @@ declare module yo { async(): any; prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; log(message: string) : void; - npmInstall(packages: string[], options?:any) :void; + npmInstall(packages: string[], options?: any, cb?: Function) :void; + installDependencies(): void; + spawnCommand(name: string, args?: string[]): void; appname: string; gruntfile: IGruntFileStatic; + options: { [key: string]: any }; } + + export interface IChoice { + name: string; + value: string; + short?: string; + } + export interface IPromptOptions{ - type:string; - name:string; - message:string; - default:string; + type: string; + name: string; + message: string; + choices?: string[] | Function | IChoice[]; + default?: string; + store?: boolean; } - + export interface IGruntFileStatic { loadNpmTasks(pluginName: string): void; insertConfig(name:string, config:any):void; @@ -70,11 +84,11 @@ declare module yo { } export interface IArgumentConfig { - desc: string; - required: boolean; - optional: boolean; - type: any; - defaults: any; + desc?: string; + required?: boolean; + optional?: boolean; + type?: any; + defaults?: any; } export interface IComposeSetting { From 818e6cf2ff8a7b0458fd9f50054ffb37778a93ed Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 15:07:14 +0100 Subject: [PATCH 058/128] More typing corrections and added tests --- yeoman-generator/yeoman-generator-tests.ts | 64 ++++++++++++++++++++++ yeoman-generator/yeoman-generator.d.ts | 43 ++++++++++----- 2 files changed, 94 insertions(+), 13 deletions(-) diff --git a/yeoman-generator/yeoman-generator-tests.ts b/yeoman-generator/yeoman-generator-tests.ts index 84f007206..f72dff4e3 100644 --- a/yeoman-generator/yeoman-generator-tests.ts +++ b/yeoman-generator/yeoman-generator-tests.ts @@ -112,3 +112,67 @@ runContext.inDir('dirPath') .withGenerators(['deps', 'deps']) .withOptions('opts') .withPrompts('answers'); + +// http://yeoman.io/generator/Base.html#destinationPath +generator.destinationPath() === 'string'; +generator.destinationPath('path1') === 'string'; +generator.destinationPath('path1', 'path2') === 'string'; +generator.destinationPath('path1', 'path2', 'path3') === 'string'; + +// http://yeoman.io/generator/Base.html#templatePath +generator.templatePath() === 'string'; +generator.templatePath('path1') === 'string'; +generator.templatePath('path1', 'path2') === 'string'; +generator.templatePath('path1', 'path2', 'path3') === 'string'; + +// http://yeoman.io/generator/Base.html#npmInstall +generator.npmInstall(); +generator.npmInstall('pkg'); +generator.npmInstall([ 'pkg1', 'pkg2' ]); +generator.npmInstall('pkg', {}); +generator.npmInstall('pkg', {}, () => {}); + +// http://yeoman.io/generator/Base.html#installDependencies +generator.installDependencies(); +generator.installDependencies({}); +generator.installDependencies({ npm: true }); +generator.installDependencies({ bower: true }); +generator.installDependencies({ skipMessage: true }); +generator.installDependencies({ callback: () => {} }); + +// http://yeoman.io/generator/Base.html#spawnCommand +generator.spawnCommand('command', []); +generator.spawnCommand('command', [ '-arg' ]); +generator.spawnCommand('command', [], {}); + +// http://yeoman.io/generator/Base.html#spawnCommandSync +generator.spawnCommandSync('command', []); +generator.spawnCommandSync('command', [ '-arg' ]); +generator.spawnCommandSync('command', [], {}); + +// http://yeoman.io/generator/Base.html#option +generator.options['opt'] === 'string'; + +// http://yeoman.io/generator/Base.html#prompt +// https://github.com/SBoudrias/Inquirer.js +generator.prompt({ name: 'Name', message: 'Message' }, (answer) => {}); +generator.prompt({ name: 'Name', message: (answers) => 'Message' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: [ 'c1', 'c2' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ 'c1', 'c2' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', choices: (answers) => [ { name: 'Choice 1', value: 'c1', short: '1' } ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: 'string' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: 10 }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: [ 'string' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: [ 10 ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => [ 'string' ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => [ 10 ] }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => 'string' }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', default: (answers) => 10 }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', type: "list" }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', validate: (input) => true }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', validate: (input) => "Error" }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', filter: (input) => input }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', when: (answers) => true }, (answer) => {}); +generator.prompt({ name: 'Name', message: '', when: true }, (answer) => {}); diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 8ebc4da89..b73037ea5 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -10,6 +10,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; + destinationPath(...path: string[]): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -19,8 +20,13 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; - - + templatePath(...path: string[]): string; + prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void; + npmInstall(packages?: string[] | string, options?: any, cb?: Function): void; + installDependencies(options?: IInstallDependencyOptions): void; + spawnCommand(name: string, args?: string[], options?: Object): void; + spawnCommandSync(name: string, args?: string[], options?: Object): void; + options: { [key: string]: any }; } export class YeomanGeneratorBase implements IYeomanGenerator, NodeJS.EventEmitter { @@ -28,7 +34,7 @@ declare module yo { composeWith(namespace: string, options: any, settings?: IComposeSetting): IYeomanGenerator; defaultFor(name: string): void; destinationRoot(rootPath: string): string; - destinationPath(file: string): string; + destinationPath(...path: string[]): string; determineAppname(): void; getCollisionFilter(): (output: any) => void; hookFor(name: string, config: IHookConfig): void; @@ -38,7 +44,7 @@ declare module yo { run(args: any, callback?: Function): void; runHooks(callback?: Function): void; sourceRoot(rootPath: string): string; - templatePath(file: string): string; + templatePath(...path: string[]): string; addListener(event: string, listener: Function): NodeJS.EventEmitter; on(event: string, listener: Function): NodeJS.EventEmitter; once(event: string, listener: Function): NodeJS.EventEmitter; @@ -49,17 +55,25 @@ declare module yo { emit(event: string, ...args: any[]): boolean; async(): any; - prompt(opt?:IPromptOptions, callback?:(answers:any)=>void) :void; + prompt(opt: IPromptOptions | IPromptOptions[], callback: (answers: any) => void): void; log(message: string) : void; npmInstall(packages: string[], options?: any, cb?: Function) :void; - installDependencies(): void; - spawnCommand(name: string, args?: string[]): void; + installDependencies(options?: IInstallDependencyOptions): void; + spawnCommand(name: string, args?: string[], options?: Object): void; + spawnCommandSync(name: string, args?: string[], options?: Object): void; appname: string; gruntfile: IGruntFileStatic; options: { [key: string]: any }; } + export interface IInstallDependencyOptions { + npm?: boolean; + bower?: boolean; + skipMessage?: boolean; + callback?: Function; + } + export interface IChoice { name: string; value: string; @@ -67,11 +81,14 @@ declare module yo { } export interface IPromptOptions{ - type: string; + type?: string; name: string; - message: string; - choices?: string[] | Function | IChoice[]; - default?: string; + message: string | ((answers: Object) => string); + choices?: string[] | IChoice[] | ((answers: Object) => (string[] | IChoice[])); + default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[])); + validate?: ((input: any) => boolean | string); + filter?: ((input: any) => any); + when?: ((answers: Object) => boolean) | boolean; store?: boolean; } @@ -84,10 +101,10 @@ declare module yo { } export interface IArgumentConfig { - desc?: string; + desc: string; required?: boolean; optional?: boolean; - type?: any; + type: any; defaults?: any; } From 185f8c594d8517f3ed7390c04a20ac5271071e1c Mon Sep 17 00:00:00 2001 From: Marian Palkus Date: Thu, 17 Dec 2015 12:39:09 +0100 Subject: [PATCH 059/128] Added type definitions for enzyme. --- enzyme/enzyme-tests.tsx | 574 ++++++++++++++++++++++++++++++++++++++++ enzyme/enzyme.d.ts | 340 ++++++++++++++++++++++++ 2 files changed, 914 insertions(+) create mode 100644 enzyme/enzyme-tests.tsx create mode 100644 enzyme/enzyme.d.ts diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx new file mode 100644 index 000000000..71e82351f --- /dev/null +++ b/enzyme/enzyme-tests.tsx @@ -0,0 +1,574 @@ +/// +/// + +import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme"; +import * as React from "react"; +import {Component, ReactElement} from "react"; +import {ShallowWrapper, ReactWrapper, CheerioWrapper} from "enzyme"; + + +// Help classes/interfaces +interface MyComponentProps { + propsProperty: any; +} + +interface MyComponentState { + stateProperty: any; +} + +class MyComponent extends Component { + setState(...args: any[]) { + } +} + +// API +module SpyLifecycleTest { + spyLifecycle(MyComponent); +} + +// ShallowWrapper +module ShallowWrapperTest { + var shallowWrapper: ShallowWrapper = + shallow(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + shallowWrapper = shallowWrapper.find('.selector'); + shallowWrapper = shallowWrapper.find(MyComponent); + } + + function test_findWhere() { + shallowWrapper = + shallowWrapper.findWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_filter() { + shallowWrapper = shallowWrapper.filter('.selector'); + shallowWrapper = shallowWrapper.filter(MyComponent); + } + + function test_filterWhere() { + shallowWrapper = + shallowWrapper.filterWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_contains() { + boolVal = shallowWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = shallowWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = shallowWrapper.is('.some-class'); + } + + function test_not() { + shallowWrapper = shallowWrapper.find('.foo').not('.bar'); + } + + function test_children() { + shallowWrapper = shallowWrapper.children(); + } + + function test_parents() { + shallowWrapper = shallowWrapper.parents(); + } + + function test_parent() { + shallowWrapper = shallowWrapper.parent(); + } + + function test_closest() { + shallowWrapper = shallowWrapper.closest('.selector'); + shallowWrapper = shallowWrapper.closest(MyComponent); + } + + function test_shallow() { + shallowWrapper = shallowWrapper.shallow(); + } + + function test_render() { + var cheerioWrapper: CheerioWrapper = shallowWrapper.render(); + } + + function test_text() { + stringVal = shallowWrapper.text(); + } + + + function test_html() { + stringVal = shallowWrapper.html(); + } + + function test_get() { + reactElement = shallowWrapper.get(1); + } + + function test_at() { + shallowWrapper = shallowWrapper.at(1); + } + + function test_first() { + shallowWrapper = shallowWrapper.first(); + } + + function test_last() { + shallowWrapper = shallowWrapper.last(); + } + + function test_state() { + shallowWrapper.state(); + shallowWrapper.state('key'); + } + + function test_props() { + objectVal = shallowWrapper.props(); + } + + function test_prop() { + shallowWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + shallowWrapper.simulate('click'); + shallowWrapper.simulate('click', args); + } + + function test_setState() { + shallowWrapper = shallowWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + shallowWrapper = shallowWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + shallowWrapper = shallowWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = shallowWrapper.instance(); + } + + function test_update() { + shallowWrapper = shallowWrapper.update(); + } + + function test_debug() { + stringVal = shallowWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = shallowWrapper.type(); + } + + function test_forEach() { + shallowWrapper = + shallowWrapper.forEach((aShallowWrapper: ShallowWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + shallowWrapper.map((aShallowWrapper: ShallowWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + shallowWrapper.reduce( + (amount: number, n: ShallowWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + shallowWrapper.reduceRight( + (amount: number, n: ShallowWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = shallowWrapper.some('.selector'); + boolVal = shallowWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = shallowWrapper.someWhere((aShallowWrapper: ShallowWrapper) => true); + } + + function test_every() { + boolVal = shallowWrapper.every('.selector'); + boolVal = shallowWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper) => true); + } +} + + +// ReactWrapper +module ReactWrapperTest { + var reactWrapper: ReactWrapper = + mount(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + reactWrapper = reactWrapper.find('.selector'); + reactWrapper = reactWrapper.find(MyComponent); + } + + function test_findWhere() { + reactWrapper = + reactWrapper.findWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_filter() { + reactWrapper = reactWrapper.filter('.selector'); + reactWrapper = reactWrapper.filter(MyComponent); + } + + function test_filterWhere() { + reactWrapper = + reactWrapper.filterWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_contains() { + boolVal = reactWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = reactWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = reactWrapper.is('.some-class'); + } + + function test_not() { + reactWrapper = reactWrapper.find('.foo').not('.bar'); + } + + function test_children() { + reactWrapper = reactWrapper.children(); + } + + function test_parents() { + reactWrapper = reactWrapper.parents(); + } + + function test_parent() { + reactWrapper = reactWrapper.parent(); + } + + function test_closest() { + reactWrapper = reactWrapper.closest('.selector'); + reactWrapper = reactWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = reactWrapper.text(); + } + + function test_html() { + stringVal = reactWrapper.html(); + } + + function test_get() { + reactElement = reactWrapper.get(1); + } + + function test_at() { + reactWrapper = reactWrapper.at(1); + } + + function test_first() { + reactWrapper = reactWrapper.first(); + } + + function test_last() { + reactWrapper = reactWrapper.last(); + } + + function test_state() { + reactWrapper.state(); + reactWrapper.state('key'); + } + + function test_props() { + objectVal = reactWrapper.props(); + } + + function test_prop() { + reactWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + reactWrapper.simulate('click'); + reactWrapper.simulate('click', args); + } + + function test_setState() { + reactWrapper = reactWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + reactWrapper = reactWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + reactWrapper = reactWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = reactWrapper.instance(); + } + + function test_update() { + reactWrapper = reactWrapper.update(); + } + + function test_debug() { + stringVal = reactWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = reactWrapper.type(); + } + + function test_forEach() { + reactWrapper = + reactWrapper.forEach((aReactWrapper: ReactWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + reactWrapper.map((aReactWrapper: ReactWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + reactWrapper.reduce( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + reactWrapper.reduceRight( + (amount: number, n: ReactWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = reactWrapper.some('.selector'); + boolVal = reactWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = reactWrapper.someWhere((aReactWrapper: ReactWrapper) => true); + } + + function test_every() { + boolVal = reactWrapper.every('.selector'); + boolVal = reactWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper) => true); + } +} + +// CheerioWrapper +module CheerioWrapperTest { + var cheerioWrapper: CheerioWrapper = + render(); + + var reactElement: ReactElement, + objectVal: Object, + boolVal: Boolean, + stringVal: String; + + function test_find() { + cheerioWrapper = cheerioWrapper.find('.selector'); + cheerioWrapper = cheerioWrapper.find(MyComponent); + } + + function test_findWhere() { + cheerioWrapper = + cheerioWrapper.findWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_filter() { + cheerioWrapper = cheerioWrapper.filter('.selector'); + cheerioWrapper = cheerioWrapper.filter(MyComponent); + } + + function test_filterWhere() { + cheerioWrapper = + cheerioWrapper.filterWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_contains() { + boolVal = cheerioWrapper.contains(
        ); + } + + function test_hasClass() { + boolVal = cheerioWrapper.find('.my-button').hasClass('disabled'); + } + + function test_is() { + boolVal = cheerioWrapper.is('.some-class'); + } + + function test_not() { + cheerioWrapper = cheerioWrapper.find('.foo').not('.bar'); + } + + function test_children() { + cheerioWrapper = cheerioWrapper.children(); + } + + function test_parents() { + cheerioWrapper = cheerioWrapper.parents(); + } + + function test_parent() { + cheerioWrapper = cheerioWrapper.parent(); + } + + function test_closest() { + cheerioWrapper = cheerioWrapper.closest('.selector'); + cheerioWrapper = cheerioWrapper.closest(MyComponent); + } + + function test_text() { + stringVal = cheerioWrapper.text(); + } + + function test_html() { + stringVal = cheerioWrapper.html(); + } + + function test_get() { + reactElement = cheerioWrapper.get(1); + } + + function test_at() { + cheerioWrapper = cheerioWrapper.at(1); + } + + function test_first() { + cheerioWrapper = cheerioWrapper.first(); + } + + function test_last() { + cheerioWrapper = cheerioWrapper.last(); + } + + function test_state() { + cheerioWrapper.state(); + cheerioWrapper.state('key'); + } + + function test_props() { + objectVal = cheerioWrapper.props(); + } + + function test_prop() { + cheerioWrapper.prop('key'); + } + + + function test_simulate(...args: any[]) { + cheerioWrapper.simulate('click'); + cheerioWrapper.simulate('click', args); + } + + function test_setState() { + cheerioWrapper = cheerioWrapper.setState({stateProperty: 'state'}); + } + + function test_setProps() { + cheerioWrapper = cheerioWrapper.setProps({propsProperty: 'foo'}); + } + + function test_setContext() { + cheerioWrapper = cheerioWrapper.setContext({name: 'baz'}); + } + + function test_instance() { + var myComponent: MyComponent = cheerioWrapper.instance(); + } + + function test_update() { + cheerioWrapper = cheerioWrapper.update(); + } + + function test_debug() { + stringVal = cheerioWrapper.debug(); + } + + function test_type() { + var stringOrFunction: String|Function = cheerioWrapper.type(); + } + + function test_forEach() { + cheerioWrapper = + cheerioWrapper.forEach((aCheerioWrapper: CheerioWrapper)=> { + }); + } + + function test_map() { + var arrayVal: Array = + cheerioWrapper.map((aCheerioWrapper: CheerioWrapper)=> { + }); + } + + function test_reduce() { + const total: number[] = + cheerioWrapper.reduce( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_reduceRight() { + const total: number[] = + cheerioWrapper.reduceRight( + (amount: number, n: CheerioWrapper) => amount + n.prop('amount') + ); + } + + function test_some() { + boolVal = cheerioWrapper.some('.selector'); + boolVal = cheerioWrapper.some(MyComponent); + } + + function test_someWhere() { + boolVal = cheerioWrapper.someWhere((aCheerioWrapper: CheerioWrapper) => true); + } + + function test_every() { + boolVal = cheerioWrapper.every('.selector'); + boolVal = cheerioWrapper.every(MyComponent); + } + + function test_everyWhere() { + boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper) => true); + } +} diff --git a/enzyme/enzyme.d.ts b/enzyme/enzyme.d.ts new file mode 100644 index 000000000..dd0c996a7 --- /dev/null +++ b/enzyme/enzyme.d.ts @@ -0,0 +1,340 @@ +// Type definitions for Enzyme v1.2.0 +// Project: https://github.com/airbnb/enzyme +// Definitions by: Marian Palkus , Cap3 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "enzyme" { + + import {ReactElement, Component} from "react"; + + export class ElementClass extends Component { + } + + /** + * Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the + * following three categories: + * + * 1. A Valid CSS Selector + * 2. A React Component Constructor + * 3. A React Component's displayName + */ + export type EnzymeSelector = String | typeof ElementClass; + + interface CommonWrapper { + /** + * Find every node in the render tree that matches the provided selector. + * @param selector The selector to match. + */ + find(selector: EnzymeSelector): T; + + /** + * Finds every node in the render tree that returns true for the provided predicate function. + * @param predicate + */ + findWhere(predicate: (shallowWrapper: ShallowWrapper) => Boolean): T; + + /** + * Removes nodes in the current wrapper that do not match the provided selector. + * @param selector The selector to match. + */ + filter(selector: EnzymeSelector): T; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true. + * @param predicate + */ + filterWhere(predicate: (shallowWrapper: ShallowWrapper) => Boolean): T; + + /** + * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in. + * @param node + */ + contains(node: ReactElement): Boolean; + + /** + * Returns whether or not the current node has a className prop including the passed in class name. + * @param className + */ + hasClass(className: String): Boolean; + + /** + * Returns whether or not the current node matches a provided selector. + * @param selector + */ + is(selector: EnzymeSelector): Boolean; + + /** + * Returns a new wrapper with only the nodes of the current wrapper that don't match the provided selector. + * This method is effectively the negation or inverse of filter. + * @param selector + */ + not(selector: EnzymeSelector): T; + + /** + * Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector + * can be provided and it will filter the children by this selector. + * @param [selector] + */ + children(selector?: EnzymeSelector): T; + + /** + * Returns a wrapper around all of the parents/ancestors of the wrapper. Does not include the node in the + * current wrapper. Optionally, a selector can be provided and it will filter the parents by this selector. + * + * Note: can only be called on a wrapper of a single node. + * @param [selector] + */ + parents(selector?: EnzymeSelector): T; + + /** + * Returns a wrapper with the direct parent of the node in the current wrapper. + */ + parent(): T; + + /** + * Returns a wrapper of the first element that matches the selector by traversing up through the current node's + * ancestors in the tree, starting with itself. + * + * Note: can only be called on a wrapper of a single node. + * @param selector + */ + closest(selector: EnzymeSelector): T; + + /** + * Returns a string of the rendered text of the current render tree. This function should be looked at with + * skepticism if being used to test what the actual HTML output of the component will be. If that is what you + * would like to test, use enzyme's render function instead. + * + * Note: can only be called on a wrapper of a single node. + */ + text(): String; + + /** + * Returns a string of the rendered HTML markup of the current render tree. + * + * Note: can only be called on a wrapper of a single node. + */ + html(): String; + + /** + * Returns the node at a given index of the current wrapper. + * @param index + */ + get(index: number): ReactElement; + + /** + * Returns a wrapper around the node at a given index of the current wrapper. + * @param index + */ + at(index: number): T; + + /** + * Reduce the set of matched nodes to the first in the set. + */ + first(): T; + + /** + * Reduce the set of matched nodes to the last in the set. + */ + last(): T; + + /** + * Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value. + * @param [key] + */ + state(key?: String): any; + + /** + * Returns the props hash for the current node of the wrapper. + * + * NOTE: can only be called on a wrapper of a single node. + */ + props(): Object; + + /** + * Returns the prop value for the node of the current wrapper with the provided key. + * + * NOTE: can only be called on a wrapper of a single node. + * @param key + */ + prop(key: String): any; + + /** + * Simulate events. + * Returns itself. + * @param event + * @param args? + */ + simulate(event: String, ...args: any[]): T; + + /** + * A method to invoke setState() on the root component instance similar to how you might in the definition of + * the component, and re-renders. This method is useful for testing your component in hard to achieve states, + * however should be used sparingly. If possible, you should utilize your component's external API in order to + * get it into whatever state you want to test, in order to be as accurate of a test as possible. This is not + * always practical, however. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setState(state: S): T; + + /** + * A method that sets the props of the root component, and re-renders. Useful for when you are wanting to test + * how the component behaves over time with changing props. Calling this, for instance, will call the + * componentWillReceiveProps lifecycle method. + * + * Similar to setState, this method accepts a props object and will merge it in with the already existing props. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setProps(state: Object): T; + + /** + * A method that sets the context of the root component, and re-renders. Useful for when you are wanting to + * test how the component behaves over time with changing contexts. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + * @param state + */ + setContext(state: Object): T; + + /** + * Gets the instance of the component being rendered as the root node passed into shallow(). + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + instance(): Component; + + /** + * Forces a re-render. Useful to run before checking the render output if something external may be updating + * the state of the component somewhere. + * Returns itself. + * + * NOTE: can only be called on a wrapper instance that is also the root instance. + */ + update(): T; + + /** + * Returns an html-like string of the wrapper for debugging purposes. Useful to print out to the console when + * tests are not passing when you expect them to. + */ + debug(): String; + + /** + * Returns the type of the current node of this wrapper. If it's a composite component, this will be the + * component constructor. If it's native DOM node, it will be a string of the tag name. + * + * Note: can only be called on a wrapper of a single node. + */ + type(): String | Function; + + /** + * Iterates through each node of the current wrapper and executes the provided function with a wrapper around + * the corresponding node passed in as the first argument. + * + * Returns itself. + * @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first + * argument, and will be run with a context of the original instance. + */ + forEach(fn: (wrapper: ShallowWrapper) => void): T; + + /** + * Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map + * function. + * Returns an array of the returned values from the mapping function.. + * @param fn A mapping function to be run for every node in the collection, the results of which will be mapped + * to the returned array. Should expect a ShallowWrapper as the first argument, and will be run + * with a context of the original instance. + */ + map(fn: (wrapper: ShallowWrapper) => any): Array; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node + * is passed in as a ShallowWrapper, and is processed from left to right. + * @param fn + * @param initialValue + */ + reduce(fn: (prevVal: R, wrapper: ShallowWrapper, index: number) => R, initialValue?: R): R[]; + + /** + * Applies the provided reducing function to every node in the wrapper to reduce to a single value. + * Each node is passed in as a ShallowWrapper, and is processed from right to left. + * @param fn + * @param initialValue + */ + reduceRight(fn: (prevVal: R, wrapper: ShallowWrapper, index: number) => R, initialValue?: R): R[]; + + /** + * Returns whether or not any of the nodes in the wrapper match the provided selector. + * @param selector + */ + some(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + someWhere(fn: (wrapper: ShallowWrapper) => Boolean): Boolean; + + /** + * Returns whether or not all of the nodes in the wrapper match the provided selector. + * @param selector + */ + every(selector: EnzymeSelector): Boolean; + + /** + * Returns whether or not any of the nodes in the wrapper pass the provided predicate function. + * @param fn + */ + everyWhere(fn: (wrapper: ShallowWrapper) => Boolean): Boolean; + + length: number; + } + + export interface ShallowWrapper extends CommonWrapper, P, S> { + shallow(): ShallowWrapper; + + render(): CheerioWrapper; + } + + export interface ReactWrapper extends CommonWrapper, P, S> { + + } + + export interface CheerioWrapper extends CommonWrapper, P, S> { + + } + + /** + * Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that + * your tests aren't indirectly asserting on behavior of child components. + * @param node + * @param [options] + */ + export function shallow(node: ReactElement

        , options?: any): ShallowWrapper; + + /** + * Mounts and renders a react component into the document and provides a testing wrapper around it. + * @param node + * @param [options] + */ + export function mount(node: ReactElement

        , options?: any): ReactWrapper; + + /** + * Render react components to static HTML and analyze the resulting HTML structure. + * @param node + * @param [options] + */ + export function render(node: ReactElement

        , options?: any): CheerioWrapper; + + export function describeWithDOM(description: String, fn: Function): void; + + export function spyLifecycle(component: typeof Component): void; +} \ No newline at end of file From b0170d98761af9f6b66743c36723497ea75d0633 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 18 Dec 2015 19:30:50 +0500 Subject: [PATCH 060/128] lodash: signatures of _.isObject have been changed --- lodash/lodash-tests.ts | 22 ++++++++++++++++++---- lodash/lodash.d.ts | 10 +++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index d661839d5..f29c10e4f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -5657,10 +5657,24 @@ result = _({}).isNumber(); } // _.isObject -result = _.isObject(any); -result = _(1).isObject(); -result = _([]).isObject(); -result = _({}).isObject(); +module TestIsObject { + { + let result: boolean; + + result = _.isObject(any); + result = _(1).isObject(); + result = _([]).isObject(); + result = _({}).isObject(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isObject(); + result = _([]).chain().isObject(); + result = _({}).chain().isObject(); + } +} // _.isPlainObject result = _.isPlainObject(any); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4e86afb66..bd2955462 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -9582,9 +9582,10 @@ declare module _ { /** * Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), * and new String('')) + * * @param value The value to check. * @return Returns true if value is an object, else false. - **/ + */ isObject(value?: any): boolean; } @@ -9595,6 +9596,13 @@ declare module _ { isObject(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * see _.isObject + */ + isObject(): LoDashExplicitWrapper; + } + //_.isPlainObject interface LoDashStatic { /** From 3a25247cd52c5814253a24b620344e9ec33c6109 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 18 Dec 2015 15:44:58 +0100 Subject: [PATCH 061/128] Definition for prettyjson package added --- prettyjson/prettyjson-tests.ts | 18 +++++++++++ prettyjson/prettyjson.d.ts | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 prettyjson/prettyjson-tests.ts create mode 100644 prettyjson/prettyjson.d.ts diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts new file mode 100644 index 000000000..da82686e1 --- /dev/null +++ b/prettyjson/prettyjson-tests.ts @@ -0,0 +1,18 @@ +/// + +var options: prettyjson.IOptions, + input: string, + output: string; + + +input = 'This is a string'; +output = prettyjson.render(input); + +output = prettyjson.render(input, {}, 4); + +output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']); + +output = prettyjson.render({param1: 'first string', param2: 'second string'}); + +output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); + diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts new file mode 100644 index 000000000..43dbf133c --- /dev/null +++ b/prettyjson/prettyjson.d.ts @@ -0,0 +1,55 @@ +// Type definitions for prettyjson +// Project: https://github.com/rafeca/prettyjson +// Definitions by: Wael BEN ZID EL GUEBSI +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +declare module "prettyjson" { + + /** + * Defines prettyjson version + */ + export var version: string; + + /** + * Render pretty json. + * + * @param data {Object} Data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function render(data: Object, options?: IOptions, indentation?: number): string; + + /** + * Render pretty json from a string. + * + * @param data {string} Serialized JSON data to prettify. + * @param options {IOptions} Hash with different options to configure the renderer. + * @param indentation {number} Indentation size. + * + * @return {string} pretty serialized json data ready to display. + */ + export function renderString(data: string, options?: IOptions, indentation?: number): string; + + export interface IOptions { + + /** + * Define behavior for Array objects + */ + emptyArrayMsg ?: string; // default: (empty) + inlineArrays ?: boolean; + + /** + * Color definition + */ + noColor ?: boolean; + keysColor ?: string; + dashColor ?: string; + numberColor ?: string; + stringColor ?: string; + + defaultIndentation ?: number; + } +} From 1a7703a16ced73453adf4b1e5f858af3a399d610 Mon Sep 17 00:00:00 2001 From: WAEL BEN ZID Date: Fri, 18 Dec 2015 15:50:24 +0100 Subject: [PATCH 062/128] Files published in the wrong branch removed --- prettyjson/prettyjson-tests.ts | 18 ----------- prettyjson/prettyjson.d.ts | 55 ---------------------------------- 2 files changed, 73 deletions(-) delete mode 100644 prettyjson/prettyjson-tests.ts delete mode 100644 prettyjson/prettyjson.d.ts diff --git a/prettyjson/prettyjson-tests.ts b/prettyjson/prettyjson-tests.ts deleted file mode 100644 index da82686e1..000000000 --- a/prettyjson/prettyjson-tests.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -var options: prettyjson.IOptions, - input: string, - output: string; - - -input = 'This is a string'; -output = prettyjson.render(input); - -output = prettyjson.render(input, {}, 4); - -output = prettyjson.render(['first string', ['nested 1', 'nested 2'], 'second string']); - -output = prettyjson.render({param1: 'first string', param2: 'second string'}); - -output = prettyjson.render({first_param: {subparam: 'first string', subparam2: 'another string'}, second_param: 'second string'}); - diff --git a/prettyjson/prettyjson.d.ts b/prettyjson/prettyjson.d.ts deleted file mode 100644 index 43dbf133c..000000000 --- a/prettyjson/prettyjson.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Type definitions for prettyjson -// Project: https://github.com/rafeca/prettyjson -// Definitions by: Wael BEN ZID EL GUEBSI -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -declare module "prettyjson" { - - /** - * Defines prettyjson version - */ - export var version: string; - - /** - * Render pretty json. - * - * @param data {Object} Data to prettify. - * @param options {IOptions} Hash with different options to configure the renderer. - * @param indentation {number} Indentation size. - * - * @return {string} pretty serialized json data ready to display. - */ - export function render(data: Object, options?: IOptions, indentation?: number): string; - - /** - * Render pretty json from a string. - * - * @param data {string} Serialized JSON data to prettify. - * @param options {IOptions} Hash with different options to configure the renderer. - * @param indentation {number} Indentation size. - * - * @return {string} pretty serialized json data ready to display. - */ - export function renderString(data: string, options?: IOptions, indentation?: number): string; - - export interface IOptions { - - /** - * Define behavior for Array objects - */ - emptyArrayMsg ?: string; // default: (empty) - inlineArrays ?: boolean; - - /** - * Color definition - */ - noColor ?: boolean; - keysColor ?: string; - dashColor ?: string; - numberColor ?: string; - stringColor ?: string; - - defaultIndentation ?: number; - } -} From 33e3ab99b09c3c4b159868ed66db602792aecdec Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 16:10:09 +0100 Subject: [PATCH 063/128] "generators" is deprecated now. Use "Base" and "NamedBase" directly. --- yeoman-generator/yeoman-generator.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index b73037ea5..48fbd835c 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -205,6 +205,8 @@ declare module yo { var file: any; var assert: IAssert; var test: ITestHelper; + + // "generators" is deprecated module generators { export class NamedBase extends YeomanGeneratorBase implements INamedBase { @@ -215,6 +217,14 @@ declare module yo { static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; } } + + export class NamedBase extends YeomanGeneratorBase implements INamedBase { + constructor(args: string | string[], options: any); + } + + export class Base extends NamedBase implements IBase { + static extend(protoProps: IQueueProps, staticProps?: any): IYeomanGenerator; + } } declare module "yeoman-generator" { From b967242e17899029877c57e81f6e11b423ab6a2b Mon Sep 17 00:00:00 2001 From: Arthur Xavier Date: Fri, 18 Dec 2015 11:41:14 -0200 Subject: [PATCH 064/128] Add type definitions for lime-js Fix indentation and callback types --- lime-js/lime-js-tests.ts | 35 +++++++ lime-js/lime-js.d.ts | 200 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 lime-js/lime-js-tests.ts create mode 100644 lime-js/lime-js.d.ts diff --git a/lime-js/lime-js-tests.ts b/lime-js/lime-js-tests.ts new file mode 100644 index 000000000..aa73444b1 --- /dev/null +++ b/lime-js/lime-js-tests.ts @@ -0,0 +1,35 @@ +/// + +var transport = new Lime.WebSocketTransport(true); +var clientChannel = new Lime.ClientChannel(transport, true, true); + +clientChannel.onMessage = (m) => { + // message received callback +}; +clientChannel.onNotification = (n) => { + // notification received callback +}; +clientChannel.onCommand = (c) => { + // command received callback +}; + +transport.onOpen = () => { + var authentication: Lime.Authentication = new Lime.GuestAuthentication(); + Lime.ClientChannelExtensions.establishSession(clientChannel, "none", "none", "test@msging.net", authentication, "test", (err, session) => { + var message: Lime.Message = { + id: "123", + to: "someone@test.net", + type: "text/plain", + content: "Hello, world!" + }; + clientChannel.sendMessage(message); + }); +}; +transport.onClose = () => { + // transport closed callback +}; +transport.onError = (err) => { + // transport error callback +}; + +transport.open("ws://test.net"); diff --git a/lime-js/lime-js.d.ts b/lime-js/lime-js.d.ts new file mode 100644 index 000000000..7e26733d3 --- /dev/null +++ b/lime-js/lime-js.d.ts @@ -0,0 +1,200 @@ +// Type definitions for lime-js 0.0.3 +// Project: https://github.com/takenet/lime-js +// Definitions by: Arthur Xavier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace Lime { + + interface Envelope { + id?: string; + from?: string; + to?: string; + pp?: string; + metadata?: any; + } + interface Reason { + code: number; + description?: string; + } + + interface Message extends Envelope { + type: string; + content: any; + } + + interface Notification extends Envelope { + event: string; + reason?: Reason; + } + class NotificationEvent { + static accepted: string; + static validated: string; + static authorized: string; + static dispatched: string; + static received: string; + static consumed: string; + } + + interface Command extends Envelope { + uri?: string; + type?: string; + resource?: any; + method: string; + status?: string; + reason?: Reason; + } + class CommandMethod { + static get: string; + static set: string; + static delete: string; + static observe: string; + static subscribe: string; + } + class CommandStatus { + static success: string; + static failure: string; + } + + interface Session extends Envelope { + state: string; + encryptionOptions?: string[]; + encryption?: string; + compressionOptions?: string[]; + compression?: string; + scheme?: string; + authentication?: any; + reason?: Reason; + } + class SessionState { + static new: string; + static negotiating: string; + static authenticating: string; + static established: string; + static finishing: string; + static finished: string; + static failed: string; + } + class SessionEncryption { + static none: string; + static tls: string; + } + class SessionCompression { + static none: string; + static gzip: string; + } + + class Authentication { + scheme: string; + static guest: string; + static plain: string; + static transport: string; + static key: string; + } + class GuestAuthentication extends Authentication { + scheme: string; + } + class TransportAuthentication extends Authentication { + scheme: string; + } + class PlainAuthentication extends Authentication { + scheme: string; + password: string; + } + class KeyAuthentication extends Authentication { + scheme: string; + key: string; + } + + class Channel { + constructor(transport: Transport, autoReplyPings: boolean, autoNotifyReceipt: boolean); + sendMessage(message: Message): void; + onMessage(message: Message): void; + sendCommand(command: Command): void; + onCommand(command: Command): void; + sendNotification(notification: Notification): void; + onNotification(notification: Notification): void; + sendSession(session: Session): void; + onSession(session: Session): void; + transport: Transport; + remoteNode: string; + localNode: string; + sessionId: string; + state: string; + } + + class ClientChannel extends Channel { + constructor(transport: Transport, autoReplyPings?: boolean, autoNotifyReceipt?: boolean); + startNewSession(): void; + negotiateSession(sessionCompression: string, sessionEncryption: string): void; + authenticateSession(identity: string, authentication: Authentication, instance: string): void; + sendFinishingSession(): void; + onSessionNegotiating(session: Session): void; + onSessionAuthenticating(session: Session): void; + onSessionEstablished(session: Session): void; + onSessionFinished(session: Session): void; + onSessionFailed(session: Session): void; + } + + class ClientChannelExtensions { + static establishSession(clientChannel: ClientChannel, compression: string, encryption: string, identity: string, authentication: Authentication, instance: string, callback: (error: Error, session: Session) => any): void; + } + + interface IMessageChannel { + sendMessage(message: Message): void; + onMessage: (message: Message) => any; + } + interface ICommandChannel { + sendCommand(command: Command): void; + onCommand: (command: Command) => any; + } + interface INotificationChannel { + sendNotification(notification: Notification): void; + onNotification: (notification: Notification) => any; + } + interface ISessionChannel { + sendSession(session: Session): void; + onSession: (session: Session) => any; + } + interface ISessionListener { + (session: Session): void; + } + + interface Transport extends ITransportStateListener { + send(envelope: Envelope): void; + onEnvelope: (envelope: Envelope) => any; + open(uri: string): void; + close(): void; + getSupportedCompression(): string[]; + setCompression(compression: string): void; + compression: string; + getSupportedEncryption(): string[]; + setEncryption(encryption: string): void; + encryption: string; + } + interface ITransportEnvelopeListener { + (envelope: Envelope): void; + } + interface ITransportStateListener { + onOpen: () => void; + onClose: () => void; + onError: (error: string) => void; + } + + class WebSocketTransport implements Transport { + webSocket: WebSocket; + constructor(traceEnabled?: boolean); + send(envelope: Envelope): void; + onEnvelope(envelope: Envelope): void; + open(uri: string): void; + close(): void; + getSupportedCompression(): string[]; + setCompression(compression: string): void; + compression: string; + getSupportedEncryption(): string[]; + setEncryption(encryption: string): void; + encryption: string; + onOpen(): void; + onClose(): void; + onError(error: string): void; + } +} From d47ea42665b7131741e7a16b7c6affd690043818 Mon Sep 17 00:00:00 2001 From: lucyhe Date: Fri, 18 Dec 2015 10:37:09 -0500 Subject: [PATCH 065/128] Add optional status to UserProfile in freedom.d.ts User's can have a status, e.g. "FRIEND" or "LOCAL_INVITED_BY_REMOTE" --- freedom/freedom.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/freedom/freedom.d.ts b/freedom/freedom.d.ts index fa80a530c..c69b800e9 100644 --- a/freedom/freedom.d.ts +++ b/freedom/freedom.d.ts @@ -497,6 +497,7 @@ declare module freedom.Social { interface UserProfile { userId: string; name: string; + status?: number; url?: string; // Image URI (e.g. data:image/png;base64,adkwe329...) imageData?: string; From 2321f2da7738733f71a24ca5e9ec1b8153ced3e3 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 18 Dec 2015 17:05:26 +0100 Subject: [PATCH 066/128] Just use `any` instead of explicit types Inquirer also supports some other stuff like separator objects as choices. It gets too complicated to properly type it because its unclear what other stuff can be used as choices so I just use `any` now. --- yeoman-generator/yeoman-generator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yeoman-generator/yeoman-generator.d.ts b/yeoman-generator/yeoman-generator.d.ts index 48fbd835c..27e79943c 100644 --- a/yeoman-generator/yeoman-generator.d.ts +++ b/yeoman-generator/yeoman-generator.d.ts @@ -84,7 +84,7 @@ declare module yo { type?: string; name: string; message: string | ((answers: Object) => string); - choices?: string[] | IChoice[] | ((answers: Object) => (string[] | IChoice[])); + choices?: any[] | ((answers: Object) => any); default?: string | number | string[] | number[] | ((answers: Object) => (string | number | string[] | number[])); validate?: ((input: any) => boolean | string); filter?: ((input: any) => any); From 4676585cf173721c4df3602e00dc188b8bbf27f7 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 17:22:35 +0100 Subject: [PATCH 067/128] Remove trailing spaces --- errorhandler/errorhandler-tests.ts | 2 +- errorhandler/errorhandler.d.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/errorhandler/errorhandler-tests.ts b/errorhandler/errorhandler-tests.ts index 0ba9edb56..3b847f87f 100644 --- a/errorhandler/errorhandler-tests.ts +++ b/errorhandler/errorhandler-tests.ts @@ -14,4 +14,4 @@ app.use(errorhandler({ log: (err, str, req, res) => { const requestWasFresh = req && req.fresh; const responseContentType = res && res.contentType -}})) \ No newline at end of file +}})) diff --git a/errorhandler/errorhandler.d.ts b/errorhandler/errorhandler.d.ts index 8ae5e924c..f021f96c5 100644 --- a/errorhandler/errorhandler.d.ts +++ b/errorhandler/errorhandler.d.ts @@ -7,18 +7,18 @@ declare module "errorhandler" { import express = require('express'); - + function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler; - + namespace errorHandler { interface LoggingCallback { (err: Error, str: string, req: express.Request, res: express.Response): void; } - + interface Options { /** * Defaults to true. - * + * * Possible values: * true : Log errors using console.error(str). * false : Only send the error back in the response. @@ -27,6 +27,6 @@ declare module "errorhandler" { log: boolean | LoggingCallback; } } - + export = errorHandler; } From 7e47928c4d7717a576243c4ac4a2c0f66d80b07e Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 19:49:13 +0100 Subject: [PATCH 068/128] Switch to "import * as": more standard way to do --- api-error-handler/api-error-handler-tests.ts | 4 ++-- api-error-handler/api-error-handler.d.ts | 2 +- errorhandler/errorhandler-tests.ts | 5 +++-- errorhandler/errorhandler.d.ts | 2 +- http-errors/http-errors-tests.ts | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api-error-handler/api-error-handler-tests.ts b/api-error-handler/api-error-handler-tests.ts index 83df91e86..0d0ca85d9 100644 --- a/api-error-handler/api-error-handler-tests.ts +++ b/api-error-handler/api-error-handler-tests.ts @@ -1,7 +1,7 @@ /// -import errorHandler = require('api-error-handler'); -import express = require('express'); +import * as errorHandler from 'api-error-handler'; +import * as express from 'express'; var api = express.Router(); api.get('/users/:userid', function (req, res, next) { diff --git a/api-error-handler/api-error-handler.d.ts b/api-error-handler/api-error-handler.d.ts index 61a63825d..d66aabf9b 100644 --- a/api-error-handler/api-error-handler.d.ts +++ b/api-error-handler/api-error-handler.d.ts @@ -6,7 +6,7 @@ /// declare module 'api-error-handler' { - import express = require('express'); + import * as express from 'express'; function apiErrorHandler(options?: any): express.ErrorRequestHandler; diff --git a/errorhandler/errorhandler-tests.ts b/errorhandler/errorhandler-tests.ts index 3b847f87f..1316888e3 100644 --- a/errorhandler/errorhandler-tests.ts +++ b/errorhandler/errorhandler-tests.ts @@ -1,7 +1,8 @@ /// -import express = require('express'); -import errorhandler = require('errorhandler'); +import * as express from 'express'; +import * as errorhandler from 'errorhandler'; + var app = express(); app.use(errorhandler()); diff --git a/errorhandler/errorhandler.d.ts b/errorhandler/errorhandler.d.ts index f021f96c5..37d5c3c41 100644 --- a/errorhandler/errorhandler.d.ts +++ b/errorhandler/errorhandler.d.ts @@ -6,7 +6,7 @@ /// declare module "errorhandler" { - import express = require('express'); + import * as express from 'express'; function errorHandler(options?: errorHandler.Options): express.ErrorRequestHandler; diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index 06b91f13b..9ee89d6a6 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -1,8 +1,8 @@ /// /// -import createError = require('http-errors'); -import express = require('express'); +import * as createError from 'http-errors'; +import * as express from 'express'; var app = express(); From 9c25433c84251bfe72bf0030a95edbbb2c81c9d5 Mon Sep 17 00:00:00 2001 From: Matt Wistrand Date: Fri, 18 Dec 2015 16:00:21 -0600 Subject: [PATCH 069/128] Update Chai typings to v3.4.0. v3.3.0 introduces the following methods: * isNotTrue * isNotFalse * isAtLeast * isAtMost v3.4.0 introduces: * oneOf assertion. * approximately alias for closeTo. --- chai/chai-3.2.0.d.ts | 388 +++++++++++++++++++++++++++++++++++++++++++ chai/chai-tests.ts | 98 +++++++++++ chai/chai.d.ts | 23 ++- 3 files changed, 504 insertions(+), 5 deletions(-) create mode 100644 chai/chai-3.2.0.d.ts diff --git a/chai/chai-3.2.0.d.ts b/chai/chai-3.2.0.d.ts new file mode 100644 index 000000000..e68e6fa3b --- /dev/null +++ b/chai/chai-3.2.0.d.ts @@ -0,0 +1,388 @@ +// Type definitions for chai 3.2.0 +// Project: http://chaijs.com/ +// Definitions by: Jed Mao , +// Bart van der Schoor , +// Andrew Brown , +// Olivier Chevet +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// + +declare module Chai { + + interface ChaiStatic { + expect: ExpectStatic; + should(): Should; + /** + * Provides a way to extend the internals of Chai + */ + use(fn: (chai: any, utils: any) => void): any; + assert: AssertStatic; + config: Config; + AssertionError: typeof AssertionError; + } + + export interface ExpectStatic extends AssertionStatic { + fail(actual?: any, expected?: any, message?: string, operator?: string): void; + } + + export interface AssertStatic extends Assert { + } + + export interface AssertionStatic { + (target: any, message?: string): Assertion; + } + + interface ShouldAssertion { + equal(value1: any, value2: any, message?: string): void; + Throw: ShouldThrow; + throw: ShouldThrow; + exist(value: any, message?: string): void; + } + + interface Should extends ShouldAssertion { + not: ShouldAssertion; + fail(actual: any, expected: any, message?: string, operator?: string): void; + } + + interface ShouldThrow { + (actual: Function): void; + (actual: Function, expected: string|RegExp, message?: string): void; + (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; + } + + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + not: Assertion; + deep: Deep; + any: KeyFilter; + all: KeyFilter; + a: TypeComparison; + an: TypeComparison; + include: Include; + includes: Include; + contain: Include; + contains: Include; + ok: Assertion; + true: Assertion; + false: Assertion; + null: Assertion; + undefined: Assertion; + NaN: Assertion; + exist: Assertion; + empty: Assertion; + arguments: Assertion; + Arguments: Assertion; + equal: Equal; + equals: Equal; + eq: Equal; + eql: Equal; + eqls: Equal; + property: Property; + ownProperty: OwnProperty; + haveOwnProperty: OwnProperty; + ownPropertyDescriptor: OwnPropertyDescriptor; + haveOwnPropertyDescriptor: OwnPropertyDescriptor; + length: Length; + lengthOf: Length; + match: Match; + matches: Match; + string(string: string, message?: string): Assertion; + keys: Keys; + key(string: string): Assertion; + throw: Throw; + throws: Throw; + Throw: Throw; + respondTo: RespondTo; + respondsTo: RespondTo; + itself: Assertion; + satisfy: Satisfy; + satisfies: Satisfy; + closeTo(expected: number, delta: number, message?: string): Assertion; + members: Members; + increase: PropertyChange; + increases: PropertyChange; + decrease: PropertyChange; + decreases: PropertyChange; + change: PropertyChange; + changes: PropertyChange; + extensible: Assertion; + sealed: Assertion; + frozen: Assertion; + + } + + interface LanguageChains { + to: Assertion; + be: Assertion; + been: Assertion; + is: Assertion; + that: Assertion; + which: Assertion; + and: Assertion; + has: Assertion; + have: Assertion; + with: Assertion; + at: Assertion; + of: Assertion; + same: Assertion; + } + + interface NumericComparison { + above: NumberComparer; + gt: NumberComparer; + greaterThan: NumberComparer; + least: NumberComparer; + gte: NumberComparer; + below: NumberComparer; + lt: NumberComparer; + lessThan: NumberComparer; + most: NumberComparer; + lte: NumberComparer; + within(start: number, finish: number, message?: string): Assertion; + } + + interface NumberComparer { + (value: number, message?: string): Assertion; + } + + interface TypeComparison { + (type: string, message?: string): Assertion; + instanceof: InstanceOf; + instanceOf: InstanceOf; + } + + interface InstanceOf { + (constructor: Object, message?: string): Assertion; + } + + interface Deep { + equal: Equal; + include: Include; + property: Property; + members: Members; + } + + interface KeyFilter { + keys: Keys; + } + + interface Equal { + (value: any, message?: string): Assertion; + } + + interface Property { + (name: string, value?: any, message?: string): Assertion; + } + + interface OwnProperty { + (name: string, message?: string): Assertion; + } + + interface OwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; + (name: string, message?: string): Assertion; + } + + interface Length extends LanguageChains, NumericComparison { + (length: number, message?: string): Assertion; + } + + interface Include { + (value: Object, message?: string): Assertion; + (value: string, message?: string): Assertion; + (value: number, message?: string): Assertion; + keys: Keys; + members: Members; + any: KeyFilter; + all: KeyFilter; + } + + interface Match { + (regexp: RegExp|string, message?: string): Assertion; + } + + interface Keys { + (...keys: string[]): Assertion; + (keys: any[]): Assertion; + (keys: Object): Assertion; + } + + interface Throw { + (): Assertion; + (expected: string, message?: string): Assertion; + (expected: RegExp, message?: string): Assertion; + (constructor: Error, expected?: string, message?: string): Assertion; + (constructor: Error, expected?: RegExp, message?: string): Assertion; + (constructor: Function, expected?: string, message?: string): Assertion; + (constructor: Function, expected?: RegExp, message?: string): Assertion; + } + + interface RespondTo { + (method: string, message?: string): Assertion; + } + + interface Satisfy { + (matcher: Function, message?: string): Assertion; + } + + interface Members { + (set: any[], message?: string): Assertion; + } + + interface PropertyChange { + (object: Object, prop: string, msg?: string): Assertion; + } + + export interface Assert { + /** + * @param expression Expression to test for truthiness. + * @param message Message to display on error. + */ + (expression: any, message?: string): void; + + fail(actual?: any, expected?: any, msg?: string, operator?: string): void; + + ok(val: any, msg?: string): void; + isOk(val: any, msg?: string): void; + notOk(val: any, msg?: string): void; + isNotOk(val: any, msg?: string): void; + + equal(act: any, exp: any, msg?: string): void; + notEqual(act: any, exp: any, msg?: string): void; + + strictEqual(act: any, exp: any, msg?: string): void; + notStrictEqual(act: any, exp: any, msg?: string): void; + + deepEqual(act: any, exp: any, msg?: string): void; + notDeepEqual(act: any, exp: any, msg?: string): void; + + isTrue(val: any, msg?: string): void; + isFalse(val: any, msg?: string): void; + + isNull(val: any, msg?: string): void; + isNotNull(val: any, msg?: string): void; + + isUndefined(val: any, msg?: string): void; + isDefined(val: any, msg?: string): void; + + isNaN(val: any, msg?: string): void; + isNotNaN(val: any, msg?: string): void; + + isAbove(val: number, abv: number, msg?: string): void; + isBelow(val: number, blw: number, msg?: string): void; + + isFunction(val: any, msg?: string): void; + isNotFunction(val: any, msg?: string): void; + + isObject(val: any, msg?: string): void; + isNotObject(val: any, msg?: string): void; + + isArray(val: any, msg?: string): void; + isNotArray(val: any, msg?: string): void; + + isString(val: any, msg?: string): void; + isNotString(val: any, msg?: string): void; + + isNumber(val: any, msg?: string): void; + isNotNumber(val: any, msg?: string): void; + + isBoolean(val: any, msg?: string): void; + isNotBoolean(val: any, msg?: string): void; + + typeOf(val: any, type: string, msg?: string): void; + notTypeOf(val: any, type: string, msg?: string): void; + + instanceOf(val: any, type: Function, msg?: string): void; + notInstanceOf(val: any, type: Function, msg?: string): void; + + include(exp: string, inc: any, msg?: string): void; + include(exp: any[], inc: any, msg?: string): void; + + notInclude(exp: string, inc: any, msg?: string): void; + notInclude(exp: any[], inc: any, msg?: string): void; + + match(exp: any, re: RegExp, msg?: string): void; + notMatch(exp: any, re: RegExp, msg?: string): void; + + property(obj: Object, prop: string, msg?: string): void; + notProperty(obj: Object, prop: string, msg?: string): void; + deepProperty(obj: Object, prop: string, msg?: string): void; + notDeepProperty(obj: Object, prop: string, msg?: string): void; + + propertyVal(obj: Object, prop: string, val: any, msg?: string): void; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; + + lengthOf(exp: any, len: number, msg?: string): void; + //alias frenzy + throw(fn: Function, msg?: string): void; + throw(fn: Function, regExp: RegExp): void; + throw(fn: Function, errType: Function, msg?: string): void; + throw(fn: Function, errType: Function, regExp: RegExp): void; + + throws(fn: Function, msg?: string): void; + throws(fn: Function, regExp: RegExp): void; + throws(fn: Function, errType: Function, msg?: string): void; + throws(fn: Function, errType: Function, regExp: RegExp): void; + + Throw(fn: Function, msg?: string): void; + Throw(fn: Function, regExp: RegExp): void; + Throw(fn: Function, errType: Function, msg?: string): void; + Throw(fn: Function, errType: Function, regExp: RegExp): void; + + doesNotThrow(fn: Function, msg?: string): void; + doesNotThrow(fn: Function, regExp: RegExp): void; + doesNotThrow(fn: Function, errType: Function, msg?: string): void; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; + + operator(val: any, operator: string, val2: any, msg?: string): void; + closeTo(act: number, exp: number, delta: number, msg?: string): void; + + sameMembers(set1: any[], set2: any[], msg?: string): void; + sameDeepMembers(set1: any[], set2: any[], msg?: string): void; + includeMembers(superset: any[], subset: any[], msg?: string): void; + + ifError(val: any, msg?: string): void; + + isExtensible(obj: {}, msg?: string): void; + extensible(obj: {}, msg?: string): void; + isNotExtensible(obj: {}, msg?: string): void; + notExtensible(obj: {}, msg?: string): void; + + isSealed(obj: {}, msg?: string): void; + sealed(obj: {}, msg?: string): void; + isNotSealed(obj: {}, msg?: string): void; + notSealed(obj: {}, msg?: string): void; + + isFrozen(obj: Object, msg?: string): void; + frozen(obj: Object, msg?: string): void; + isNotFrozen(obj: Object, msg?: string): void; + notFrozen(obj: Object, msg?: string): void; + + + } + + export interface Config { + includeStack: boolean; + } + + export class AssertionError { + constructor(message: string, _props?: any, ssf?: Function); + name: string; + message: string; + showDiff: boolean; + stack: string; + } +} + +declare var chai: Chai.ChaiStatic; + +declare module "chai" { + export = chai; +} + +interface Object { + should: Chai.Assertion; +} diff --git a/chai/chai-tests.ts b/chai/chai-tests.ts index 9b646b152..df09aea3e 100644 --- a/chai/chai-tests.ts +++ b/chai/chai-tests.ts @@ -1166,6 +1166,25 @@ function closeTo() { }, 'blah: expected -10 to be close to 20 +/- 29'); } +function approximately() { + expect(1.5).to.be.approximately(1.0, 0.5); + (1.5).should.be.approximately(1.0, 0.5); + expect(10).to.be.approximately(20, 20); + (10).should.be.approximately(20, 20); + expect(-10).to.be.approximately(20, 30); + (-10).should.be.approximately(20, 30); + + err(() => { + expect(2).to.be.approximately(1.0, 0.5, 'blah'); + (2).should.be.approximately(1.0, 0.5, 'blah'); + }, 'blah: expected 2 to be close to 1 +/- 0.5'); + + err(() => { + expect(-10).to.be.approximately(20, 29, 'blah'); + (-10).should.be.approximately(20, 29, 'blah'); + }, 'blah: expected -10 to be close to 20 +/- 29'); +} + function includeMembers() { expect([1, 2, 3]).to.include.members([]); [1, 2, 3].should.include.members([]); @@ -1255,6 +1274,20 @@ function increaseDecreaseChange() { same.should.not.change(obj, "val"); } +function oneOf() { + var obj = { z: 3 }; + + expect(5).to.be.oneOf([1, 5, 4]); + expect('z').to.be.oneOf(['x', 'y', 'z']); + expect(obj).to.be.oneOf([obj]); + + expect(5).to.not.be.oneOf([1, -12, 4]); + expect(5).to.not.be.oneOf([1, [5], 4]); + expect('z').to.not.be.oneOf(['w', 'x', 'y']); + expect('z').to.not.be.oneOf(['x', 'y', ['z']]); + expect(obj).to.not.be.oneOf([{ z: 3 }]); +} + //tdd declare function suite(description: string, action: Function): void; declare function test(description: string, action: Function): void; @@ -1879,6 +1912,20 @@ suite('assert', () => { }, 'expected -10 to be close to 20 +/- 29'); }); + test('approximately', () => { + assert.approximately(1.5, 1.0, 0.5); + assert.approximately(10, 20, 20); + assert.approximately(-10, 20, 30); + + err(() => { + assert.approximately(2, 1.0, 0.5); + }, 'expected 2 to be close to 1 +/- 0.5'); + + err(() => { + assert.approximately(-10, 20, 29); + }, 'expected -10 to be close to 20 +/- 29'); + }); + test('members', () => { assert.includeMembers([1, 2, 3], [2, 3]); assert.includeMembers([1, 2, 3], []); @@ -1945,4 +1992,55 @@ suite('assert', () => { test('notFrozen', () => { assert.notFrozen({}); }); test('isNotFrozen', () => { assert.isNotFrozen({}); }); + test('isNotTrue', () => { + assert.isNotTrue(false); + + err(() => { + assert.isNotTrue(true); + }, 'expected true to not be true'); + }); + + test('isNotFalse', () => { + assert.isNotFalse(true); + + err(() => { + assert.isNotFalse(false); + }, 'expected false to not be false'); + }); + + test('isAtLeast', () => { + assert.isAtLeast(5, 3); + assert.isAtLeast(5, 5); + + err(() => { + assert.isAtLeast(3, 5); + }, 'expected 3 to be greater than or equal to 5'); + }); + + test('isAtMost', () => { + assert.isAtMost(3, 5); + assert.isAtMost(5, 5); + + err(() => { + assert.isAtMost(5, 3); + }, 'expected 5 to be less than or equal to 3'); + }); + + test('oneOf', () => { + var obj = { z: 3 }; + + assert.oneOf(5, [1, 5, 4]); + assert.oneOf('z', ['x', 'y', 'z']); + assert.oneOf(obj, [obj]); + + err(() => { + assert.oneOf(5, [1, [5], 4]); + }, 'expected 5 to be one of [1, [5], 4]'); + err(() => { + assert.oneOf('z', ['w', 'x', 'y']); + }, 'expected "z" to be one of [w, x, y]'); + err(() => { + assert.oneOf(obj, [{ z: 3 }]); + }, 'expected { z: 3 } to be one of [{ z: 3 }]'); + }); }); diff --git a/chai/chai.d.ts b/chai/chai.d.ts index e68e6fa3b..074827b65 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -1,9 +1,10 @@ -// Type definitions for chai 3.2.0 +// Type definitions for chai 3.4.0 // Project: http://chaijs.com/ // Definitions by: Jed Mao , // Bart van der Schoor , // Andrew Brown , -// Olivier Chevet +// Olivier Chevet , +// Matt Wistrand // Definitions: https://github.com/borisyankov/DefinitelyTyped // @@ -97,7 +98,8 @@ declare module Chai { itself: Assertion; satisfy: Satisfy; satisfies: Satisfy; - closeTo(expected: number, delta: number, message?: string): Assertion; + closeTo: CloseTo; + approximately: CloseTo; members: Members; increase: PropertyChange; increases: PropertyChange; @@ -108,7 +110,7 @@ declare module Chai { extensible: Assertion; sealed: Assertion; frozen: Assertion; - + oneOf(list: any[], message?: string): Assertion; } interface LanguageChains { @@ -155,6 +157,10 @@ declare module Chai { (constructor: Object, message?: string): Assertion; } + interface CloseTo { + (expected: number, delta: number, message?: string): Assertion; + } + interface Deep { equal: Equal; include: Include; @@ -259,6 +265,9 @@ declare module Chai { isTrue(val: any, msg?: string): void; isFalse(val: any, msg?: string): void; + isNotTrue(val: any, msg?: string): void; + isNotFalse(val: any, msg?: string): void; + isNull(val: any, msg?: string): void; isNotNull(val: any, msg?: string): void; @@ -271,6 +280,9 @@ declare module Chai { isAbove(val: number, abv: number, msg?: string): void; isBelow(val: number, blw: number, msg?: string): void; + isAtLeast(val: number, atlst: number, msg?: string): void; + isAtMost(val: number, atmst: number, msg?: string): void; + isFunction(val: any, msg?: string): void; isNotFunction(val: any, msg?: string): void; @@ -339,6 +351,7 @@ declare module Chai { operator(val: any, operator: string, val2: any, msg?: string): void; closeTo(act: number, exp: number, delta: number, msg?: string): void; + approximately(act: number, exp: number, delta: number, msg?: string): void; sameMembers(set1: any[], set2: any[], msg?: string): void; sameDeepMembers(set1: any[], set2: any[], msg?: string): void; @@ -361,7 +374,7 @@ declare module Chai { isNotFrozen(obj: Object, msg?: string): void; notFrozen(obj: Object, msg?: string): void; - + oneOf(inList: any, list: any[], msg?: string): void; } export interface Config { From c6190204d5ae6aab5ac1744bf3cefb270e4cdf52 Mon Sep 17 00:00:00 2001 From: Tim Slatcher Date: Fri, 18 Dec 2015 22:45:39 +0000 Subject: [PATCH 070/128] Fix fixed-data-table typings, Column extends from React.Props so you can supply a key --- fixed-data-table/fixed-data-table-tests.tsx | 34 +++++++++------------ fixed-data-table/fixed-data-table.d.ts | 4 +-- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/fixed-data-table/fixed-data-table-tests.tsx b/fixed-data-table/fixed-data-table-tests.tsx index 916c0e64a..1f10a9fdb 100644 --- a/fixed-data-table/fixed-data-table-tests.tsx +++ b/fixed-data-table/fixed-data-table-tests.tsx @@ -143,26 +143,20 @@ class MyTable4 extends React.Component<{}, MyTable4State> { headerHeight={50} width={1000} height={500}> - Name} - cell={ - - } - width={200}/> - - Email} - cell={ - - } - width={200} - /> + { + ["name", "email"].map(field => + {field}} + cell={ + + } + width={200}/> + ) + } ); } diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index 5fb0438a0..219b7e39f 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -249,7 +249,7 @@ declare module FixedDataTable { /** * Component that defines the attributes of table column. */ - interface ColumnProps { + interface ColumnProps extends __React.Props { /** * The horizontal alignment of the table cell content. * @@ -498,4 +498,4 @@ declare module FixedDataTable { declare module "fixed-data-table" { export = FixedDataTable; -} \ No newline at end of file +} From 4b4c41fbb4a87a3721668f30040ada0a6e6ec3d3 Mon Sep 17 00:00:00 2001 From: Matt Wistrand Date: Fri, 18 Dec 2015 17:33:35 -0600 Subject: [PATCH 071/128] Add test file for chai-3.2.0.d.ts. --- chai/chai-3.2.0-tests.ts | 1948 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1948 insertions(+) create mode 100644 chai/chai-3.2.0-tests.ts diff --git a/chai/chai-3.2.0-tests.ts b/chai/chai-3.2.0-tests.ts new file mode 100644 index 000000000..9b646b152 --- /dev/null +++ b/chai/chai-3.2.0-tests.ts @@ -0,0 +1,1948 @@ +/// +import chai = require('chai'); + +// ReSharper disable WrongExpressionStatement + +var expect = chai.expect; +var assert = chai.assert; +var should = chai.should(); +declare var err: Function; + +function chaiVersion() { + expect(chai).to.have.property('version'); + (<{}>chai).should.have.property('version'); +} + +function assertion() { + expect('test').to.be.a('string'); + 'test'.should.be.a('string'); + expect('foo').to.equal('foo'); + 'foo'.should.equal('foo'); + should.equal('foo', 'foo'); +} + +function fail() { + err(() => { + should.fail('foo', 'bar'); + }, 'expected fail to throw an AssertionError'); + err(() => { + should.fail('foo', 'bar', 'should fail'); + }, 'expected fail to throw an AssertionError'); + err(() => { + should.fail('foo', 'bar', 'should fail', 'equal'); + }, 'expected fail to throw an AssertionError'); + + err(() => { + expect.fail('foo', 'bar'); + }, 'expected fail to throw an AssertionError'); + err(() => { + expect.fail('foo', 'bar', 'should fail'); + }, 'expected fail to throw an AssertionError'); + err(() => { + expect.fail('foo', 'bar', 'should fail', 'equal'); + }, 'expected fail to throw an AssertionError'); +} + +// ReSharper disable once InconsistentNaming +function _true() { + expect(true).to.be.true; + true.should.be.true; + expect(false).to.not.be.true; + false.should.not.be.true; + expect(1).to.not.be.true; + (1).should.not.be.true; + + err(() => { + expect('test').to.be.true; + 'test'.should.be.true; + }, 'expected \'test\' to be true'); +} + +function ok() { + expect(true).to.be.ok; + true.should.be.ok; + expect(false).to.not.be.ok; + false.should.not.be.ok; + expect(1).to.be.ok; + (1).should.be.ok; + expect(0).to.not.be.ok; + (0).should.not.be.ok; + + err(() => { + expect('').to.be.ok; + ''.should.be.ok; + }, 'expected \'\' to be truthy'); + + err(() => { + expect('test').to.not.be.ok; + 'test'.should.not.be.ok; + }, 'expected \'test\' to be falsy'); +} + +function _false() { + expect(false).to.be.false; + false.should.be.false; + expect(true).to.not.be.false; + true.should.not.be.false; + expect(0).to.not.be.false; + (0).should.not.be.false; + + err(() => { + expect('').to.be.false; + ''.should.be.false; + }, 'expected \'\' to be false'); +} + +function _null() { + expect(null).to.be.null; + should.equal(null, null); + expect(false).to.not.be.null; + false.should.not.be.null; + + err(() => { + expect('').to.be.null; + ''.should.be.null; + }, 'expected \'\' to be null'); +} + +function _undefined() { + expect(undefined).to.be.undefined; + should.equal(undefined, undefined); + expect(null).to.not.be.undefined; + should.not.equal(null, undefined); + + err(() => { + expect('').to.be.undefined; + ''.should.be.undefined; + }, 'expected \'\' to be undefined'); +} + +function _NaN() { + expect(NaN).to.be.NaN; + expect(12).to.be.not.NaN; + expect("NaN").to.be.not.NaN; + (NaN).should.be.NaN; + (12).should.be.not.NaN; + ("NaN").should.be.not.NaN; +} + +function exist() { + var foo = 'bar'; + expect(foo).to.exist; + should.exist(foo); + expect(void (0)).to.not.exist; + should.not.exist(void (0)); +} + +function argumentsTest() { + var args = arguments; + expect(args).to.be.arguments; + args.should.be.arguments; + expect([]).to.not.be.arguments; + [].should.not.be.arguments; + expect(args).to.be.an('arguments').and.be.arguments; + args.should.be.an('arguments').and.be.arguments; + expect([]).to.be.an('array').and.not.be.Arguments; + [].should.be.an('array').and.not.be.Arguments; +} + +function equal() { + expect(undefined).to.equal(void (0)); + should.equal(undefined, void (0)); +} + +function _typeof() { + expect('test').to.be.a('string'); + 'test'.should.be.a('string'); + + err(() => { + expect('test').to.not.be.a('string'); + 'test'.should.not.be.a('string'); + }, 'expected \'test\' not to be a string'); + + expect(arguments).to.be.an('arguments'); + arguments.should.be.an('arguments'); + + expect(5).to.be.a('number'); + (5).should.be.a('number'); + + expect(new Number(1)).to.be.a('number'); + (new Number(1)).should.be.a('number'); + expect(Number(1)).to.be.a('number'); + Number(1).should.be.a('number'); + expect(true).to.be.a('boolean'); + true.should.be.a('boolean'); + expect(new Array()).to.be.a('array'); + (new Array()).should.be.a('array'); + expect(new Object()).to.be.a('object'); + (new Object()).should.be.a('object'); + expect({}).to.be.a('object'); + ({}).should.be.a('object'); + expect([]).to.be.a('array'); + [].should.be.a('array'); + expect(() => { }).to.be.a('function'); + (() => { }).should.be.a('function'); + expect(null).to.be.a('null'); + // N.B. previous line has no should equivalent + + err(() => { + expect(5).to.not.be.a('number', 'blah'); + (5).should.not.be.a('number', 'blah'); + }, 'blah: expected 5 not to be a number'); +} + +class Foo { } +function _instanceof() { + expect(new Foo()).to.be.an.instanceof(Foo); + (new Foo()).should.be.an.instanceof(Foo); + + err(() => { + expect(3).to.an.instanceof(Foo, 'blah'); + (3).should.an.instanceof(Foo, 'blah'); + }, 'blah: expected 3 to be an instance of Foo'); +} + +function within() { + expect(5).to.be.within(5, 10); + (5).should.be.within(5, 10); + expect(5).to.be.within(3, 6); + (5).should.be.within(3, 6); + expect(5).to.be.within(3, 5); + (5).should.be.within(3, 5); + expect(5).to.not.be.within(1, 3); + (5).should.not.be.within(1, 3); + expect('foo').to.have.length.within(2, 4); + 'foo'.should.have.length.within(2, 4); + expect([1, 2, 3]).to.have.length.within(2, 4); + [1, 2, 3].should.have.length.within(2, 4); + + err(() => { + expect(5).to.not.be.within(4, 6, 'blah'); + (5).should.not.be.within(4, 6, 'blah'); + }, 'blah: expected 5 to not be within 4..6', 'blah'); + + err(() => { + expect(10).to.be.within(50, 100, 'blah'); + (10).should.be.within(50, 100, 'blah'); + }, 'blah: expected 10 to be within 50..100'); + + err(() => { + expect('foo').to.have.length.within(5, 7, 'blah'); + 'foo'.should.have.length.within(5, 7, 'blah'); + }, 'blah: expected \'foo\' to have a length within 5..7'); + + err(() => { + expect([1, 2, 3]).to.have.length.within(5, 7, 'blah'); + [1, 2, 3].should.have.length.within(5, 7, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length within 5..7'); +} + +function above() { + expect(5).to.be.above(2); + (5).should.be.above(2); + expect(5).to.be.greaterThan(2); + (5).should.be.greaterThan(2); + expect(5).to.not.be.above(5); + (5).should.not.be.above(5); + expect(5).to.not.be.above(6); + (5).should.not.be.above(6); + expect('foo').to.have.length.above(2); + 'foo'.should.have.length.above(2); + expect([1, 2, 3]).to.have.length.above(2); + [1, 2, 3].should.have.length.above(2); + + err(() => { + expect(5).to.be.above(6, 'blah'); + (5).should.be.above(6, 'blah'); + }, 'blah: expected 5 to be above 6', 'blah'); + + err(() => { + expect(10).to.not.be.above(6, 'blah'); + (10).should.not.be.above(6, 'blah'); + }, 'blah: expected 10 to be at most 6'); + + err(() => { + expect('foo').to.have.length.above(4, 'blah'); + 'foo'.should.have.length.above(4, 'blah'); + }, 'blah: expected \'foo\' to have a length above 4 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.above(4, 'blah'); + [1, 2, 3].should.have.length.above(4, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length above 4 but got 3'); +} + +function least() { + expect(5).to.be.at.least(2); + (5).should.be.at.least(2); + expect(5).to.be.at.least(5); + (5).should.be.at.least(5); + expect(5).to.not.be.at.least(6); + (5).should.not.be.at.least(6); + expect('foo').to.have.length.of.at.least(2); + 'foo'.should.have.length.of.at.least(2); + expect([1, 2, 3]).to.have.length.of.at.least(2); + [1, 2, 3].should.have.length.of.at.least(2); + + err(() => { + expect(5).to.be.at.least(6, 'blah'); + (5).should.be.at.least(6, 'blah'); + }, 'blah: expected 5 to be at least 6', 'blah'); + + err(() => { + expect(10).to.not.be.at.least(6, 'blah'); + (10).should.not.be.at.least(6, 'blah'); + }, 'blah: expected 10 to be below 6'); + + err(() => { + expect('foo').to.have.length.of.at.least(4, 'blah'); + 'foo'.should.have.length.of.at.least(4, 'blah'); + }, 'blah: expected \'foo\' to have a length at least 4 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.of.at.least(4, 'blah'); + [1, 2, 3].should.have.length.of.at.least(4, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length at least 4 but got 3'); + + err(() => { + expect([1, 2, 3, 4]).to.not.have.length.of.at.least(4, 'blah'); + [1, 2, 3, 4].should.not.have.length.of.at.least(4, 'blah'); + }, 'blah: expected [ 1, 2, 3, 4 ] to have a length below 4'); +} + +function below() { + expect(2).to.be.below(5); + (2).should.be.below(5); + expect(2).to.be.lessThan(5); + (2).should.be.lessThan(5); + expect(2).to.not.be.below(2); + (2).should.not.be.below(2); + expect(2).to.not.be.below(1); + (2).should.not.be.below(1); + expect('foo').to.have.length.below(4); + 'foo'.should.have.length.below(4); + expect([1, 2, 3]).to.have.length.below(4); + [1, 2, 3].should.have.length.below(4); + + err(() => { + expect(6).to.be.below(5, 'blah'); + (6).should.be.below(5, 'blah'); + }, 'blah: expected 6 to be below 5'); + + err(() => { + expect(6).to.not.be.below(10, 'blah'); + (6).should.not.be.below(10, 'blah'); + }, 'blah: expected 6 to be at least 10'); + + err(() => { + expect('foo').to.have.length.below(2, 'blah'); + 'foo'.should.have.length.below(2, 'blah'); + }, 'blah: expected \'foo\' to have a length below 2 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.below(2, 'blah'); + [1, 2, 3].should.have.length.below(2, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length below 2 but got 3'); +} + +function most() { + expect(2).to.be.at.most(5); + (2).should.be.at.most(5); + expect(2).to.be.at.most(2); + (2).should.be.at.most(2); + expect(2).to.not.be.at.most(1); + (2).should.not.be.at.most(1); + expect(2).to.not.be.at.most(1); + (2).should.not.be.at.most(1); + expect('foo').to.have.length.of.at.most(4); + 'foo'.should.have.length.of.at.most(4); + expect([1, 2, 3]).to.have.length.of.at.most(4); + [1, 2, 3].should.have.length.of.at.most(4); + + err(() => { + expect(6).to.be.at.most(5, 'blah'); + (6).should.be.at.most(5, 'blah'); + }, 'blah: expected 6 to be at most 5'); + + err(() => { + expect(6).to.not.be.at.most(10, 'blah'); + (6).should.not.be.at.most(10, 'blah'); + }, 'blah: expected 6 to be above 10'); + + err(() => { + expect('foo').to.have.length.of.at.most(2, 'blah'); + 'foo'.should.have.length.of.at.most(2, 'blah'); + }, 'blah: expected \'foo\' to have a length at most 2 but got 3'); + + err(() => { + expect([1, 2, 3]).to.have.length.of.at.most(2, 'blah'); + [1, 2, 3].should.have.length.of.at.most(2, 'blah'); + }, 'blah: expected [ 1, 2, 3 ] to have a length at most 2 but got 3'); + + err(() => { + expect([1, 2]).to.not.have.length.of.at.most(2, 'blah'); + [1, 2].should.not.have.length.of.at.most(2, 'blah'); + }, 'blah: expected [ 1, 2 ] to have a length above 2'); +} + +function match() { + expect('foobar').to.match(/^foo/); + 'foobar'.should.match(/^foo/); + expect('foobar').to.not.match(/^bar/); + 'foobar'.should.not.match(/^bar/); + + expect('foobar').matches(/^foo/); + 'foobar'.should.not.matches(/^bar/); + + err(() => { + expect('foobar').to.match(/^bar/i, 'blah'); + 'foobar'.should.match(/^bar/i, 'blah'); + }, 'blah: expected \'foobar\' to match /^bar/i'); + + err(() => { + expect('foobar').to.not.match(/^foo/i, 'blah'); + 'foobar'.should.not.match(/^foo/i, 'blah'); + }, 'blah: expected \'foobar\' not to match /^foo/i'); +} + +function length2() { + expect('test').to.have.length(4); + 'test'.should.have.length(4); + expect('test').to.not.have.length(3); + 'test'.should.not.have.length(3); + expect([1, 2, 3]).to.have.length(3); + [1, 2, 3].should.have.length(3); + + err(() => { + expect(4).to.have.length(3, 'blah'); + (4).should.have.length(3, 'blah'); + }, 'blah: expected 4 to have a property \'length\''); + + err(() => { + expect('asd').to.not.have.length(3, 'blah'); + 'asd'.should.not.have.length(3, 'blah'); + }, 'blah: expected \'asd\' to not have a length of 3'); +} + +function eql() { + expect('test').to.eql('test'); + 'test'.should.eql('test'); + expect({ foo: 'bar' }).to.eql({ foo: 'bar' }); + ({ foo: 'bar' }).should.eql({ foo: 'bar' }); + expect(1).to.eql(1); + (1).should.eql(1); + expect('4').to.not.eql(4); + '4'.should.not.eql(4); + + err(() => { + expect(4).to.eql(3, 'blah'); + (4).should.eql(3, 'blah'); + }, 'blah: expected 4 to deeply equal 3'); +} + +class Buffer { + constructor(arr: number[]) { + } +} +function buffer() { + expect(new Buffer([1])).to.eql(new Buffer([1])); + (new Buffer([1])).should.eql(new Buffer([1])); + + err(() => { + expect(new Buffer([0])).to.eql(new Buffer([1])); + (new Buffer([0])).should.eql(new Buffer([1])); + }, 'expected to deeply equal '); +} + +function equal2() { + expect('test').to.equal('test'); + 'test'.should.equal('test'); + should.equal('test', 'test'); + expect(1).to.equal(1); + (1).should.equal(1); + should.equal(1, 1); + + err(() => { + expect(4).to.equal(3, 'blah'); + (4).should.equal(3, 'blah'); + should.equal(4, 3, 'blah'); + }, 'blah: expected 4 to equal 3'); + + err(() => { + expect('4').to.equal(4, 'blah'); + '4'.should.equal(4, 'blah'); + should.equal(4, 4, 'blah'); + }, 'blah: expected \'4\' to equal 4'); +} + +function deepEqual() { + expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' }); + ({ foo: 'bar' }).should.deep.equal({ foo: 'bar' }); + expect({ foo: 'bar' }).not.to.deep.equal({ foo: 'baz' }); +} + +function deepEqual2() { + expect(/a/).to.deep.equal(/a/); + /a/.should.deep.equal(/a/); + expect(/a/).not.to.deep.equal(/b/); + expect(/a/).not.to.deep.equal({}); + expect(/a/g).to.deep.equal(/a/g); + /a/g.should.deep.equal(/a/g); + expect(/a/g).not.to.deep.equal(/b/g); + expect(/a/i).to.deep.equal(/a/i); + /a/i.should.deep.equal(/a/i); + expect(/a/i).not.to.deep.equal(/b/i); + expect(/a/m).to.deep.equal(/a/m); + /a/m.should.deep.equal(/a/m); + expect(/a/m).not.to.deep.equal(/b/m); +} + +// ReSharper disable once InconsistentNaming +function deepEqual3() { + var a = new Date(1, 2, 3); + var b = new Date(4, 5, 6); + expect(a).to.deep.equal(a); + a.should.deep.equal(a); + expect(a).not.to.deep.equal(b); + a.should.not.deep.equal(b); + expect(a).not.to.deep.equal({}); + a.should.not.deep.equal({}); +} + +function deepInclude() { + expect(['foo', 'bar']).to.deep.include(['bar', 'foo']); + ['foo', 'bar'].should.deep.include(['bar', 'foo']); + expect(['foo', 'bar']).not.to.deep.equal(['foo', 'baz']); + ['foo', 'bar'].should.not.deep.equal(['foo', 'baz']); +} + +class FakeArgs { + length: number; +} + +function empty() { + FakeArgs.prototype.length = 0; + + expect('').to.be.empty; + + ''.should.be.empty; + expect('foo').not.to.be.empty; + 'foo'.should.not.be.empty; + expect([]).to.be.empty; + [].should.be.empty; + expect(['foo']).not.to.be.empty; + ['foo'].should.not.be.empty; + expect(new FakeArgs).to.be.empty; + (new FakeArgs).should.be.empty; + expect({ arguments: 0 }).not.to.be.empty; + ({ arguments: 0 }).should.not.be.empty; + expect({}).to.be.empty; + ({}).should.be.empty; + expect({ foo: 'bar' }).not.to.be.empty; + ({ foo: 'bar' }).should.not.be.empty; + + err(() => { + expect('').not.to.be.empty; + ''.should.not.be.empty; + }, 'expected \'\' not to be empty'); + + err(() => { + expect('foo').to.be.empty; + 'foo'.should.be.empty; + 'foo'.should.be.empty; + }, 'expected \'foo\' to be empty'); + + err(() => { + expect([]).not.to.be.empty; + [].should.not.be.empty; + }, 'expected [] not to be empty'); + + err(() => { + expect(['foo']).to.be.empty; + ['foo'].should.be.empty; + }, 'expected [ \'foo\' ] to be empty'); + + err(() => { + expect(new FakeArgs).not.to.be.empty; + (new FakeArgs).should.not.be.empty; + }, 'expected { length: 0 } not to be empty'); + + err(() => { + expect({ arguments: 0 }).to.be.empty; + ({ arguments: 0 }).should.be.empty; + }, 'expected { arguments: 0 } to be empty'); + + err(() => { + expect({}).not.to.be.empty; + ({}).should.not.be.empty; + }, 'expected {} not to be empty'); + + err(() => { + expect({ foo: 'bar' }).to.be.empty; + ({ foo: 'bar' }).should.be.empty; + }, 'expected { foo: \'bar\' } to be empty'); +} + +function property() { + expect('test').to.have.property('length'); + 'test'.should.have.property('length'); + expect(4).to.not.have.property('length'); + (4).should.not.have.property('length'); + + expect({ 'foo.bar': 'baz' }) + .to.have.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should.have.property('foo.bar'); + expect({ foo: { bar: 'baz' } }) + .to.not.have.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should.not.have.property('foo.bar'); + + err(() => { + expect('asd').to.have.property('foo'); + 'asd'.should.have.property('foo'); + }, 'expected \'asd\' to have a property \'foo\''); + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.have.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should.have.property('foo.bar'); + }, 'expected { foo: { bar: \'baz\' } } to have a property \'foo.bar\''); +} + +function deepProperty() { + expect({ 'foo.bar': 'baz' }) + .to.not.have.deep.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should + .not.have.deep.property('foo.bar'); + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar'); + + err(() => { + expect({ 'foo.bar': 'baz' }) + .to.have.deep.property('foo.bar'); + ({ 'foo.bar': 'baz' }).should + .have.deep.property('foo.bar'); + }, 'expected { \'foo.bar\': \'baz\' } to have a deep property \'foo.bar\''); +} + +function property2() { + expect('test').to.have.property('length', 4); + 'test'.should.have.property('length', 4); + expect('asd').to.have.property('constructor', String); + 'asd'.should.have.property('constructor', String); + + err(() => { + expect('asd').to.have.property('length', 4, 'blah'); + 'asd'.should.have.property('length', 4, 'blah'); + }, 'blah: expected \'asd\' to have a property \'length\' of 4, but got 3'); + + err(() => { + expect('asd').to.not.have.property('length', 3, 'blah'); + 'asd'.should.not.have.property('length', 3, 'blah'); + }, 'blah: expected \'asd\' to not have a property \'length\' of 3'); + + err(() => { + expect('asd').to.not.have.property('foo', 3, 'blah'); + 'asd'.should.not.have.property('foo', 3, 'blah'); + }, 'blah: \'asd\' has no property \'foo\''); + + err(() => { + expect('asd').to.have.property('constructor', Number, 'blah'); + 'asd'.should.have.property('constructor', Number, 'blah'); + }, 'blah: expected \'asd\' to have a property \'constructor\' of [Function: Number], but got [Function: String]'); +} + +function deepProperty2() { + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar', 'baz'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar', 'baz'); + + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.have.deep.property('foo.bar', 'quux', 'blah'); + ({ foo: { bar: 'baz' } }).should + .have.deep.property('foo.bar', 'quux', 'blah'); + }, 'blah: expected { foo: { bar: \'baz\' } } to have a deep property \'foo.bar\' of \'quux\', but got \'baz\''); + err(() => { + expect({ foo: { bar: 'baz' } }) + .to.not.have.deep.property('foo.bar', 'baz', 'blah'); + ({ foo: { bar: 'baz' } }).should + .not.have.deep.property('foo.bar', 'baz', 'blah'); + }, 'blah: expected { foo: { bar: \'baz\' } } to not have a deep property \'foo.bar\' of \'baz\''); + err(() => { + expect({ foo: 5 }) + .to.not.have.deep.property('foo.bar', 'baz', 'blah'); + ({ foo: 5 }).should + .not.have.deep.property('foo.bar', 'baz', 'blah'); + }, 'blah: { foo: 5 } has no deep property \'foo.bar\''); +} + +function ownProperty() { + expect('test').to.have.ownProperty('length'); + 'test'.should.have.ownProperty('length'); + expect('test').to.haveOwnProperty('length'); + 'test'.should.haveOwnProperty('length'); + expect({ length: 12 }).to.have.ownProperty('length'); + ({ length: 12 }).should.have.ownProperty('length'); + + err(() => { + expect({ length: 12 }).to.not.have.ownProperty('length', 'blah'); + ({ length: 12 }).should.not.have.ownProperty('length', 'blah'); + }, 'blah: expected { length: 12 } to not have own property \'length\''); +} + +function ownPropertyDescriptor() { + expect('test').to.have.ownPropertyDescriptor('length'); + expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 }); + expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 }); + expect('test').to.haveOwnPropertyDescriptor('length').to.have.property('enumerable', false); + expect('test').to.haveOwnPropertyDescriptor('length').to.contain.keys('value'); + + 'test'.should.have.ownPropertyDescriptor('length'); + 'test'.should.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 }); + 'test'.should.not.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 }); + 'test'.should.haveOwnPropertyDescriptor('length').to.have.property('enumerable', false); + 'test'.should.haveOwnPropertyDescriptor('length').to.contain.keys('value'); +} + +function string() { + expect('foobar').to.have.string('bar'); + 'foobar'.should.have.string('bar'); + expect('foobar').to.have.string('foo'); + 'foobar'.should.have.string('foo'); + expect('foobar').to.not.have.string('baz'); + 'foobar'.should.not.have.string('baz'); + + err(() => { + expect(3).to.have.string('baz'); + (3).should.have.string('baz'); + }, 'expected 3 to be a string'); + + err(() => { + expect('foobar').to.have.string('baz', 'blah'); + 'foobar'.should.have.string('baz', 'blah'); + }, 'blah: expected \'foobar\' to contain \'baz\''); + + err(() => { + expect('foobar').to.not.have.string('bar', 'blah'); + 'foobar'.should.not.have.string('bar', 'blah'); + }, 'blah: expected \'foobar\' to not contain \'bar\''); +} + +function include() { + expect(['foo', 'bar']).to.include('foo'); + ['foo', 'bar'].should.include('foo'); + expect(['foo', 'bar']).to.include('foo'); + ['foo', 'bar'].should.include('foo'); + expect(['foo', 'bar']).to.include('bar'); + ['foo', 'bar'].should.include('bar'); + expect([1, 2]).to.include(1); + [1, 2].should.include(1); + expect(['foo', 'bar']).to.not.include('baz'); + ['foo', 'bar'].should.not.include('baz'); + expect(['foo', 'bar']).to.not.include(1); + ['foo', 'bar'].should.not.include(1); + // alias + + expect(['foo', 'bar']).includes('foo'); + ['foo', 'bar'].should.includes('foo'); + + err(() => { + expect(['foo']).to.include('bar', 'blah'); + ['foo'].should.include('bar', 'blah'); + }, 'blah: expected [ \'foo\' ] to include \'bar\''); + + err(() => { + expect(['bar', 'foo']).to.not.include('foo', 'blah'); + ['bar', 'foo'].should.not.include('foo', 'blah'); + }, 'blah: expected [ \'bar\', \'foo\' ] to not include \'foo\''); +} + +function keys() { + expect({ foo: 1 }).to.have.keys(['foo']); + ({ foo: 1 }).should.have.keys(['foo']); + expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']); + ({ foo: 1, bar: 2 }).should.have.keys(['foo', 'bar']); + expect({ foo: 1, bar: 2 }).to.have.keys('foo', 'bar'); + ({ foo: 1, bar: 2 }).should.have.keys('foo', 'bar'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('foo', 'bar'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('bar', 'foo'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('bar', 'foo'); + expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('baz'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.keys('baz'); + // alias + + expect({ foo: 1, bar: 2, baz: 3 }).contains.keys('baz'); + + expect({ foo: 1, bar: 2 }).to.have.all.keys(['foo', 'bar']); + expect({ foo: 1, bar: 2 }).to.have.any.keys(['foo', 'bar']); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.all.keys('baz'); + ({ foo: 1, bar: 2, baz: 3 }).should.contain.any.keys('baz'); + + expect({ foo: 1, bar: 2 }).to.contain.keys('foo'); + ({ foo: 1, bar: 2 }).should.contain.keys('foo'); + expect({ foo: 1, bar: 2 }).to.contain.keys('bar', 'foo'); + ({ foo: 1, bar: 2 }).should.contain.keys('bar', 'foo'); + expect({ foo: 1, bar: 2 }).to.contain.keys(['foo']); + ({ foo: 1, bar: 2 }).should.contain.keys(['foo']); + expect({ foo: 1, bar: 2 }).to.contain.keys(['bar']); + ({ foo: 1, bar: 2 }).should.contain.keys(['bar']); + expect({ foo: 1, bar: 2 }).to.contain.keys(['bar', 'foo']); + ({ foo: 1, bar: 2 }).should.contain.keys(['bar', 'foo']); + + expect({ foo: 1, bar: 2 }).to.not.have.keys('baz'); + ({ foo: 1, bar: 2 }).should.not.have.keys('baz'); + expect({ foo: 1, bar: 2 }).to.not.have.keys('foo', 'baz'); + ({ foo: 1, bar: 2 }).should.not.have.keys('foo', 'baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('foo', 'baz'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('foo', 'baz'); + expect({ foo: 1, bar: 2 }).to.not.contain.keys('baz', 'foo'); + ({ foo: 1, bar: 2 }).should.not.contain.keys('baz', 'foo'); + + err(() => { + expect({ foo: 1 }).to.have.keys(); + ({ foo: 1 }).should.have.keys(); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.have.keys([]); + ({ foo: 1 }).should.have.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.not.have.keys([]); + ({ foo: 1 }).should.not.have.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.contain.keys([]); + ({ foo: 1 }).should.contain.keys([]); + }, 'keys required'); + + err(() => { + expect({ foo: 1 }).to.have.keys(['bar']); + ({ foo: 1 }).should.have.keys(['bar']); + }, 'expected { foo: 1 } to have key \'bar\''); + + err(() => { + expect({ foo: 1 }).to.have.keys(['bar', 'baz']); + ({ foo: 1 }).should.have.keys(['bar', 'baz']); + }, 'expected { foo: 1 } to have keys \'bar\', and \'baz\''); + + err(() => { + expect({ foo: 1 }).to.have.keys(['foo', 'bar', 'baz']); + ({ foo: 1 }).should.have.keys(['foo', 'bar', 'baz']); + }, 'expected { foo: 1 } to have keys \'foo\', \'bar\', and \'baz\''); + + err(() => { + expect({ foo: 1 }).to.not.have.keys(['foo']); + ({ foo: 1 }).should.not.have.keys(['foo']); + }, 'expected { foo: 1 } to not have key \'foo\''); + + err(() => { + expect({ foo: 1 }).to.not.have.keys(['foo']); + ({ foo: 1 }).should.not.have.keys(['foo']); + }, 'expected { foo: 1 } to not have key \'foo\''); + + err(() => { + expect({ foo: 1, bar: 2 }).to.not.have.keys(['foo', 'bar']); + ({ foo: 1, bar: 2 }).should.not.have.keys(['foo', 'bar']); + }, 'expected { foo: 1, bar: 2 } to not have keys \'foo\', and \'bar\''); + + err(() => { + expect({ foo: 1 }).to.not.contain.keys(['foo']); + ({ foo: 1 }).should.not.contain.keys(['foo']); + }, 'expected { foo: 1 } to not contain key \'foo\''); + + err(() => { + expect({ foo: 1 }).to.contain.keys('foo', 'bar'); + ({ foo: 1 }).should.contain.keys('foo', 'bar'); + }, 'expected { foo: 1 } to contain keys \'foo\', and \'bar\''); +} + +function chaining() { + var tea = { name: 'chai', extras: ['milk', 'sugar', 'smile'] }; + expect(tea).to.have.property('extras').with.lengthOf(3); + tea.should.have.property('extras').with.lengthOf(3); + + err(() => { + expect(tea).to.have.property('extras').with.lengthOf(4); + tea.should.have.property('extras').with.lengthOf(4); + }, 'expected [ \'milk\', \'sugar\', \'smile\' ] to have a length of 4 but got 3'); + + expect(tea).to.be.a('object').and.have.property('name', 'chai'); + tea.should.be.a('object').and.have.property('name', 'chai'); +} + +function exxtensible() { + expect({}).to.be.extensible; + expect(Object.preventExtensions({})).to.be.not.extensible; + ({}).should.be.extensible; + Object.preventExtensions({}).should.not.be.extensible; +} +function sealed() { + expect({}).to.be.not.sealed; + expect(Object.seal({})).to.be.sealed; + ({}).should.be.not.sealed; + Object.seal({}).should.be.sealed; +} + +function frozen() { + expect({}).to.be.not.frozen; + expect(Object.freeze({})).to.be.frozen; + ({}).should.be.not.frozen; + Object.freeze({}).should.be.frozen; +} + + +class PoorlyConstructedError { } +function _throw() { + // See GH-45: some poorly-constructed custom errors don't have useful names + // on either their constructor or their constructor prototype, but instead + // only set the name inside the constructor itself. + PoorlyConstructedError.prototype = Object.create(Error.prototype); + + var specificError = new RangeError('boo'); + + var goodFn = () => { } + , badFn = () => { throw new Error('testing'); } + , refErrFn = () => { throw new ReferenceError('hello'); } + , ickyErrFn = () => { throw new PoorlyConstructedError(); } + , specificErrFn = () => { throw specificError; }; + + expect(goodFn).to.not.throw(); + goodFn.should.not.throw(); + should.not.throw(goodFn); + expect(goodFn).to.not.throw(Error); + goodFn.should.not.throw(Error); + should.not.throw(goodFn, Error); + expect(goodFn).to.not.throw(specificError); + goodFn.should.not.throw(specificError); + should.not.throw(goodFn, specificError); + + expect(badFn).to.throw(); + badFn.should.throw(); + should.throw(badFn); + expect(badFn).to.throw(Error); + badFn.should.throw(Error); + should.throw(badFn, Error); + expect(badFn).to.not.throw(ReferenceError); + badFn.should.not.throw(ReferenceError); + should.not.throw(badFn, ReferenceError); + expect(badFn).to.not.throw(specificError); + badFn.should.not.throw(specificError); + should.not.throw(badFn, specificError); + + expect(refErrFn).to.throw(); + refErrFn.should.throw(); + should.throw(refErrFn); + expect(refErrFn).to.throw(ReferenceError); + refErrFn.should.throw(ReferenceError); + should.throw(refErrFn, ReferenceError); + expect(refErrFn).to.throw(Error); + refErrFn.should.throw(Error); + should.throw(refErrFn, Error); + expect(refErrFn).to.not.throw(TypeError); + refErrFn.should.not.throw(TypeError); + should.not.throw(refErrFn, TypeError); + expect(refErrFn).to.not.throw(specificError); + refErrFn.should.not.throw(specificError); + should.not.throw(refErrFn, specificError); + + expect(ickyErrFn).to.throw(); + ickyErrFn.should.throw(); + should.throw(ickyErrFn); + expect(ickyErrFn).to.throw(PoorlyConstructedError); + ickyErrFn.should.throw(PoorlyConstructedError); + should.throw(ickyErrFn, PoorlyConstructedError); + expect(ickyErrFn).to.throw(Error); + ickyErrFn.should.throw(Error); + should.throw(ickyErrFn, Error); + expect(ickyErrFn).to.not.throw(specificError); + ickyErrFn.should.not.throw(specificError); + should.not.throw(ickyErrFn, specificError); + expect(specificErrFn).to.throw(specificError); + specificErrFn.should.throw(specificError); + should.throw(ickyErrFn, specificError); + + expect(badFn).to.throw(/testing/); + badFn.should.throw(/testing/); + should.throw(badFn, /testing/); + expect(badFn).to.not.throw(/hello/); + badFn.should.not.throw(/hello/); + should.not.throw(badFn, /hello/); + expect(badFn).to.throw('testing'); + badFn.should.throw('testing'); + should.throw(badFn, 'testing'); + expect(badFn).to.not.throw('hello'); + badFn.should.not.throw('hello'); + should.not.throw(badFn, 'hello'); + + expect(badFn).to.throw(Error, /testing/); + badFn.should.throw(Error, /testing/); + should.throw(badFn, Error, /testing/); + expect(badFn).to.throw(Error, 'testing'); + badFn.should.throw(Error, 'testing'); + should.throw(badFn, Error, 'testing'); + + err(() => { + expect(goodFn).to.throw(); + goodFn.should.throw(); + should.throw(goodFn); + }, 'expected [Function] to throw an error'); + + err(() => { + expect(goodFn).to.throw(ReferenceError); + goodFn.should.throw(ReferenceError); + should.throw(goodFn, ReferenceError); + }, 'expected [Function] to throw ReferenceError'); + + err(() => { + expect(goodFn).to.throw(specificError); + goodFn.should.throw(specificError); + should.throw(goodFn, specificError); + }, 'expected [Function] to throw [RangeError: boo]'); + + err(() => { + expect(badFn).to.not.throw(); + badFn.should.not.throw(); + should.not.throw(badFn); + }, 'expected [Function] to not throw an error but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.throw(ReferenceError); + badFn.should.throw(ReferenceError); + should.throw(badFn, ReferenceError); + }, 'expected [Function] to throw \'ReferenceError\' but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.throw(specificError); + badFn.should.throw(specificError); + should.throw(badFn, specificError); + }, 'expected [Function] to throw [RangeError: boo] but [Error: testing] was thrown'); + + err(() => { + expect(badFn).to.not.throw(Error); + badFn.should.not.throw(Error); + should.not.throw(badFn, Error); + }, 'expected [Function] to not throw \'Error\' but [Error: testing] was thrown'); + + err(() => { + expect(refErrFn).to.not.throw(ReferenceError); + refErrFn.should.not.throw(ReferenceError); + should.not.throw(refErrFn, ReferenceError); + }, 'expected [Function] to not throw \'ReferenceError\' but [ReferenceError: hello] was thrown'); + + err(() => { + expect(badFn).to.throw(PoorlyConstructedError); + badFn.should.throw(PoorlyConstructedError); + should.throw(badFn, PoorlyConstructedError); + }, 'expected [Function] to throw \'PoorlyConstructedError\' but [Error: testing] was thrown'); + + err(() => { + expect(ickyErrFn).to.not.throw(PoorlyConstructedError); + ickyErrFn.should.not.throw(PoorlyConstructedError); + should.not.throw(ickyErrFn, PoorlyConstructedError); + }, /^(expected \[Function\] to not throw 'PoorlyConstructedError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/); + + err(() => { + expect(ickyErrFn).to.throw(ReferenceError); + ickyErrFn.should.throw(ReferenceError); + should.throw(ickyErrFn, ReferenceError); + }, /^(expected \[Function\] to throw 'ReferenceError' but)(.*)(PoorlyConstructedError|\{ Object \()(.*)(was thrown)$/); + + err(() => { + expect(specificErrFn).to.throw(new ReferenceError('eek')); + specificErrFn.should.throw(new ReferenceError('eek')); + should.throw(specificErrFn, new ReferenceError('eek')); + }, 'expected [Function] to throw [ReferenceError: eek] but [RangeError: boo] was thrown'); + + err(() => { + expect(specificErrFn).to.not.throw(specificError); + specificErrFn.should.not.throw(specificError); + should.not.throw(specificErrFn, specificError); + }, 'expected [Function] to not throw [RangeError: boo]'); + + err(() => { + expect(badFn).to.not.throw(/testing/); + badFn.should.not.throw(/testing/); + should.not.throw(badFn, /testing/); + }, 'expected [Function] to throw error not matching /testing/'); + + err(() => { + expect(badFn).to.throw(/hello/); + badFn.should.throw(/hello/); + should.throw(badFn, /hello/); + }, 'expected [Function] to throw error matching /hello/ but got \'testing\''); + + err(() => { + expect(badFn).to.throw(Error, /hello/, 'blah'); + badFn.should.throw(Error, /hello/, 'blah'); + should.throw(badFn, Error, /hello/, 'blah'); + }, 'blah: expected [Function] to throw error matching /hello/ but got \'testing\''); + + err(() => { + expect(badFn).to.throw(Error, 'hello', 'blah'); + badFn.should.throw(Error, 'hello', 'blah'); + should.throw(badFn, Error, 'hello', 'blah'); + }, 'blah: expected [Function] to throw error including \'hello\' but got \'testing\''); +} + +function use() { + // ReSharper disable once InconsistentNaming + chai.use((_chai) => { + _chai.can.use.any(); + }); +} + +class Klass { + val: number; + constructor() { this.val = 0; } + bar() { } + + static baz() { } +} + +function respondTo() { + var obj = new Klass(); + + expect(Klass).to.respondTo('bar'); + expect(obj).respondsTo('bar'); + Klass.should.respondTo('bar'); + Klass.should.respondsTo('bar'); + expect(Klass).to.not.respondTo('foo'); + Klass.should.not.respondTo('foo'); + expect(Klass).itself.to.respondTo('func'); + expect(Klass).itself.not.to.respondTo('bar'); + + expect(obj).not.to.respondTo('foo'); + obj.should.not.respondTo('foo'); + + err(() => { + expect(Klass).to.respondTo('baz', 'constructor'); + Klass.should.respondTo('baz', 'constructor'); + }, /^(constructor: expected)(.*)(\[Function: Klass\])(.*)(to respond to \'baz\')$/); + + err(() => { + expect(obj).to.respondTo('baz', 'object'); + obj.should.respondTo('baz', 'object'); + }, /^(object: expected)(.*)(\{ foo: \[Function\] \}|\{ Object \()(.*)(to respond to \'baz\')$/); +} + +function satisfy() { + function matcher(num: number) { + return num === 1; + } + + expect(1).to.satisfy(matcher); + (1).should.satisfy(matcher); + + err(() => { + expect(2).to.satisfy(matcher, 'blah'); + (2).should.satisfy(matcher, 'blah'); + }, 'blah: expected 2 to satisfy [Function: matcher]'); +} + +function closeTo() { + expect(1.5).to.be.closeTo(1.0, 0.5); + (1.5).should.be.closeTo(1.0, 0.5); + expect(10).to.be.closeTo(20, 20); + (10).should.be.closeTo(20, 20); + expect(-10).to.be.closeTo(20, 30); + (-10).should.be.closeTo(20, 30); + + err(() => { + expect(2).to.be.closeTo(1.0, 0.5, 'blah'); + (2).should.be.closeTo(1.0, 0.5, 'blah'); + }, 'blah: expected 2 to be close to 1 +/- 0.5'); + + err(() => { + expect(-10).to.be.closeTo(20, 29, 'blah'); + (-10).should.be.closeTo(20, 29, 'blah'); + }, 'blah: expected -10 to be close to 20 +/- 29'); +} + +function includeMembers() { + expect([1, 2, 3]).to.include.members([]); + [1, 2, 3].should.include.members([]); + + expect([1, 2, 3]).to.include.members([3, 2]); + + [1, 2, 3].should.include.members([3, 2]); + + expect([1, 2, 3]).to.not.include.members([8, 4]); + + [1, 2, 3].should.not.include.members([8, 4]); + + expect([1, 2, 3]).to.not.include.members([1, 2, 3, 4]); + + [1, 2, 3].should.not.include.members([1, 2, 3, 4]); +} + +function sameMembers() { + expect([5, 4]).to.have.same.members([4, 5]); + [5, 4].should.have.same.members([4, 5]); + expect([5, 4]).to.have.same.members([5, 4]); + [5, 4].should.have.same.members([5, 4]); + + expect([5, 4]).to.not.have.same.members([]); + [5, 4].should.not.have.same.members([]); + expect([5, 4]).to.not.have.same.members([6, 3]); + [5, 4].should.not.have.same.members([6, 3]); + expect([5, 4]).to.not.have.same.members([5, 4, 2]); + [5, 4].should.not.have.same.members([5, 4, 2]); + + assert.sameMembers([5, 4], [4, 5]); +} +function sameDeepMembers() { + expect([{ id: 5 }, { id: 4 }]).to.have.same.deep.members([{ id: 4 }, { id: 5 }]); + [{ id: 5 }, { id: 4 }].should.have.same.deep.members([{ id: 4 }, { id: 5 }]); + expect([{ id: 5 }, { id: 4 }]).to.have.same.members([{ id: 5 }, { id: 4 }]); + [{ id: 5 }, { id: 4 }].should.have.same.members([{ id: 5 }, { id: 4 }]); + + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([]); + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([{ id: 6 }, { id: 3 }]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([{ id: 6 }, { id: 3 }]); + expect([{ id: 5 }, { id: 4 }]).to.not.have.same.members([{ id: 5 }, { id: 4 }, { id: 2 }]); + [{ id: 5 }, { id: 4 }].should.not.have.same.members([{ id: 5 }, { id: 4 }, { id: 2 }]); + + assert.sameDeepMembers([{ id: 5 }, { id: 4 }], [{ id: 4 }, { id: 5 }]); +} + +function members() { + expect([5, 4]).members([4, 5]); + expect([5, 4]).members([5, 4]); + + expect([5, 4]).not.members([]); + expect([5, 4]).not.members([6, 3]); + expect([5, 4]).not.members([5, 4, 2]); +} + +function increaseDecreaseChange() { + var obj = { val: 10 }; + var inc = () => { obj.val++; }; + var dec = () => { obj.val--; }; + var same = () => { }; + + expect(inc).to.increase(obj, "val"); + expect(inc).increases(obj, "val"); + expect(inc).to.change(obj, "val"); + + expect(dec).to.decrease(obj, "val"); + expect(dec).decreases(obj, "val"); + expect(dec).to.change(obj, "val"); + expect(dec).changes(obj, "val"); + + expect(inc).to.not.decrease(obj, "val"); + expect(dec).to.not.increase(obj, "val"); + expect(same).to.not.increase(obj, "val"); + expect(same).to.not.decrease(obj, "val"); + expect(same).to.not.change(obj, "val"); + + inc.should.increase(obj, "val"); + inc.should.change(obj, "val"); + + dec.should.decrease(obj, "val"); + dec.should.change(obj, "val"); + + inc.should.not.decrease(obj, "val"); + dec.should.not.increase(obj, "val"); + same.should.not.change(obj, "val"); +} + +//tdd +declare function suite(description: string, action: Function): void; +declare function test(description: string, action: Function): void; + +interface FieldObj { + field: any; +} + +class CrashyObject { + inspect(): void { + throw new Error('Arg\'s inspect() called even though the test passed'); + } +} + +suite('assert', () => { + + test('assert', () => { + var foo = 'bar'; + assert(foo === 'bar', 'expected foo to equal `bar`'); + + err(() => { + assert(foo === 'baz', 'expected foo to equal `bar`'); + }, 'expected foo to equal `bar`'); + }); + + test('isTrue', () => { + assert.isTrue(true); + + err(() => { + assert.isTrue(false); + }, 'expected false to be true'); + + err(() => { + assert.isTrue(1); + }, 'expected 1 to be true'); + + err(() => { + assert.isTrue('test'); + }, 'expected \'test\' to be true'); + }); + + test('ok', () => { + assert.ok(true); + assert.ok(1); + assert.ok('test'); + assert.isOk(true); + assert.isOk(1); + assert.isOk('test'); + + err(() => { + assert.ok(false); + }, 'expected false to be truthy'); + + err(() => { + assert.ok(0); + }, 'expected 0 to be truthy'); + + err(() => { + assert.ok(''); + }, 'expected \'\' to be truthy'); + }); + + test('notOk', () => { + assert.notOk(false); + assert.notOk(0); + assert.notOk(''); + assert.isNotOk(false); + assert.isNotOk(0); + assert.isNotOk(''); + + err(() => { + assert.notOk(true); + }, 'expected true to be falsy'); + + err(() => { + assert.notOk(1); + }, 'expected 1 to be falsy'); + + err(() => { + assert.notOk('test'); + }, 'expected \'test\' to be falsy'); + }); + + test('isFalse', () => { + assert.isFalse(false); + + err(() => { + assert.isFalse(true); + }, 'expected true to be false'); + + err(() => { + assert.isFalse(0); + }, 'expected 0 to be false'); + }); + + test('equal', () => { + assert.equal(void (0), undefined); + }); + + test('typeof / notTypeOf', () => { + assert.typeOf('test', 'string'); + assert.typeOf(true, 'boolean'); + assert.typeOf(5, 'number'); + + err(() => { + assert.typeOf(5, 'string'); + }, 'expected 5 to be a string'); + + }); + + test('notTypeOf', () => { + assert.notTypeOf('test', 'number'); + + err(() => { + assert.notTypeOf(5, 'number'); + }, 'expected 5 not to be a number'); + }); + + test('instanceOf', () => { + assert.instanceOf(new Foo(), Foo); + + err(() => { + assert.instanceOf(5, Foo); + }, 'expected 5 to be an instance of Foo'); + assert.instanceOf(new CrashyObject(), CrashyObject); + }); + + test('notInstanceOf', () => { + assert.notInstanceOf(new Foo(), String); + + err(() => { + assert.notInstanceOf(new Foo(), Foo); + }, 'expected {} to not be an instance of Foo'); + }); + + test('isObject', () => { + assert.isObject({}); + assert.isObject(new Foo()); + + err(() => { + assert.isObject(true); + }, 'expected true to be an object'); + + err(() => { + assert.isObject(Foo); + }, 'expected [Function: Foo] to be an object'); + + err(() => { + assert.isObject('foo'); + }, 'expected \'foo\' to be an object'); + }); + + test('isNotObject', () => { + assert.isNotObject(5); + + err(() => { + assert.isNotObject({}); + }, 'expected {} not to be an object'); + }); + + test('notEqual', () => { + assert.notEqual(3, 4); + + err(() => { + assert.notEqual(5, 5); + }, 'expected 5 to not equal 5'); + }); + + test('strictEqual', () => { + assert.strictEqual('foo', 'foo'); + + err(() => { + assert.strictEqual('5', 5); + }, 'expected \'5\' to equal 5'); + }); + + test('notStrictEqual', () => { + assert.notStrictEqual(5, '5'); + + err(() => { + assert.notStrictEqual(5, 5); + }, 'expected 5 to not equal 5'); + }); + + test('deepEqual', () => { + assert.deepEqual({ tea: 'chai' }, { tea: 'chai' }); + + err(() => { + assert.deepEqual({ tea: 'chai' }, { tea: 'black' }); + }, 'expected { tea: \'chai\' } to deeply equal { tea: \'black\' }'); + + var obja = Object.create({ tea: 'chai' }) + , objb = Object.create({ tea: 'chai' }); + + assert.deepEqual(obja, objb); + + var obj1 = Object.create({ tea: 'chai' }) + , obj2 = Object.create({ tea: 'black' }); + + err(() => { + assert.deepEqual(obj1, obj2); + }, 'expected { tea: \'chai\' } to deeply equal { tea: \'black\' }'); + }); + + test('deepEqual (ordering)', () => { + var a = { a: 'b', c: 'd' } + , b = { c: 'd', a: 'b' }; + assert.deepEqual(a, b); + }); + + test('deepEqual (circular)', () => { + var circularObject: any = {} + , secondCircularObject: any = {}; + circularObject.field = circularObject; + secondCircularObject.field = secondCircularObject; + + assert.deepEqual(circularObject, secondCircularObject); + + err(() => { + secondCircularObject.field2 = secondCircularObject; + assert.deepEqual(circularObject, secondCircularObject); + }, 'expected { field: [Circular] } to deeply equal { Object (field, field2) }'); + }); + + test('notDeepEqual', () => { + assert.notDeepEqual({ tea: 'jasmine' }, { tea: 'chai' }); + err(() => { + assert.notDeepEqual({ tea: 'chai' }, { tea: 'chai' }); + }, 'expected { tea: \'chai\' } to not deeply equal { tea: \'chai\' }'); + }); + + test('notDeepEqual (circular)', () => { + var circularObject: any = {} + , secondCircularObject: any = { tea: 'jasmine' }; + circularObject.field = circularObject; + secondCircularObject.field = secondCircularObject; + + assert.notDeepEqual(circularObject, secondCircularObject); + + err(() => { + delete secondCircularObject.tea; + assert.notDeepEqual(circularObject, secondCircularObject); + }, 'expected { field: [Circular] } to not deeply equal { field: [Circular] }'); + }); + + test('isNull', () => { + assert.isNull(null); + + err(() => { + assert.isNull(undefined); + }, 'expected undefined to equal null'); + }); + + test('isNotNull', () => { + assert.isNotNull(undefined); + + err(() => { + assert.isNotNull(null); + }, 'expected null to not equal null'); + }); + + test('isUndefined', () => { + assert.isUndefined(undefined); + + err(() => { + assert.isUndefined(null); + }, 'expected null to equal undefined'); + }); + + test('isDefined', () => { + assert.isDefined(null); + + err(() => { + assert.isDefined(undefined); + }, 'expected undefined to not equal undefined'); + }); + + test('isNaN', () => { + assert.isNaN(NaN); + + err(() => { + assert.isNaN(12); + }, 'expected 12 to be NaN'); + }); + + test('isNotNaN', () => { + assert.isNotNaN(12); + + err(() => { + assert.isNotNaN(NaN); + }, 'expected NaN to not NaN'); + }); + + test('isFunction', () => { + var func = () => { + }; + assert.isFunction(func); + + err(() => { + assert.isFunction({}); + }, 'expected {} to be a function'); + }); + + test('isNotFunction', () => { + assert.isNotFunction(5); + + err(() => { + assert.isNotFunction(() => { + }); + }, 'expected [Function] not to be a function'); + }); + + test('isArray', () => { + assert.isArray([]); + assert.isArray(new Array()); + + err(() => { + assert.isArray({}); + }, 'expected {} to be an array'); + }); + + test('isNotArray', () => { + assert.isNotArray(3); + + err(() => { + assert.isNotArray([]); + }, 'expected [] not to be an array'); + + err(() => { + assert.isNotArray(new Array()); + }, 'expected [] not to be an array'); + }); + + test('isString', () => { + assert.isString('Foo'); + assert.isString(new String('foo')); + + err(() => { + assert.isString(1); + }, 'expected 1 to be a string'); + }); + + test('isNotString', () => { + assert.isNotString(3); + assert.isNotString(['hello']); + + err(() => { + assert.isNotString('hello'); + }, 'expected \'hello\' not to be a string'); + }); + + test('isNumber', () => { + assert.isNumber(1); + assert.isNumber(Number('3')); + + err(() => { + assert.isNumber('1'); + }, 'expected \'1\' to be a number'); + }); + + test('isNotNumber', () => { + assert.isNotNumber('hello'); + assert.isNotNumber([5]); + + err(() => { + assert.isNotNumber(4); + }, 'expected 4 not to be a number'); + }); + + test('isBoolean', () => { + assert.isBoolean(true); + assert.isBoolean(false); + + err(() => { + assert.isBoolean('1'); + }, 'expected \'1\' to be a boolean'); + }); + + test('isNotBoolean', () => { + assert.isNotBoolean('true'); + + err(() => { + assert.isNotBoolean(true); + }, 'expected true not to be a boolean'); + + err(() => { + assert.isNotBoolean(false); + }, 'expected false not to be a boolean'); + }); + + test('include', () => { + assert.include('foobar', 'bar'); + assert.include([1, 2, 3], 3); + + err(() => { + assert.include('foobar', 'baz'); + }, 'expected \'foobar\' to contain \'baz\''); + + err(() => { + assert.include(undefined, 'bar'); + }, 'expected an array or string'); + }); + + test('notInclude', () => { + assert.notInclude('foobar', 'baz'); + assert.notInclude([1, 2, 3], 4); + + err(() => { + assert.notInclude('foobar', 'bar'); + }, 'expected \'foobar\' to not contain \'bar\''); + + err(() => { + assert.notInclude(undefined, 'bar'); + }, 'expected an array or string'); + }); + + test('lengthOf', () => { + assert.lengthOf([1, 2, 3], 3); + assert.lengthOf('foobar', 6); + + err(() => { + assert.lengthOf('foobar', 5); + }, 'expected \'foobar\' to have a length of 5 but got 6'); + + err(() => { + assert.lengthOf(1, 5); + }, 'expected 1 to have a property \'length\''); + }); + + test('match', () => { + assert.match('foobar', /^foo/); + assert.notMatch('foobar', /^bar/); + + err(() => { + assert.match('foobar', /^bar/i); + }, 'expected \'foobar\' to match /^bar/i'); + + err(() => { + assert.notMatch('foobar', /^foo/i); + }, 'expected \'foobar\' not to match /^foo/i'); + }); + + test('property', () => { + var obj = { foo: { bar: 'baz' } }; + var simpleObj = { foo: 'bar' }; + assert.property(obj, 'foo'); + assert.deepProperty(obj, 'foo.bar'); + assert.notProperty(obj, 'baz'); + assert.notProperty(obj, 'foo.bar'); + assert.notDeepProperty(obj, 'foo.baz'); + assert.deepPropertyVal(obj, 'foo.bar', 'baz'); + assert.deepPropertyNotVal(obj, 'foo.bar', 'flow'); + + err(() => { + assert.property(obj, 'baz'); + }, 'expected { foo: { bar: \'baz\' } } to have a property \'baz\''); + + err(() => { + assert.deepProperty(obj, 'foo.baz'); + }, 'expected { foo: { bar: \'baz\' } } to have a deep property \'foo.baz\''); + + err(() => { + assert.notProperty(obj, 'foo'); + }, 'expected { foo: { bar: \'baz\' } } to not have property \'foo\''); + + err(() => { + assert.notDeepProperty(obj, 'foo.bar'); + }, 'expected { foo: { bar: \'baz\' } } to not have deep property \'foo.bar\''); + + err(() => { + assert.propertyVal(simpleObj, 'foo', 'ball'); + }, 'expected { foo: \'bar\' } to have a property \'foo\' of \'ball\', but got \'bar\''); + + err(() => { + assert.deepPropertyVal(obj, 'foo.bar', 'ball'); + }, 'expected { foo: { bar: \'baz\' } } to have a deep property \'foo.bar\' of \'ball\', but got \'baz\''); + + err(() => { + assert.propertyNotVal(simpleObj, 'foo', 'bar'); + }, 'expected { foo: \'bar\' } to not have a property \'foo\' of \'bar\''); + + err(() => { + assert.deepPropertyNotVal(obj, 'foo.bar', 'baz'); + }, 'expected { foo: { bar: \'baz\' } } to not have a deep property \'foo.bar\' of \'baz\''); + }); + + test('throws', () => { + assert.throws(() => { + throw new Error('foo'); + }); + assert.throws(() => { + throw new Error('bar'); + }, 'bar'); + assert.throws(() => { + throw new Error('bar'); + }, /bar/); + assert.throws(() => { + throw new Error('bar'); + }, Error); + assert.throws(() => { + throw new Error('bar'); + }, Error, 'bar'); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, TypeError); + }, 'expected [Function] to throw \'TypeError\' but [Error: foo] was thrown'); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'foo\''); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, Error, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'foo\''); + + err(() => { + assert.throws(() => { + throw new Error('foo'); + }, TypeError, 'bar'); + }, 'expected [Function] to throw \'TypeError\' but [Error: foo] was thrown'); + + err(() => { + assert.throws(() => { + }); + }, 'expected [Function] to throw an error'); + + err(() => { + assert.throws(() => { + throw new Error(''); + }, 'bar'); + }, 'expected [Function] to throw error including \'bar\' but got \'\''); + + err(() => { + assert.throws(() => { + throw new Error(''); + }, /bar/); + }, 'expected [Function] to throw error matching /bar/ but got \'\''); + }); + + test('doesNotThrow', () => { + assert.doesNotThrow(() => { + }); + assert.doesNotThrow(() => { + }, 'foo'); + + err(() => { + assert.doesNotThrow(() => { + throw new Error('foo'); + }); + }, 'expected [Function] to not throw an error but [Error: foo] was thrown'); + }); + + test('ifError', () => { + assert.ifError(false); + assert.ifError(null); + assert.ifError(undefined); + + err(() => { + assert.ifError('foo'); + }, 'expected \'foo\' to be falsy'); + }); + + test('operator', () => { + assert.operator(1, '<', 2); + assert.operator(2, '>', 1); + assert.operator(1, '==', 1); + assert.operator(1, '<=', 1); + assert.operator(1, '>=', 1); + assert.operator(1, '!=', 2); + assert.operator(1, '!==', 2); + + err(() => { + assert.operator(1, '=', 2); + }, 'Invalid operator "="'); + + err(() => { + assert.operator(2, '<', 1); + }, 'expected 2 to be < 1'); + + err(() => { + assert.operator(1, '>', 2); + }, 'expected 1 to be > 2'); + + err(() => { + assert.operator(1, '==', 2); + }, 'expected 1 to be == 2'); + + err(() => { + assert.operator(2, '<=', 1); + }, 'expected 2 to be <= 1'); + + err(() => { + assert.operator(1, '>=', 2); + }, 'expected 1 to be >= 2'); + + err(() => { + assert.operator(1, '!=', 1); + }, 'expected 1 to be != 1'); + + err(() => { + assert.operator(1, '!==', '1'); + }, 'expected 1 to be !== \'1\''); + }); + + test('closeTo', () => { + assert.closeTo(1.5, 1.0, 0.5); + assert.closeTo(10, 20, 20); + assert.closeTo(-10, 20, 30); + + err(() => { + assert.closeTo(2, 1.0, 0.5); + }, 'expected 2 to be close to 1 +/- 0.5'); + + err(() => { + assert.closeTo(-10, 20, 29); + }, 'expected -10 to be close to 20 +/- 29'); + }); + + test('members', () => { + assert.includeMembers([1, 2, 3], [2, 3]); + assert.includeMembers([1, 2, 3], []); + assert.includeMembers([1, 2, 3], [3]); + + err(() => { + assert.includeMembers([5, 6], [7, 8]); + }, 'expected [ 5, 6 ] to be a superset of [ 7, 8 ]'); + + err(() => { + assert.includeMembers([5, 6], [5, 6, 0]); + }, 'expected [ 5, 6 ] to be a superset of [ 5, 6, 0 ]'); + }); + + test('memberEquals', () => { + assert.sameMembers([], []); + assert.sameMembers([1, 2, 3], [3, 2, 1]); + assert.sameMembers([4, 2], [4, 2]); + + err(() => { + assert.sameMembers([], [1, 2]); + }, 'expected [] to have the same members as [ 1, 2 ]'); + + err(() => { + assert.sameMembers([1, 54], [6, 1, 54]); + }, 'expected [ 1, 54 ] to have the same members as [ 6, 1, 54 ]'); + }); + + + test('isAbove', () => { + assert.isAbove(10, 5); + + err(() => { + assert.isAbove(1, 5); + }, 'expected 1 to be above 5'); + err(() => { + assert.isAbove(5, 5); + }, 'expected 5 to be above 5'); + }); + + test('isBelow', () => { + assert.isBelow(5, 10); + + err(() => { + assert.isBelow(5, 1); + }, 'expected 5 to be above 1'); + err(() => { + assert.isBelow(5, 5); + }, 'expected 5 to be below 5'); + }); + + test('extensible', () => { assert.extensible({}); }); + test('isExtensible', () => { assert.isExtensible({}); }); + test('notExtensible', () => { assert.notExtensible(Object.preventExtensions({})); }); + test('isNotExtensible', () => { assert.isNotExtensible(Object.preventExtensions({})); }); + + test('sealed', () => { assert.sealed(Object.seal({})); }); + test('isSealed', () => { assert.isSealed(Object.seal({})); }); + test('notSealed', () => { assert.notSealed({}); }); + test('isNotSealed', () => { assert.isNotSealed({}); }); + + test('frozen', () => { assert.frozen(Object.freeze({})); }); + test('isFrozen', () => { assert.isFrozen(Object.freeze({})); }); + test('notFrozen', () => { assert.notFrozen({}); }); + test('isNotFrozen', () => { assert.isNotFrozen({}); }); + +}); From e16ce4a79a83a6c31e90c8661903dc2c36ae511d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 19 Dec 2015 03:25:03 +0100 Subject: [PATCH 072/128] export HttpError thanks to a namespace --- http-errors/http-errors-tests.ts | 2 + http-errors/http-errors.d.ts | 156 ++++++++++++++++--------------- 2 files changed, 82 insertions(+), 76 deletions(-) diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index 9ee89d6a6..440325900 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -67,3 +67,5 @@ var err = new createError['404'](); //createError['404'](); // TypeScript should fail with "Did you mean to include 'new'?" //new createError(); // TypeScript should fail with "Only a void function can be called with the 'new' keyword" + +let error: createError.HttpError; diff --git a/http-errors/http-errors.d.ts b/http-errors/http-errors.d.ts index 6f78ff6a7..e15a7cb4e 100644 --- a/http-errors/http-errors.d.ts +++ b/http-errors/http-errors.d.ts @@ -4,82 +4,86 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'http-errors' { - interface HttpError extends Error { - status: number; - statusCode: number; - expose: boolean; + namespace createHttpError { + + // See https://github.com/jshttp/http-errors/blob/1.3.1/index.js#L42 + interface HttpError extends Error { + status: number; + statusCode: number; + expose: boolean; + } + + interface CreateHttpError { + // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 + [code: string]: new() => HttpError; + + (...args: Array): HttpError; + + Continue: new() => HttpError; + SwitchingProtocols: new() => HttpError; + Processing: new() => HttpError; + OK: new() => HttpError; + Created: new() => HttpError; + Accepted: new() => HttpError; + NonAuthoritativeInformation: new() => HttpError; + NoContent: new() => HttpError; + ResetContent: new() => HttpError; + PartialContent: new() => HttpError; + MultiStatus: new() => HttpError; + AlreadyReported: new() => HttpError; + IMUsed: new() => HttpError; + MultipleChoices: new() => HttpError; + MovedPermanently: new() => HttpError; + Found: new() => HttpError; + SeeOther: new() => HttpError; + NotModified: new() => HttpError; + UseProxy: new() => HttpError; + Unused: new() => HttpError; + TemporaryRedirect: new() => HttpError; + PermanentRedirect: new() => HttpError; + BadRequest: new() => HttpError; + Unauthorized: new() => HttpError; + PaymentRequired: new() => HttpError; + Forbidden: new() => HttpError; + NotFound: new() => HttpError; + MethodNotAllowed: new() => HttpError; + NotAcceptable: new() => HttpError; + ProxyAuthenticationRequired: new() => HttpError; + RequestTimeout: new() => HttpError; + Conflict: new() => HttpError; + Gone: new() => HttpError; + LengthRequired: new() => HttpError; + PreconditionFailed: new() => HttpError; + PayloadTooLarge: new() => HttpError; + URITooLong: new() => HttpError; + UnsupportedMediaType: new() => HttpError; + RangeNotSatisfiable: new() => HttpError; + ExpectationFailed: new() => HttpError; + ImATeapot: new() => HttpError; + UnprocessableEntity: new() => HttpError; + Locked: new() => HttpError; + FailedDependency: new() => HttpError; + UnorderedCollection: new() => HttpError; + UpgradeRequired: new() => HttpError; + PreconditionRequired: new() => HttpError; + TooManyRequests: new() => HttpError; + RequestHeaderFieldsTooLarge: new() => HttpError; + UnavailableForLegalReasons: new() => HttpError; + InternalServerError: new() => HttpError; + NotImplemented: new() => HttpError; + BadGateway: new() => HttpError; + ServiceUnavailable: new() => HttpError; + GatewayTimeout: new() => HttpError; + HTTPVersionNotSupported: new() => HttpError; + VariantAlsoNegotiates: new() => HttpError; + InsufficientStorage: new() => HttpError; + LoopDetected: new() => HttpError; + BandwidthLimitExceeded: new() => HttpError; + NotExtended: new() => HttpError; + NetworkAuthenticationRequired: new() => HttpError; + } } - interface CreateHttpError { - // See https://github.com/Microsoft/TypeScript/issues/227#issuecomment-50092674 - [code: string]: new() => HttpError; - - (...args: Array): HttpError; - - Continue: new() => HttpError; - SwitchingProtocols: new() => HttpError; - Processing: new() => HttpError; - OK: new() => HttpError; - Created: new() => HttpError; - Accepted: new() => HttpError; - NonAuthoritativeInformation: new() => HttpError; - NoContent: new() => HttpError; - ResetContent: new() => HttpError; - PartialContent: new() => HttpError; - MultiStatus: new() => HttpError; - AlreadyReported: new() => HttpError; - IMUsed: new() => HttpError; - MultipleChoices: new() => HttpError; - MovedPermanently: new() => HttpError; - Found: new() => HttpError; - SeeOther: new() => HttpError; - NotModified: new() => HttpError; - UseProxy: new() => HttpError; - Unused: new() => HttpError; - TemporaryRedirect: new() => HttpError; - PermanentRedirect: new() => HttpError; - BadRequest: new() => HttpError; - Unauthorized: new() => HttpError; - PaymentRequired: new() => HttpError; - Forbidden: new() => HttpError; - NotFound: new() => HttpError; - MethodNotAllowed: new() => HttpError; - NotAcceptable: new() => HttpError; - ProxyAuthenticationRequired: new() => HttpError; - RequestTimeout: new() => HttpError; - Conflict: new() => HttpError; - Gone: new() => HttpError; - LengthRequired: new() => HttpError; - PreconditionFailed: new() => HttpError; - PayloadTooLarge: new() => HttpError; - URITooLong: new() => HttpError; - UnsupportedMediaType: new() => HttpError; - RangeNotSatisfiable: new() => HttpError; - ExpectationFailed: new() => HttpError; - ImATeapot: new() => HttpError; - UnprocessableEntity: new() => HttpError; - Locked: new() => HttpError; - FailedDependency: new() => HttpError; - UnorderedCollection: new() => HttpError; - UpgradeRequired: new() => HttpError; - PreconditionRequired: new() => HttpError; - TooManyRequests: new() => HttpError; - RequestHeaderFieldsTooLarge: new() => HttpError; - UnavailableForLegalReasons: new() => HttpError; - InternalServerError: new() => HttpError; - NotImplemented: new() => HttpError; - BadGateway: new() => HttpError; - ServiceUnavailable: new() => HttpError; - GatewayTimeout: new() => HttpError; - HTTPVersionNotSupported: new() => HttpError; - VariantAlsoNegotiates: new() => HttpError; - InsufficientStorage: new() => HttpError; - LoopDetected: new() => HttpError; - BandwidthLimitExceeded: new() => HttpError; - NotExtended: new() => HttpError; - NetworkAuthenticationRequired: new() => HttpError; - } - - var httpError: CreateHttpError; - export = httpError; + var createHttpError: createHttpError.CreateHttpError; + export = createHttpError; } From b42e2a25b6e7f0314b7cc9ddd51638870e80c424 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Sat, 19 Dec 2015 03:26:50 +0100 Subject: [PATCH 073/128] export Response thanks to a namespace --- api-error-handler/api-error-handler-tests.ts | 2 ++ api-error-handler/api-error-handler.d.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/api-error-handler/api-error-handler-tests.ts b/api-error-handler/api-error-handler-tests.ts index 0d0ca85d9..fc92cf9a7 100644 --- a/api-error-handler/api-error-handler-tests.ts +++ b/api-error-handler/api-error-handler-tests.ts @@ -9,3 +9,5 @@ api.get('/users/:userid', function (req, res, next) { }); api.use(errorHandler()); + +let res: errorHandler.Response; diff --git a/api-error-handler/api-error-handler.d.ts b/api-error-handler/api-error-handler.d.ts index d66aabf9b..90318acd0 100644 --- a/api-error-handler/api-error-handler.d.ts +++ b/api-error-handler/api-error-handler.d.ts @@ -8,6 +8,22 @@ declare module 'api-error-handler' { import * as express from 'express'; + namespace apiErrorHandler { + + // Body response: the JSON returned by api-error-handler + // See https://github.com/expressjs/api-error-handler/blob/1.0.0/index.js + interface Response { + status: number; + stack?: string; + message: string; + + // Client errors + code?: any; + name?: string; + type?: any; + } + } + function apiErrorHandler(options?: any): express.ErrorRequestHandler; export = apiErrorHandler; From 95c02169ba8fa58ac1092422efbd2e3174a206f4 Mon Sep 17 00:00:00 2001 From: Jungman Date: Sat, 19 Dec 2015 20:35:43 +0900 Subject: [PATCH 074/128] Add missing properties for webpack --- webpack/webpack-tests.ts | 27 +++++++++++++++++++++++++++ webpack/webpack.d.ts | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index 27a4a5385..8d794968f 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -232,6 +232,33 @@ configuration = { configuration = { output: { chunkFilename: "[chunkhash].bundle.js" } }; +// +// https://webpack.github.io/docs/configuration.html +// + +configuration = { + entry: [ + "./entry1", + "./entry2" + ] +}; + +configuration = { + devtool: "#inline-source-map" +}; + +loader = { + test: /\.jsx$/, + include: [ + path.resolve(__dirname, "app/src"), + path.resolve(__dirname, "app/test") + ], + exclude: [ + path.resolve(__dirname, "node_modules") + ], + loader: "babel-loader" +}; + declare var require: any; declare var path: any; configuration = { diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts index f2049bbc9..3889446b2 100644 --- a/webpack/webpack.d.ts +++ b/webpack/webpack.d.ts @@ -6,7 +6,8 @@ declare module "webpack" { namespace webpack { interface Configuration { - entry?: string|Entry; + entry?: string|string[]|Entry; + devtool?: string; output?: Output; module?: Module; plugins?: (Plugin|Function)[]; @@ -28,6 +29,8 @@ declare module "webpack" { } interface Loader { + exclude?: string[]; + include?: string[]; test: RegExp; loader?: string; loaders?: string[]; From 86897d7a5c90e73abbf313a38e58797410e9b1f4 Mon Sep 17 00:00:00 2001 From: Hugo ESQUIBET Date: Sat, 19 Dec 2015 16:47:34 +0100 Subject: [PATCH 075/128] adding react-select typings support from https://github.com/JedWatson/react-select --- react-select/react-select.d.ts | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 react-select/react-select.d.ts diff --git a/react-select/react-select.d.ts b/react-select/react-select.d.ts new file mode 100644 index 000000000..b79126345 --- /dev/null +++ b/react-select/react-select.d.ts @@ -0,0 +1,63 @@ +/// + +// Typings for https://github.com/JedWatson/react-select +//***Usage*** +// import ReactSelect = require('react-select'); +// + +declare module "react-select" { + // Import React + import React = require("react"); + + interface Option{ + label : string; + value : any; + } + + interface ReactSelectProps extends React.Props{ + addLabelText? : string; + allowCreate? : boolean; + asyncOptions? : ()=>any; + autoload? : boolean; + backspaceRemoves? : boolean; + cacheAsyncResults? : boolean; + className? : string; + clearable? : boolean; + clearAllText? : string; + clearValueText? : string; + delimiter? : string; + disabled? : boolean; + filterOption? : (option,filterString : string)=>any; + filterOptions? : (options:Array,filterString : string,values : Array)=>any; + ignoreCase? : boolean; // default true whether to perform case-insensitive filtering + inputProps? : any; + isLoading? : boolean; + labelKey? : string; + matchPos? : string; + matchProp? : string; + multi? : boolean; + name? : string; + newOptionCreator? : ()=>any; + noResultsText? : string; + onBlur? : (event)=>void; + onChange? : (newValue)=>void; + onFocus? : (event)=>void; + onInputChange? : (inputValue)=>void; + onOptionLabelClick? : (value, event)=>void; + optionRenderer? : ()=>void; + options? : Array