From 8b4d86692afb25b45e34f0682cf460f19a9f6496 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 29 Oct 2025 22:14:23 -0500 Subject: [PATCH] TypeScript fixes --- src/lib/ElectronFSAdapter.ts | 8 ++++---- src/lib/JSRuntime.ts | 6 +++--- src/lib/LightningFSAdapter.ts | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/ElectronFSAdapter.ts b/src/lib/ElectronFSAdapter.ts index 8ea5a5ed..c445c9d3 100644 --- a/src/lib/ElectronFSAdapter.ts +++ b/src/lib/ElectronFSAdapter.ts @@ -47,13 +47,13 @@ export class ElectronFSAdapter implements JSRuntimeFS { return error; } - async readFile(path: string): Promise>; + async readFile(path: string): Promise>; async readFile(path: string, options: 'utf8'): Promise; async readFile(path: string, options: string): Promise; async readFile(path: string, options: { encoding: 'utf8' }): Promise; async readFile(path: string, options: { encoding: string }): Promise; - async readFile(path: string, options?: string | { encoding?: string }): Promise>; - async readFile(path: string, options?: string | { encoding?: string }): Promise> { + async readFile(path: string, options?: string | { encoding?: string }): Promise>; + async readFile(path: string, options?: string | { encoding?: string }): Promise> { try { const encoding = typeof options === 'string' ? options : options?.encoding; const result = await this.electron.fs.readFile(path, encoding); @@ -69,7 +69,7 @@ export class ElectronFSAdapter implements JSRuntimeFS { } } - async writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise { + async writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise { try { const encoding = typeof options === 'string' ? options : options?.encoding; // Convert Uint8Array to regular array for IPC serialization diff --git a/src/lib/JSRuntime.ts b/src/lib/JSRuntime.ts index b0afb994..43b89a7d 100644 --- a/src/lib/JSRuntime.ts +++ b/src/lib/JSRuntime.ts @@ -4,14 +4,14 @@ */ export interface JSRuntimeFS { // Core file operations with proper overloads for type safety - readFile(path: string): Promise>; + readFile(path: string): Promise>; readFile(path: string, options: 'utf8'): Promise; readFile(path: string, options: string): Promise; readFile(path: string, options: { encoding: 'utf8' }): Promise; readFile(path: string, options: { encoding: string }): Promise; - readFile(path: string, options?: string | { encoding?: string }): Promise>; + readFile(path: string, options?: string | { encoding?: string }): Promise>; - writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise; + writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise; // readdir overloads for different return types readdir(path: string): Promise; diff --git a/src/lib/LightningFSAdapter.ts b/src/lib/LightningFSAdapter.ts index c2a21304..6e08a2c2 100644 --- a/src/lib/LightningFSAdapter.ts +++ b/src/lib/LightningFSAdapter.ts @@ -8,18 +8,18 @@ import type { JSRuntimeFS, DirectoryEntry } from './JSRuntime'; export class LightningFSAdapter implements JSRuntimeFS { constructor(private lightningFS: LightningFS.PromisifiedFS) {} - async readFile(path: string): Promise>; + async readFile(path: string): Promise>; async readFile(path: string, options: 'utf8'): Promise; async readFile(path: string, options: string): Promise; async readFile(path: string, options: { encoding: 'utf8' }): Promise; async readFile(path: string, options: { encoding: string }): Promise; - async readFile(path: string, options?: string | { encoding?: string }): Promise>; - async readFile(path: string, options?: string | { encoding?: string }): Promise { + async readFile(path: string, options?: string | { encoding?: string }): Promise>; + async readFile(path: string, options?: string | { encoding?: string }): Promise> { const encoding = typeof options === 'string' ? options : options?.encoding; return this.lightningFS.readFile(path, encoding); } - async writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise { + async writeFile(path: string, data: string | Uint8Array, options?: string | { encoding?: string }): Promise { const encoding = typeof options === 'string' ? options : options?.encoding; return this.lightningFS.writeFile(path, data, encoding); }