Skip to content

fix: Update FilePickerOptions onFilesPicked type#30

Merged
glebedel merged 4 commits intomainfrom
cursor/update-filepickeroptions-onfilespicked-type-b681
Sep 3, 2025
Merged

fix: Update FilePickerOptions onFilesPicked type#30
glebedel merged 4 commits intomainfrom
cursor/update-filepickeroptions-onfilespicked-type-b681

Conversation

@glebedel
Copy link
Copy Markdown
Contributor

@glebedel glebedel commented Sep 3, 2025

Context

This PR addresses an inaccuracy in the FilePickerOptions interface where the onFilesPicked callback parameter type did not match the actual data structure received at runtime. Users reported that the callback receives an object with a files property, rather than a direct array of File objects.

Why

To ensure type safety and provide an accurate API definition for developers, the onFilesPicked callback's parameter type has been updated to correctly reflect that it receives an object { files: File[] }. This prevents type mismatches and eliminates the need for user-side workarounds.

What

  • Corrected the onFilesPicked callback parameter type in src/types.ts and src/filePicker.ts from (data: File[]) => void to (data: { files: File[] }) => void.
  • Updated the README.md documentation, including code examples and the parameter description, to reflect the correct callback signature.

Checklist

Use the checklist below as a guide to ensure your PR is ready for review

  • 📝 PR has description (comment /describe to generate a description via the PR agent)
  • 🧪 PR includes tests (Existing tests were run and passed)
  • 🪵 PR includes logs
  • 📸 PR includes screenshots demonstrating the impact (eg: UI screenshots, stack diffs, perf improvements etc.)
  • 📜 Docs have been updated where relevant (README.md)

Slack Thread

Open in Cursor Open in Web

Summary by cubic

Fixes the FilePickerOptions.onFilesPicked type to match runtime. The callback now receives { files: File[] } instead of File[]; docs updated to reflect this.

  • Migration
    • Update callbacks to onFilesPicked: (data) => { /* use data.files */ }.
    • No runtime behavior changes; this aligns types with existing behavior.

Co-authored-by: guillaume <guillaume@stackone.com>
@cursor
Copy link
Copy Markdown

cursor bot commented Sep 3, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

cursoragent and others added 2 commits September 3, 2025 21:43
Co-authored-by: guillaume <guillaume@stackone.com>
Co-authored-by: guillaume <guillaume@stackone.com>
@glebedel glebedel marked this pull request as ready for review September 3, 2025 22:00
Copilot AI review requested due to automatic review settings September 3, 2025 22:00
@glebedel glebedel requested a review from a team as a code owner September 3, 2025 22:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR corrects the type definition for the FilePickerOptions.onFilesPicked callback to match the actual runtime behavior, where the callback receives an object containing arrays of selected files, folders, and drives rather than a direct array of files.

  • Updated the callback signature to accept an object with optional files, folders, and drives properties
  • Added new type definitions for Folder and Drive to support the expanded functionality
  • Updated documentation to reflect the correct callback structure and usage patterns

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/types.ts Adds Folder and Drive types and updates onFilesPicked callback signature
src/index.ts Exports the new Folder, Drive, and FilePickerOptions types
src/filePicker.ts Updates imports and internal callback type to match new signature
README.md Updates documentation with correct callback usage examples and type descriptions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@glebedel glebedel changed the title Update FilePickerOptions onFilesPicked type fix: Update FilePickerOptions onFilesPicked type Sep 3, 2025
…cker

Co-authored-by: guillaume <guillaume@stackone.com>
@glebedel glebedel enabled auto-merge (squash) September 3, 2025 22:04
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

driveSelectionEnabled = true,
onFilesPicked = (files) => {
console.log('Selected files:', files);
onFilesPicked = (data) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ':' for the object property; '=' makes the example invalid JavaScript.

Prompt for AI agents
Address the following comment on README.md at line 63:

<comment>Use &#39;:&#39; for the object property; &#39;=&#39; makes the example invalid JavaScript.</comment>

<file context>
@@ -60,8 +60,17 @@ const options = {
     driveSelectionEnabled = true,
-    onFilesPicked = (files) =&gt; {
-        console.log(&#39;Selected files:&#39;, files);
+    onFilesPicked = (data) =&gt; {
+        // data may contain files, folders, and/or drives based on what was selected
+        if (data.files) {
</file context>

@glebedel glebedel merged commit 2250c3b into main Sep 3, 2025
2 checks passed
@glebedel glebedel deleted the cursor/update-filepickeroptions-onfilespicked-type-b681 branch September 3, 2025 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants