Skip to content

Commit 6c1adad

Browse files
committed
Fix error TS2345 reported by TypeScript
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 36924ff commit 6c1adad

30 files changed

Lines changed: 92 additions & 70 deletions

js/src/database/central_columns.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ AJAX.registerOnload('database/central_columns.js', function () {
184184
);
185185
} else {
186186
$('#f_' + rownum + ' td input[id=checkbox_row_' + rownum + ']').val($('#f_' + rownum + ' input[name=col_name]').val()).html();
187-
$('#f_' + rownum + ' td[name=col_name] span').text($('#f_' + rownum + ' input[name=col_name]').val()).html();
188-
$('#f_' + rownum + ' td[name=col_type] span').text($('#f_' + rownum + ' select[name=col_type]').val()).html();
189-
$('#f_' + rownum + ' td[name=col_length] span').text($('#f_' + rownum + ' input[name=col_length]').val()).html();
190-
$('#f_' + rownum + ' td[name=collation] span').text($('#f_' + rownum + ' select[name=collation]').val()).html();
191-
$('#f_' + rownum + ' td[name=col_attribute] span').text($('#f_' + rownum + ' select[name=col_attribute]').val()).html();
187+
$('#f_' + rownum + ' td[name=col_name] span').text(($('#f_' + rownum + ' input[name=col_name]').val() as string)).html();
188+
$('#f_' + rownum + ' td[name=col_type] span').text(($('#f_' + rownum + ' select[name=col_type]').val() as string)).html();
189+
$('#f_' + rownum + ' td[name=col_length] span').text(($('#f_' + rownum + ' input[name=col_length]').val() as string)).html();
190+
$('#f_' + rownum + ' td[name=collation] span').text(($('#f_' + rownum + ' select[name=collation]').val() as string)).html();
191+
$('#f_' + rownum + ' td[name=col_attribute] span').text(($('#f_' + rownum + ' select[name=col_attribute]').val() as string)).html();
192192
$('#f_' + rownum + ' td[name=col_isNull] span').text($('#f_' + rownum + ' input[name=col_isNull]').is(':checked') ? 'Yes' : 'No').html();
193193
$('#f_' + rownum + ' td[name=col_extra] span').text($('#f_' + rownum + ' input[name=col_extra]').is(':checked') ? 'auto_increment' : '').html();
194-
$('#f_' + rownum + ' td[name=col_default] span').text($('#f_' + rownum + ' :input[name=col_default]').val()).html();
194+
$('#f_' + rownum + ' td[name=col_default] span').text(($('#f_' + rownum + ' :input[name=col_default]').val() as string)).html();
195195
}
196196

197197
$('#save_' + rownum).hide();

js/src/database/multi_table_query.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ AJAX.registerOnload('database/multi_table_query.js', function () {
159159
});
160160
});
161161

162+
// @ts-ignore
162163
$('#sql_results').html($resultsDom);
163164
$('#slide-handle').trigger('click');// Collapse search criteria area
164165
}

