Skip to content

[UI] Enable strict TypeScript checking for date-picker popover - #3976

Merged
sfeilmeier merged 3 commits into
OpenEMS:developfrom
PunugupatiSaikumar:feature/ui-pickdate-popover-typescript-strict
Sep 22, 2026
Merged

sfeilmeier merged 3 commits into
OpenEMS:developfrom
PunugupatiSaikumar:feature/ui-pickdate-popover-typescript-strict

Conversation

@PunugupatiSaikumar

Copy link
Copy Markdown
Contributor

Changes

  • Enable strict checking for the date-picker popover.
  • Declare the callback supplied when creating the popover.
  • Preserve existing date-function behavior for undefined input.
  • Correct the allowed-history-periods helper's input and return types

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

❌ Your patch check has failed because the patch coverage (50.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3976      +/-   ##
=============================================
- Coverage      55.47%   55.47%   -0.00%     
+ Complexity     19537    19536       -1     
=============================================
  Files           3861     3861              
  Lines         178080   178082       +2     
  Branches       14818    14818              
=============================================
- Hits           98771    98767       -4     
- Misses         75424    75431       +7     
+ Partials        3885     3884       -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sfeilmeier sfeilmeier linked an issue Sep 22, 2026 that may be closed by this pull request
this.myDpOptions.disableUntil = {
day: Utils.subtractSafely(getDate(this.edge?.firstSetupProtocol), 1) ?? 1,
month: Utils.addSafely(getMonth(this.edge?.firstSetupProtocol), 1) ?? 1,
day: Utils.subtractSafely(getDate(dateInput), 1) ?? 1,

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.

Utils is deprecated. Replace with NumberUtils

month: Utils.addSafely(getMonth(this.edge?.firstSetupProtocol), 1) ?? 1,
day: Utils.subtractSafely(getDate(dateInput), 1) ?? 1,
month: Utils.addSafely(getMonth(dateInput), 1) ?? 1,
year: this.edge?.firstSetupProtocol?.getFullYear() ?? 2013,

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.

That entire logic was flawed. Please see my changes.

@sfeilmeier

Copy link
Copy Markdown
Contributor

Review of session changes

  1. Utils.subtractSafely/Utils.addSafelyNumberUtils.subtractSafely/NumberUtils.addSafely — good cleanup, the Utils variants are marked @deprecated in favor of NumberUtils. Utils import removed since it's now unused.

  2. Removed the NaN-substitution hack in favor of an explicit branch: disableUntil is now only computed from firstSetupProtocol when it's actually defined; otherwise it falls back to a named default. This is clearer and removes the fragile getDate(NaN)/NumberUtils.subtractSafely(NaN, 1) ?? 1 path we flagged earlier (which silently produced NaN instead of falling back). Good fix — this also resolves the pre-existing latent bug, not just the typing issue.

  3. DEFAULT_DISABLE_UNTIL constant — extracting { day: 1, month: 1, year: 2013 } into private static readonly DEFAULT_DISABLE_UNTIL: IMyDate removes duplication between the myDpOptions field initializer and the ngOnInit() fallback, and gives the magic literal a name. Good improvement; note the original // TODO start with date since the edge is available comment was dropped when the initializer changed to reference the constant — that TODO is still relevant (the field initializer still defaults to 2013 before ngOnInit runs), consider re-adding it near the constant declaration if that context should be preserved.

  4. Ternary formatting — the final ternary is a bit dense (7 lines) but auto-formatted consistently with the project's Prettier/ESLint config (verified: lint passes clean). Readability is acceptable given it now clearly branches on a single condition (firstSetupProtocol !== undefined) instead of threading a synthetic NaN through math helpers.

No remaining concerns — this is a solid, self-contained improvement on top of the already-reviewed diff, and it's fully covered by the existing EdgePermission/PickdatePopover test suites (32/32 passing) plus tsc --noEmit and ng lint with zero errors.

@sfeilmeier
sfeilmeier merged commit f8341fe into OpenEMS:develop Sep 22, 2026
6 of 7 checks passed
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.

UI: turn on strict mode

2 participants