Skip to main content
Module

x/scaffold/src/deps/types.ts>Except

scaffold your next project with style and 💗
Latest
type alias Except
import { type Except } from "https://deno.land/x/scaffold@0.3.0/src/deps/types.ts";

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.

This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types (microsoft/TypeScript#30825).

Examples

Example 1

import type {Except} from 'type-fest';

type Foo = {
	a: number;
	b: string;
	c: boolean;
};

type FooWithoutA = Except<Foo, 'a' | 'c'>;
//=> {b: string};

Type Parameters

ObjectType
KeysType extends keyof ObjectType
definition: [KeyType in keyof ObjectTypein keyof Filter<KeyType, KeysType>]: ObjectType[KeyType]