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