[英]JSDoc - What does it mean to return * from a function?
/**
* 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 {*}
指定函数返回类型*
。
*
是代表任何类型的通配符。
换句话说, 该函数可以返回任何type 。
查看JSDocs文档以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.