Update types

This commit is contained in:
Joel Jeremy Marquez
2025-02-21 08:58:33 -08:00
parent 8275ad90b2
commit d1c69a4937
3 changed files with 15 additions and 8 deletions

View File

@@ -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

View File

@@ -265,7 +265,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)));
@@ -563,7 +563,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
@@ -716,7 +716,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`,

View File

@@ -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';
@@ -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
@@ -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);