JSDoc - return * 从函数中意味着什么?
JSDoc - What does it mean to return * from a function?
使用 WebStorm, the following JSDoc 生成文档:
/**
* Patient retrieval success action
* @param {Object} patient - Patient object returned from getPatient search query
* @returns {{type, patient: *}}
*/
export const getPatientSuccess = patient => ({
type: PATIENT_LOADED,
patient,
});
在此上下文中,patient
是一个可能包含可变信息的对象。这是另一个包含类似 JSDoc 生成注释的部分:
/**
* Functional stateless component to display medication data
* @param medications
* @returns {*}
* @constructor
*/
const Medications = ({ medications }) => {
if (medications.status === 'success') {
// Return table of medications if available
return (/** Table of medications */);
}
// Return NoDataView by default if no meds are available
return (
<NoDataView
heading="Data Unavailable"
subtext="Medications data unavailable"
isGlyphHidden={false}
/>
);
};
在此上下文中,可能会返回可变组件信息。这就是 @returns {*}
的意思吗?
在 JSDocs 中,类型信息通常包含在 @returns
和 @param
属性的大括号中。
@return {*}
指定函数 return 的类型为 *
.
*
是一个通配符,代表任何类型。
换句话说,函数可以return任何类型。
查看 JSDocs docs 了解更多信息。
表示
{*} Whatever you want
In the documantation you can see and here is a doc of the returns returns
使用 WebStorm, the following JSDoc 生成文档:
/**
* Patient retrieval success action
* @param {Object} patient - Patient object returned from getPatient search query
* @returns {{type, patient: *}}
*/
export const getPatientSuccess = patient => ({
type: PATIENT_LOADED,
patient,
});
在此上下文中,patient
是一个可能包含可变信息的对象。这是另一个包含类似 JSDoc 生成注释的部分:
/**
* Functional stateless component to display medication data
* @param medications
* @returns {*}
* @constructor
*/
const Medications = ({ medications }) => {
if (medications.status === 'success') {
// Return table of medications if available
return (/** Table of medications */);
}
// Return NoDataView by default if no meds are available
return (
<NoDataView
heading="Data Unavailable"
subtext="Medications data unavailable"
isGlyphHidden={false}
/>
);
};
在此上下文中,可能会返回可变组件信息。这就是 @returns {*}
的意思吗?
在 JSDocs 中,类型信息通常包含在 @returns
和 @param
属性的大括号中。
@return {*}
指定函数 return 的类型为 *
.
*
是一个通配符,代表任何类型。
换句话说,函数可以return任何类型。
查看 JSDocs docs 了解更多信息。
表示
{*} Whatever you want
In the documantation you can see and here is a doc of the returns returns