```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] === '{') {
            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('Invalid placeholder');
            }

            const name = template.slice(i + 1, j);
            if (!values.hasOwnProperty(name)) {
                throw new Error(`Missing value for placeholder ${name}`);
            }

            result += values[name];
            i = j + 1;
        } else {
            result += template[i];
            i++;
        }
    }

    return result;
}
```