¿Cómo implementar typedef para el tipo genérico?
Aquí está el typedef de WeakRef:
/** * @typedef {Object} WeakRef * @property {function(): any} deref */aquí está usando, pregunta dentro de la lista:
export class MyCl { /** * @type {WeakRef} */ #ref; /** * @param {HTMLElement} el */ myMethod(el) { this.#ref = new WeakRef(el); } myMethod2() { let htmlEl = this.#ref.deref(); // <======== // htmlEl here is 'any', it must be 'HTMLElement' }lo intento
/** * @typedef {Object} WeakRef * @template T * @property {function(): T} deref */pero no sé cómo configurar T aquí:
/** * @type {WeakRef} * how to say T is HTMLElement <======== */ #ref;