Skip to content

[OP-20343] Frontend typings: third-party modules and helpers - #25659

Open
myabc wants to merge 5 commits into
devfrom
implementation/op-20343-eslint-typing-fix-third-party
Open

myabc wants to merge 5 commits into
devfrom
implementation/op-20343-eslint-typing-fix-third-party

Conversation

@myabc

@myabc myabc commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/OP-20343

What are you trying to accomplish?

Part of OP-20341: removes ESLint typing violations around untyped third-party APIs and shared helpers, without changing behaviour.

  • Types the dom-plane module and the DOM autoscroll service.
  • Types shared helper signatures (click positioning, tracking functions, debounced event emitter, debug output, icon builder).
  • Types the timezone service inputs and the resize timer.
  • Types the EnjoyHint onboarding tour.
  • Types the CKEditor config, UI and watchdog interfaces.

Application-code typing violations drop from 1,203 to 1,117; shared/helpers, core/datetime, core/setup and the CKEditor editor components are at zero.

What approach did you choose and why?

Changes are types and boundary casts only; no runtime narrowing was added. The Gecko-only rangeParent/rangeOffset event properties are cast at their one read site, and CKEditor's config type declares only the autosave key the app reads.

TimezoneService#parseDate now accepts MomentInput, since filter callers already pass Moment values. DomAutoscrollService#autoScroll returns boolean|undefined, matching its two Stimulus callers. Typing CKEditor's UI made three inline disables unused, so they are removed.

Typing the autoscroll parameters surfaces three existing prefer-nullish-coalescing hits on untouched lines; switching || to ?? there would change behaviour for 0, so they stay for the separate nullish-coalescing housekeeping.

Stacked on #25656, which touches the same declaration files; GitHub retargets this to dev once #25656 merges.

AI involvement

Directed – I specified the requirements and AI implemented most of it; I validated via testing rather than a full line-by-line review.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)
Browser JavaScript diff (3 files, type-only changes omitted)

Each changed browser file (TypeScript and templates, excluding specs, test helpers and declaration files) is transpiled on its own with frontend/tsconfig.json, before and after; this is the emitted JavaScript that differs.

