Open
Description
Right now I couldn't find a way to document that a function argument (a property, or anything really) is a class, or a constructor of a specific type.
Here's a condensed example of the problem:
class View {}
class SomeView extends View {}
/* *
* This is a factory function that instantiates a new view object
* from the given View class and the given data.
*
* @param {???} ViewClass a constructor/class that extends View
* @param {*} [data]
* @return View a new View instance
* */
function createView(ViewClass, data) {
return new ViewClass(data)
}
var something = createView(SomeView, {});
How is it possible to tell that the type of ViewClass
is a constructor/class and that it extends View?
What should go in the place of the question marks up there?
@param {View} thing
this means that thing
is a View
instance, not a class
@param {Function<View>} thing
this doesn't really mean that thing
is a class that extends View
@param {typeof View} thing
logically this is what we're looking for, but frankly I've never seen this one used before, not in the docs at least
Metadata
Metadata
Assignees
Labels
No labels