Skip to content

Add missing methods for FormData type #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3796,7 +3796,12 @@ declare var FocusNavigationEvent: {
}

interface FormData {
append(name: any, value: any, blobName?: string): void;
append(name: string, value: string | blob, fileName?: string): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you mean Blob, my guess is this is what is causing the test failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're totally right, thanks so much for catching that. I just fixed it and it seems to be passing now. Thank you!

delete(name: string): void;
get(name: string): FormDataEntryValue | null;
getAll(name: string): FormDataEntryValue[];
has(name: string): boolean;
set(name: string, value: string | blob, fileName?: string): void;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

From the spec: https://xhr.spec.whatwg.org/#formdata the definition should look like:

type FormDataEntryValue = File or string;

interface FormData {
  append(name: string, value: string): void;
  append(name:string, blobValue:Blob, filename?:string):void;
  delete(name: string):void;
  get(name:string):  FormDataEntryValue | null;
  getAll(name: string): FormDataEntryValue[];
  has(name: string): boolean;
  set(name:string, value:string): void;
  set(name: string, blobValue:Blob, filename?: string): void;
};

Choose a reason for hiding this comment

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

You can add arbitrary Blob, but you can only get File back? interesting


declare var FormData: {
Expand Down Expand Up @@ -14940,4 +14945,5 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;
type ScrollRestoration = "auto" | "manual";
type ScrollRestoration = "auto" | "manual";
type FormDataEntryValue = string | File;
3 changes: 2 additions & 1 deletion baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1745,4 +1745,5 @@ type IDBKeyPath = string;
type RequestInfo = Request | string;
type USVString = string;
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type BufferSource = ArrayBuffer | ArrayBufferView;
type FormDataEntryValue = string | File;
40 changes: 40 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1534,5 +1534,45 @@
"name": "getElementById",
"flavor": "DOM",
"signatures": ["getElementById(elementId: string): HTMLElement | null"]
},
{
"kind": "typedef",
"name": "FormDataEntryValue",
"type": "string | File"
},
{
"kind": "method",
"interface": "FormData",
"name": "delete",
"flavor": "Web",
"signatures": ["delete(name: string): void"]
},
{
"kind": "method",
"interface": "FormData",
"name": "get",
"flavor": "Web",
"signatures": ["get(name: string): FormDataEntryValue | null"]
},
{
"kind": "method",
"interface": "FormData",
"name": "getAll",
"flavor": "Web",
"signatures": ["getAll(name: string): FormDataEntryValue[]"]
},
{
"kind": "method",
"interface": "FormData",
"name": "has",
"flavor": "Web",
"signatures": ["has(name: string): boolean"]
},
{
"kind": "method",
"interface": "FormData",
"name": "set",
"flavor": "Web",
"signatures": ["set(name: string, value: string | blob, fileName?: string): void"]
}
]
7 changes: 7 additions & 0 deletions inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1016,5 +1016,12 @@
"interface": "DOMImplementation",
"name": "createDocument",
"signatures": ["createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document"]
},
{
"kind": "method",
"interface": "FormData",
"name": "append",
"flavor": "Web",
"signatures": ["append(name: string, value: string | blob, fileName?: string): void"]
}
]