js/src/designer/move.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ const mouseMove = function (e) {
101101
$curClick.attr('data-top', newY);
102102

103103
if (onGrid) {
104-
newX = parseInt(newX / gridSize) * gridSize;
105-
newY = parseInt(newY / gridSize) * gridSize;
104+
newX = parseInt((newX / gridSize).toString()) * gridSize;
105+
newY = parseInt((newY / gridSize).toString()) * gridSize;
106106
}
107107

108108
if (newX < 0) {
@@ -634,8 +634,8 @@ const addOtherDbTables = function () {
634634
.append($selectDb).append($selectTable);
635635
var modal = DesignerMove.displayModal($form, window.Messages.strAddTables, '#designerGoModal');
636636
$('#designerModalGoButton').on('click', function () {
637-
var db = $('#add_table_from').val();
638-
var table = $('#add_table').val();
637+
var db = ($('#add_table_from').val() as string);
638+
var table = ($('#add_table').val() as string);
639639

640640
// Check if table already imported or not.
641641
var $table = $('[id="' + encodeURIComponent(db) + '.' + encodeURIComponent(table) + '"]');
@@ -922,7 +922,7 @@ const deletePages = function () {
922922
var modal = DesignerMove.displayModal(data.message, window.Messages.strDeletePage, '#designerGoModal');
923923
$('#designerModalGoButton').on('click', function () {
924924
var $form = $('#edit_delete_pages');
925-
var selected = $form.find('select[name="selected_page"]').val();
925+
var selected = ($form.find('select[name="selected_page"]').val() as string);
926926
if (selected === '0') {
927927
ajaxShowMessage(window.Messages.strSelectPage, 2000);
928928

js/src/drag_drop_import.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ var DragDropImport = {
262262
icon + '"> ');
263263

264264
// Decrease liveUploadCount by one
265-
$('.pma_import_count').html(--DragDropImport.liveUploadCount);
265+
$('.pma_import_count').html((--DragDropImport.liveUploadCount).toString());
266266
if (! DragDropImport.liveUploadCount) {
267267
$('.pma_sql_import_status h2 .close').fadeIn();
268268
}
@@ -314,7 +314,7 @@ var DragDropImport = {
314314

315315
if (ext !== '') {
316316
// Increment liveUploadCount by one
317-
$('.pma_import_count').html(++DragDropImport.liveUploadCount);
317+
$('.pma_import_count').html((++DragDropImport.liveUploadCount).toString());
318318
$('.pma_sql_import_status h2 .close').fadeOut();
319319

320320
$('.pma_sql_import_status div li[data-hash="' + hash + '"]')
@@ -339,7 +339,7 @@ var DragDropImport = {
339339
fd.append('sql_compatibility', 'NONE');
340340
fd.append('sql_no_auto_value_on_zero', 'something');
341341
fd.append('ajax_request', 'true');
342-
fd.append('hash', hash);
342+
fd.append('hash', hash.toString());
343343

344344
// init uploading
345345
DragDropImport.sendFileToServer(fd, hash);

js/src/gis_data_editor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
294294
var prefix = name.substring(0, name.length - 11);
295295
// Find the number of points
296296
var $noOfPointsInput = $('input[name=\'' + prefix + '[no_of_points]' + '\']');
297-
var noOfPoints = parseInt($noOfPointsInput.val(), 10);
297+
var noOfPoints = parseInt(($noOfPointsInput.val() as string), 10);
298298
// Add the new data point
299299
var html = addDataPoint(noOfPoints, prefix);
300300
$a.before(html);
@@ -314,7 +314,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
314314

315315
// Find the number of lines
316316
var $noOfLinesInput = $('input[name=\'' + prefix + '[no_of_lines]' + '\']');
317-
var noOfLines = parseInt($noOfLinesInput.val(), 10);
317+
var noOfLines = parseInt(($noOfLinesInput.val() as string), 10);
318318

319319
// Add the new linesting of inner ring based on the type
320320
var html = '<br>';
@@ -349,7 +349,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
349349
var prefix = name.substring(0, name.length - 13);
350350
// Find the number of polygons
351351
var $noOfPolygonsInput = $('input[name=\'' + prefix + '[no_of_polygons]' + '\']');
352-
var noOfPolygons = parseInt($noOfPolygonsInput.val(), 10);
352+
var noOfPolygons = parseInt(($noOfPolygonsInput.val() as string), 10);
353353

354354
// Add the new polygon
355355
var html = window.Messages.strPolygon + ' ' + (noOfPolygons + 1) + ':<br>';
@@ -378,7 +378,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
378378
var prefix = 'gis_data[GEOMETRYCOLLECTION]';
379379
// Find the number of geoms
380380
var $noOfGeomsInput = $('input[name=\'' + prefix + '[geom_count]' + '\']');
381-
var noOfGeoms = parseInt($noOfGeomsInput.val(), 10);
381+
var noOfGeoms = parseInt(($noOfGeomsInput.val() as string), 10);
382382

383383
var html1 = window.Messages.strGeometry + ' ' + (noOfGeoms + 1) + ':<br>';
384384
var $geomType = $('select[name=\'gis_data[' + (noOfGeoms - 1) + '][gis_type]\']').clone();

js/src/import.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ AJAX.registerOnload('import.js', function () {
240240
} else if (percent > 9 || complete > 2000000) {
241241
// Calculate estimated time
242242
var usedTime = now - importStart;
243-
var seconds = parseInt(((total - complete) / complete) * usedTime / 1000);
243+
var seconds = parseInt((((total - complete) / complete) * usedTime / 1000).toString());
244244
var speed = window.sprintf(
245245
window.Messages.uploadProgressPerSecond,
246246
Functions.formatBytes(complete / usedTime * 1000, 1, window.Messages.strDecimalSeparator)
247247
);
248248

249-
var minutes = parseInt(seconds / 60);
249+
var minutes = parseInt((seconds / 60).toString());
250250
seconds %= 60;
251251
var estimatedTime;
252252
if (minutes > 0) {

js/src/jqplot/plugins/jqplot.byteFormatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import $ from 'jquery';
4848
return function (format, value) {
4949
var val = value;
5050
if (typeof val === 'number') {
51-
val = parseFloat(val) || 0;
51+
val = parseFloat(val.toString()) || 0;
5252

5353
return formatByte(val, i);
5454
} else {

js/src/makegrid.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,14 +775,14 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine
775775

776776
if (data.transformations !== undefined) {
777777
$.each(data.transformations, function (cellIndex, value) {
778-
var $thisField = $(g.t).find('.to_be_saved').eq(cellIndex);
778+
var $thisField = $(g.t).find('.to_be_saved').eq(Number(cellIndex));
779779
$thisField.find('span').html(value);
780780
});
781781
}
782782

783783
if (data.relations !== undefined) {
784784
$.each(data.relations, function (cellIndex, value) {
785-
var $thisField = $(g.t).find('.to_be_saved').eq(cellIndex);
785+
var $thisField = $(g.t).find('.to_be_saved').eq(Number(cellIndex));
786786
$thisField.find('span').html(value);
787787
});
788788
}
@@ -1278,7 +1278,7 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine
12781278
}
12791279

12801280
fullWhereClause.push(whereClause);
1281-
var conditionArray = JSON.parse($tr.find('.condition_array').val());
1281+
var conditionArray = JSON.parse(($tr.find('.condition_array').val() as string));
12821282

12831283
/**
12841284
* multi edit variables, for current row

js/src/modules/ajax-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ 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: JQuery): void {
154-
if ($thisMessageBox !== undefined && $thisMessageBox instanceof $) {
153+
const ajaxRemoveMessage = function ($thisMessageBox: JQuery | boolean): void {
154+
if ($thisMessageBox !== undefined && typeof $thisMessageBox !== 'boolean' && $thisMessageBox instanceof $) {
155155
$thisMessageBox
156156
.stop(true, true)
157157
.fadeOut('medium');

js/src/modules/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ function setupValidation () {
548548

549549
// disable textarea spellcheck
550550
if (tagName === 'TEXTAREA') {
551-
$el.attr('spellcheck', false);
551+
$el.attr('spellcheck', 'false');
552552
}
553553
});
554554

0 commit comments

Comments
 (0)