diff --git a/source/except.d.ts b/source/except.d.ts index e89092b77..2137b2f5d 100644 --- a/source/except.d.ts +++ b/source/except.d.ts @@ -1,5 +1,6 @@ import type {ApplyDefaultOptions} from './internal/index.d.ts'; import type {IsEqual} from './is-equal.d.ts'; +import type {LiteralUnion} from './literal-union.d.ts'; /** Filter out keys from an object. @@ -100,10 +101,10 @@ type PostPayloadFixed = Except; @category Object */ -export type Except = +export type Except, Options extends ExceptOptions = {}> = _Except>; -type _Except> = { +type _Except> = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> diff --git a/test-d/except.ts b/test-d/except.ts index 0c6ba25c7..142579ccc 100644 --- a/test-d/except.ts +++ b/test-d/except.ts @@ -28,3 +28,14 @@ type Example = { const test: Except = {foo: 123, bar: 'asdf'}; expectType(test.foo); expectType(test['bar']); + +// Test for generic type +type GenericType = T extends string ? { + foo: T; + bar: string; +} : { + baz: T; +}; +type GenericTypeExcept = Except, 'foo'>; +expectType>({} as {bar: string}); +expectType>({} as {baz: number});