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

Update types for fileSave/fileOpen to accept options arrays (close #61) #62

Closed jmrog closed 3 years ago

jmrog commented 3 years ago

@tomayac This should do what you're looking for.

tomayac commented 3 years ago

Thanks for tackling this! <3 Quick feedback:

We need setupLegacyCleanupAndRejection for all three pickers: save, open, directory.

The save picker likewise should have extensions and mimeTypes.

(I’m heading out for the weekend, I’ll be back on Monday.)

jmrog commented 3 years ago

Thanks for tackling this! <3 Quick feedback:

We need setupLegacyCleanupAndRejection for all three pickers: save, open, directory.

I think you mean just for open and directory, right? The save operation at least currently does not use that method. I'm unsure whether this was an oversight or was done intentionally, maybe because the legacy save operation just triggers a download and then carries on?

In any case, I'll add it to the types for the directory open operation; they were missing in the previous iteration.

The save picker likewise should have extensions and mimeTypes.

Oh, okay; it looks like mimeTypes was missing from the earlier types for the save operation, in that case, but I can add it in.

As for extensions, it's already included, via CoreFileOptions. 👍

jmrog commented 3 years ago

Okay, @tomayac, the latest update to the PR adds setupLegacyCleanupAndRejection to the directory operation as well as the open operation. It also has extensions and mimeTypes for both save and open options objects. Finally, it enforces the requirement that only the first options object (when it is an array) specifies certain properties. Whether we want to do that last part is up to you, but it is a nice developer experience; I'm just now sure how far back you want to go with TypeScript version support.

tomayac commented 3 years ago

Thanks a lot for tackling this. Part of the v0.20.2 release.