fix types

This commit is contained in:
Ashley Harrison
2023-08-29 15:33:03 +01:00
parent f74bd3a52d
commit f549f18ce0
2 changed files with 12 additions and 6 deletions
+1 -3
View File
@@ -118,9 +118,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"]
[0, 0, 0, "Do not use any type assertions.", "8"]
],
"packages/grafana-data/src/datetime/parser.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@@ -131,9 +131,17 @@ export const dateTimeForTimeZone = (
}
if (timezone && timezone !== 'browser') {
// TODO fix types here
//@ts-ignore
return moment.tz(input as MomentInput, formatInput, timezone) as DateTime;
let result: moment.Moment;
if (typeof input === 'string' && formatInput) {
result = moment.tz(input, formatInput, timezone);
} else {
result = moment.tz(input, timezone);
}
if (isDateTime(result)) {
return result;
}
}
return dateTime(input, formatInput);