Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/phryneas/ts-deep-extract-types


https://github.com/phryneas/ts-deep-extract-types

library

Last synced: 11 days ago
JSON representation

Awesome Lists containing this project

README

        

This packages exposes types that allow you to extract deeply nested types.

# `type DeepExtractTypeSkipArrays`

Extracts a deeply-nested type from the target `Path` in `Source`, skipping arrays and ignoring null|undefined|optional types:

```ts
type QueryResult = { allPosts?: Array<{ users?: Array<{ name: string }> }> };
// will be { name: string }
type User = DeepExtractTypeSkipArrays;
```

# `type DeepExtractType`

Extracts a deeply-nested type from the target `Path` in `Source`, ignoring null|undefined|optional types:

```ts
type QueryResult = { user?: { firstPost?: { title: string } } };
// will be { title: string }
type Post = DeepExtractType;
```