Skip to content

remove utilFunctor from a few easy places - #13084

Open
k-yle wants to merge 1 commit into
developfrom
kh/functor3
Open

k-yle wants to merge 1 commit into
developfrom
kh/functor3

Conversation

@k-yle

@k-yle k-yle commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

utilFunctor is a bit too cunning for typescript to understand. while it might be handy for a method to accept both x and () => x, we don't actually make use of this ability. For each method, we pass a literal 100% of the time, or a function 100% of the time.

imo getting rid of x = _x.apply(this, arguments) also makes it easier to understand what's going on. in many cases the arguments and this that were being forwarded we not actually being used.

@k-yle k-yle added this to the typescript migration milestone Oct 29, 2026
@k-yle k-yle added the chore Improvements to the iD development experience or codebase label Oct 29, 2026
@k-yle
k-yle added this pull request to stack #13086 October 29, 2026 10:09
Comment thread modules/ui/popover.js
@@ -148,7 +147,7 @@ export function uiPopover(klass) {
popoverSelection.classed('fade', true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

popoverSelection.classed('fade', true);, together with var animate = _animation; and var _animation = false; looks like a dead code

probably as followup PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

first if (animate) { look like it is never entered, second that classing as fade seems to have no possible effect

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good spotting yeah ur right

@matkoniecz

Copy link
Copy Markdown
Collaborator

For each method, we pass a literal 100% of the time, or a function 100% of the time.

I guess that to review this PR I also need to check whether places getting literal now are always using it as a literal

including potentially from outside, or maybe it is safe to assume that _ convention for internal-only is respected?

@k-yle

k-yle commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

yes unfortuantely this one is a pain to review. TypeScript proved that it works in the branch where this file is already converted to TS, and this PR is just cherrypicking the relevant lines from that branch

@tyrasd

tyrasd commented Nov 24, 2026

Copy link
Copy Markdown
Member

btw: the functor logic had already been causing issues in the past when refactoring some of the UI text rendering from (html) strings to d3 callback functions, which were easily confused by the code for functors. 🙈 so definitely a big 👍 from my side to get rid of this for good. the extra () => … here and there is totally acceptable.

This branch was successfully deployed

1 active (outdated) deployment
pr-preview-13084 — 868a1c68 Deployed Nov 2, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Improvements to the iD development experience or codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants