diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index a864dbcb13..95d0041063 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -13,5 +13,5 @@ If adding a new definition: - [ ] Include the required [files](https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package) and header. Base these on the README, *not* on an existing project. If changing an existing definition: -- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <> +- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <> - [ ] Increase the version number in the header if appropriate. diff --git a/README.md b/README.md index 0a7131bd99..7187e9e8f6 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Your package should have this structure: | index.d.ts | This contains the typings for the package. | | foo-tests.ts | This contains sample code which tests the typings. This code does *not* run, but it is type-checked. | | tsconfig.json | This allows you to run `tsc` within the package. | +| tslint.json | Enables linting. | Generate these by running `npm run new-package -- new-package-name`. @@ -130,7 +131,7 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D * `interface X {}`: An empty interface is essentially the `{}` type: it places no constraints on an object. * `interface IFoo {}`: Don't add `I` to the front of an interface name. * `interface Foo { new(): Foo; }`: - This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); } + This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }`. * `const Class: { new(): IClass; }`: Prefer to use a class declaration `class Class { constructor(); }` instead of a new-able constant. * `namespace foo {}`: diff --git a/eventemitter2/index.d.ts b/eventemitter2/index.d.ts index 0372b675dc..33ffe20b09 100644 --- a/eventemitter2/index.d.ts +++ b/eventemitter2/index.d.ts @@ -23,7 +23,7 @@ interface EventEmitter2Configuration { * max listeners that can be assigned to an event, default 10. */ maxListeners?: number; - + /** * show event name in memory leak message when more than maximum amount of listeners is assigned, default false */ diff --git a/fuse/index.d.ts b/fuse/index.d.ts index 9f1de6ff03..5376144e22 100644 --- a/fuse/index.d.ts +++ b/fuse/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Fuse.js 2.2.0 +// Type definitions for Fuse.js 2.5.0 // Project: https://github.com/krisk/Fuse // Definitions by: Greg Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -9,7 +9,8 @@ declare class Fuse { } declare namespace fuse { - interface IFuseOptions extends ISearchOptions { + interface IFuseOptions { + id?: string; caseSensitive?: boolean; include?: string[]; shouldSort?: boolean; @@ -18,9 +19,9 @@ declare namespace fuse { getFn?: (obj: any, path: string) => any; keys?: string[] | { name:string; weight:number} []; verbose?:boolean; - } - - interface ISearchOptions { + tokenize?: boolean; + tokenSeparator? : RegExp; + matchAllTokens?: boolean; location?: number; distance?: number; threshold?: number; diff --git a/react-data-grid/index.d.ts b/react-data-grid/index.d.ts index c76ab540b8..7c438468e9 100644 --- a/react-data-grid/index.d.ts +++ b/react-data-grid/index.d.ts @@ -6,6 +6,12 @@ /// declare namespace AdazzleReactDataGrid { + + interface SelectionParams { + rowIdx: number, + row: any + } + interface GridProps { /** * Gets the data to render in each row. Required. @@ -170,6 +176,20 @@ declare namespace AdazzleReactDataGrid { * @default 0 */ rowScrollTimeout?: number + /** + * Options object for selecting rows + */ + rowSelection?: { + showCheckbox?: boolean + enableShiftSelect?: boolean + onRowsSelected?: (rows: Array) => void, + onRowsDeselected?: (rows: Array) => void, + selectBy?: { + indexes?: Array; + keys?: { rowKey: string, values: Array }; + isSelectedKey?: string; + } + } } /** @@ -393,6 +413,7 @@ declare namespace AdazzleReactDataGrid { // Various events export import RowUpdateEvent = AdazzleReactDataGrid.RowUpdateEvent; + export import SelectionParams = AdazzleReactDataGrid.SelectionParams; export import CellDragEvent = AdazzleReactDataGrid.CellDragEvent; export import DragHandleDoubleClickEvent = AdazzleReactDataGrid.DragHandleDoubleClickEvent; export import CellCopyPasteEvent = AdazzleReactDataGrid.CellCopyPasteEvent; diff --git a/react-data-grid/react-data-grid-tests.tsx b/react-data-grid/react-data-grid-tests.tsx index 4c2598c87c..bff860ee02 100644 --- a/react-data-grid/react-data-grid-tests.tsx +++ b/react-data-grid/react-data-grid-tests.tsx @@ -243,7 +243,19 @@ class Example extends React.Component { return this.state.rows.length; } + onRowsSelected(rows: Array) { + var selectedIndexes = this.state.selectedIndexes as Array; + + this.setState({selectedIndexes: selectedIndexes.concat(rows.map(r => r.rowIdx))}); + } + onRowsDeselected(rows: Array) { + var rowIndexes = rows.map(r => r.rowIdx); + var selectedIndexes = this.state.selectedIndexes as Array; + this.setState({selectedIndexes: selectedIndexes.filter(i => rowIndexes.indexOf(i) === -1 )}); + } + render() { + let selectedRows = ['id1', 'id2']; return ( { rowHeight={50} minHeight={600} rowScrollTimeout={200} + rowSelection={{ + showCheckbox: true, + enableShiftSelect: true, + onRowsSelected: this.onRowsSelected, + onRowsDeselected: this.onRowsDeselected, + selectBy: { + keys: {rowKey: 'id', values: selectedRows} + } + }} /> ); diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 53e8813a9e..c3eb4a3170 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -65,6 +65,7 @@ declare namespace ReactDayPicker { numberOfMonths?: number; renderDay?: (date: Date) => number | string | JSX.Element; enableOutsideDays?: boolean; + firstDayOfWeek?:number; canChangeMonth?: boolean; disabledDays?: (date: Date) => boolean; fixedWeeks?: boolean; diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 1dbb3f8682..da7ea7f16e 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -47,9 +47,11 @@ export type PlainRoute = Router.PlainRoute; export type EnterHook = Router.EnterHook; export type LeaveHook = Router.LeaveHook; export type ParseQueryString = Router.ParseQueryString; +export type LocationDescriptor = Router.LocationDescriptor; export type RedirectFunction = Router.RedirectFunction; export type RouteComponent = Router.RouteComponent; export type RouteComponentProps = Router.RouteComponentProps; +export type RouteConfig = Router.RouteConfig; export type RouteHook = Router.RouteHook; export type StringifyQuery = Router.StringifyQuery; export type RouterListener = Router.RouterListener; diff --git a/react-router/lib/Link.d.ts b/react-router/lib/Link.d.ts index 58e9f85bcf..7b41e61dc2 100644 --- a/react-router/lib/Link.d.ts +++ b/react-router/lib/Link.d.ts @@ -1,6 +1,5 @@ import * as React from 'react'; import Router from './Router'; -import * as H from 'history'; declare const Link: Link; type Link = Link.Link; @@ -12,9 +11,7 @@ declare namespace Link { activeStyle?: React.CSSProperties; activeClassName?: string; onlyActiveOnIndex?: boolean; - to: Router.RoutePattern | H.LocationDescriptor; - query?: H.Query; - state?: H.LocationState; + to: Router.RoutePattern | Router.LocationDescriptor | ((...args: any[]) => Router.LocationDescriptor); } interface Link extends React.ComponentClass {} diff --git a/react-router/lib/Router.d.ts b/react-router/lib/Router.d.ts index 5a4cfacb15..a9c5417f47 100644 --- a/react-router/lib/Router.d.ts +++ b/react-router/lib/Router.d.ts @@ -2,8 +2,8 @@ import * as React from 'react'; import RouterContext from './RouterContext'; import { QueryString, Query, - Location, LocationDescriptor, LocationState, - History, + Location, LocationDescriptor, LocationState as HLocationState, + History, Href, Pathname, Path } from 'history'; declare const Router: Router; @@ -33,13 +33,19 @@ declare namespace Router { type RouterListener = (error: Error, nextState: RouterState) => void; + type LocationDescriptor = { + pathname?: Pathname + query?: Query + hash?: Href + state?: HLocationState + } interface RedirectFunction { (location: LocationDescriptor): void; /** * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated */ - (state: LocationState, pathname: Pathname | Path, query?: Query): void; + (state: HLocationState, pathname: Pathname | Path, query?: Query): void; } interface RouterState { @@ -87,7 +93,7 @@ declare namespace Router { interface RouterOnContext extends History { setRouteLeaveHook(route: PlainRoute, hook?: RouteHook): () => void; - isActive(pathOrLoc: LocationDescriptor, indexOnly?: boolean): boolean; + isActive(pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean): boolean; } // Wrap a component using withRouter(Component) to provide a router object @@ -97,14 +103,14 @@ declare namespace Router { // https://github.com/reactjs/react-router/blob/v2.4.0/upgrade-guides/v2.4.0.md interface InjectedRouter { - push: (pathOrLoc: History.LocationDescriptor) => void - replace: (pathOrLoc: History.LocationDescriptor) => void + push: (pathOrLoc: Path | LocationDescriptor) => void + replace: (pathOrLoc: Path | LocationDescriptor) => void go: (n: number) => void goBack: () => void goForward: () => void setRouteLeaveHook(route: PlainRoute, callback: RouteHook): void createPath(path: History.Path, query?: History.Query): History.Path createHref(path: History.Path, query?: History.Query): History.Href - isActive: (pathOrLoc: History.LocationDescriptor, indexOnly?: boolean) => boolean + isActive: (pathOrLoc: Path | LocationDescriptor, indexOnly?: boolean) => boolean } } diff --git a/toastr/index.d.ts b/toastr/index.d.ts index 40eb219869..5cd8b30c82 100644 --- a/toastr/index.d.ts +++ b/toastr/index.d.ts @@ -187,6 +187,12 @@ interface Toastr { (toast: JQuery, clearOptions: { force: boolean }): void; }; /** + * Removes all toasts (without animation) + */ + remove: { + (): void; + }; + /** * Create an error toast */ error: ToastrDisplayMethod; diff --git a/toastr/toastr-tests.ts b/toastr/toastr-tests.ts index d005191dd2..a8297b6eb4 100644 --- a/toastr/toastr-tests.ts +++ b/toastr/toastr-tests.ts @@ -8,6 +8,7 @@ function test_basic() { t.push(toastr.error('I do not think that word means what you think it means.', 'Inconceivable!')); toastr.clear(t[0]); // clear 1 toastr.clear(); // clear all + toastr.remove(); var msg = 'Do you think Rodents of Unusual Size really exist?'; var title = 'Fireswamp Legends'; diff --git a/xrm/index.d.ts b/xrm/index.d.ts index 2b3957fcb3..38a0fb7e90 100644 --- a/xrm/index.d.ts +++ b/xrm/index.d.ts @@ -482,17 +482,32 @@ declare namespace Xrm export module Async { /** - * Called when the operation is successful. + * Object passed to ErrorCallbackDelegate */ - export type SuccessCallbackDelegate = ( object: any ) => void; + export interface ErrorCallbackObject + { + errorCode: number; + message: string; + } + + export interface SuccessCallbackObject + { + savedEntityReference: Page.LookupValue; + } + + /** + * Called when the operation is successful. + * Currently, only the Xrm.Utility.openQuickCreate successCallback + * is passed a parameter so an optional parameter for it is included + */ + export type SuccessCallbackDelegate = (object?: SuccessCallbackObject ) => void; /** * Called when the operation fails. * - * @param {number} errorCode The error code. - * @param {string} message The message. + * @param {ErrorCallbackObject} error The error object */ - export type ErrorCallbackDelegate = ( errorCode: number, message: string ) => void; + export type ErrorCallbackDelegate = ( error: ErrorCallbackObject ) => void; /** * Interface for Xrm.Page.data promises. diff --git a/xrm/xrm-tests.ts b/xrm/xrm-tests.ts index 73015cd4c9..65ae6e0184 100644 --- a/xrm/xrm-tests.ts +++ b/xrm/xrm-tests.ts @@ -72,7 +72,7 @@ if (Xrm.Page.data.process != null) /// Demonstrate v7.1 Quick Create form -Xrm.Utility.openQuickCreate("account").then(( newRecord: Xrm.Page.LookupValue ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, (code, message) => {console.log(message)}); +Xrm.Utility.openQuickCreate("account").then(( object ) => { if (object) alert( `Newly created record Id: ${object.savedEntityReference.id}` ); }, (error) => {console.log(`Code: ${error.errorCode}, Message: ${error.message}`)}); /// Make all controls visible.