refactor: improve typing

This commit is contained in:
Carlos Valente
2024-06-15 22:33:48 +02:00
committed by Carlos Valente
parent 81a07099ae
commit b7daf2926a
12 changed files with 64 additions and 28 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import { consoleSubdued, consoleRed } from '../utils/console.js';
class Logger {
private queue: Log[];
private escalateErrorFn: (error: string) => void | null;
private escalateErrorFn: ((error: string) => void) | null;
private canLog = false;
constructor() {
@@ -20,7 +20,7 @@ class Logger {
/**
* Enabling setup logger after init
*/
init(escalateErrorFn: (error: string) => void) {
init(escalateErrorFn?: (error: string) => void) {
// flush logs from queue
this.queue.forEach((log) => {
this._push(log);
@@ -1,4 +1,4 @@
import { DatabaseModel, OntimeRundown, Settings, URLPreset } from 'ontime-types';
import { DatabaseModel, OntimeRundown, Settings, URLPreset, ViewSettings } from 'ontime-types';
import { safeMerge } from '../DataProvider.utils.js';
describe('safeMerge', () => {
@@ -49,7 +49,7 @@ describe('safeMerge', () => {
} as DatabaseModel;
it('returns existing data if new data is not provided', () => {
const mergedData = safeMerge(existing, undefined);
const mergedData = safeMerge(existing, {});
expect(mergedData).toEqual(existing);
});
@@ -136,6 +136,7 @@ describe('safeMerge', () => {
rundown: [],
project: {
title: '',
description: '',
publicUrl: '',
publicInfo: '',
backstageUrl: '',
@@ -153,8 +154,9 @@ describe('safeMerge', () => {
viewSettings: {
overrideStyles: false,
endMessage: '',
},
} as ViewSettings,
urlPresets: [],
customFields: {},
osc: {
portIn: 8888,
portOut: 9999,
@@ -163,6 +165,10 @@ describe('safeMerge', () => {
enabledOut: false,
subscriptions: [],
},
http: {
enabledOut: false,
subscriptions: [],
},
} as DatabaseModel;
const newData = {