> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/js/typescript/generics.md).

# Generics

A type that takes other types are parameters

### Limiting Acceptable Types

extends on the left limits the types acceptable

```typescript
type RecursivePartialBy<T, K extends keyof T> = Omit<T, K> &
  RecursivePartial<Pick<T, K>>;
```

### Conditional Typing

extends on the right can create conditional typing

```typescript
type TypeDataPartial<T> = T extends { type_data: unknown }
  ? RecursivePartialBy<T, "type_data">
  : T;
```
