[whatwg/webidl] Is a function signature with a parameter type `(DOMString or Interface)` a footgun? (Issue #1604)

saschanaz created an issue (whatwg/webidl#1604)

### What is the issue with the Web IDL Standard?

Context: https://bugzilla.mozilla.org/show_bug.cgi?id=2040944#c10, https://github.com/whatwg/fs/pull/180

The File System PR adds this:

```webidl
  Promise<undefined> move(USVString newEntryName);
  Promise<undefined> move(FileSystemDirectoryHandle destinationDirectory);
  Promise<undefined> move(FileSystemDirectoryHandle destinationDirectory, USVString newEntryName);
```

So `.move("path as string")` or `.move(aDirectoryHandle)`. The problem happens with `.move(aFileSystemFileHandle)`, because it's an interface instance but not a FileSystemDirectoryHandle, the parameter is silently eaten as a string, resulting `[object FileSystemFileHandle]` without any error.

Implicitly stringification has probably been always a footgun but this is even more footgun as you do expect either a string or a specific typed object here, any other object will cause a silent fire.

The suggested Gecko patch in the bug adds another signature to avoid this:

```webidl
  // the only role of this signature ... is to throw an exception.
  Promise<undefined> move(FileSystemFileHandle aFileHandle);
```

I hate this, but can we do any better here?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1604
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1604@github.com>

Received on Thursday, 11 June 2026 13:32:07 UTC