[AI] Typescript: low hanging fruit (#7091)

* [AI] Use loot-core workspace in desktop-electron and fix related types

- Add loot-core as workspace dependency in desktop-electron
- Import GlobalPrefsJson from loot-core package in desktop-electron
- Allow null in usersSlice data type (UsersState)
- Add explicit SQL.Database return type to openDatabase in sqlite electron

Made-with: Cursor

* Re-add loot-core as a workspace dependency in desktop-electron
This commit is contained in:
Matiss Janis Aboltins
2026-03-04 18:32:01 +00:00
committed by GitHub
parent b373b612a4
commit cf05a7ea01
6 changed files with 11 additions and 3 deletions

View File

@@ -60,7 +60,7 @@ export const signOut = createAppAsyncThunk(
);
type UsersState = {
data: Awaited<ReturnType<Handlers['subscribe-get-user']>>;
data: Awaited<ReturnType<Handlers['subscribe-get-user']>> | null;
};
const initialState: UsersState = {

View File

@@ -25,7 +25,7 @@ import type {
import { copy, exists, mkdir, remove } from 'fs-extra';
import promiseRetry from 'promise-retry';
import type { GlobalPrefsJson } from '../loot-core/src/types/prefs';
import type { GlobalPrefsJson } from 'loot-core/src/types/prefs';
import { getMenu } from './menu';
import {

View File

@@ -30,6 +30,7 @@
"cross-env": "^10.1.0",
"electron": "39.2.7",
"electron-builder": "26.4.0",
"loot-core": "workspace:*",
"typescript": "^5.9.3",
"typescript-strict-plugin": "^2.4.4"
},

View File

@@ -100,7 +100,7 @@ function regexp(regex: string, text: string | null) {
return new RegExp(regex).test(text || '') ? 1 : 0;
}
export function openDatabase(pathOrBuffer: string | Buffer) {
export function openDatabase(pathOrBuffer: string | Buffer): SQL.Database {
const db = new SQL(pathOrBuffer);
// Define Unicode-aware LOWER, UPPER, and LIKE implementation.
// This is necessary because better-sqlite3 uses SQLite build without ICU support.

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---
TypeScript: clean up some types

View File

@@ -14415,6 +14415,7 @@ __metadata:
electron: "npm:39.2.7"
electron-builder: "npm:26.4.0"
fs-extra: "npm:^11.3.3"
loot-core: "workspace:*"
promise-retry: "npm:^2.0.1"
typescript: "npm:^5.9.3"
typescript-strict-plugin: "npm:^2.4.4"