fixes(tsc): typing issue

This commit is contained in:
Maieul BOYER 2025-09-29 11:54:30 +02:00
parent 404735fe22
commit 537cd03bb5

View file

@ -39,7 +39,7 @@ export const UserImpl: Omit<IUserDb, keyof Database> = {
return userFromRow( return userFromRow(
this.prepare( this.prepare(
'SELECT * FROM user WHERE name = @name LIMIT 1', 'SELECT * FROM user WHERE name = @name LIMIT 1',
).get({ name }), ).get({ name }) as (Partial<User> | undefined),
); );
}, },
@ -54,7 +54,7 @@ export const UserImpl: Omit<IUserDb, keyof Database> = {
return userFromRow( return userFromRow(
this.prepare('SELECT * FROM user WHERE id = @id LIMIT 1').get({ this.prepare('SELECT * FROM user WHERE id = @id LIMIT 1').get({
id, id,
}) as SqliteReturn, }) as (Partial<User> | undefined),
); );
}, },
@ -71,7 +71,7 @@ export const UserImpl: Omit<IUserDb, keyof Database> = {
return userFromRow( return userFromRow(
this.prepare( this.prepare(
'INSERT OR FAIL INTO user (name, password) VALUES (@name, @password) RETURNING *', 'INSERT OR FAIL INTO user (name, password) VALUES (@name, @password) RETURNING *',
).get({ name, password }), ).get({ name, password }) as (Partial<User> | undefined),
); );
}, },
@ -154,7 +154,7 @@ async function hashPassword(
* *
* @returns The user if it exists, undefined otherwise * @returns The user if it exists, undefined otherwise
*/ */
function userFromRow(row: Partial<User>): User | undefined { function userFromRow(row?: Partial<User>): User | undefined {
if (isNullish(row)) return undefined; if (isNullish(row)) return undefined;
if (isNullish(row.id)) return undefined; if (isNullish(row.id)) return undefined;
if (isNullish(row.name)) return undefined; if (isNullish(row.name)) return undefined;