Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
fix: FormData::entries(), FormData::[Symbol.iterator]() (#175)
Browse files Browse the repository at this point in the history
* fix: `FormData::entries()`, `FormData::[Symbol.iterator]()`

The types for `FormData::entries()`, `FormData::[Symbol.iterator]()` are marked as arrays of IterableIterators, which doesn't seem right. This PR removes the array notation, and adds tests for the both of them.

* rename typechecks.yml -> checks.yml

* add a changeset

* pass tests
  • Loading branch information
threepointone committed Jan 18, 2022
1 parent f1c3c40 commit 17d21e9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-deers-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-types": patch
---

fix: FormData::entries(), FormData::[Symbol.iterator]()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests, Linter & Typecheck
name: Checks

on: pull_request

Expand Down
4 changes: 2 additions & 2 deletions overrides/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ declare class FormData {
set(name: string, value: string): void;
set(name: string, value: Blob, filename?: string): void;

entries(): IterableIterator<[key: string, value: File | string][]>;
[Symbol.iterator](): IterableIterator<[key: string, value: File | string][]>;
entries(): IterableIterator<[key: string, value: File | string]>;
[Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;

forEach<This = unknown>(
callback: (
Expand Down
12 changes: 12 additions & 0 deletions tests/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const formData = new FormData();

const data: { [key: string]: string | File } = {};
for (const [key, value] of formData.entries()) {
// data[key] = value; // TODO: this should be uncommented
}

for (const [key, value] of formData) {
// data[key] = value; // TODO: this should be uncommented
}

export {};

0 comments on commit 17d21e9

Please sign in to comment.