Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Feb 21, 2025
1 parent 42217ea commit 9ca91b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/loot-core/src/server/aql/schema/executors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ async function execTransactionsGrouped(
return execQuery(queryState, state, s, params, outputTypes);
}

let rows;
let matched = null;
let rows: Array<{ group_id: db.DbTransaction['id']; matched: string }>;
let matched: Set<db.DbTransaction['id']> = null;

if (isHappyPathQuery(queryState)) {
// This is just an optimization - we can just filter out children
Expand Down
6 changes: 3 additions & 3 deletions packages/loot-core/src/server/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export async function delete_(table, id) {
}

export async function deleteAll(table: string) {
const rows: Array<{ id: string }> = await all(`
const rows = await all<{ id: string }>(`
SELECT id FROM ${table} WHERE tombstone = 0
`);
await Promise.all(rows.map(({ id }) => delete_(table, id)));
Expand Down Expand Up @@ -560,7 +560,7 @@ export async function mergePayees(
ids: Array<DbPayee['id']>,
) {
// Load in payees so we can check some stuff
const dbPayees: DbPayee[] = await all('SELECT * FROM payees');
const dbPayees = await all<DbPayee>('SELECT * FROM payees');
const payees = groupById(dbPayees);

// Filter out any transfer payees
Expand Down Expand Up @@ -713,7 +713,7 @@ export async function moveAccount(
'SELECT * FROM accounts WHERE id = ?',
[id],
);
let accounts;
let accounts: Pick<DbAccount, 'id' | 'sort_order'>[];
if (account.closed) {
accounts = await all(
`SELECT id, sort_order FROM accounts WHERE closed = 1 ORDER BY sort_order, name`,
Expand Down
13 changes: 10 additions & 3 deletions packages/loot-core/src/server/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { captureBreadcrumb } from '../platform/exceptions';
import * as sqlite from '../platform/server/sqlite';
import { sheetForMonth } from '../shared/months';

import { DbPreference } from './db';
import {
DbPreference,
DbReflectBudget,
DbZeroBudget,
DbZeroBudgetMonth,
} from './db';
import * as Platform from './platform';
import { Spreadsheet } from './spreadsheet/spreadsheet';
import { resolveName } from './spreadsheet/util';
Expand Down Expand Up @@ -205,7 +210,7 @@ export async function loadUserBudgets(
)) ?? {};

const table = budgetType === 'report' ? 'reflect_budgets' : 'zero_budgets';
const budgets = await db.all(`
const budgets = await db.all<DbReflectBudget | DbZeroBudget>(`
SELECT * FROM ${table} b
LEFT JOIN categories c ON c.id = b.category
WHERE c.tombstone = 0
Expand All @@ -229,7 +234,9 @@ export async function loadUserBudgets(

// For zero-based budgets, load the buffered amounts
if (budgetType !== 'report') {
const budgetMonths = await db.all('SELECT * FROM zero_budget_months');
const budgetMonths = await db.all<DbZeroBudgetMonth>(
'SELECT * FROM zero_budget_months',
);
for (const budgetMonth of budgetMonths) {
const sheetName = sheetForMonth(budgetMonth.id);
sheet.set(`${sheetName}!buffered`, budgetMonth.buffered);
Expand Down

0 comments on commit 9ca91b1

Please sign in to comment.