```ts
function clipText(text: string, from: number, to: number): string {
  if (from < 0 || to < 0) {
    throw new Error("Places must be non-negative");
  }
  if (from > text.length || to > text.length) {
    throw new Error("Places must not exceed the length of the text");
  }
  if (from > to) {
    [from, to] = [to, from];
  }
  return text.substring(from, to);
}
```