> For the complete documentation index, see [llms.txt](https://docs.tsafe.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tsafe.dev/is.md).

# is

`is` is meant to be used in conjunction with assert and enable you to tell the compiler:

"*Trust me this `value` is of type `T`"* or "*Trust me this `value` is not of type `T`*"

![](https://user-images.githubusercontent.com/6702424/118082020-c2e5dd80-b3bc-11eb-9ea9-71fa8206f704.gif)

```typescript
import { assert, is } from "tsafe/assert";

type Circle = { radius: number };
type Square = { sideLength: number };
type Shape = Circle | Square;

declare const shape: Shape;

//You: Trust me TypeScript, I know that shape is a Circle.
assert(is<Circle>(shape));

//TypeScript: Ok if you say so...it has a radius then.
shape.radius;
```

Equally useful you can tell TypeScript that your shape is not a `Square`, it will infer that, it is then a `Circle`.

```typescript
//You: Trust me TypeScript, I know that shape is not a Square.
assert(!is<Square>(shape));

//TypeScript: Ok so by elimination it should be a Circle!
shape.radius;
```

{% hint style="danger" %}
`is` must **always** be used in conjunction with [`assert`](/assert.md) as described in the example above.

You aren't even allowed to do something like `assert(is<Circle>(shape) && shape.radius > 100 )`

For any other use case consider[`typeGuard`](/typeguard.md) instead.
{% endhint %}

{% hint style="warning" %}
It is important to understand that here that when you run the instruction `assert(typeGuard<Circle>(shape))` if the shape happens not to be a Circle you won't get an error at runtime.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tsafe.dev/is.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
