```ts
export function fillTemplate(template: string, values: Record<string, string>): string {
  if (typeof template !== 'string') {
    throw new Error('Invalid template type');
  }

  let result = '';
  let i = 0;

  while (i < template.length) {
    if (template[i] === '{') {
      let j = i + 1;
      while (j < template.length && /^[a-zA-Z\d_]/.test(template[j])) {
        j++;
      }
      if (j <= i + 1 || template[j] !== '}') {
        throw new Error('Unterminated placeholder');
      }
      const name = template.slice(i + 1, j);
      if (name === '') {
        throw new Error('Empty placeholder name');
      }
      result += values[name] ?? '';
      i = j + 1;
    } else {
      result += template[i];
      i++;
    }
  }

  return result;
}
```