diff --git a/source/is-union.d.ts b/source/is-union.d.ts index 06ca80903..0e8e6a442 100644 --- a/source/is-union.d.ts +++ b/source/is-union.d.ts @@ -1,4 +1,5 @@ import type {IsNever} from './is-never.d.ts'; +import type {IsEqual} from './is-equal.d.ts'; /** Returns a boolean for whether the given type is a union. @@ -24,7 +25,7 @@ type InternalIsUnion = IsNever extends true ? false : T extends any - ? [U] extends [T] + ? IsEqual extends true ? false : true : never diff --git a/test-d/is-union.ts b/test-d/is-union.ts index 1258af3c8..2c1f5608b 100644 --- a/test-d/is-union.ts +++ b/test-d/is-union.ts @@ -16,3 +16,12 @@ expectType>(true); expectType>(true); expectType>(true); expectType>(true); + +type TestUnion = + // Here, the entire union extends both the individual members: + // So, `TestUnion` extends `{opt?: number; a: number; b: string}`, and + // `TestUnion` extends `{a: number; b: string}`. + | {opt?: number; a: number; b: string} + | {a: number; b: string}; + +expectType>(true);