diff --git frontend/src/app/shared/helpers/drag-and-drop/dom-autoscroll.service.js
index 98f4098..344f87d 100644
--- frontend/src/app/shared/helpers/drag-and-drop/dom-autoscroll.service.js
+++ frontend/src/app/shared/helpers/drag-and-drop/dom-autoscroll.service.js
@@ -1,4 +1,4 @@
-import { createPointCB, getClientRect as getRect, pointInside } from 'dom-plane';
+import { createPointCB, getClientRect as getRect, pointInside, } from 'dom-plane';
 export class DomAutoscrollService {
     constructor(elements, params) {
         this.down = false;
diff --git frontend/src/app/shared/helpers/rxjs/debounced-event-emitter.js
index 3915da0..e67eccb 100644
--- frontend/src/app/shared/helpers/rxjs/debounced-event-emitter.js
+++ frontend/src/app/shared/helpers/rxjs/debounced-event-emitter.js
@@ -12,7 +12,7 @@ export class DebouncedEventEmitter {
     emit(value) {
         this.debouncer.next(value);
     }
-    subscribe(generatorOrNext, error, complete) {
-        return this.emitter.subscribe(generatorOrNext, error, complete);
+    subscribe(...params) {
+        return this.emitter.subscribe(...params);
     }
 }
diff --git frontend/src/app/shared/helpers/set-click-position/set-click-position.js
index c45e09a..012c60f 100644
--- frontend/src/app/shared/helpers/set-click-position/set-click-position.js
+++ frontend/src/app/shared/helpers/set-click-position/set-click-position.js
@@ -9,9 +9,10 @@ export function setPosition(element, offset) {
 }
 export function getPosition(evt) {
     try {
-        if (evt.rangeParent) {
+        const geckoEvent = evt;
+        if (geckoEvent.rangeParent) {
             const range = document.createRange();
-            range.setStart(evt.rangeParent, evt.rangeOffset);
+            range.setStart(geckoEvent.rangeParent, geckoEvent.rangeOffset);
             return range.startOffset;
         }
         const legacyDocument = document;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Preserve observer-object subscriptions in the debounced event emitter API.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds TypeScript typings for third-party integrations and shared frontend helpers without intended runtime changes.

Changes:

  • Typed dom-plane, EnjoyHint, CKEditor, autoscroll, timezone, and resize APIs.
  • Replaced untyped helper signatures.
  • Removed obsolete ESLint suppressions.

Review note: debounced-event-emitter should preserve the Partial<Observer<T>> subscription overload.

File Description
frontend/​src/​typings/​shims.d.ts Types the onboarding global.
frontend/​src/​typings.d.ts Declares dom-plane APIs.
frontend/​src/​app/​shared/​helpers/​set-click-position/​set-click-position.ts Types Gecko event properties.
frontend/​src/​app/​shared/​helpers/​rxjs/​debounced-event-emitter.ts Types emitter subscriptions.
frontend/​src/​app/​shared/​helpers/​op-icon-builder.ts Types SVG icon data.
frontend/​src/​app/​shared/​helpers/​drag-and-drop/​dom-autoscroll.service.ts Types autoscroll parameters and points.
frontend/​src/​app/​shared/​helpers/​debug_output.ts Types timing helper results.
frontend/​src/​app/​shared/​helpers/​angular/​tracking-functions.ts Types comparison helpers.
frontend/​src/​app/​shared/​components/​editor/​components/​ckeditor/​op-ckeditor.component.ts Removes obsolete suppression.
frontend/​src/​app/​shared/​components/​editor/​components/​ckeditor/​ckeditor.types.ts Adds CKEditor typings.
frontend/​src/​app/​shared/​components/​editor/​components/​ckeditor/​ckeditor-setup.service.ts Removes obsolete suppression.
frontend/​src/​app/​shared/​components/​editor/​components/​ckeditor-augmented-textarea/​ckeditor-augmented-textarea.component.ts Removes obsolete suppression.
frontend/​src/​app/​core/​setup/​globals/​onboarding/​onboarding_tour.ts Types EnjoyHint integration.
frontend/​src/​app/​core/​setup/​globals/​global-listeners/​setup-server-response.ts Types the resize timer.
frontend/​src/​app/​core/​datetime/​timezone.service.ts Types date-related inputs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread frontend/src/app/shared/helpers/rxjs/debounced-event-emitter.ts Outdated
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/bim/spec/features/card_view/select_card_spec.rb[1:1:2]
  • rspec ./modules/bim/spec/features/card_view/select_card_spec.rb[1:1:3]
  • rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25659, linked for reference only):

- `rspec ./modules/bim/spec/features/card_view/select_card_spec.rb[1:1:2]`
- `rspec ./modules/bim/spec/features/card_view/select_card_spec.rb[1:1:3]`
- `rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]`

Treat this as a standalone task, unrelated to PR #25659. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25659 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @myabc to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @myabc, and request a review from @myabc.
On every commit, set @myabc as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

Declares the dom-plane point, client rect and callback shapes from the
library source instead of `any`, and types the autoscroll service's
constructor params, pointer point and move event against them. The
empty point object is cast once at construction, keeping today's
lazily populated behaviour.

https://community.openproject.org/wp/OP-20343
Replaces `any` in the comparators, click-position helper, timing
helpers, octicon builder and debounced emitter with the types their
callers already pass: `unknown` operands, the Gecko-only
`rangeParent`/`rangeOffset` event fields, a generic timing result,
`SVGData`, and the `EventEmitter` subscribe callbacks. Drops the
redundant union in `compareByHrefOrString` and an unused disable.

https://community.openproject.org/wp/OP-20343
Types the ISO date formatters with moment's `MomentInput` and
`Moment`, since callers pass dates, strings and moments alike, and
widens `parseDate` to match. Types the resize debounce handle as the
`setTimeout` return type.

https://community.openproject.org/wp/OP-20343
Declares the EnjoyHint constructor options and the instance methods
the onboarding tour calls, and types `window.onboardingTourInstance`
with them. Collapses the redundant `string|unknown` step index
signature and drops the disable the typed constructor makes unused.

https://community.openproject.org/wp/OP-20343
Declares the parts of the CKEditor instance the app touches: the
autosave config lookup, the focus tracker and the toolbar element.
Editor and watchdog config arguments become `unknown`, since they are
passed through opaquely, and the error stack an optional string.
Removes the member-access disables the typed `ui` makes unused.

https://community.openproject.org/wp/OP-20343
@myabc
myabc force-pushed the housekeeping/eslint-fixes branch from f8ecee6 to f1cdcca Compare September 29, 2026 09:47
@myabc
myabc force-pushed the implementation/op-20343-eslint-typing-fix-third-party branch from 1e00295 to e9afabb Compare September 29, 2026 09:47
@myabc myabc added eslint javascript Pull requests that update Javascript code needs review labels Sep 29, 2026
@myabc myabc added this to the 18.0.x milestone Sep 29, 2026
@github-actions github-actions Bot added the ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. label Sep 29, 2026
@myabc
myabc marked this pull request as ready for review September 29, 2026 10:22
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]
  • rspec ./spec/features/work_packages/details/relations/primerized_relations_syncing_spec.rb[1:2]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #25659, linked for reference only):

- `rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]`
- `rspec ./spec/features/work_packages/details/relations/primerized_relations_syncing_spec.rb[1:2]`

Treat this as a standalone task, unrelated to PR #25659. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25659 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @myabc to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @myabc, and request a review from @myabc.
On every commit, set @myabc as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

Base automatically changed from housekeeping/eslint-fixes to dev September 29, 2026 18:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. eslint javascript Pull requests that update Javascript code needs review

Development

Successfully merging this pull request may close these issues.

2 participants