-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
message_events: Convert module to typescript. #32492
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
Conversation
8ee4c56
to
5cd85f9
Compare
Made the changes Anders suggested, though the PR description is still accurate. |
5cd85f9
to
f0c9ac7
Compare
f0c9ac7
to
b646054
Compare
web/src/message_events.ts
Outdated
function filter_has_term_type(filter: Filter | undefined, term_type: string): boolean { | ||
return ( | ||
filter !== undefined && |
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.
Accepting Filter | undefined
here has no advantage; every caller either passes a defined Filter
or has to later check for undefined
anyway.
function filter_has_term_type(filter: Filter | undefined, term_type: string): boolean { | |
return ( | |
filter !== undefined && | |
function filter_has_term_type(filter: Filter, term_type: string): boolean { | |
return ( |
assert(first_message !== undefined); | ||
const first_id = first_message.id; | ||
const last_message = msg_list.last(); | ||
assert(last_message !== undefined); |
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.
Do we know these aren’t undefined
?
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.
If they had been, the previously existing code would have given an error for calling .id
on undefined
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 I'm not sure the previous code is correct here; @amanagr can investigate as a follow-up.
b646054
to
b8232a5
Compare
Accepting an undefined Filter has no advantage; every caller either passes a defined Filter or has to later check for undefined anyway.
b8232a5
to
b5d14a9
Compare
prev_stream?: number; | ||
topic?: string; | ||
prev_topic?: 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.
Probably a good follow-up would be to refine this type to be a union of different types of edit history event types used elsewhere in the codebase. EditHistoryEntry
is fairly different. Might be appropriate to just leave an issue for this if it seems like work.
Merged, thanks @evykassirer! Pretty excited to have this one merged, since it's one of the last handful of big files, and one of the more logically complex. |
There are a handful of things I made assumptions about that I need to check, one of which is related to a failing test, but opening this as a draft for now in case anyone wants to take a first pass review on it.