I'm trying to JSDoc a simple React Typescript component with hooks. Unfortunately, I can't seem to find a way that makes JSDoc work with declared destructured arrays. There are some answers related to destructuring object params, but these don't work for arrays.
/**
* @property {boolean} 0 - documentation for isLoading
* @property {func} 1 - documentation for setIsLoading
*/
const [isLoading, setIsLoading] = React.useState<boolean>(false);
Update 1: Still having trouble finding a way to document this destructure. There is a corner case where if I custom type an object, it works:
export type AuthFormInput = {
/** Value of the Email input field */
email: string;
/** Value of the Password input field */
password: string;
};
const [form, setForm] = React.useState<AuthFormInput>({
email: '',
password: ''
});
...
// JSDoc will work here
const email = form.email;
const [isLoading, setIsLoading]
. – Merola