# TSR0201: Type assertion from '…' to '…' narrows the type. Use 'parse<…>', 'is<…>' or a narrowing check instead.

> A type assertion ('as T' or '<T>x') narrows the type without a check. Use parse<T>, is<T> or a narrowing check instead.

## What it means

`e as T` and `<T>e` are allowed only when `e` is already assignable to `T` (an upcast). `as const`, `satisfies T` and assertions to `unknown` are always allowed. A source of type `any` counts as `unknown`, and in `x as unknown as T` the outer assertion is checked on its own. A cast of a value from an external source reports [TSR1401](https://ts-r.dev/errors/TSR1401/) instead.

## Example

```ts
// unknown to a type parameter.
function cast<T>(x: unknown): T {
  return x as T; // @expect TSR0201
}
export const s: string = cast<string>(1);
```

## How to fix

- Validate the value: `parse<User>(data)`, or check it with `is<User>(data)`.
- Narrow with `instanceof` or a discriminant check (for DOM elements: `if (el instanceof HTMLInputElement)`).
- For test fixtures written as `{} as T`, build a complete value with a typed builder.
- If the code really is safe, use `// @ts-r-unsafe S-02: <reason>` on the line before.

Sound mode is defined in [design record 0007](https://github.com/Webb-Ventures/typescript-rust/blob/main/docs/design/0007-sound-mode.md) (accepted 2026-10-15).

Source: https://ts-r.dev/errors/TSR0201/
