@omnifyjp/ts 3.23.3 → 3.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -566,18 +566,27 @@ export function formatZodSchemasSection(schemaName, zodSchemas, displayNames, ex
566
566
  parts.push(`export function get${schemaName}Label(locale: string): string {\n`);
567
567
  parts.push(` return ${lowerName}I18n.label[locale as keyof typeof ${lowerName}I18n.label] ?? ${lowerName}I18n.label['en'] ?? '${schemaName}';\n`);
568
568
  parts.push(`}\n\n`);
569
+ // #83 (v3.23.4): cast the fields lookup through a structural index type
570
+ // so the helpers type-check even when the schema has zero properties.
571
+ // Without the cast, `keyof typeof i18n.fields` is `never` for an empty
572
+ // fields object and every downstream `.label` / `.placeholder` access
573
+ // produces `error TS2339: Property 'label' does not exist on type 'never'`.
574
+ // Hits every kind:extend schema with no project-owned properties (Branch,
575
+ // Organization, Role, User in the godx-tempo SSO set).
576
+ const fieldRecordType = `Record<string, { label: Record<string, string>; placeholder?: Record<string, string> }>`;
569
577
  parts.push(`/** Get field label for a specific locale */\n`);
570
578
  parts.push(`export function get${schemaName}FieldLabel(field: string, locale: string): string {\n`);
571
- parts.push(` const fieldI18n = ${lowerName}I18n.fields[field as keyof typeof ${lowerName}I18n.fields];\n`);
579
+ parts.push(` const fields = ${lowerName}I18n.fields as ${fieldRecordType};\n`);
580
+ parts.push(` const fieldI18n = fields[field];\n`);
572
581
  parts.push(` if (!fieldI18n) return field;\n`);
573
- parts.push(` return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;\n`);
582
+ parts.push(` return fieldI18n.label[locale] ?? fieldI18n.label['en'] ?? field;\n`);
574
583
  parts.push(`}\n\n`);
575
584
  parts.push(`/** Get field placeholder for a specific locale */\n`);
576
585
  parts.push(`export function get${schemaName}FieldPlaceholder(field: string, locale: string): string {\n`);
577
- parts.push(` const fieldI18n = ${lowerName}I18n.fields[field as keyof typeof ${lowerName}I18n.fields];\n`);
578
- parts.push(` if (!fieldI18n || !('placeholder' in fieldI18n)) return '';\n`);
579
- parts.push(` const placeholder = fieldI18n.placeholder as Record<string, string>;\n`);
580
- parts.push(` return placeholder[locale] ?? placeholder['en'] ?? '';\n`);
586
+ parts.push(` const fields = ${lowerName}I18n.fields as ${fieldRecordType};\n`);
587
+ parts.push(` const fieldI18n = fields[field];\n`);
588
+ parts.push(` if (!fieldI18n?.placeholder) return '';\n`);
589
+ parts.push(` return fieldI18n.placeholder[locale] ?? fieldI18n.placeholder['en'] ?? '';\n`);
581
590
  parts.push(`}\n`);
582
591
  return parts.join('');
583
592
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/ts",
3
- "version": "3.23.3",
3
+ "version": "3.23.4",
4
4
  "description": "TypeScript model type generator from Omnify schemas.json",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",