```ts
// solution.ts

export function countBy(records: Record<string, string>[], field: string): Record<string, number> {
  if (field.trim() === '') {
    throw new Error('Field name cannot be empty text');
  }

  const counts: Record<string, number> = {};

  for (const record of records) {
    const fieldValue = record[field];

    if (fieldValue !== undefined) {
      counts[fieldValue] = (counts[fieldValue] || 0) + 1;
    }
  }

  return counts;
}
```