Skip to content

TS types in redux actions and tests#5535

Merged
edisile merged 3 commits intomainfrom
releases-ui-ts
Dec 16, 2025
Merged

TS types in redux actions and tests#5535
edisile merged 3 commits intomainfrom
releases-ui-ts

Conversation

@edisile
Copy link
Copy Markdown
Contributor

@edisile edisile commented Dec 16, 2025

Done

  • added TS type for redux actions and tests
  • updated reducers to use these types

How to QA

no need for QA

Testing

Security

  • Security considerations for review (list them):
    • Examples:
    • Access control: users can only access their own data
    • Input: user input is validated and sanitised
    • Sensitive data: secret or private data is not exposed in any way
    • ...
  • This PR has no security considerations (explain why): just TS types

Issue / Card

Fixes #

Screenshots

* Initial plan

* Convert 5 simple action files to TypeScript: globalNotification, modal, currentTrack, pendingCloses, revisions

Co-authored-by: edisile <4310497+edisile@users.noreply.github.com>

* Convert medium complexity action files to TypeScript: branches, architectures, availableRevisionsSelect, channelMap, history

Co-authored-by: edisile <4310497+edisile@users.noreply.github.com>

* Convert final complex action files to TypeScript: defaultTrack and pendingReleases

Co-authored-by: edisile <4310497+edisile@users.noreply.github.com>

* Fix test failure: remove extra properties from Progressive object

Co-authored-by: edisile <4310497+edisile@users.noreply.github.com>

* fix: available revisions action

* fix: release response types

* fix: types that copilot missed or mangled

* fix: tests imports, no idea how they passed before

* chore: cleanup unused imports

* chore: types for gaEventTracking action

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: edisile <4310497+edisile@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 16, 2025 11:28
@webteam-app
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates Redux actions and tests from JavaScript to TypeScript, improving type safety throughout the releases management system. The refactoring moves action type definitions from reducer files to dedicated action files, establishing a cleaner architectural pattern. However, the migration introduces several type safety issues through excessive use of 'any' casts and incomplete type definitions that undermine the benefits of TypeScript.

Key changes:

  • Converted JavaScript action files to TypeScript with proper type definitions
  • Moved action type definitions from reducer files to action files for better organization
  • Updated all reducer and test imports to reference action files instead of reducer files
  • Added type safety improvements to component props using typeof for function types

Reviewed changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
static/js/publisher/types/releaseTypes.ts Updated AvailableRevisionsSelect to use typeof constants; exported ReleaseErrorResponse; modified DispatchFn type
static/js/publisher/pages/Releases/reducers/*.ts Removed action type definitions and updated imports to reference action files
static/js/publisher/pages/Releases/reducers/tests/*.test.ts Updated imports to reference action files; added type assertions to test data
static/js/publisher/pages/Releases/actions/*.ts New TypeScript versions of action files with type definitions and action creators
static/js/publisher/pages/Releases/actions/*.js Deleted JavaScript versions replaced by TypeScript files
static/js/publisher/pages/Releases/actions/index.ts New barrel export file for centralized action exports
static/js/publisher/pages/Releases/components/*.tsx Improved type safety for triggerGAEvent props using typeof and Parameters utility type
Comments suppressed due to low confidence (7)

static/js/publisher/pages/Releases/reducers/pendingCloses.ts:21

  • The reducer file exports 'ReleaseRevisionAction' and 'CancelPendingReleasesAction' which are actions that belong to pendingReleases, not pendingCloses. Following the refactoring pattern in this PR, these action types should only be defined and exported from their corresponding action files. The reducer should only import these types, not re-export them. This creates confusion and duplication.
    static/js/publisher/pages/Releases/actions/defaultTrack.ts:108
  • Multiple dispatch calls are being cast to 'any' to bypass type checking (lines 59, 95, 108). This undermines the type safety improvements of this PR. Instead of casting to 'any', consider updating the DispatchFn type or creating properly typed dispatch methods that accept the specific action types being used.
    static/js/publisher/pages/Releases/actions/defaultTrack.ts:34
  • Using '(window as any).CSRF_TOKEN' bypasses type checking. Consider defining a proper type declaration for the window object with CSRF_TOKEN property, such as: 'declare global { interface Window { CSRF_TOKEN: string; } }' in a types file.
    static/js/publisher/pages/Releases/actions/pendingReleases.ts:135
  • The object is being cast to 'Progressive' but only contains 'percentage' and 'paused'. The Progressive type requires three properties: "current-percentage", "paused", and "percentage" (all can be null). You're missing "current-percentage". Either provide all required Progressive properties or create a more specific type that only requires the properties being set.
    static/js/publisher/pages/Releases/actions/history.ts:61
  • The dispatch call is being cast to 'any' to bypass type checking. This defeats the purpose of adding TypeScript types. The issue is that 'closeHistory()' returns 'CloseHistoryAction' but 'DispatchFn' expects a union that includes 'GenericReleasesAction<string, never>'. Consider updating the DispatchFn type definition or the action union types to properly include all valid actions without requiring type casts.
    static/js/publisher/pages/Releases/actions/pendingReleases.ts:157
  • The payload is being cast to 'Progressive' but only contains 'percentage'. The Progressive type requires three properties: "current-percentage", "paused", and "percentage" (all can be null). You're missing "current-percentage". Either provide all required Progressive properties or create a more specific action payload type that only requires the properties being set.
    static/js/publisher/pages/Releases/actions/pendingReleases.ts:168
  • The payload is being cast to 'Progressive' but only contains 'percentage'. The Progressive type requires three properties: "current-percentage", "paused", and "percentage" (all can be null). You're missing "current-percentage". Either provide all required Progressive properties or create a more specific action payload type that only requires the properties being set.

Comment thread static/js/publisher/pages/Releases/actions/revisions.ts
Comment thread static/js/publisher/pages/Releases/actions/releases.ts
Comment thread static/js/publisher/pages/Releases/actions/channelMap.ts
Comment thread static/js/publisher/pages/Releases/reducers/__tests__/pendingReleases.test.ts Outdated
Comment thread static/js/publisher/pages/Releases/actions/branches.ts Outdated
Comment thread static/js/publisher/types/releaseTypes.ts
Copy link
Copy Markdown
Contributor

@steverydz steverydz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@edisile edisile merged commit a8863ab into main Dec 16, 2025
13 checks passed
@edisile edisile deleted the releases-ui-ts branch December 16, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants