```ts
export function topologicalSort(nodes: readonly string[], edges: readonly (readonly [string, string])[]): string[] {
    const graph: { [node: string]: string[] } = {};
    const inDegree: { [node: string]: number } = {};

    nodes.forEach(node => {
        graph[node] = [];
        inDegree[node] = 0;
    });

    edges.forEach(([from, to]) => {
        if (!nodes.includes(from) || !nodes.includes(to)) {
            throw new Error(`Edge includes a node not in the provided list: ${from} -> ${to}`);
        }
        graph[from].push(to);
        inDegree[to]++;
    });

    const queue = nodes.filter(node => inDegree[node] === 0);

    const result: string[] = [];

    while (queue.length > 0) {
        const node = queue.shift()!;
        result.push(node);

        graph[node].forEach(neighbor => {
            inDegree[neighbor]--;
            if (inDegree[neighbor] === 0) {
                queue.push(neighbor);
            }
        });
    }

    if (result.length !== nodes.length) {
        throw new Error("Cycle detected in the graph");
    }

    return result;
}
```