From 07deed85edf73b0d794db713559eb9a4f1f476ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elis=C3=A9e?= Date: Thu, 10 Dec 2015 19:16:01 +0100 Subject: [PATCH 1/7] Fix electron.nativeImage's type --- 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 7c5fa8b4d..48f893d06 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1700,7 +1700,7 @@ declare module GitHubElectron { interface Electron { clipboard: GitHubElectron.Clipboard; crashReporter: GitHubElectron.CrashReporter; - nativeImage: GitHubElectron.NativeImage; + nativeImage: typeof GitHubElectron.NativeImage; screen: GitHubElectron.Screen; shell: GitHubElectron.Shell; remote: GitHubElectron.Remote; From 0eaa2e33f76641182d1713c2f865c1417c68a37c Mon Sep 17 00:00:00 2001 From: Nick Zamosenchuk Date: Fri, 11 Dec 2015 14:13:49 +0100 Subject: [PATCH 2/7] [ngNotify] create Type Definition for Angular JS ngNotify library ngNotify is a simple, lightweight and elegant notification service for AngularJS applications. This commit/pull request contains a type definition for the latest version of this library --- ng-notify/ng-notify-tests.ts | 11 ++++++ ng-notify/ng-notify.d.ts | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 ng-notify/ng-notify-tests.ts create mode 100644 ng-notify/ng-notify.d.ts diff --git a/ng-notify/ng-notify-tests.ts b/ng-notify/ng-notify-tests.ts new file mode 100644 index 000000000..4a03d62ce --- /dev/null +++ b/ng-notify/ng-notify-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +class NgNotifyTestController { + + static $inject = ['$scope', 'ngNotify']; + + constructor($scope:ng.IScope, ngNotify:ngNotify.INotifyService) { + ngNotify.set('Your error message goes here!', 'error'); + } +}; \ No newline at end of file diff --git a/ng-notify/ng-notify.d.ts b/ng-notify/ng-notify.d.ts new file mode 100644 index 000000000..f1092df62 --- /dev/null +++ b/ng-notify/ng-notify.d.ts @@ -0,0 +1,72 @@ +// Type definitions for ng-notify 0.7.1 +// Project: https://github.com/matowens/ng-notify +// Definitions by: Nick Zamosenchuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +declare module ngNotify { + + /** + * Contains the options used to configure notification. + */ + interface IUserOptions{ + type?: string; + theme?: string; + position?: string; + duration?: number; + sticky?: boolean; + button?: boolean; + html?: boolean; + } + + /** + * Simply and lightweight notification service for AngularJS + */ + interface INotifyService { + + /** + * Allows to create a whole new set of styles for each notification type. + * @param themeName The name used when setting the theme in the config object. + * @param className The class used to target this theme in the stylesheet. + */ + addTheme(themeName:string, className:string):void; + + /** + * Allows to create a new type of notification to use in their app. + * @param typeName The name used to trigger this notification type in the set method. + * @param className The class used to target this type in the stylesheet. + */ + addType(typeName:string, className:string):void; + + /** + * Sets default settings for all notifications to take into account when displaying. + * @param userOptions Notification configuration object + */ + config(userOptions: IUserOptions):void; + + /** + * Manually dismisses any sticky notifications that may still be set. + */ + dismiss():void; + + /** + * Displays a notification message. + * @param message A message text to display. + */ + set(message: string):void; + + /** + * Displays a notification message and sets the type for this one notification. + * @param message A message text to display. + * @param type The type of the notification. + */ + set(message: string, type: string):void; + + /** + * displays a notification message and sets the formatting/behavioral options for this one notification. + * @param message A message text to display. + * @param userOptions Notification configuration object. + */ + set(message: string, userOptions: IUserOptions):void; + } +} From 5c9b77c2db4f324ab2431f27b35a0b9c44383dbe Mon Sep 17 00:00:00 2001 From: George Wu Date: Fri, 11 Dec 2015 21:49:53 +0800 Subject: [PATCH 3/7] Added type definitions for sql.js. --- sql.js/sql.js-tests.ts | 81 ++++++++++++++++++++++++++++++++++++++++++ sql.js/sql.js.d.ts | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 sql.js/sql.js-tests.ts create mode 100644 sql.js/sql.js.d.ts diff --git a/sql.js/sql.js-tests.ts b/sql.js/sql.js-tests.ts new file mode 100644 index 000000000..eeba3f080 --- /dev/null +++ b/sql.js/sql.js-tests.ts @@ -0,0 +1,81 @@ +/// +/// + +import fs = require("fs"); +import SQL = require("sql.js"); + +var DB_PATH = "data.db"; + +function createFile(path: string): void { + var fd = fs.openSync(path, "a"); + fs.closeSync(fd); +} + +// Open the database file. If it does not exist, create a blank database in memory. +var databaseData: Buffer; +databaseData = fs.existsSync(DB_PATH) ? fs.readFileSync(DB_PATH) : null; +var db = new SQL.Database(databaseData); + +// Create a new table 'test_table' in the database in memory. +var createTableStatement = + "DROP TABLE IF EXISTS test_table;" + + "CREATE TABLE test_table (id INTEGER PRIMARY KEY, content TEXT);"; +db.run(createTableStatement); + +// Insert 2 records for testing. +var insertRecordStatement = + "INSERT INTO test_table (id, content) VALUES (@id, @content);"; +db.run(insertRecordStatement, { + "@id": 1, + "@content": "Content 1" +}); +db.run(insertRecordStatement, { + "@id": 2, + "@content": "Content 2" +}); + +try { + // This query will throw exception: primary key constraint failed. + db.run(insertRecordStatement, { + "@id": 1, + "@content": "Content 3" + }); +} catch (ex) { + console.warn(ex); +} + +// A simple SELECT query. +var selectRecordStatement = + "SELECT * FROM test_table WHERE id = @id;" +var selectStatementObject = db.prepare(selectRecordStatement); +var results = selectStatementObject.get({ + "@id": 1 +}); +console.log(results); +selectStatementObject.free(); + +// Access the results one by one, asynchronously. +var selectRecordsStatement = + "SELECT * FROM test_table;"; +db.each( + selectRecordsStatement, + (obj: SQL.SQLValueObject): void => { + console.log(obj); + }, + (): void => { + console.info("Iteration done."); + dbAccessDone(); + }); + + +function dbAccessDone(): void { + // Save the database into SQLite version 3 format. + if (!fs.existsSync(DB_PATH)) { + createFile(DB_PATH); + } + var exportedData = db.export(); + fs.writeFileSync(DB_PATH, exportedData); + + // Finally, close the database connection and release the resources in memory. + db.close(); +} diff --git a/sql.js/sql.js.d.ts b/sql.js/sql.js.d.ts new file mode 100644 index 000000000..5f2ddd069 --- /dev/null +++ b/sql.js/sql.js.d.ts @@ -0,0 +1,71 @@ + +// Type definitions for sql.js (Sep. 6 2015 snapshot) +// Project: https://github.com/kripken/sql.js +// Definitions by: George Wu +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "sql.js" { + + type SQLValue = number | string | Uint8Array; + type KeyValueObject = { [key: string]: SQLValue }; + type SQLValueObject = { [columnName: string]: SQLValue }; + type DataRow = SQLValue[]; + + class Database { + constructor(data: Buffer); + constructor(data: Uint8Array); + constructor(data: number[]); + + run(sql: string): Database; + run(sql: string, params: KeyValueObject): Database; + run(sql: string, params: SQLValue[]): Database; + + exec(sql: string): QueryResults[]; + + each(sql: string, callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, params: KeyValueObject, callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, params: SQLValue[], callback: (obj: SQLValueObject) => void, done: () => void): void; + + prepare(sql: string): Statement; + prepare(sql: string, params: KeyValueObject): Statement; + prepare(sql: string, params: SQLValue[]): Statement; + + export(): Uint8Array; + + close(): void; + } + + class Statement { + bind(): boolean; + bind(values: KeyValueObject): boolean; + bind(values: SQLValue[]): boolean; + + step(): boolean; + + get(): DataRow; + get(params: KeyValueObject): DataRow; + get(params: SQLValue[]): DataRow; + + getColumnNames(): string[]; + + getAsObject(): SQLValueObject; + getAsObject(params: KeyValueObject): SQLValueObject; + getAsObject(params: SQLValue[]): SQLValueObject; + + run(): void; + run(values: KeyValueObject): void; + run(values: SQLValue[]): void; + + reset(): void; + + freemem(): void; + + free(): boolean; + } + + interface QueryResults { + columns: string[]; + values: DataRow[]; + } + +} From 98339951b7a45fe9679a83777d61bad70a037976 Mon Sep 17 00:00:00 2001 From: George Wu Date: Fri, 11 Dec 2015 22:09:48 +0800 Subject: [PATCH 4/7] Renewed code to follow DefinitelyTyped's contribution guidelines. --- sql.js/sql.js-tests.ts | 2 +- sql.js/sql.js.d.ts | 46 +++++++++++++++++++----------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sql.js/sql.js-tests.ts b/sql.js/sql.js-tests.ts index eeba3f080..40fceb8fb 100644 --- a/sql.js/sql.js-tests.ts +++ b/sql.js/sql.js-tests.ts @@ -59,7 +59,7 @@ var selectRecordsStatement = "SELECT * FROM test_table;"; db.each( selectRecordsStatement, - (obj: SQL.SQLValueObject): void => { + (obj: { [columnName: string]: number | string | Uint8Array }): void => { console.log(obj); }, (): void => { diff --git a/sql.js/sql.js.d.ts b/sql.js/sql.js.d.ts index 5f2ddd069..d3f22afc1 100644 --- a/sql.js/sql.js.d.ts +++ b/sql.js/sql.js.d.ts @@ -1,15 +1,11 @@ - -// Type definitions for sql.js (Sep. 6 2015 snapshot) +// Type definitions for sql.js // Project: https://github.com/kripken/sql.js // Definitions by: George Wu // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module "sql.js" { +/// - type SQLValue = number | string | Uint8Array; - type KeyValueObject = { [key: string]: SQLValue }; - type SQLValueObject = { [columnName: string]: SQLValue }; - type DataRow = SQLValue[]; +declare module "sql.js" { class Database { constructor(data: Buffer); @@ -17,18 +13,18 @@ declare module "sql.js" { constructor(data: number[]); run(sql: string): Database; - run(sql: string, params: KeyValueObject): Database; - run(sql: string, params: SQLValue[]): Database; + run(sql: string, params: { [key: string]: number | string | Uint8Array }): Database; + run(sql: string, params: (number | string | Uint8Array)[]): Database; exec(sql: string): QueryResults[]; - each(sql: string, callback: (obj: SQLValueObject) => void, done: () => void): void; - each(sql: string, params: KeyValueObject, callback: (obj: SQLValueObject) => void, done: () => void): void; - each(sql: string, params: SQLValue[], callback: (obj: SQLValueObject) => void, done: () => void): void; + each(sql: string, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; + each(sql: string, params: { [key: string]: number | string | Uint8Array }, callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; + each(sql: string, params: (number | string | Uint8Array)[], callback: (obj: { [columnName: string]: number | string | Uint8Array }) => void, done: () => void): void; prepare(sql: string): Statement; - prepare(sql: string, params: KeyValueObject): Statement; - prepare(sql: string, params: SQLValue[]): Statement; + prepare(sql: string, params: { [key: string]: number | string | Uint8Array }): Statement; + prepare(sql: string, params: (number | string | Uint8Array)[]): Statement; export(): Uint8Array; @@ -37,24 +33,24 @@ declare module "sql.js" { class Statement { bind(): boolean; - bind(values: KeyValueObject): boolean; - bind(values: SQLValue[]): boolean; + bind(values: { [key: string]: number | string | Uint8Array }): boolean; + bind(values: (number | string | Uint8Array)[]): boolean; step(): boolean; - get(): DataRow; - get(params: KeyValueObject): DataRow; - get(params: SQLValue[]): DataRow; + get(): (number | string | Uint8Array)[]; + get(params: { [key: string]: number | string | Uint8Array }): (number | string | Uint8Array)[]; + get(params: (number | string | Uint8Array)[]): (number | string | Uint8Array)[]; getColumnNames(): string[]; - getAsObject(): SQLValueObject; - getAsObject(params: KeyValueObject): SQLValueObject; - getAsObject(params: SQLValue[]): SQLValueObject; + getAsObject(): { [columnName: string]: number | string | Uint8Array }; + getAsObject(params: { [key: string]: number | string | Uint8Array }): { [columnName: string]: number | string | Uint8Array }; + getAsObject(params: (number | string | Uint8Array)[]): { [columnName: string]: number | string | Uint8Array }; run(): void; - run(values: KeyValueObject): void; - run(values: SQLValue[]): void; + run(values: { [key: string]: number | string | Uint8Array }): void; + run(values: (number | string | Uint8Array)[]): void; reset(): void; @@ -65,7 +61,7 @@ declare module "sql.js" { interface QueryResults { columns: string[]; - values: DataRow[]; + values: (number | string | Uint8Array)[][]; } } From bd1d3d2e0bf4a16d9d0aa3fee767b1d3658dc801 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 17:45:26 +0100 Subject: [PATCH 5/7] Initial definitions for react-datagrid. --- react-datagrid/react-datagrid-test.tsx | 82 +++++++ react-datagrid/react-datagrid.d.ts | 310 +++++++++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 react-datagrid/react-datagrid-test.tsx create mode 100644 react-datagrid/react-datagrid.d.ts diff --git a/react-datagrid/react-datagrid-test.tsx b/react-datagrid/react-datagrid-test.tsx new file mode 100644 index 000000000..c0ca90a1a --- /dev/null +++ b/react-datagrid/react-datagrid-test.tsx @@ -0,0 +1,82 @@ +/// +/// +/// + +import * as React from "react"; +import ReactDataGrid = require("react-datagrid"); + +var data: any[] = []; + +var columns: ReactDataGrid.Column[] = [ + { name: 'index', title: '#', width: 50 }, + { name: 'firstName', style: { color: 'red' }, visible: true}, + { name: 'lastName', render: (v) => {return v + " Phd"}}, + { name: 'city', textAlign: 'right', defaultVisible: true}, + { name: 'email', defaultHidden: true } +]; +var selected = {}; +var sortInfo: ReactDataGrid.SortInfo[] = [ { name: 'country', dir: 'asc'}] + +export module X { +export class ExampleBasic extends React.Component<{},{}> { + render(): React.ReactElement { + return ( + + ); + } +} +} + +class ExampleFull extends React.Component<{},{}> { + + render(): React.ReactElement { + return ( + {}} + onPageSizeChange={(pageSize: number, props: ReactDataGrid.DataGridProps) => {}} + onColumnOrderChange={(index: number, dropIndex: number) => {}} + onColumnResize={(firstCol: ReactDataGrid.Column, firstSize: number, secondCol: ReactDataGrid.Column, secondSize: number) => {}} + onSelectionChange={(newSelectedId: string, data: any) => {}} + onSortChange={(sortInfo: ReactDataGrid.SortInfo[]) => {}} + onFilter={(column: ReactDataGrid.Column, value: any, allFilterValues: any[]) => {} } + /> + ); + } +} diff --git a/react-datagrid/react-datagrid.d.ts b/react-datagrid/react-datagrid.d.ts new file mode 100644 index 000000000..aca7d355e --- /dev/null +++ b/react-datagrid/react-datagrid.d.ts @@ -0,0 +1,310 @@ +// Type definitions for react-datagrid 1.2.15 +// Project: https://github.com/zippyui/react-datagrid.git +// Definitions by: Stephen Jelfs +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-datagrid" { + import DataGrid = ReactDataGrid.DataGrid; + export = DataGrid; +} + +declare namespace ReactDataGrid { + import React = __React; + + interface DataGridProps extends React.Props { + /** + * Array/String/Function/Promise - for local data, an array of object + * to render in the grid. For remote data, a string url, or a function + * that returns a promise. + */ + dataSource: any[] | string | ((query: {pageSize: number, skip: number}) => Promise); + + dataSourceCount?: number; + + /** + * String - the name of the property where the id is found for each + * object in the data array. + */ + idProperty: string; + + /** + * Array - an array of columns that are going to be rendered in the + * grid. + */ + columns: Column[]; + + /** + * Sorting the data array is not done by the grid. You can however + * pass in sort info so the grid renders with sorting icons as needed. + */ + onSortChange?: (sortInfo: SortInfo[]) => void; + + /** + * Array - an array with sorting information. + */ + sortInfo?: SortInfo[]; + + style?: __React.CSSProperties; + + /** + * Object/Function - you can specify either a style object to be + * applied to all rows, or a function. The function is called with + * (data, props) (so you have access to props.index for example) and + * is expected to return a style object. + */ + rowStyle?: __React.CSSProperties | ((data: any, props: RowProps) => React.CSSProperties); + + /** + * Boolean - show a column menu to show/hide columns. + */ + withColumnMenu?: boolean; + + /** + * If you want to enable column reordering, just specify the + * onColumnOrderChange prop on the grid: + */ + onColumnOrderChange?: (index: number, dropIndex: number) => void; + + /** + * If you want to enable column resized, just specify the + * onColumnResize prop on the grid: + */ + onColumnResize?: (firstCol: Column, firstSize: number, + secondCol: Column, secondSize: number) => void; + + /** + * If you want to enable selection, just specify the + * onSelectionChange prop on the grid: + */ + onSelectionChange?: (newSelected: {}, data: any) => void; + + /** + * When a column is shown/hidden, you can be notified using the + * onColumnVisibilityChange callback prop. + */ + onColumnVisibilityChange?: (column: Column, visibility: boolean) => void; + + /** + * The current selection. + */ + selected?: {}; + + /** + * Group rows by matching values. + */ + groupBy?: any[]; + + /** + * If you want to enable filter, just specify the + * onFilter prop on the grid: + */ + onFilter?: (column: Column, value: any, allFilterValues: any[]) => void; + + /** + * To apply the filter while typing. + */ + liveFilter?: boolean; + + /** + * Empty text for no records. + */ + emptyText?: string; + + /** + * Loading grid. + */ + loading?: boolean; + + /** + * If you dont want loadMask over header, specify + */ + loadMaskOverHeader?: boolean; + + /** + * Show cell borders. Other valid values: 'horizontal', 'vertical'. + */ + showCellBorders?: boolean | string; + + /** + * Custom row height. + */ + rowHeight?: number; + + /** + * When you have remote data, pagination is setup by default. If you + * want to disable pagination, specify the pagination prop with a false + * value. + */ + pagination?: boolean; + defaultPageSize?: number; + defaultPage?: number; + + /** + * Number - controlled alternative for defaultPageSize. When pageSize + * changes, onPageSizeChange(pageSize) is called. + */ + pageSize?: number; + + /** + * Number - controlled alternative for defaultPage. When page changes, + * onPageChange(page) is called. + */ + page?: number; + + /** + * Customize the pagination toolbar. + */ + paginationToolbarProps?: PaginationToolbarProps; + + /** + * handle page changes. + */ + onPageChange?: (page: number) => void; + + /** + * handle page size changes. + */ + onPageSizeChange?: (pageSize: number, props: DataGridProps) => void; + } + + interface SortInfo { + name: string; + dir: string; + } + + interface Column { + /** + * String - each column should have a name property. + */ + name: string; + + /** + * String/ReactElement - a title to show in the header. If not + * specified, a humanized version of name will be used. Can be a string + * or anything that React can render, so you can customize it as you + * please. + */ + title?: string | React.ReactElement; + + /** + * Function - if you want custom rendering, specify this property. + * + * The column.render function is called with 3 args: + * value - the default value to be rendered (equals to data[column.name]) + * data - the corresponding data object for the current row + cellProps - an object with props for the current cell + */ + render?: (value: any, data: any, cellProps: CellProps) => any; + + /** + * Object - if you want cells in this column to be have a custom + * style. + */ + style?: __React.CSSProperties; + + /** + * String - one of 'left', 'right', 'center'. + */ + textAlign?: string; + + /** + * String - a className to be applied to all cells in this column + */ + className?: string; + + width?: number; + + minWidth?: number; + + /** + * Columns are flexible via flexbox. Specify a flex property for this. + * Unless a column specifies a flex or a width property, it is assumed + * to have flex: 1. + */ + flex?: number; + + /** + * Specify a column as visible/hidden. + */ + defaultVisible?: boolean; + defaultHidden?: boolean; + + /** + * Boolean - controlled (which means you have to manually set column + * visibility when it changes, by using onColumnVisibilityChange). + */ + visible?: boolean; + } + + interface CellProps { + /** + * the index of the row + */ + rowIndex: number; + + /** + * the index of the column + */ + index: number; + + /** + * a style for the cell + */ + style: React.CSSProperties; + + /** + * a class name for the cell + */ + className: string; + } + + interface RowProps { + /** + * the index of the row + */ + index: number; + + /** + * a class name for the row when the mouse is over it + */ + overClassName: string; + + /** + * a class name for the row when selected + */ + selectedClassName: string; + + /** + * a class name for the row + */ + className: string; + } + + interface PaginationToolbarProps { + /** + * Available page sizes. + */ + pageSizes: number[]; + + /** + * Hide/show page sizes. + */ + showPageSize: boolean; + + /** + * Customize icons. + */ + showRefreshIcon: boolean; + iconSize: number; + iconProps: { + style: React.SVGAttributes, + overStyle: React.SVGAttributes, + disabledStyle: React.SVGAttributes + } + } + + export class DataGrid extends __React.Component { + } +} From d065f93bab68ae7be4625c3b2847e601b2311505 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 17:58:28 +0100 Subject: [PATCH 6/7] Added missing promises --- react-datagrid/react-datagrid.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/react-datagrid/react-datagrid.d.ts b/react-datagrid/react-datagrid.d.ts index aca7d355e..1dc5d8361 100644 --- a/react-datagrid/react-datagrid.d.ts +++ b/react-datagrid/react-datagrid.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// declare module "react-datagrid" { import DataGrid = ReactDataGrid.DataGrid; From 55f9ccc901fbb3c42c8afd2d2bcc2ca864054062 Mon Sep 17 00:00:00 2001 From: stephenjelfs Date: Fri, 11 Dec 2015 18:07:34 +0100 Subject: [PATCH 7/7] Renamed tests file. --- .../{react-datagrid-test.tsx => react-datagrid-tests.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-datagrid/{react-datagrid-test.tsx => react-datagrid-tests.tsx} (100%) diff --git a/react-datagrid/react-datagrid-test.tsx b/react-datagrid/react-datagrid-tests.tsx similarity index 100% rename from react-datagrid/react-datagrid-test.tsx rename to react-datagrid/react-datagrid-tests.tsx