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
@@ -30,7 +30,7 @@ describe('mergeObject()', () => {
test('it handles falsy values', () => {
const a = {
first: 'yes',
second: 'yes',
second: 'yes' as string | null,
third: 'yes',
};
const b = {
+5 -1
View File
@@ -9,7 +9,11 @@ export function getNetworkInterfaces(): { name: string; address: string }[] {
const results: { name: string; address: string }[] = [];
for (const name of Object.keys(nets)) {
for (const net of nets[name]) {
const netObjects = nets[name];
if (!netObjects) {
continue;
}
for (const net of netObjects) {
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
if (net.family === 'IPv4' && !net.internal) {
results.push({
+1 -1
View File
@@ -53,7 +53,7 @@ export function mergeObject<T extends object>(a: T, b: Partial<T>): T {
}
if (typeof bValue === 'object' && bValue !== null && typeof aValue === 'object' && aValue !== null) {
// @ts-expect-error -- library side, ignore for now
// @ts-expect-error -- not sure how to type this
merged[key] = deepmerge(aValue, bValue);
} else if (bValue !== undefined) {
merged[key] = bValue;