@@ -75,6 +75,11 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
7575 }
7676 }
7777
78+ /**
79+ * @param {string } name
80+ * @param {string | undefined } filename
81+ * @returns {[string, File|string] }
82+ */
7883 function normalizeArgs ( name , value , filename ) {
7984 if ( value instanceof Blob ) {
8085 filename = filename !== undefined
@@ -97,6 +102,11 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
97102 return value . replace ( / \r ? \n | \r / g, '\r\n' )
98103 }
99104
105+ /**
106+ * @template T
107+ * @param {ArrayLike<T> } arr
108+ * @param {{ (elm: T): void; } } cb
109+ */
100110 function each ( arr , cb ) {
101111 for ( let i = 0 ; i < arr . length ; i ++ ) {
102112 cb ( arr [ i ] )
@@ -112,14 +122,14 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
112122 /**
113123 * FormData class
114124 *
115- * @param {HTMLElement = } form
125+ * @param {HTMLFormElement = } form
116126 */
117127 constructor ( form ) {
128+ /** @type {[string, string|File][] } */
118129 this . _data = [ ]
119130
120131 const self = this
121-
122- form && each ( form . elements , elm => {
132+ form && each ( form . elements , ( /** @type {HTMLInputElement } */ elm ) => {
123133 if (
124134 ! elm . name ||
125135 elm . disabled ||
@@ -196,7 +206,6 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
196206 *
197207 * @param {Function } callback Executed for each item with parameters (value, name, thisArg)
198208 * @param {Object= } thisArg `this` context for callback function
199- * @return {undefined }
200209 */
201210 forEach ( callback , thisArg ) {
202211 ensureArgs ( arguments , 1 )
@@ -275,11 +284,11 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
275284 * @param {string } name Filed name
276285 * @param {string } value Field value
277286 * @param {string= } filename Filename (optional)
278- * @return {undefined }
279287 */
280288 set ( name , value , filename ) {
281289 ensureArgs ( arguments , 2 )
282290 name = String ( name )
291+ /** @type {[string, string|File][] } */
283292 const result = [ ]
284293 const args = normalizeArgs ( name , value , filename )
285294 let replace = true
@@ -347,7 +356,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData
347356 * The class itself is iterable
348357 * alias for formdata.entries()
349358 *
350- * @return {Iterator }
359+ * @return {Iterator }
351360 */
352361 [ Symbol . iterator ] ( ) {
353362 return this . entries ( )
0 commit comments