I have a ES2015 style prototype class.
/**
* @constructor
* @param {Internal.RecipesEventJS} e
* @param {(InputItem_|Internal.InputFluid_)[]} inputs
*/
function CVIPressurizingWrapper(e, inputs) {
this.e_ = e
this.inputs_ = inputs
this.secondaryFluidInput_ = null
this.secondaryFluidResult_ = null
this.processingTime_ = 40
this.heatRequirement_ = null
}
...
// other chainable methods below
It's annyoying to require an e for every instance of construction, so I have a helper to do partial appliation on the constructor, except it returns a instantiated instance of the class.
/**
* Returns a concrete instantiation of the given constructor with the
* RecipesEventJS context applied as the first argument.
* @param {Internal.RecipesEventJS} e
* @param {Function} constructor
* @returns {Function}
*/
const getConstructorWrapper = (e, constructor) => {
return function () {
const args = [constructor, e]
for (const arg of arguments) {
args.push(arg)
}
const newclass = constructor.bind.apply(constructor, args)
return new newclass()
}
}
Which lets me alias it as follows:
ServerEvents.recipes(e => {
/**
* @callback {CVIPressurizingWrapperCB}
* @param {(InputItem_|Internal.InputFluid_)[]} inputs
* @returns {CVIPressurizingWrapper}
*/
/**
* @type {CVIPressurizingWrapperCB}
*/
const pressurizing = getConstructorWrapper(e, CVIPressurizingWrapper)
})
The actual code I have is a lot more complex, I'm summarizing the gist of how it works here. pressurizing is now a function that takes inputs and returns a concrete instance of the class (no need for new). However, my completions don't work. This is the best way to annotate this AFAICT from SO. Annotating pressurizing with /** @param */ directly does not work either. Has anyone done anything else like this?

