Skip to content

Commit 93c1030

Browse files
committed
Fix some errors reported by TypeScript
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 42c0851 commit 93c1030

File tree

17 files changed

+68
-21
lines changed

17 files changed

+68
-21
lines changed

js/global.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,25 @@ interface JQuery {
2929
sortTable: (textSelector: string) => JQuery<HTMLElement>;
3030

3131
filterByValue: (value: any) => any;
32+
33+
uiTooltip(): JQuery;
34+
uiTooltip(methodName: 'destroy'): void;
35+
uiTooltip(methodName: 'disable'): void;
36+
uiTooltip(methodName: 'enable'): void;
37+
uiTooltip(methodName: 'open'): void;
38+
uiTooltip(methodName: 'close'): void;
39+
uiTooltip(methodName: 'widget'): JQuery;
40+
uiTooltip(methodName: string): JQuery;
41+
uiTooltip(options: JQueryUI.TooltipOptions): JQuery;
42+
uiTooltip(optionLiteral: string, optionName: string): any;
43+
uiTooltip(optionLiteral: string, options: JQueryUI.TooltipOptions): any;
44+
uiTooltip(optionLiteral: string, optionName: string, optionValue: any): JQuery;
3245
}
3346

3447
interface JQueryStatic {
35-
timepicker: JQueryUI.Datepicker;
48+
timepicker: any;
49+
50+
tablesorter: any;
3651

3752
jqplot: any;
3853
}

js/src/codemirror/addon/lint/sql-lint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import $ from 'jquery';
22
import { CommonParams } from '../../../modules/common.ts';
33

