This is an automated email from the ASF dual-hosted git repository.

hainenber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a74424545a fix(types): add explicit types for extendedDayjs plugin 
methods (#37923)
8a74424545a is described below

commit 8a74424545ac96699eaefb91f6f0951aecee0fbd
Author: Evan Rusackas <[email protected]>
AuthorDate: Mon Feb 23 18:58:46 2026 -0500

    fix(types): add explicit types for extendedDayjs plugin methods (#37923)
---
 .../packages/superset-ui-core/src/utils/dates.ts   | 40 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/packages/superset-ui-core/src/utils/dates.ts 
b/superset-frontend/packages/superset-ui-core/src/utils/dates.ts
index 9594f15c988..1082b67afe1 100644
--- a/superset-frontend/packages/superset-ui-core/src/utils/dates.ts
+++ b/superset-frontend/packages/superset-ui-core/src/utils/dates.ts
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import dayjs, { Dayjs } from 'dayjs';
+import dayjs, { Dayjs, ConfigType } from 'dayjs';
 import utc from 'dayjs/plugin/utc';
 import timezone from 'dayjs/plugin/timezone';
 import calendar from 'dayjs/plugin/calendar';
@@ -40,8 +40,42 @@ dayjs.updateLocale('en', {
   invalidDate: 'Invalid date',
 });
 
-export const extendedDayjs = dayjs;
-export type { Dayjs };
+// Extended Dayjs instance type with plugin methods.
+// When extending dayjs with a new plugin, add its instance methods here.
+export interface ExtendedDayjs extends Dayjs {
+  // Derived from dayjs/plugin/utc
+  utc(keepLocalTime?: boolean): ExtendedDayjs;
+  local(): ExtendedDayjs;
+  isUTC(): boolean;
+  // Derived from dayjs/plugin/timezone
+  tz(timezone?: string, keepLocalTime?: boolean): ExtendedDayjs;
+  // Derived from dayjs/plugin/relativeTime
+  fromNow(withoutSuffix?: boolean): string;
+  toNow(withoutSuffix?: boolean): string;
+  from(compared: ConfigType, withoutSuffix?: boolean): string;
+  to(compared: ConfigType, withoutSuffix?: boolean): string;
+  // Derived from dayjs/plugin/calendar
+  calendar(referenceTime?: ConfigType, formats?: object): string;
+}
+
+// Type for dayjs factory with all plugins loaded.
+// When extending dayjs with a new plugin, add its static methods here.
+type DayjsWithPlugins = {
+  (config?: ConfigType, format?: string, strict?: boolean): ExtendedDayjs;
+  // Derived from dayjs/plugin/utc
+  utc(config?: ConfigType, format?: string, strict?: boolean): ExtendedDayjs;
+  // Derived from dayjs/plugin/timezone
+  tz: {
+    (input?: ConfigType, timezone?: string): ExtendedDayjs;
+    guess(): string;
+    setDefault(timezone?: string): void;
+  };
+  // Derived from dayjs/plugin/updateLocale
+  updateLocale(locale: string, config: object): object;
+} & Omit<typeof dayjs, 'utc' | 'tz'>;
+
+export const extendedDayjs = dayjs as unknown as DayjsWithPlugins;
+export type { Dayjs, ConfigType };
 
 export const fDuration = function (
   t1: number,

Reply via email to