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

    let result = '';
    let i = 0;

    while (i < template.length) {
        if (template[i] === '{' && i + 1 < template.length && template[i + 1] === '}') {
            throw new Error('Empty placeholder not allowed');
        } else if (template[i] === '{') {
            let j = i + 1;
            while (j < template.length && /[a-zA-Z0-9_]/.test(template[j])) {
                j++;
            }
            const placeholder = template.slice(i, j);
            if (j === i + 1 || template[j] !== '}') {
                throw new Error('Invalid placeholder');
            }
            const name = placeholder.slice(1, -1);
            if (!name) {
                throw new Error('Empty placeholder not allowed');
            }
            result += values[name];
            i = j;
        } else {
            result += template[i];
            i++;
        }
    }

    return result;
}
```