Skip to content

Commit bc3e930

Browse files
authored
chore: fix invalid JSDoc (#21794)
* chore: fix invalid JSDoc * chore: fix invalid JSDoc * fixup!
1 parent e67f343 commit bc3e930

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎lib/serialization/PlainObjectSerializer.js‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33
*/
44

55
"use strict";
6+
/** @import { ObjectDeserializerContext, ObjectSerializerContext } from "./ObjectMiddleware" */
67

7-
/** @typedef {EXPECTED_FUNCTION} CacheAssoc */
8+
/** @typedef {ObjectSerializerContext<EXPECTED_ANY>["write"]} CacheAssoc */
89

910
/**
1011
* Defines the shared type used by this module.
11-
* @template T
12-
* @typedef {WeakMap<CacheAssoc, ObjectStructure<T>>}
12+
* @type {WeakMap<CacheAssoc, ObjectStructure<PropertyKey>>}
1313
*/
1414
const cache = new WeakMap();
1515

1616
/**
1717
* Represents ObjectStructure.
18-
* @template T
18+
* @template {PropertyKey} K
1919
*/
2020
class ObjectStructure {
2121
constructor() {
22-
/** @type {undefined | keyof T[]} */
22+
/** @type {undefined | K[]} */
2323
this.keys = undefined;
24-
/** @type {undefined | Map<keyof T, ObjectStructure<T>>} */
24+
/** @type {undefined | Map<K, ObjectStructure<K>>} */
2525
this.children = undefined;
2626
}
2727

2828
/**
2929
* Returns keys.
30-
* @param {keyof T[]} keys keys
31-
* @returns {keyof T[]} keys
30+
* @param {K[]} keys keys
31+
* @returns {K[]} keys
3232
*/
3333
getKeys(keys) {
3434
if (this.keys === undefined) this.keys = keys;
@@ -37,13 +37,14 @@ class ObjectStructure {
3737

3838
/**
3939
* Returns object structure.
40-
* @param {keyof T} key key
41-
* @returns {ObjectStructure<T>} object structure
40+
* @param {K} key key
41+
* @returns {ObjectStructure<K>} object structure
4242
*/
4343
key(key) {
4444
if (this.children === undefined) this.children = new Map();
4545
const child = this.children.get(key);
4646
if (child !== undefined) return child;
47+
/** @type {ObjectStructure<K>} */
4748
const newChild = new ObjectStructure();
4849
this.children.set(key, newChild);
4950
return newChild;
@@ -52,13 +53,15 @@ class ObjectStructure {
5253

5354
/**
5455
* Returns keys.
55-
* @template T
56-
* @param {(keyof T)[]} keys keys
56+
* @template {PropertyKey} K
57+
* @param {K[]} keys keys
5758
* @param {CacheAssoc} cacheAssoc cache assoc fn
58-
* @returns {(keyof T)[]} keys
59+
* @returns {K[]} keys
5960
*/
6061
const getCachedKeys = (keys, cacheAssoc) => {
61-
let root = cache.get(cacheAssoc);
62+
let root = /** @type {ObjectStructure<K> | undefined} */ (
63+
cache.get(cacheAssoc)
64+
);
6265
if (root === undefined) {
6366
root = new ObjectStructure();
6467
cache.set(cacheAssoc, root);
@@ -75,7 +78,7 @@ class PlainObjectSerializer {
7578
* Serializes this instance into the provided serializer context.
7679
* @template {object} T
7780
* @param {T} obj plain object
78-
* @param {import("./ObjectMiddleware").ObjectSerializerContext<((keyof T)[] | keyof T | null | T[keyof T])[]>} context context
81+
* @param {ObjectSerializerContext<((keyof T)[] | keyof T | null | T[keyof T])[]>} context context
7982
*/
8083
serialize(obj, context) {
8184
const keys = /** @type {(keyof T)[]} */ (Object.keys(obj));
@@ -103,7 +106,7 @@ class PlainObjectSerializer {
103106
/**
104107
* Restores this instance from the provided deserializer context.
105108
* @template {object} T
106-
* @param {import("./ObjectMiddleware").ObjectDeserializerContext<((keyof T)[] | keyof T | null | T[keyof T])[]>} context context
109+
* @param {ObjectDeserializerContext<((keyof T)[] | keyof T | null | T[keyof T])[]>} context context
107110
* @returns {T} plain object
108111
*/
109112
deserialize(context) {

‎lib/util/cleverMerge.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const cachedSetProperty = (obj, property, value) => {
100100
* @property {ByValues | undefined} byValues value depending on selector property, merged with base
101101
*/
102102

103-
/** @typedef {(function(...EXPECTED_ANY): object) & { [DYNAMIC_INFO]: [DynamicFunction, object] }} DynamicFunction */
103+
/** @typedef {((...x: EXPECTED_ANY) => object) & { [DYNAMIC_INFO]: [DynamicFunction, object] }} DynamicFunction */
104104

105105
/**
106106
* Defines the parsed object static type used by this module.

0 commit comments

Comments
 (0)