lightning-fs icon indicating copy to clipboard operation
lightning-fs copied to clipboard

Incorrect `IDB` interface

Open chuanqisun opened this issue 1 year ago • 2 comments

I noticed that current IDB interface had two errors:

  1. The constructor type was typed as a regular function
  2. The readFile was mis-typed as loadFile

/lightning-fs/index.d.ts

export interface IDB {
- constructor(dbname: string, storename: string): IDB
+ new (dbname: string, storename: string): IDB
  saveSuperblock(sb: Uint8Array): TypeOrPromise<void>
  loadSuperblock(): TypeOrPromise<FS.SuperBlock>
- loadFile(inode: number): TypeOrPromise<Uint8Array>
+ readFile(inode: number): TypeOrPromise<Uint8Array>
  writeFile(inode: number, data: Uint8Array): TypeOrPromise<void>
  wipe(): TypeOrPromise<void>
  close(): TypeOrPromise<void>
}

chuanqisun avatar Jun 15 '24 19:06 chuanqisun

Do you want to add a PR?

jcubic avatar Jun 15 '24 21:06 jcubic

See #127. Note that I removed the constructor instead of using new. I realized that my originally proposed fix was wrong as well and the constructor interface was unnecessary.

chuanqisun avatar Jun 15 '24 22:06 chuanqisun