-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle loot-core types into the API #2053
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
206d4ee
to
e63c8c4
Compare
👋 Overall I really like where this is going. Adding proper types to the api package would be amazing. But I think we're not there yet with this PR. I looked through the output type definitions and they aren't yet pulling through the full type objects. Everything is typed as For example: - export function getBudgetMonth(month: any): any;
+ export function getBudgetMonth(month: string): {
+ month: unknown;
+ incomeAvailable: number;
+ lastMonthOverspent: number;
+ forNextMonth: number;
+ totalBudgeted: number;
+ toBudget: number;
+ fromLastMonth: number;
+ totalIncome: number;
+ totalSpent: number;
+ totalBalance: number;
+ categoryGroups: Record<string, unknown>[];
+ }; Is there anything we could do to pull in these full, rich types? |
e63c8c4
to
3d45bbe
Compare
@MatissJanis yep, they are in there now. Needed to bring the handlers types into the mutators and typescripting the send method. I had just initially done the index because it was smaller. I've moved this back into WIP, as doing the mutators has shown that there is already some fixes needed in loot-core to get runHandler also passing around types. And that the api-handlers and server handlers types have diverged. (it's all working here in this MR, but I want to split those fixes into their own). I also want to finish more of the mutator api tests before fully moving mutator.js to typescript. As it's hard to catch typescript errors for methods that are never called. And I need to take a closer loot at the security finding from codeQL. |
Amazing! Thank you for all this work here. It's definitely a massive improvement! Let me know if there's any way I could assist. |
Split the loot-core fixes to #2136 which should be ready for review, and is useful in it's own right separate from the api. |
So we can have loot-core be the source of truth for some types that get passed through - Improves downstream development with API by including types - Use path aliases for dist vs dev tsconfigs - Convert api index to typescript as example - Permit ts-ignore for issues with our version of typescript
3d45bbe
to
ab03b4d
Compare
@MatissJanis this is ready for another review. Just the already existing return types are wired up, so I've disabled strict for the methods.ts to keep this PR smaller. Will need a few followups to get into useful shape for folks using the api. |
Merged |
* Bundle loot-core types into the API So we can have loot-core be the source of truth for some types that get passed through - Improves downstream development with API by including types - Use path aliases for dist vs dev tsconfigs - Convert api index to typescript as example - Permit ts-ignore for issues with our version of typescript --------- Co-authored-by: Matiss Janis Aboltins <matiss@mja.lv>
So we can have loot-core be the source of truth for some types that get passed through between the API and bundle
Testing
dist
and@types
is populatedFuture 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