Staff report: relax CustomFieldRow JSDoc for dotted property names
This commit is contained in:
+16
-11
@@ -15,15 +15,20 @@
|
|||||||
* @typedef {import("../types/form").StaffFieldDescriptor} StaffFieldDescriptor
|
* @typedef {import("../types/form").StaffFieldDescriptor} StaffFieldDescriptor
|
||||||
* @typedef {import("../types/form").StaffRenderKind} StaffRenderKind
|
* @typedef {import("../types/form").StaffRenderKind} StaffRenderKind
|
||||||
*
|
*
|
||||||
* @typedef {object} CustomFieldRow
|
* The CustomFieldRow shape isn't fully expressible in JSDoc because two of
|
||||||
* @property {string} name
|
* its property names contain dots (the APIv4 joined-field syntax). TypeScript
|
||||||
* @property {string} label
|
* callers declare their own typed interface for the row; here we use a
|
||||||
* @property {string} data_type
|
* permissive shape so the @ts-check pass doesn't complain about the dotted
|
||||||
* @property {string} html_type
|
* accesses below.
|
||||||
* @property {number | null | undefined} option_group_id
|
*
|
||||||
* @property {number} weight
|
* @typedef {Record<string, unknown> & {
|
||||||
* @property {string} "custom_group_id.name"
|
* name: string;
|
||||||
* @property {string} "custom_group_id.title"
|
* label: string;
|
||||||
|
* data_type: string;
|
||||||
|
* html_type: string;
|
||||||
|
* option_group_id: number | null | undefined;
|
||||||
|
* weight: number;
|
||||||
|
* }} CustomFieldRow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ORG_GROUP_NAMES = new Set(["Food_Co_op_Organizing"]);
|
const ORG_GROUP_NAMES = new Set(["Food_Co_op_Organizing"]);
|
||||||
@@ -33,8 +38,8 @@ const ORG_GROUP_NAMES = new Set(["Food_Co_op_Organizing"]);
|
|||||||
* @returns {StaffFieldDescriptor}
|
* @returns {StaffFieldDescriptor}
|
||||||
*/
|
*/
|
||||||
export function mapCustomFieldRow(row) {
|
export function mapCustomFieldRow(row) {
|
||||||
const groupName = row["custom_group_id.name"];
|
const groupName = /** @type {string} */ (row["custom_group_id.name"]);
|
||||||
const groupTitle = row["custom_group_id.title"];
|
const groupTitle = /** @type {string} */ (row["custom_group_id.title"]);
|
||||||
/** @type {"activity" | "org"} */
|
/** @type {"activity" | "org"} */
|
||||||
const groupKind = ORG_GROUP_NAMES.has(groupName) ? "org" : "activity";
|
const groupKind = ORG_GROUP_NAMES.has(groupName) ? "org" : "activity";
|
||||||
const optionGroupId =
|
const optionGroupId =
|
||||||
|
|||||||
Reference in New Issue
Block a user