diff --git a/packages/loot-core/src/mocks/budget.ts b/packages/loot-core/src/mocks/budget.ts index 7f53c8ac3f9..5d4849e49b6 100644 --- a/packages/loot-core/src/mocks/budget.ts +++ b/packages/loot-core/src/mocks/budget.ts @@ -10,6 +10,7 @@ import { batchMessages, setSyncingMode } from '../server/sync'; import * as monthUtils from '../shared/months'; import q from '../shared/query'; import type { + CategoryEntity, CategoryGroupEntity, PayeeEntity, TransactionEntity, @@ -585,7 +586,7 @@ export async function createTestBudget(handlers) { }), ); - let payees: PayeeEntity[] = [ + let payees: Array = [ { name: 'Starting Balance' }, { name: 'Kroger' }, { name: 'Publix' }, @@ -608,7 +609,9 @@ export async function createTestBudget(handlers) { }), ); - let categoryGroups: CategoryGroupEntity[] = [ + let categoryGroups: Array< + CategoryGroupEntity & { categories: Omit[] } + > = [ { name: 'Usual Expenses', categories: [ @@ -650,7 +653,6 @@ export async function createTestBudget(handlers) { isIncome: group.is_income ? 1 : 0, }); - // @ts-expect-error Missing proper type refinement for (let category of group.categories) { category.id = await handlers['category-create']({ ...category, diff --git a/packages/loot-core/src/mocks/index.ts b/packages/loot-core/src/mocks/index.ts index 1759224ad55..3ee4a61dcc8 100644 --- a/packages/loot-core/src/mocks/index.ts +++ b/packages/loot-core/src/mocks/index.ts @@ -53,9 +53,8 @@ export function generateCategoryGroups(definition) { } function _generateTransaction(data): TransactionEntity { - const id = data.id || uuidv4(); return { - id: id, + id: data.id || uuidv4(), amount: data.amount || Math.floor(random() * 10000 - 7000), payee: data.payee || 'payed-to', notes: 'Notes', @@ -64,7 +63,6 @@ function _generateTransaction(data): TransactionEntity { category: data.category, sort_order: data.sort_order != null ? data.sort_order : 1, cleared: false, - error: null, }; } @@ -76,7 +74,7 @@ export function generateTransaction(data, splitAmount?, showError = false) { if (splitAmount) { const parent = trans; - parent.isParent = true; + parent.is_parent = true; result.push( { diff --git a/packages/loot-core/src/types/models/account.d.ts b/packages/loot-core/src/types/models/account.d.ts index 3bb86d4cb95..6bc9ce4d460 100644 --- a/packages/loot-core/src/types/models/account.d.ts +++ b/packages/loot-core/src/types/models/account.d.ts @@ -5,7 +5,6 @@ export type AccountEntity = { closed: 0 | 1; sort_order: number; tombstone: 0 | 1; - subtype: string | null; // TODO: remove? } & (_SyncFields | _SyncFields); type _SyncFields = { diff --git a/packages/loot-core/src/types/models/category-group.d.ts b/packages/loot-core/src/types/models/category-group.d.ts index 227dba003c3..eca289e442e 100644 --- a/packages/loot-core/src/types/models/category-group.d.ts +++ b/packages/loot-core/src/types/models/category-group.d.ts @@ -4,6 +4,4 @@ export interface CategoryGroupEntity { is_income?: boolean; sort_order?: number; tombstone?: boolean; - // TODO: remove once properly typed - [k: string]: unknown; } diff --git a/packages/loot-core/src/types/models/payee.d.ts b/packages/loot-core/src/types/models/payee.d.ts index 67f14cd306f..381f840b126 100644 --- a/packages/loot-core/src/types/models/payee.d.ts +++ b/packages/loot-core/src/types/models/payee.d.ts @@ -5,6 +5,4 @@ export interface PayeeEntity { name: string; transfer_acct?: AccountEntity; tombstone?: boolean; - // TODO: remove once properly typed - [k: string]: unknown; } diff --git a/packages/loot-core/src/types/models/rule.d.ts b/packages/loot-core/src/types/models/rule.d.ts index 263cd78b3c9..a374ed29bcf 100644 --- a/packages/loot-core/src/types/models/rule.d.ts +++ b/packages/loot-core/src/types/models/rule.d.ts @@ -3,8 +3,7 @@ import { type ScheduleEntity } from './schedule'; export interface RuleEntity { id: string; stage: string; - conditions_op?: string; - conditionsOp?: string; // TODO: this should not be here.. figure out howto remove it + conditionsOp: 'any' | 'and'; conditions: RuleConditionEntity[]; actions: RuleActionEntity[]; tombstone?: boolean; diff --git a/packages/loot-core/src/types/models/transaction.d.ts b/packages/loot-core/src/types/models/transaction.d.ts index b5366b8d6ea..73103e40cbf 100644 --- a/packages/loot-core/src/types/models/transaction.d.ts +++ b/packages/loot-core/src/types/models/transaction.d.ts @@ -15,7 +15,6 @@ export interface TransactionEntity { notes?: string; date: string; imported_id?: string; - error?: unknown; imported_payee?: string; starting_balance_flag?: boolean; transfer_id?: string; @@ -24,6 +23,4 @@ export interface TransactionEntity { tombstone?: boolean; schedule?: ScheduleEntity; subtransactions?: TransactionEntity[]; - // TODO: remove once properly typed - [k: string]: unknown; } diff --git a/upcoming-release-notes/1680.md b/upcoming-release-notes/1680.md new file mode 100644 index 00000000000..256921d9aa4 --- /dev/null +++ b/upcoming-release-notes/1680.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Typescript: hardening data entity types