# exclude

## Practical example

```typescript
import { exclude } from "tsafe/exclude";

type Circle = {
	type: "circle";
	radius: number;
};

type Square = {
	type: "square";
	sideLength: number;
};

type Shape = Circle | Square;

declare const shapes: Shape[];

//Assumes we want to do something for every Circle

shapes
	.map(shape => (shape.type === "circle" ? shape : null))
	.filter(exclude(null))
	.forEach(circle => {
		//Here circle is of type Circle
		//if we had used .filter(shape=> shape.type === "circle")
		//it would be functionally the same but circle would be of type
		//Shape
	});
```

## Basic examples

```typescript
import { exclude } from "tsafe/exclude";

const arr = ["a", "b", "c", "d"] as const;
const newArr = arr.filter(exclude("a"));

//type of newArr is ("b" | "c" | "d")[]
//value of newArr is ["b", "c", "d"]
```

You can also exclude more than on element:

```typescript
import { exclude } from "tsafe/exclude";

const arr = ["a", "b", "c", "d"] as const;
const newArr = arr.filter(exclude(["a", "b"]));

//type of newArr is ("c" | "d")[]
//value of newArr is ["c", "d"]
```


---

# Agent Instructions: 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/exclude.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.
