使用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}
*/