4+
// @ts-ignore
45
window.CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
56
// Skipping check if text box is empty.
67
if (text.trim() === '') {

js/src/designer/database.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var designerTables = [
1414
];
1515

1616
var DesignerOfflineDB = (function () {
17-
var designerDB = {};
17+
var designerDB: {[k: string]: any} = {};
1818

1919
/**
2020
* @type {IDBDatabase|null}
@@ -61,8 +61,8 @@ var DesignerOfflineDB = (function () {
6161
var request = window.indexedDB.open('pma_designer', version);
6262

6363
request.onupgradeneeded = function (e) {
64-
var db = e.target.result;
65-
e.target.transaction.onerror = designerDB.onerror;
64+
var db = (e.target as IDBRequest).result;
65+
(e.target as IDBRequest).transaction.onerror = designerDB.onerror;
6666

6767
var t;
6868
for (t in designerTables) {
@@ -80,7 +80,7 @@ var DesignerOfflineDB = (function () {
8080
};
8181

8282
request.onsuccess = function (e) {
83-
datastore = e.target.result;
83+
datastore = (e.target as IDBRequest).result;
8484
if (typeof callback === 'function') {
8585
callback(true);
8686
}

js/src/modules/ajax-message.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const ajaxShowMessage = function (message = null, timeout = null, type = null) {
150150
*
151151
* @param {JQuery} $thisMessageBox Element that holds the notification
152152
*/
153-
const ajaxRemoveMessage = function ($thisMessageBox): void {
153+
const ajaxRemoveMessage = function ($thisMessageBox: JQuery): void {
154154
if ($thisMessageBox !== undefined && $thisMessageBox instanceof $) {
155155
$thisMessageBox
156156
.stop(true, true)
@@ -164,9 +164,13 @@ const ajaxRemoveMessage = function ($thisMessageBox): void {
164164
}
165165
};
166166

167-
/**
168-
* @return {number}
169-
*/
167+
declare global {
168+
interface Window {
169+
getAjaxMessageCount: () => number;
170+
ajaxShowMessage: typeof ajaxShowMessage;
171+
}
172+
}
173+
170174
window.getAjaxMessageCount = () => ajaxMessageCount;
171175
window.ajaxShowMessage = ajaxShowMessage;
172176

js/src/modules/common.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ const CommonParams = (function () {
9797
};
9898
}());
9999

100+
declare global {
101+
interface Window {
102+
CommonParams: typeof CommonParams;
103+
}
104+
}
105+
100106
window.CommonParams = CommonParams;
101107

102108
export { CommonParams };

js/src/modules/config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function getFieldValue (field, fieldType) {
139139
* @return {object}
140140
*/
141141
function getAllValues () {
142-
var $elements = $('fieldset input, fieldset select, fieldset textarea');
142+
var $elements = $('fieldset input, fieldset select, fieldset textarea') as JQuery<HTMLInputElement>;
143143
var values = {};
144144
var type;
145145
var value;
@@ -809,11 +809,11 @@ function on () {
809809
$form.find('input[type=submit]').prop('disabled', disabled);
810810
}).on('submit', function (e) {
811811
var $form = $(this);
812-
if ($form.attr('name') === 'prefs_export' && $('#export_local_storage')[0].checked) {
812+
if ($form.attr('name') === 'prefs_export' && ($('#export_local_storage') as JQuery<HTMLInputElement>)[0].checked) {
813813
e.preventDefault();
814814
// use AJAX to read JSON settings and save them
815815
savePrefsToLocalStorage($form);
816-
} else if ($form.attr('name') === 'prefs_import' && $('#import_local_storage')[0].checked) {
816+
} else if ($form.attr('name') === 'prefs_import' && ($('#import_local_storage') as JQuery<HTMLInputElement>)[0].checked) {
817817
// set 'json' input and submit form
818818
$form.find('input[name=json]').val(window.localStorage.config);
819819
}
@@ -844,6 +844,9 @@ const Config = {
844844

845845
declare global {
846846
interface Window {
847+
configInlineParams: any[] | undefined;
848+
configScriptLoaded: boolean | undefined;
849+
defaultValues: object;
847850
validators: typeof validators;
848851
Config: typeof Config;
849852
}

js/src/modules/console/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ export const Config = {
7474
* Used for update console config
7575
*/
7676
update: function (): void {
77-
this.set('AlwaysExpand', !! document.getElementById('consoleOptionsAlwaysExpandCheckbox').checked);
78-
this.set('StartHistory', !! document.getElementById('consoleOptionsStartHistoryCheckbox').checked);
79-
this.set('CurrentQuery', !! document.getElementById('consoleOptionsCurrentQueryCheckbox').checked);
80-
this.set('EnterExecutes', !! document.getElementById('consoleOptionsEnterExecutesCheckbox').checked);
81-
this.set('DarkTheme', !! document.getElementById('consoleOptionsDarkThemeCheckbox').checked);
77+
this.set('AlwaysExpand', !! (document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked);
78+
this.set('StartHistory', !! (document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked);
79+
this.set('CurrentQuery', !! (document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked);
80+
this.set('EnterExecutes', !! (document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked);
81+
this.set('DarkTheme', !! (document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked);
8282
/* Setting the dark theme of the console*/
8383
const consoleContent = document.getElementById('pma_console').querySelector('.content');
8484
if (this.DarkTheme) {

js/src/modules/cross_framing_protection.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
declare global {
2+
interface Window {
3+
allowThirdPartyFraming: boolean | string;
4+
}
5+
}
6+
17
/**
28
* Conditionally included if framing is not allowed.
39
*/

js/src/modules/functions/formatDateTime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function formatDateTime (date, seconds = false) {
1414
timefmt = 'HH:mm:ss';
1515
}
1616

17+
// @ts-ignore
1718
return result + ' ' + $.datepicker.formatTime(
1819
timefmt, {
1920
hour: date.getHours(),

js/src/modules/functions/ignorePhpErrors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ function ignorePhpErrors (clearPrevErrors = undefined) {
3030
$pmaErrors.remove();
3131
}
3232

33+
declare global {
34+
interface Window {
35+
ignorePhpErrors: typeof ignorePhpErrors;
36+
}
37+
}
38+
3339
window.ignorePhpErrors = ignorePhpErrors;
3440

3541
export { ignorePhpErrors };

0 commit comments

Comments
 (0)