react-docgen
react-docgen copied to clipboard
Cannot get comment under object in TypeScript
The shape
is Object
, the comment of shape.string
and shape.number
don't work.
// [email protected]
const code = `
import React from 'react';
import PropTypes from 'prop-types';
type Props = {
/**
* shape
*/
shape: {
/**
* string
*/
string: string;
/**
* number
*/
number: number;
};
};
class TSReactComponent extends Component<Props> {
render() {
return (
<div {...this.props} />
);
}
}
export default TSReactComponent;
`;
const result = parse(code) || {};
/**
* result ==> json
*
* shape.string doesn't have description, should be { "description": "string" }
* shape.number doesn't have description, should be { "description": "number" }
*/
const json = {
"props": {
"shape": {
"required": true,
"tsType": {
"name": "signature",
"type": "object",
"raw": "{\n /**\n * string\n */\n string: string;\n /**\n * number\n */\n number: number;\n}",
"signature": {
"properties": [{
"key": "string",
"value": {
"name": "string",
"required": true
}
}, {
"key": "number",
"value": {
"name": "number",
"required": true
}
}]
}
},
"description": "shape"
}
}
};
I've faced the same problem.
interface MainOptions {
/** If set to true video will start on load. */
autoplay: boolean;
/** If set to true video will repeat after end */
repeat: boolean;
}
interface props {
/** Main options of the player */
options: Partial<MainOptions>;
}
But I don't get any description for autoplay
and repeat
params.
Any solutions?