bito-code-review[bot] commented on code in PR #37923:
URL: https://github.com/apache/superset/pull/37923#discussion_r2796594879
##########
superset-frontend/packages/superset-ui-core/src/utils/dates.ts:
##########
@@ -40,8 +40,29 @@ dayjs.updateLocale('en', {
invalidDate: 'Invalid date',
});
-export const extendedDayjs = dayjs;
-export type { Dayjs };
+// Extended Dayjs instance type with plugin methods
+export interface ExtendedDayjs extends Dayjs {
+ utc(keepLocalTime?: boolean): ExtendedDayjs;
+ local(): ExtendedDayjs;
+ tz(timezone?: string, keepLocalTime?: boolean): ExtendedDayjs;
+ fromNow(withoutSuffix?: boolean): string;
+ toNow(withoutSuffix?: boolean): string;
+}
+
+// Type for dayjs factory with all plugins loaded
+type DayjsWithPlugins = {
+ (config?: ConfigType, format?: string): ExtendedDayjs;
+ utc(config?: ConfigType, format?: string): ExtendedDayjs;
+ tz: {
+ (input?: ConfigType, timezone?: string): ExtendedDayjs;
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Type Safety: Interface Return Types</b></div>
<div id="fix">
The ExtendedDayjs interface defines methods like utc(), local(), and tz()
that return Dayjs instances, but since ExtendedDayjs extends Dayjs and these
methods maintain the extended functionality, they should return ExtendedDayjs
to preserve type safety during chaining (e.g.,
extendedDayjs().utc().tz().fromNow()).
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
export interface ExtendedDayjs extends Dayjs {
utc(keepLocalTime?: boolean): ExtendedDayjs;
local(): ExtendedDayjs;
isUTC(): boolean;
tz(timezone?: string, keepLocalTime?: boolean): ExtendedDayjs;
fromNow(withoutSuffix?: boolean): string;
toNow(withoutSuffix?: boolean): string;
from(compared: ConfigType, withoutSuffix?: boolean): string;
to(compared: ConfigType, withoutSuffix?: boolean): string;
calendar(referenceTime?: ConfigType, formats?: object): string;
}
````
</div>
</details>
</div>
<small><i>Code Review Run #fefbdf</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]