Fix some errors reported by TypeScript
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
42c085199e
commit
93c103078b
17
js/global.d.ts
vendored
17
js/global.d.ts
vendored
@ -29,10 +29,25 @@ interface JQuery {
|
||||
sortTable: (textSelector: string) => JQuery<HTMLElement>;
|
||||
|
||||
filterByValue: (value: any) => any;
|
||||
|
||||
uiTooltip(): JQuery;
|
||||
uiTooltip(methodName: 'destroy'): void;
|
||||
uiTooltip(methodName: 'disable'): void;
|
||||
uiTooltip(methodName: 'enable'): void;
|
||||
uiTooltip(methodName: 'open'): void;
|
||||
uiTooltip(methodName: 'close'): void;
|
||||
uiTooltip(methodName: 'widget'): JQuery;
|
||||
uiTooltip(methodName: string): JQuery;
|
||||
uiTooltip(options: JQueryUI.TooltipOptions): JQuery;
|
||||
uiTooltip(optionLiteral: string, optionName: string): any;
|
||||
uiTooltip(optionLiteral: string, options: JQueryUI.TooltipOptions): any;
|
||||
uiTooltip(optionLiteral: string, optionName: string, optionValue: any): JQuery;
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
timepicker: JQueryUI.Datepicker;
|
||||
timepicker: any;
|
||||
|
||||
tablesorter: any;
|
||||
|
||||
jqplot: any;
|
||||
}
|
||||
|
||||
1
js/src/codemirror/addon/lint/sql-lint.ts
vendored
1
js/src/codemirror/addon/lint/sql-lint.ts
vendored
@ -1,6 +1,7 @@
|
||||
import $ from 'jquery';
|
||||
import { CommonParams } from '../../../modules/common.ts';
|
||||
|
||||
// @ts-ignore
|
||||
window.CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
|
||||
// Skipping check if text box is empty.
|
||||
if (text.trim() === '') {
|
||||
|
||||
@ -14,7 +14,7 @@ var designerTables = [
|
||||
];
|
||||
|
||||
var DesignerOfflineDB = (function () {
|
||||
var designerDB = {};
|
||||
var designerDB: {[k: string]: any} = {};
|
||||
|
||||
/**
|
||||
* @type {IDBDatabase|null}
|
||||
@ -61,8 +61,8 @@ var DesignerOfflineDB = (function () {
|
||||
var request = window.indexedDB.open('pma_designer', version);
|
||||
|
||||
request.onupgradeneeded = function (e) {
|
||||
var db = e.target.result;
|
||||
e.target.transaction.onerror = designerDB.onerror;
|
||||
var db = (e.target as IDBRequest).result;
|
||||
(e.target as IDBRequest).transaction.onerror = designerDB.onerror;
|
||||
|
||||
var t;
|
||||
for (t in designerTables) {
|
||||
@ -80,7 +80,7 @@ var DesignerOfflineDB = (function () {
|
||||
};
|
||||
|
||||
request.onsuccess = function (e) {
|
||||
datastore = e.target.result;
|
||||
datastore = (e.target as IDBRequest).result;
|
||||
if (typeof callback === 'function') {
|
||||
callback(true);
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ const ajaxShowMessage = function (message = null, timeout = null, type = null) {
|
||||
*
|
||||
* @param {JQuery} $thisMessageBox Element that holds the notification
|
||||
*/
|
||||
const ajaxRemoveMessage = function ($thisMessageBox): void {
|
||||
const ajaxRemoveMessage = function ($thisMessageBox: JQuery): void {
|
||||
if ($thisMessageBox !== undefined && $thisMessageBox instanceof $) {
|
||||
$thisMessageBox
|
||||
.stop(true, true)
|
||||
@ -164,9 +164,13 @@ const ajaxRemoveMessage = function ($thisMessageBox): void {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
declare global {
|
||||
interface Window {
|
||||
getAjaxMessageCount: () => number;
|
||||
ajaxShowMessage: typeof ajaxShowMessage;
|
||||
}
|
||||
}
|
||||
|
||||
window.getAjaxMessageCount = () => ajaxMessageCount;
|
||||
window.ajaxShowMessage = ajaxShowMessage;
|
||||
|
||||
|
||||
@ -97,6 +97,12 @@ const CommonParams = (function () {
|
||||
};
|
||||
}());
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
CommonParams: typeof CommonParams;
|
||||
}
|
||||
}
|
||||
|
||||
window.CommonParams = CommonParams;
|
||||
|
||||
export { CommonParams };
|
||||
|
||||
@ -139,7 +139,7 @@ function getFieldValue (field, fieldType) {
|
||||
* @return {object}
|
||||
*/
|
||||
function getAllValues () {
|
||||
var $elements = $('fieldset input, fieldset select, fieldset textarea');
|
||||
var $elements = $('fieldset input, fieldset select, fieldset textarea') as JQuery<HTMLInputElement>;
|
||||
var values = {};
|
||||
var type;
|
||||
var value;
|
||||
@ -809,11 +809,11 @@ function on () {
|
||||
$form.find('input[type=submit]').prop('disabled', disabled);
|
||||
}).on('submit', function (e) {
|
||||
var $form = $(this);
|
||||
if ($form.attr('name') === 'prefs_export' && $('#export_local_storage')[0].checked) {
|
||||
if ($form.attr('name') === 'prefs_export' && ($('#export_local_storage') as JQuery<HTMLInputElement>)[0].checked) {
|
||||
e.preventDefault();
|
||||
// use AJAX to read JSON settings and save them
|
||||
savePrefsToLocalStorage($form);
|
||||
} else if ($form.attr('name') === 'prefs_import' && $('#import_local_storage')[0].checked) {
|
||||
} else if ($form.attr('name') === 'prefs_import' && ($('#import_local_storage') as JQuery<HTMLInputElement>)[0].checked) {
|
||||
// set 'json' input and submit form
|
||||
$form.find('input[name=json]').val(window.localStorage.config);
|
||||
}
|
||||
@ -844,6 +844,9 @@ const Config = {
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
configInlineParams: any[] | undefined;
|
||||
configScriptLoaded: boolean | undefined;
|
||||
defaultValues: object;
|
||||
validators: typeof validators;
|
||||
Config: typeof Config;
|
||||
}
|
||||
|
||||
@ -74,11 +74,11 @@ export const Config = {
|
||||
* Used for update console config
|
||||
*/
|
||||
update: function (): void {
|
||||
this.set('AlwaysExpand', !! document.getElementById('consoleOptionsAlwaysExpandCheckbox').checked);
|
||||
this.set('StartHistory', !! document.getElementById('consoleOptionsStartHistoryCheckbox').checked);
|
||||
this.set('CurrentQuery', !! document.getElementById('consoleOptionsCurrentQueryCheckbox').checked);
|
||||
this.set('EnterExecutes', !! document.getElementById('consoleOptionsEnterExecutesCheckbox').checked);
|
||||
this.set('DarkTheme', !! document.getElementById('consoleOptionsDarkThemeCheckbox').checked);
|
||||
this.set('AlwaysExpand', !! (document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked);
|
||||
this.set('StartHistory', !! (document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked);
|
||||
this.set('CurrentQuery', !! (document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked);
|
||||
this.set('EnterExecutes', !! (document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked);
|
||||
this.set('DarkTheme', !! (document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked);
|
||||
/* Setting the dark theme of the console*/
|
||||
const consoleContent = document.getElementById('pma_console').querySelector('.content');
|
||||
if (this.DarkTheme) {
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
allowThirdPartyFraming: boolean | string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally included if framing is not allowed.
|
||||
*/
|
||||
|
||||
@ -14,6 +14,7 @@ export default function formatDateTime (date, seconds = false) {
|
||||
timefmt = 'HH:mm:ss';
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return result + ' ' + $.datepicker.formatTime(
|
||||
timefmt, {
|
||||
hour: date.getHours(),
|
||||
|
||||
@ -30,6 +30,12 @@ function ignorePhpErrors (clearPrevErrors = undefined) {
|
||||
$pmaErrors.remove();
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
ignorePhpErrors: typeof ignorePhpErrors;
|
||||
}
|
||||
}
|
||||
|
||||
window.ignorePhpErrors = ignorePhpErrors;
|
||||
|
||||
export { ignorePhpErrors };
|
||||
|
||||
@ -8,7 +8,7 @@ import { ajaxShowMessage } from '../ajax-message.ts';
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
export default function isStorageSupported (type, warn = false) {
|
||||
export default function isStorageSupported (type: 'localStorage' | 'sessionStorage', warn = false): boolean {
|
||||
try {
|
||||
window[type].setItem('PMATest', 'test');
|
||||
// Check whether key-value pair was set successfully
|
||||
|
||||
@ -91,7 +91,7 @@ const onKeyDownArrowsHandler = function (event) {
|
||||
nO.focus();
|
||||
|
||||
if (nO.tagName !== 'SELECT') {
|
||||
nO.select();
|
||||
(nO as HTMLInputElement).select();
|
||||
}
|
||||
|
||||
e.returnValue = false;
|
||||
|
||||
@ -465,6 +465,7 @@ export default function highlightSql ($base) {
|
||||
var $highlight = $('<div class="sql-highlight cm-s-default"></div>');
|
||||
$sql.append($highlight);
|
||||
if (typeof window.CodeMirror !== 'undefined') {
|
||||
// @ts-ignore
|
||||
window.CodeMirror.runMode($sql.text(), 'text/x-mysql', $highlight[0]);
|
||||
$pre.hide();
|
||||
$highlight.find('.cm-keyword').each(documentationKeyword);
|
||||
|
||||
@ -249,6 +249,7 @@ AJAX.registerOnload('table/zoom_plot_jqplot.js', function () {
|
||||
* Input form validation
|
||||
**/
|
||||
$('#inputFormSubmitId').on('click', function () {
|
||||
// @ts-ignore
|
||||
if ($('#tableid_0').get(0).selectedIndex === 0 || $('#tableid_1').get(0).selectedIndex === 0) {
|
||||
ajaxShowMessage(window.Messages.strInputNull);
|
||||
} else if (xLabel === yLabel) {
|
||||
|
||||
@ -11,14 +11,15 @@ AJAX.registerOnload('transformations/image_upload.js', function () {
|
||||
// Change thumbnail when image file is selected
|
||||
// through file upload dialog
|
||||
$('input.image-upload').on('change', function () {
|
||||
if (this.files && this.files[0]) {
|
||||
const fileInput = this as HTMLInputElement;
|
||||
if (fileInput.files && fileInput.files[0]) {
|
||||
var reader = new FileReader();
|
||||
var $input = $(this);
|
||||
reader.onload = function (e) {
|
||||
$input.prevAll('img').attr('src', e.target.result);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(this.files[0]);
|
||||
reader.readAsDataURL(fileInput.files[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -13,6 +13,7 @@ AJAX.registerOnload('transformations/json.js', function () {
|
||||
if ($pre.is(':visible')) {
|
||||
var $highlight = $('<div class="json-highlight cm-s-default"></div>');
|
||||
$json.append($highlight);
|
||||
// @ts-ignore
|
||||
window.CodeMirror.runMode($json.text(), 'application/json', $highlight[0]);
|
||||
$pre.hide();
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ AJAX.registerOnload('transformations/xml.js', function () {
|
||||
if ($pre.is(':visible')) {
|
||||
var $highlight = $('<div class="xml-highlight cm-s-default"></div>');
|
||||
$json.append($highlight);
|
||||
// @ts-ignore
|
||||
window.CodeMirror.runMode($json.text(), 'application/xml', $highlight[0]);
|
||||
$pre.hide();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user