Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (17 sloc) 886 Bytes
Create a type from an object type without certain keys.
This type is a stricter version of [`Omit`]( The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
Please upvote [this issue]( if you want to have the stricter version as a built-in in TypeScript.
import {Except} from 'type-fest';
type Foo = {
a: number;
b: string;
c: boolean;
type FooWithoutA = Except<Foo, 'a' | 'c'>;
//=> {b: string};
export type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>;
You can’t perform that action at this time.