Is there a way to document fields in an interface in TypeScript?
If you want to see it appearing when your mouse is hover in your editor, I suggest you document the interface and use the @field
inside the documentation comment.
Alternatively you could use @member
maybe that gives a better syntax-highlighting for the doc
/**
* This is the description of the interface
*
* @interface EditDialogField
* @member {string} label is used for whatever reason
* @field {string} prop is used for other reason
*/
interface EditDialogField {
label: string;
prop: string;
required?: boolean;
type: 'input';
validators?: Validator[];
}
Result inside VSCode
Got it!
interface EditDialogField {
/** Explain label here */
label: string;
/** Explain prop here */
prop: string;
required?: boolean;
type: 'input';
validators?: Validator[];
}