【发布时间】:2018-01-19 01:20:06
【问题描述】:
/**
* 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 {*} 的意思吗?
【问题讨论】:
-
我认为这意味着返回整个
(*)药物表。 -
@JustinJmnz 不,它表示具体类型,而不是它所代表的内容。
*是一个通配符,所以它基本上意味着“可以是一个数组、字符串、数字、布尔值,谁知道!”。或者更现实地说,它可能类似于对象或对象数组。或者,有人在键入 JSDoc 时变得懒惰,因为如果您返回的类型数量有限,您可以说类似{String|Array<String>}之类的内容。
标签: javascript reactjs react-redux jsdoc