Skip to content
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

some fixes when setting noImplicitAny: true #5840

Merged
merged 16 commits into from Jan 26, 2023
Merged

some fixes when setting noImplicitAny: true #5840

merged 16 commits into from Jan 26, 2023

Conversation

b0b3rt
Copy link
Collaborator

@b0b3rt b0b3rt commented Oct 6, 2022

┆Issue is synchronized with this Asana task by Unito

@b0b3rt b0b3rt mentioned this pull request Oct 25, 2022
@b0b3rt b0b3rt marked this pull request as ready for review November 30, 2022 00:49
@b0b3rt b0b3rt requested a review from a team as a code owner November 30, 2022 00:49
@b0b3rt b0b3rt requested review from jpaddison3 and removed request for a team November 30, 2022 00:49
@jpaddison3 jpaddison3 self-assigned this Nov 30, 2022
if (linkIsExcludedFromPreview(href))
continue;
const id = linkTag.getAttribute("id");
const rel = linkTag.getAttribute("rel")
const id = linkTag.getAttribute("id") ?? '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be undefined rather than '' I think (and same for others in this function)

Copy link
Collaborator

@jpaddison3 jpaddison3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a bunch for this. I didn't look over everything, but aggressively skimmed half the changes. I could imaaaaaagine some of the changes from undefined to '' causing behavior changes, but it seems unlikely. All of the type changes I trust you for and/or seem correct.

Please fix the tests before merging, obvs

@jpaddison3 jpaddison3 assigned b0b3rt and unassigned jpaddison3 Nov 30, 2022
Comment on lines 70 to 79
const handleScroll = (e) => {
const isAtBottom = Math.abs((e.target.scrollHeight - e.target.scrollTop) - e.target.clientHeight) < 10;
const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {
const isAtBottom = Math.abs((e.currentTarget.scrollHeight - e.currentTarget.scrollTop) - e.currentTarget.clientHeight) < 10;

// If we are not at the bottom that means the user has scrolled up,
// in which case never autoscroll to the bottom again
if (!isAtBottom)
setUserHasScrolled(true);

// Start loading more when we are less than 1 page from the top
if (!loadingMoreComments && commentCount < totalComments && e.target.scrollTop < e.target.clientHeight)
if (!loadingMoreComments && commentCount < totalComments && e.currentTarget.scrollTop < e.currentTarget.clientHeight)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @Will-Howard this is one of the few actual code changes in this PR. I'm not 100% sure how to test this change; adding the React.UIEvent<HTMLDivElement> type to the event caused it to complain that target didn't exist, but currentTarget does. According to DefinitelyTyped/DefinitelyTyped#11508 (comment) it seems like we should probably be using currentTarget, not super confident.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this whole file can actually be deleted now. We are now using the TagSubforumPage2 component which doesn't use this (instead of TagSubforumPage), and I don't think there's any chance of going back at this point

@@ -78,7 +78,7 @@ const RecentDiscussionTag = ({ tag, refetch = () => {}, comments, expandAllThrea

const lastVisitedAt = markedAsVisitedAt || tag.lastVisitedAt
const lastCommentId = comments && comments[0]?._id
const nestedComments = useOrderPreservingArray(unflattenComments(comments), (comment) => comment._id);
const nestedComments = useOrderPreservingArray(unflattenComments(comments), (comment) => comment.item._id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Will-Howard removing the implicit typing in useOrderPreservingArray caused this to error - I think it may have been silently failing to work, since CommentTreeNode doesn't have an _id, it's a container with an item (which is the comment that has an _id). But not sure what functional tests I ought to be trying here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing! I thought this had already been fixed but maybe it got lost in a merge or the PR was closed 🤷‍♂️. The functional test would be that if there are several comments being rendered in the card and you reply to the one at the bottom, it shouldn't jump to the top

@b0b3rt b0b3rt merged commit a1ec8cb into master Jan 26, 2023
@jpaddison3
Copy link
Collaborator

🎉 about this finally getting merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants