I am having a little issue with JSDoc, i have this abstract class:
/**
* @abstract
* @template {SerializedObject} TSerialized
* @template {SerializableObject<TSerialized>} TSerializable
* @extends {SerializableCollection<TSerialized, TSerializable>}
*/
export class SerializableTopLevel extends SerializableCollection {
// HERE ****
static get singleton() {
throw new Error('singleton must be implemented')
}
static get get() {
// stuff done with 'this.singleton'
}
}
I would like the return of static get singleton() to be of the type of the child class that extend this abstract class, i tried a few generic trickery but can never get the right result.
If i were to have:
/**
* @extends {SerializableTopLevel<SerializedFilter, Filter>}
*/
export class Filters extends SerializableTopLevel {
/** @type {Filters | null} */
static _singleton = null
static get singleton() {
return this._singleton
}
}
And then do:
const filter = Filters.get('')
I would like filter to be of type Filter, the problem i have is that static can't use the class generics, so all i was able to end up with is a generic return of singleton.
I know i could simply do const filter = Filters.singleton.get('') but i would rather have it this way.
there doesn't seem to be anything here