Skip to content

Commit a9b9382

Browse files
committed
doc: Improve JSDoc template type names
V and U are not particularly useful. ValueType and TransformedType more clearly convey the meaning of these types. Signed-off-by: Kevin Locke <[email protected]>
1 parent 87405fb commit a9b9382

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

index.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ const { isArray } = Array;
1717
*/
1818
const httpMethodSet = new Set(METHODS);
1919

20-
/** Transforms a value which has type object<string,T> but is not defined as
21-
* Map[string,T] in OpenAPI.
20+
/** Transforms a value which has type object<string,ValueType> but is not
21+
* defined as Map[string,ValueType] in OpenAPI.
2222
*
2323
* Note: This is currently used for schema properties, where #transformMap()
2424
* often complicates transformations due to differences with Map[string,Schema]
2525
* on definitions/components.schema and complicates optimizations.
2626
*
2727
* @private
28-
* @template T, U
28+
* @template ValueType, TransformedType
2929
* @this {!OpenApiTransformerBase}
30-
* @param {!object<string,T>|*} obj Map-like object to transform.
31-
* @param {function(this:!OpenApiTransformerBase, T): U} transform Method which
32-
* transforms values in obj.
30+
* @param {!object<string,ValueType>|*} obj Map-like object to transform.
31+
* @param {function(this:!OpenApiTransformerBase, ValueType): TransformedType
32+
* } transform Method which transforms values in obj.
3333
* @param {boolean=} skipExtensions If true, do not call transform on {@link
3434
* https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#specificationExtensions
3535
* Specification Extensions} (i.e. properties starting with "x-").
3636
* Such properties are copied to the returned object without transformation.
37-
* @returns {!object<string,U>|*} If obj is a Map, a plain object with the
38-
* same own enumerable string-keyed properties as obj with values returned
39-
* by transform. Otherwise, obj is returned unchanged.
37+
* @returns {!object<string,TransformedType>|*} If obj is a Map, a plain object
38+
* with the same own enumerable string-keyed properties as obj with values
39+
* returned by transform. Otherwise, obj is returned unchanged.
4040
*/
4141
function transformMapLike(obj, transform, skipExtensions) {
4242
if (typeof obj !== 'object' || obj === null) {
@@ -103,7 +103,8 @@ function transformMapLike(obj, transform, skipExtensions) {
103103
* </ul>
104104
*/
105105
class OpenApiTransformerBase {
106-
/** Transforms a <code>Map[string, T]</code> using a given transform method.
106+
/** Transforms a <code>Map[string, ValueType]</code> using a given transform
107+
* method.
107108
*
108109
* Similar to modify-values and _.mapValues from lodash.
109110
*
@@ -116,13 +117,13 @@ class OpenApiTransformerBase {
116117
* the first argument with transformed values.</li>
117118
* </ul>
118119
*
119-
* @template T, U
120-
* @param {!object<string,T>|*} obj Map to transform.
121-
* @param {function(this:!OpenApiTransformerBase, T): U} transform Method
122-
* which transforms values in obj.
123-
* @returns {!object<string,U>|*} If obj is a Map, a plain object with the
124-
* same own enumerable string-keyed properties as obj with values returned
125-
* by transform. Otherwise, obj is returned unchanged.
120+
* @template ValueType, TransformedType
121+
* @param {!object<string,ValueType>|*} obj Map to transform.
122+
* @param {function(this:!OpenApiTransformerBase, ValueType): TransformedType
123+
* } transform Method which transforms values in obj.
124+
* @returns {!object<string,TransformedType>|*} If obj is a Map, a plain
125+
* object with the same own enumerable string-keyed properties as obj with
126+
* values returned by transform. Otherwise, obj is returned unchanged.
126127
*/
127128
transformMap(obj, transform) {
128129
return transformMapLike.call(this, obj, transform);

0 commit comments

Comments
 (0)