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

Erroneous typings for FileSystemHandlePermissionDescriptor #47

Closed jmrog closed 3 years ago

jmrog commented 3 years ago

The typings for FileSystemHandlePermissionDescriptor do not seem to be correct. They currently look like this:

export interface FileSystemHandlePermissionDescriptor {
  fileSystemHandle: FileSystemHandle;
  mode: 'read' | 'readWrite';
}

But the working draft defines FileSystemHandlePermissionDescriptor like so:

dictionary FileSystemHandlePermissionDescriptor {
  FileSystemPermissionMode mode = "read";
};

In other words, there should be an (optional) mode property only; there should not be a fileSystemHandle property at all, and mode should not be required. Furthermore, the valid values for mode should be 'read' and 'readwrite'.

(As some additional corroboration, the MDN docs for queryPermission and requestPermission indicate the same thing.)

I think what went wrong originally is that FileSystemHandlePermissionDescriptor was confused with FileSystemPermissionDescriptor (note the absence of "Handle" in the latter); see here.

[EDIT: PR attached below.]