TypeScript 學習筆記-JSDoc


使用JSDoc

 /**基礎類型*/
 /**@type {string} */

 /**聯合類型 */
 /**@type {string | number} */

 /**數組類型 */
 /**@type {string[]} */
 /**@type {Array.<string>} */

 /**對象字面量類型 */
 /**@type {a:string,b:number} */

 /**map-like 類型 */
 /**@type {Object.<string,number>} */

 /**array-like 類型 */
 /**@type {Object.<number,object>} */

 /**closure 語法 */
 /**@type {function(string,boolean):number} */
 /**TypeScript 語法 */
 /**@type {(a:string,b:string) => number} */

 /**函數類型 */
 /**@type {function} */

 /**任意類型 */
 /**@type {*} */
 /**@type {?} */

 /**導入類型 */
 /**@param {import('./a').Pet} */
 /**@typedef Pet {import("./a").Pet} */
 /**@type {Pet} */

 /**params語法類似於type,唯一區別於可選屬性 ,arg可選且默認值為test*/
 /**@param [arg = 'test'] */

 /**返回值類型 */
 /**@return {string} */

 /**復雜類型 */
 /**@typedef {prop1:string,prop2:string,prop3?:number} SpecialType */
 /**@typedef {(prop1:string,prop2?:number) => number} Predicate*/

 /**泛型類型 */
 /**@template T */
 /**@param {T} */
 /**@return {T} */
 function id(x) {return x;}

 /**指定this的類型 */
 /**@this {HTMLElement} */

 

 

/**基礎類型*/
/** @type {string} */

/**聯合類型 */
/** @type {string | number} */

/**數組類型 */
/** @type {string[]} */
/** @type {Array.<string>} */

/**對象字面量類型 */
/** @type {a:string,b:number} */

/**map-like 類型 */
/** @type {Object.<string,number>} */

/**array-like 類型 */
/** @type {Object.<number,object>} */

/**closure 語法 */
/** @type {function(string,boolean):number} */
/**TypeScript 語法 */
/** @type {(a:string,b:string) => number} */

/**函數類型 */
/** @type {function} */

/**任意類型 */
/** @type {*} */
/** @type {?} */

/**導入類型 */
/** @param {import('./a').Pet} */
/** @typedef Pet {import("./a").Pet} */
/** @type {Pet} */

/**params語法類似於type,唯一區別於可選屬性 ,arg可選且默認值為test*/
/** @param [arg = 'test'] */

/**返回值類型 */
/** @return {string} */

/**復雜類型 */
/** @typedef {prop1:string,prop2:string,prop3?:number} SpecialType */
/** @typedef {(prop1:string,prop2?:number) => number} Predicate */

/**泛型類型 */
/** @template T */
/** @param {T} */
/** @return {T} */
function id( x) { return x;}

/**指定this的類型 */
/** @this {HTMLElement} */

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM