H
H
Herberito Galustyan2019-08-27 20:36:35
typescript
Herberito Galustyan, 2019-08-27 20:36:35

Is there a way to skip certain types?

I have a type

type Person = { id: string; name: boolean; su:number }

Using Omit, you can skip certain properties.
type Sedra = Omit<Person, "su"|"id">;
// {name: boolean;}

TypeScript has a way to skip certain types.
example
type Sedra = OmitType<Person, boolean|number >;
    // {id: string;}

Is there an OmitType?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
forspamonly2, 2019-08-31
@Herberto

can be crafted from mapped type, indexed type, conditional type, and Pick library type

type OmitType<T, O> = Pick<T, {[P in keyof T]: T[P] extends O ? never : P}[keyof T]>

V
Vitaly, 2019-08-27
@vshvydky

https://devblogs.microsoft.com/typescript/announci...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question