GoogleChromeLabs / browser-fs-access

File System Access API with legacy fallback in the browser
https://googlechromelabs.github.io/browser-fs-access/demo/
Apache License 2.0
1.38k stars 84 forks source link

Possibly missing types for FileSystemDirectoryHandle, FileSystemFileHandle #93

Closed theo-staizen closed 2 years ago

theo-staizen commented 2 years ago

During compilation typescript complains about missing types for FileSystemDirectoryHandle and FileSystemFileHandle and as far as I can tell this is correct, as there is only a reference to those types in index.d.ts, but no declaration.

image

For a very crude fix, I added the following, as I was only using fileOpen

 declare global {
  interface FileSystemDirectoryHandle extends FileSystemHandle {}
  interface FileSystemFileHandle extends FileSystemHandle {
    createWritable(): Promise<FileSystemWritableStream>
    getFile(): Promise<File>
  }
  interface FileSystemWritableStream extends WritableStream {}
}
tomayac commented 2 years ago

Can you use the types as declared in https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/wicg-file-system-access?

theo-staizen commented 2 years ago

Thanks @tomayac, that worked, but i had to manually reference it /// <reference types="wicg-file-system-access" /> I hope this is only temporary, given that this package is exporting its own types, things should "just work"

tomayac commented 2 years ago

I was under the impression TypeScript shipped with an ever-growing set of types, and sometimes updating the TypeScript version resolved issues like this. That being said, I'm not a TS user myself, so may well be wrong.