-
Notifications
You must be signed in to change notification settings - Fork 541
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
Conversation
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;
…cription and rename name to fileName.
File
and FormData
types declarations.File
and FormData
types declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
…MDN documentation.
* 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.
* 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.
This PR brings various fixes for FormData and File types declarations, including:
FormData
:File
:File.stream()
method, becauseFile
inheritsBlob
which already has this method;FileOptions
interface inheritsBlobOptions
from@types/node
declarations;name
argument inFile
constructor tofileName
(based on: https://github.com/microsoft/TypeScript/blob/5546f207c5d20578f1d215ccc110dd42bf8d359b/lib/lib.dom.d.ts#L5220)fileBits
description to reflect supported input (based on: https://developer.mozilla.org/en-US/docs/Web/API/File/File)I also noticed both
File
andBlob
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