mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
TypeScript fixes
This commit is contained in:
3 files changed
+11
-11
No files matched your search
@@ -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
|
||||
|
||||
@@ -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[]>;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user