TypeScript fixes

This commit is contained in:
Alex Gleason committed 2025-10-29 22:14:23 -05:00
1 parent a4f9e0b94b
commit 8b4d86692a
3 files changed
+11 -11

No files matched your search

+4 -4
View File
@@ -47,13 +47,13 @@ export class ElectronFSAdapter implements JSRuntimeFS {
return error;
}
async readFile(path: string): Promise<Uint8Array<ArrayBuffer>>;
async readFile(path: string): Promise<Uint8Array<ArrayBufferLike>>;
async readFile(path: string, options: 'utf8'): Promise<string>;
async readFile(path: string, options: string): Promise<string>;
async readFile(path: string, options: { encoding: 'utf8' }): Promise<string>;
async readFile(path: string, options: { encoding: string }): Promise<string>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBuffer>>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBuffer>> {
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBufferLike>>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBufferLike>> {
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<void> {
async writeFile(path: string, data: string | Uint8Array<ArrayBufferLike>, options?: string | { encoding?: string }): Promise<void> {
try {
const encoding = typeof options === 'string' ? options : options?.encoding;
// Convert Uint8Array to regular array for IPC serialization
+3 -3
View File
@@ -4,14 +4,14 @@
*/
export interface JSRuntimeFS {
// Core file operations with proper overloads for type safety
readFile(path: string): Promise<Uint8Array<ArrayBuffer>>;
readFile(path: string): Promise<Uint8Array<ArrayBufferLike>>;
readFile(path: string, options: 'utf8'): Promise<string>;
readFile(path: string, options: string): Promise<string>;
readFile(path: string, options: { encoding: 'utf8' }): Promise<string>;
readFile(path: string, options: { encoding: string }): Promise<string>;
readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBuffer>>;
readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBufferLike>>;
writeFile(path: string, data: string | Uint8Array<ArrayBuffer>, options?: string | { encoding?: string }): Promise<void>;
writeFile(path: string, data: string | Uint8Array<ArrayBufferLike>, options?: string | { encoding?: string }): Promise<void>;
// readdir overloads for different return types
readdir(path: string): Promise<string[]>;
+4 -4
View File
@@ -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<Uint8Array<ArrayBuffer>>;
async readFile(path: string): Promise<Uint8Array<ArrayBufferLike>>;
async readFile(path: string, options: 'utf8'): Promise<string>;
async readFile(path: string, options: string): Promise<string>;
async readFile(path: string, options: { encoding: 'utf8' }): Promise<string>;
async readFile(path: string, options: { encoding: string }): Promise<string>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBuffer>>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array> {
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBufferLike>>;
async readFile(path: string, options?: string | { encoding?: string }): Promise<string | Uint8Array<ArrayBufferLike>> {
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<void> {
async writeFile(path: string, data: string | Uint8Array<ArrayBufferLike>, options?: string | { encoding?: string }): Promise<void> {
const encoding = typeof options === 'string' ? options : options?.encoding;
return this.lightningFS.writeFile(path, data, encoding);
}