2016-04-20 23 views
11

Bir ES6 sınıf içinde (belgelerine) Aşağıdaki kodu var varsayarsak:JSDOC'de bir typedef parametresi nasıl genişletilir?

/** 
* @typedef Test~options 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 

Şimdi başka bir fonksiyon belgelemek istiyoruz, kabul test2 isim verelim. Bu işlev tam olarak aynı options nesnesini alır, ancak başka bir özelliğe parent gerekir.

Bu, yedekli seçenekleri belgelemeden nasıl belgelenir? Gereksiz araçlar:

/** 
* @typedef Test~options 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 


/** 
* @typedef Test~options2 
* @type {object.<string>} 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
* @property {object} parent - The parent element 
*/ 

/** 
* @param {Test~options2} opt - Option object 
*/ 
test2(opt){ 

} 
+0

Referans deneyin: Bu belirttiği için https://github.com/jsdoc3/jsdoc/issues/1199 – dude

cevap

2

o GitHub'dan

/** 
* @typedef {object.<string>} Test~options 
* @property {array} elements - An array containing elements 
* @property {number} length - The array length 
*/ 

/** 
* @param {Test~options} opt - Option object 
*/ 
test(opt){ 

} 

/** 
* @typedef {Test~options} Test~options2 
* @property {object} parent - The parent element 
*/ 

/** 
* @param {Test~options2} opt - Option object 
*/ 
test2(opt){ 

} 
+0

en iyi çözüm, şimdiye kadar olduğu ** ikincisine bağlanan "Test ~ options" olarak "Test ~ options2" türünü ** yazın. Ama bu ideal değil, çünkü "genişletilmiş" tipinin tüm parametrelerini tekrarlamıyor; Sadece yeni paramları listeler. JSDoc bunun için daha iyi biçimlendirme üzerinde çalışmalıdır. – chharvey