[PR #2053] [MERGED] Bundle loot-core types into the API #4086

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

📋 Pull Request Information

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

Base: masterHead: api-bundle-loot-core-types


📝 Commits (8)

  • ab03b4d Bundle loot-core types into the API
  • dd5da5d Ignore ts bundle error
  • 486e316 Fix build failures
  • 9b2b7dc Merge branch 'master' into api-bundle-loot-core-types
  • 3d8d317 Ensure api doesn't change with type introduction
  • 1fafa5d Improve type casing for InitConfig
  • 12f25cb Fix copy-paste error
  • d4e1688 Merge remote-tracking branch 'origin/master' into api-bundle-loot-core-types

📊 Changes

19 files changed (+190 additions, -62 deletions)

View changed files

📝 .eslintignore (+1 -0)
📝 .eslintrc.js (+5 -0)
📝 .gitignore (+1 -0)
packages/api/index.js (+0 -38)
packages/api/index.ts (+53 -0)
📝 packages/api/methods.ts (+12 -6)
📝 packages/api/package.json (+6 -4)
📝 packages/api/tsconfig.dist.json (+6 -2)
packages/loot-core/bin/build-api (+21 -0)
📝 packages/loot-core/package.json (+1 -1)
📝 packages/loot-core/src/server/importers/ynab5.ts (+2 -2)
📝 packages/loot-core/src/server/main.ts (+7 -1)
📝 packages/loot-core/src/server/mutators.ts (+4 -2)
📝 packages/loot-core/src/shared/schedules.ts (+2 -0)
📝 packages/loot-core/src/types/api-handlers.d.ts (+5 -4)
packages/loot-core/tsconfig.api.json (+12 -0)
📝 tsconfig.json (+4 -0)
upcoming-release-notes/2053.md (+6 -0)
📝 yarn.lock (+42 -2)

📄 Description

So we can have loot-core be the source of truth for some types that get passed through between the API and bundle

  • Improves downstream development with API by including types (currently just the known return types are wired up)
  • Include type output with custom tsconfig for loot-core for the API
    • build loot-core (server focused) types at the same time as the webpack bundle
    • currently copying over existing loot-core handwritten .d.ts files (we may want to rename these to .ts files, so we only pull in the ones the loot-core main.ts actually use)
  • Use path aliases for dist vs dev tsconfigs
  • Convert api index to typescript as example
  • convert the send in mutators.ts to typescript to show mutators return types working
  • Permit ts-ignore for issues with our version of typescript

Testing

  • confirmed vscode was fine with package/api/index.ts (top level tsconfig alias working properly)
  • typecheck and lint pass on clean checkout, but also after api is build and dist and @types is populated
  • Ran a yarn build and yarn pack on the api, then installed into a test project (actual_mint_importer).
    • vscode giving the right typehints
    • didn't do any tsc linting from the test project

Future thoughts

tsconfig composite

I took a crack at turning on references and composite for the api, (and moving the tsconfig.dist.json in the api to be just tsconfig.dist.json), but this requires a lot more tuning of the tsconfig files (dropping the extends, fixing the rootDir, and fun with how includes and excludes combine). Wasn't worth it for this


🔄 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/2053 **Author:** [@twk3](https://github.com/twk3) **Created:** 12/9/2023 **Status:** ✅ Merged **Merged:** 1/20/2024 **Merged by:** [@twk3](https://github.com/twk3) **Base:** `master` ← **Head:** `api-bundle-loot-core-types` --- ### 📝 Commits (8) - [`ab03b4d`](https://github.com/actualbudget/actual/commit/ab03b4d929024f11627585298318d4e26c6515f3) Bundle loot-core types into the API - [`dd5da5d`](https://github.com/actualbudget/actual/commit/dd5da5df11dfb4fea75e496f753250c36513661f) Ignore ts bundle error - [`486e316`](https://github.com/actualbudget/actual/commit/486e316a69a4d0c4220681cd88c8fadf8b60c716) Fix build failures - [`9b2b7dc`](https://github.com/actualbudget/actual/commit/9b2b7dc35524549c64c4b73661ec606345df8c9a) Merge branch 'master' into api-bundle-loot-core-types - [`3d8d317`](https://github.com/actualbudget/actual/commit/3d8d3170ebe140b53ae4064190704897ca904225) Ensure api doesn't change with type introduction - [`1fafa5d`](https://github.com/actualbudget/actual/commit/1fafa5d160e409a01083e9f5699fe38f6bd82991) Improve type casing for InitConfig - [`12f25cb`](https://github.com/actualbudget/actual/commit/12f25cb1741bbf5be684c37ad4ea54a17bbf0204) Fix copy-paste error - [`d4e1688`](https://github.com/actualbudget/actual/commit/d4e168863e730a44b8d351211cf566b538c4722e) Merge remote-tracking branch 'origin/master' into api-bundle-loot-core-types ### 📊 Changes **19 files changed** (+190 additions, -62 deletions) <details> <summary>View changed files</summary> 📝 `.eslintignore` (+1 -0) 📝 `.eslintrc.js` (+5 -0) 📝 `.gitignore` (+1 -0) ➖ `packages/api/index.js` (+0 -38) ➕ `packages/api/index.ts` (+53 -0) 📝 `packages/api/methods.ts` (+12 -6) 📝 `packages/api/package.json` (+6 -4) 📝 `packages/api/tsconfig.dist.json` (+6 -2) ➕ `packages/loot-core/bin/build-api` (+21 -0) 📝 `packages/loot-core/package.json` (+1 -1) 📝 `packages/loot-core/src/server/importers/ynab5.ts` (+2 -2) 📝 `packages/loot-core/src/server/main.ts` (+7 -1) 📝 `packages/loot-core/src/server/mutators.ts` (+4 -2) 📝 `packages/loot-core/src/shared/schedules.ts` (+2 -0) 📝 `packages/loot-core/src/types/api-handlers.d.ts` (+5 -4) ➕ `packages/loot-core/tsconfig.api.json` (+12 -0) 📝 `tsconfig.json` (+4 -0) ➕ `upcoming-release-notes/2053.md` (+6 -0) 📝 `yarn.lock` (+42 -2) </details> ### 📄 Description So we can have loot-core be the source of truth for some types that get passed through between the API and bundle - Improves downstream development with API by including types (currently just the known return types are wired up) - Include type output with custom tsconfig for loot-core for the API * build loot-core (server focused) types at the same time as the webpack bundle * currently copying over existing loot-core handwritten .d.ts files (we may want to rename these to .ts files, so we only pull in the ones the loot-core main.ts actually use) - Use path aliases for dist vs dev tsconfigs - Convert api index to typescript as example - convert the send in mutators.ts to typescript to show mutators return types working - Permit ts-ignore for issues with our version of typescript ## Testing - confirmed vscode was fine with package/api/index.ts (top level tsconfig alias working properly) - typecheck and lint pass on clean checkout, but also after api is build and `dist` and `@types` is populated - Ran a yarn build and yarn pack on the api, then installed into a test project (actual_mint_importer). * vscode giving the right typehints * didn't do any tsc linting from the test project ## Future thoughts ### tsconfig composite I took a crack at turning on references and composite for the api, (and moving the tsconfig.dist.json in the api to be just tsconfig.dist.json), but this requires a lot more tuning of the tsconfig files (dropping the extends, fixing the rootDir, and fun with how includes and excludes combine). Wasn't worth it for this --- <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:51:18 -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#4086