Answer the question
In order to leave comments, you need to log in
How to configure jsdoc to define dynamic return type when inheriting?
Good afternoon!
I really ask for help.
class ApiModel {
item_class
list = {}
url
loadItems() {
fetch(this.url).then(data => {
data.forEach(item => {
// класс будет определен в наследумом классе
let item_class = this.item_class
this.list[item.id] = new item_class(item)
})
})
}
/**
* @return Что тут писать ?
*/
getList(){
return this.list
}
/**
* @param id
* @return Что тут писать ?
*/
getItem(id){
return this.list[id]
}
}
class ProductModel extends ApiModel {
url='some-route'
item_class = ProductItem
}
class ProductItem {
constructor(data) {
this.data = data
}
/** методы сущнсоти **/
}
let product_model = new ProductModel()
let product_item = product_model.getItem(id)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question