Skip to content

Commit 8000b01

Browse files
committed
Fix errors TS2362 and TS2363 reported by TypeScript
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent c3224a5 commit 8000b01

7 files changed

Lines changed: 23 additions & 21 deletions

File tree

js/src/import.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ AJAX.registerOnload('import.js', function () {
205205
$('#upload_form_status_info').html(clockImage + ' ' + window.Messages.uploadProgressMaximumAllowedSize);
206206
$('#upload_form_status').css('display', 'none');
207207
} else {
208-
var now = new Date();
209-
now = Date.UTC(
210-
now.getFullYear(),
211-
now.getMonth(),
212-
now.getDate(),
213-
now.getHours(),
214-
now.getMinutes(),
215-
now.getSeconds()
216-
) + now.getMilliseconds() - 1000;
208+
var nowDate = new Date();
209+
const now = Date.UTC(
210+
nowDate.getFullYear(),
211+
nowDate.getMonth(),
212+
nowDate.getDate(),
213+
nowDate.getHours(),
214+
nowDate.getMinutes(),
215+
nowDate.getSeconds()
216+
) + nowDate.getMilliseconds() - 1000;
217217

218218
var statusText = window.sprintf(
219219
window.Messages.uploadProgressStatusText,

js/src/modules/git-info.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ const GitInfo = {
4848
if (data && data.version && data.date) {
4949
const current = GitInfo.parseVersionString($('span.version').text());
5050
const latest = GitInfo.parseVersionString(data.version);
51+
if (current === false || latest === false) {
52+
return;
53+
}
54+
5155
const url = 'index.php?route=/url&url=https://www.phpmyadmin.net/files/' + escapeHtml(encodeURIComponent(data.version)) + '/';
5256
let versionInformationMessage = document.createElement('span');
5357
versionInformationMessage.className = 'latest';

js/src/server/status/monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function destroyGrid () {
8787

8888
AJAX.registerOnload('server/status/monitor.js', function () {
8989
var $jsDataForm = $('#js_data');
90-
serverTimeDiff = new Date().getTime() - $jsDataForm.find('input[name=server_time]').val();
90+
serverTimeDiff = new Date().getTime() - Number($jsDataForm.find('input[name=server_time]').val());
9191
serverOs = $jsDataForm.find('input[name=server_os]').val();
9292
isSuperUser = $jsDataForm.find('input[name=is_superuser]').val();
9393
serverDbIsLocal = $jsDataForm.find('input[name=server_db_isLocal]').val();

js/src/sql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ AJAX.registerOnload('sql.js', function () {
10951095
});
10961096

10971097
$(document).on('submit', '.maxRowsForm', function () {
1098-
var unlimNumRows = $(this).find('input[name="unlim_num_rows"]').val();
1098+
var unlimNumRows = Number($(this).find('input[name="unlim_num_rows"]').val());
10991099

11001100
var maxRowsCheck = Functions.checkFormElementInRange(
11011101
this,

js/src/table/gis_visualization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ AJAX.registerOnload('table/gis_visualization.js', function () {
281281
// zoom in
282282
scale *= zoomFactor;
283283

284-
var width = $(gisSvg).attr('width');
285-
var height = $(gisSvg).attr('height');
284+
var width = Number($(gisSvg).attr('width'));
285+
var height = Number($(gisSvg).attr('height'));
286286
// zooming in keeping the center unmoved.
287287
x = width / 2 - (width / 2 - x) * zoomFactor;
288288
y = height / 2 - (height / 2 - y) * zoomFactor;
@@ -302,8 +302,8 @@ AJAX.registerOnload('table/gis_visualization.js', function () {
302302
// zoom out
303303
scale /= zoomFactor;
304304

305-
var width = $(gisSvg).attr('width');
306-
var height = $(gisSvg).attr('height');
305+
var width = Number($(gisSvg).attr('width'));
306+
var height = Number($(gisSvg).attr('height'));
307307
// zooming out keeping the center unmoved.
308308
x = width / 2 - (width / 2 - x) / zoomFactor;
309309
y = height / 2 - (height / 2 - y) / zoomFactor;

js/src/table/select.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,20 @@ AJAX.registerOnload('table/select.js', function () {
357357
if ($targetField.is('select')) {
358358
$targetField.val(finalValue);
359359
var $options = $targetField.find('option');
360-
var $closestMin = null;
361-
var $closestMax = null;
360+
var $closestMin: JQuery<HTMLOptionElement> | null = null;
361+
var $closestMax: JQuery<HTMLOptionElement> | null = null;
362362
// Find closest min and max value.
363363
$options.each(function () {
364364
if (
365365
$closestMin === null
366-
|| Math.abs($(this).val() - minValue) < Math.abs($closestMin.val() - minValue)
366+
|| Math.abs(Number($(this).val()) - Number(minValue)) < Math.abs(Number($closestMin.val()) - Number(minValue))
367367
) {
368368
$closestMin = $(this);
369369
}
370370

371371
if (
372372
$closestMax === null
373-
|| Math.abs($(this).val() - maxValue) < Math.abs($closestMax.val() - maxValue)
373+
|| Math.abs(Number($(this).val()) - Number(maxValue)) < Math.abs(Number($closestMax.val()) - Number(maxValue))
374374
) {
375375
$closestMax = $(this);
376376
}

webpack.config.cjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const publicPath = path.resolve(__dirname, 'public');
1212
const typeScriptErrorsToIgnore = [
1313
2322, // TS2322: Type '%s' is not assignable to type '%s'.
1414
2345, // TS2345: Argument of type '%s' is not assignable to parameter of type '%s'.
15-
2362, // TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
16-
2363, // TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
1715
2365, // TS2365: Operator '%s' cannot be applied to types '%s' and '%s'.
1816
2367, // TS2367: This comparison appears to be unintentional because the types '%s' and '%s' have no overlap.
1917
2405, // TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.

0 commit comments

Comments
 (0)