From b75e1e9f1eadce5e899dd1247e465a138546cc4e Mon Sep 17 00:00:00 2001 From: emiyaaaaa Date: Fri, 15 May 2026 10:26:56 +0800 Subject: [PATCH 1/3] update Except type --- source/except.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/except.d.ts b/source/except.d.ts index e89092b77..91f193b0d 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, Options extends Required> = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> From b7a62722933feaf3739ca9c992b08c089006d7fd Mon Sep 17 00:00:00 2001 From: emiyaaaaa Date: Fri, 15 May 2026 10:52:05 +0800 Subject: [PATCH 2/3] update _Except type --- source/except.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/except.d.ts b/source/except.d.ts index 91f193b0d..2137b2f5d 100644 --- a/source/except.d.ts +++ b/source/except.d.ts @@ -104,7 +104,7 @@ type PostPayloadFixed = Except; export type Except, Options extends ExceptOptions = {}> = _Except>; -type _Except, Options extends Required> = { +type _Except> = { [KeyType in keyof ObjectType as Filter]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial> From cca59c6b113a0b5b5ceb50e62ee5fe7a4bae8eba Mon Sep 17 00:00:00 2001 From: emiyaaaaa Date: Fri, 15 May 2026 11:04:11 +0800 Subject: [PATCH 3/3] add test --- test-d/except.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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});