[PR #2136] [MERGED] Add proper types to runHandler #4141

Closed
opened 2026-02-28 20:52:07 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/2136
Author: @twk3
Created: 12/29/2023
Status: Merged
Merged: 1/9/2024
Merged by: @twk3

Base: masterHead: typescript-run-handler


📝 Commits (3)

  • 66d8f2d Add proper types to runHandler
  • e638096 Add release note
  • a44f01a Merge branch 'master' into typescript-run-handler

📊 Changes

8 files changed (+56 additions, -44 deletions)

View changed files

📝 packages/loot-core/src/mocks/budget.ts (+8 -7)
📝 packages/loot-core/src/platform/server/connection/index.web.ts (+1 -5)
📝 packages/loot-core/src/server/main.ts (+9 -9)
📝 packages/loot-core/src/server/mutators.ts (+5 -5)
📝 packages/loot-core/src/server/schedules/types/handlers.ts (+1 -1)
📝 packages/loot-core/src/types/api-handlers.d.ts (+17 -8)
📝 packages/loot-core/src/types/server-handlers.d.ts (+9 -9)
upcoming-release-notes/2136.md (+6 -0)

📄 Description

Summary

  • Args and return values from runHandler should now work within loot core
  • Updated some of the handler types to be more accurate

Split from https://github.com/actualbudget/actual/pull/2053 to start preparing to bring types to the API.

Verify

Can be verified by going to one of the places that runHandlers is called, like the main.test.ts or the mocks/budget.ts and trying to put in some incorrect args to a handler that is strongly typed.

Like the following where a test: "this will error" was added:

await runHandler(handlers['schedule/create'], {
        schedule: {
          name: 'Phone bills',
          posts_transaction: false,
          test: "this will error",
        },
        conditions: [
          {
            op: 'is',
            field: 'payee',
            value: payees.find(item => item.name === 'Dominion Power').id,
          },
          {
            op: 'is',
            field: 'account',
            value: account.id,
          },
          {
            op: 'is',
            field: 'date',
            value: {
              start: monthUtils.currentDay(),
              frequency: 'monthly',
              patterns: [],
              skipWeekend: false,
              weekendSolveMode: 'after',
            },
          },
          { op: 'isapprox', field: 'amount', value: -12000 },
        ],
      });

Then either yarn typecheck or your IDE with flag the error.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/2136 **Author:** [@twk3](https://github.com/twk3) **Created:** 12/29/2023 **Status:** ✅ Merged **Merged:** 1/9/2024 **Merged by:** [@twk3](https://github.com/twk3) **Base:** `master` ← **Head:** `typescript-run-handler` --- ### 📝 Commits (3) - [`66d8f2d`](https://github.com/actualbudget/actual/commit/66d8f2de261ee8231ae088f3dbdd3d6b6ad6ff20) Add proper types to runHandler - [`e638096`](https://github.com/actualbudget/actual/commit/e6380967a4ef07c4508fa7660e0fe9abac9c84df) Add release note - [`a44f01a`](https://github.com/actualbudget/actual/commit/a44f01a9002dbb294b70565587c595f216d69dd5) Merge branch 'master' into typescript-run-handler ### 📊 Changes **8 files changed** (+56 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/mocks/budget.ts` (+8 -7) 📝 `packages/loot-core/src/platform/server/connection/index.web.ts` (+1 -5) 📝 `packages/loot-core/src/server/main.ts` (+9 -9) 📝 `packages/loot-core/src/server/mutators.ts` (+5 -5) 📝 `packages/loot-core/src/server/schedules/types/handlers.ts` (+1 -1) 📝 `packages/loot-core/src/types/api-handlers.d.ts` (+17 -8) 📝 `packages/loot-core/src/types/server-handlers.d.ts` (+9 -9) ➕ `upcoming-release-notes/2136.md` (+6 -0) </details> ### 📄 Description ## Summary - Args and return values from runHandler should now work within loot core - Updated some of the handler types to be more accurate Split from https://github.com/actualbudget/actual/pull/2053 to start preparing to bring types to the API. ## Verify Can be verified by going to one of the places that runHandlers is called, like the main.test.ts or the mocks/budget.ts and trying to put in some incorrect args to a handler that is strongly typed. Like the following where a `test: "this will error"` was added: ``` await runHandler(handlers['schedule/create'], { schedule: { name: 'Phone bills', posts_transaction: false, test: "this will error", }, conditions: [ { op: 'is', field: 'payee', value: payees.find(item => item.name === 'Dominion Power').id, }, { op: 'is', field: 'account', value: account.id, }, { op: 'is', field: 'date', value: { start: monthUtils.currentDay(), frequency: 'monthly', patterns: [], skipWeekend: false, weekendSolveMode: 'after', }, }, { op: 'isapprox', field: 'amount', value: -12000 }, ], }); ``` Then either `yarn typecheck` or your IDE with flag the error. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-02-28 20:52:07 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#4141