-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Migration of Chart to TypeScript #28370
base: master
Are you sure you want to change the base?
Conversation
}; | ||
export interface ChartProps { | ||
annotationData?: object; | ||
actions: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use more specific types? In general we try to avoid using very generic types like any
or object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the annotation property
, I believe the interface I created in this PR should be suitable.
For the actions
property I created a type.
What do you think about that?
Co-authored-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
class Chart extends React.PureComponent<ChartProps, {}> { | ||
static defaultProps = defaultProps; | ||
|
||
renderStartTime: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does renderStartTime
come from? In the old version, we're only reading it, but we don't assign any value to it. In your changes you put renderStartTime
in ChartProps, but also as class's field. I don't think it's actually passed as a prop anywhere, and as a class field it's also only read, not assigned.
So maybe we should just remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this from ChartProps.
You mean we should remove him from line 198 and 200 ( start_offset and duration keys)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, unless I misunderstand something here, renderStartTime is always undefined because we don’t set its value anywhere, so maybe we could remove it from the code. @rusackas any objections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we want to actually fix it and assign a timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should understand why it was put there.
I remain waiting for instructions, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if it's not wired up, that's an odd problem. It sure seems like it'd be useful for logging, which seems to be its intent. There's one in ChartRenderer.jsx
that IS wired up, for reference. Maybe we don't need both though?
It WAS set in the original commit, actually. I haven't checked to see when its initialization was removed but clearly there wasn't much outcry.
I'd err on the side of more logging, not less. Maybe @eschutho would be interested in taking more advantage of this insight :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No any
please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Added a few comments
@@ -214,7 +209,7 @@ class Chart extends React.PureComponent<ChartProps, {}> { | |||
}); | |||
} | |||
|
|||
renderErrorMessage(queryResponse: queryResponse) { | |||
renderErrorMessage(QueryResponse: QueryResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argument should be lowercase, only the type is PascalCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not look like this was resolved
Co-authored-by: JUST.in DO IT <justin.park@airbnb.com>
onQuery?: MouseEventHandler<HTMLSpanElement>; | ||
onFilterMenuOpen?: Function; | ||
onFilterMenuClose?: Function; | ||
ownState?: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a better type for this?
@@ -214,7 +209,7 @@ class Chart extends React.PureComponent<ChartProps, {}> { | |||
}); | |||
} | |||
|
|||
renderErrorMessage(queryResponse: queryResponse) { | |||
renderErrorMessage(QueryResponse: QueryResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not look like this was resolved
@@ -201,7 +238,7 @@ class Chart extends React.PureComponent { | |||
}); | |||
} | |||
|
|||
renderErrorMessage(queryResponse) { | |||
renderErrorMessage(QueryResponse: QueryResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderErrorMessage(QueryResponse: QueryResponse) { | |
renderErrorMessage(queryResponse: QueryResponse) { |
emitCrossFilters?: boolean; | ||
} | ||
|
||
export type QueryResponse = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that the response will always be an error. I think we already have a correct type for this. We either need to adjust that to account for the error or create one specifically for when get an error:
Instead of this QueryResponse see: superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts
ChartDataResponse
For the error maybe superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts
ClientErrorObject
class Chart extends React.PureComponent<ChartProps, {}> { | ||
static defaultProps = defaultProps; | ||
|
||
renderStartTime: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No any
please
subtitle: JSX.Element; | ||
copyText: string; | ||
link?: string; | ||
source: ChartSource; | ||
stackTrace?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this could be an extension of superset-frontend/packages/superset-ui-core/src/query/getClientErrorObject.ts
ClientErrorObject
SUMMARY
Migrate Chart to TypeScript
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N.A.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION