Skip to content
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

fix: Improve File and FormData types declarations. #1042

Merged
merged 4 commits into from
Sep 22, 2021

Conversation

octet-stream
Copy link
Contributor

@octet-stream octet-stream commented Sep 21, 2021

This PR brings various fixes for FormData and File types declarations, including:

  1. FormData:
  • Declare class methods as they should be;
  • Minor fixes for methods documentation in code;
  • Remove unnecessary constructor declaration;
  • Remove unnecessary part from FormData class description;
  1. File:

I also noticed both File and Blob can be constructed with objects that have @@iterator, this probably have to be reflected in declarations as well? Both in undici File and @types/node

See: https://github.com/web-platform-tests/wpt/blob/30e724ac90157333d34198f0c29131b2e2a6b1da/FileAPI/blob/Blob-constructor.any.js#L58-L105

1. `FormData`:
  * Declare class methods as they should be;
  * Minor fixes for methods documentation in code;
  * Remove unnecessary constructor declaration;
  * Remove unnecessary part from FormData class description;
2. `File`:
  * Replace getters with readonly properties;
  * Remove `File.stream()` method, because `File` inherits `Blob` which already has this method;
  * `FileOptions` interface inherits `BlobOptions` from `@types/node` declarations;
@octet-stream octet-stream changed the title Fixes for File and FormData types declarations. fix: Improve File and FormData types declarations. Sep 21, 2021
types/formdata.d.ts Outdated Show resolved Hide resolved
Copy link
Member

@szmarczak szmarczak left a comment

Choose a reason for hiding this comment

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

lgtm

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2021

Codecov Report

Merging #1042 (b6a4884) into main (1e1a6db) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1042      +/-   ##
==========================================
+ Coverage   94.89%   94.92%   +0.02%     
==========================================
  Files          37       37              
  Lines        3623     3643      +20     
==========================================
+ Hits         3438     3458      +20     
  Misses        185      185              
Impacted Files Coverage Δ
lib/core/errors.js 100.00% <0.00%> (ø)
lib/client.js 98.00% <0.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e1a6db...b6a4884. Read the comment docs.

@ronag ronag merged commit 609d89b into nodejs:main Sep 22, 2021
@octet-stream octet-stream deleted the fetch-types-fixes branch September 22, 2021 09:32
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* Fixes for `File` and `FormData` types declarations.

1. `FormData`:
  * Declare class methods as they should be;
  * Minor fixes for methods documentation in code;
  * Remove unnecessary constructor declaration;
  * Remove unnecessary part from FormData class description;
2. `File`:
  * Replace getters with readonly properties;
  * Remove `File.stream()` method, because `File` inherits `Blob` which already has this method;
  * `FileOptions` interface inherits `BlobOptions` from `@types/node` declarations;

* Minor fix for File constructor types delcaration: Update fileBits description and rename name to fileName.

* Rename arguments in FormData.forEach type declarations.

* Rename ctx argument to thisArg in FormData.forEach() method to match MDN documentation.
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* Fixes for `File` and `FormData` types declarations.

1. `FormData`:
  * Declare class methods as they should be;
  * Minor fixes for methods documentation in code;
  * Remove unnecessary constructor declaration;
  * Remove unnecessary part from FormData class description;
2. `File`:
  * Replace getters with readonly properties;
  * Remove `File.stream()` method, because `File` inherits `Blob` which already has this method;
  * `FileOptions` interface inherits `BlobOptions` from `@types/node` declarations;

* Minor fix for File constructor types delcaration: Update fileBits description and rename name to fileName.

* Rename arguments in FormData.forEach type declarations.

* Rename ctx argument to thisArg in FormData.forEach() method to match MDN documentation.
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.

None yet

4 participants