From 4200e4a4c20f4d82412f11928c323d4ff51c03dc Mon Sep 17 00:00:00 2001 From: TeamworkGuy2 Date: Fri, 17 Apr 2015 00:57:15 +0000 Subject: [PATCH] Added strong types to test file --- websql/websql-tests.ts | 10 +++++----- websql/websql.d.ts | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/websql/websql-tests.ts b/websql/websql-tests.ts index b0e0b2522..131883c24 100644 --- a/websql/websql-tests.ts +++ b/websql/websql-tests.ts @@ -116,7 +116,7 @@ interface Results { function createTable(dbState: DbState, name: string, columns: string[], callback: (rec: SQLResultSet[]) => void) { var sqls: SqlQuery[] = []; var colDefs = columns.map((col) => { - var colType = null; + var colType: string = null; var type = col.charAt(0); switch (type) { case 'i': @@ -152,14 +152,14 @@ interface Results { * other - null */ function createMockRecord(columns: string[]): any { - var rec = {}; + var rec: { [id: string]: any } = {}; for (var i = 0, size = columns.length; i < size; i++) { var col = columns[i]; var type = col.charAt(0); switch (type) { case 'i': case 'l': - rec[col] = parseInt(Math.random() * 1000000); + rec[col] = parseInt((Math.random() * 1000000).toString()); break; case 'f': case 'd': @@ -244,7 +244,7 @@ interface Results { function resultSetToResults(results: SQLResultSet[]) { var resObjs: Results[] = []; for (var i = 0, count = results.length; i < count; i++) { - var resAry = []; + var resAry: any[] = []; var sqlRsI = results[i]; var resObj = { data: resAry, @@ -262,7 +262,7 @@ interface Results { } - function compareRecords(rec1, rec2): boolean { + function compareRecords(rec1: any, rec2: any): boolean { var props = Object.keys(rec1); for (var i = 0, size = props.length; i < size; i++) { var prop = props[i]; diff --git a/websql/websql.d.ts b/websql/websql.d.ts index fad3f0211..7a9a248ea 100644 --- a/websql/websql.d.ts +++ b/websql/websql.d.ts @@ -164,14 +164,14 @@ interface SQLResultSetRowList { /** 4.6 Errors and exceptions - asynchronous database API error */ declare class SQLError { - static UNKNOWN_ERR; // = 0; - static DATABASE_ERR; // = 1; - static VERSION_ERR; // = 2; - static TOO_LARGE_ERR; // = 3; - static QUOTA_ERR; // = 4; - static SYNTAX_ERR; // = 5; - static CONSTRAINT_ERR; // = 6; - static TIMEOUT_ERR; // = 7; + static UNKNOWN_ERR: number; // = 0; + static DATABASE_ERR: number; // = 1; + static VERSION_ERR: number; // = 2; + static TOO_LARGE_ERR: number; // = 3; + static QUOTA_ERR: number; // = 4; + static SYNTAX_ERR: number; // = 5; + static CONSTRAINT_ERR: number; // = 6; + static TIMEOUT_ERR: number; // = 7; code: number; message: DOMString; @@ -182,34 +182,34 @@ declare class SQLException { /** Code 0 - The transaction failed for reasons unrelated to the database itself * and not covered by any other error code. */ - static UNKNOWN_ERR; // = 0; + static UNKNOWN_ERR: number; // = 0; /** Code 1 - The statement failed for database reasons not covered by any other error code. */ - static DATABASE_ERR; // = 1; + static DATABASE_ERR: number; // = 1; /** Code 2 - The operation failed because the actual database version was not what it should be. * For example, a statement found that the actual database version no longer matched the * expected version of the Database or DatabaseSync object, or the Database.changeVersion() * or DatabaseSync.changeVersion() methods were passed a version that doesn't match the actual database version. */ - static VERSION_ERR; // = 2; + static VERSION_ERR: number; // = 2; /** Code 3 - The statement failed because the data returned from the database was too large. * The SQL "LIMIT" modifier might be useful to reduce the size of the result set. */ - static TOO_LARGE_ERR; // = 3; + static TOO_LARGE_ERR: number; // = 3; /** Code 4 - The statement failed because there was not enough remaining storage space, * or the storage quota was reached and the user declined to give more space to the database. */ - static QUOTA_ERR; // = 4; + static QUOTA_ERR: number; // = 4; /** Code 5 - The statement failed because of a syntax error, or the number of arguments did * not match the number of ? placeholders in the statement, or the statement tried to use a * statement that is not allowed, such as BEGIN, COMMIT, or ROLLBACK, or the statement tried * to use a verb that could modify the database but the transaction was read-only. */ - static SYNTAX_ERR; // = 5; + static SYNTAX_ERR: number; // = 5; /** Code 6 - An INSERT, UPDATE, or REPLACE statement failed due to a constraint failure. * For example, because a row was being inserted and the value given for the primary * key column duplicated the value of an existing row. */ - static CONSTRAINT_ERR; // = 6; + static CONSTRAINT_ERR: number; // = 6; /** Code 7 - A lock for the transaction could not be obtained in a reasonable time. */ - static TIMEOUT_ERR; // = 7; + static TIMEOUT_ERR: number; // = 7; code: number; message: DOMString;