server-ts: Implement review comments

This commit is contained in:
Elian Doran 2024-02-17 18:55:41 +02:00
parent 8af5434462
commit 1e91db865b
No known key found for this signature in database
5 changed files with 9 additions and 8 deletions

View File

@ -68,7 +68,7 @@ class Becca {
}
findAttributesWithPrefix(type: string, name: string): BAttribute[] {
const resArr = [];
const resArr: BAttribute[][] = [];
const key = `${type}-${name}`;
for (const idx in this.attributeIndex) {
@ -105,7 +105,7 @@ class Becca {
}
getNotes(noteIds: string[], ignoreMissing: boolean = false): BNote[] {
const filteredNotes = [];
const filteredNotes: BNote[] = [];
for (const noteId of noteIds) {
const note = this.notes[noteId];

View File

@ -678,7 +678,7 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.
*
* @property {Becca} becca - provides access to the backend in-memory object graph, see {@link https://github.com/zadam/trilium/blob/master/src/becca/becca}
* @property {Becca} becca - provides access to the backend in-memory object graph, see {@link https://github.com/zadam/trilium/blob/master/src/becca/becca.js}
*/
this.__private = {
becca

View File

@ -3,7 +3,7 @@
import crypto = require('crypto');
import log = require('../log');
function arraysIdentical(a: Buffer, b: Buffer) {
function arraysIdentical(a: any[] | Buffer, b: any[] | Buffer) {
let i = a.length;
if (i !== b.length) return false;
while (i--) {

View File

@ -4,9 +4,10 @@ import BNote = require("../../becca/entities/bnote");
class NoteSet {
private notes: BNote[];
private noteIdSet: Set<string>;
private sorted: boolean;
notes: BNote[];
sorted: boolean;
constructor(notes: BNote[] = []) {
this.notes = notes;

View File

@ -157,10 +157,10 @@ function iterateRows(query: string, params: Params = []) {
function getMap<K extends string | number | symbol, V>(query: string, params: Params = []) {
const map: Record<K, V> = {} as Record<K, V>;
const results = getRawRows<any>(query, params);
const results = getRawRows<[K, V]>(query, params);
for (const row of results || []) {
map[row[0] as K] = row[1];
map[row[0]] = row[1];
}
return map;