File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -198,13 +198,19 @@ type RecurseUniqueUnionDeep<U> =
198198 : U extends UnknownArray
199199 ? InternalUniqueUnionDeep < U >
200200 : U extends Lambda
201- // `Parametes` and `ReturnType` results are possible to be object or lambda; both should be passed into `UniqueUnionDeep`.
202- ? ( ...args : UniqueUnionDeep < Parameters < U > > extends infer A extends any [ ] ? A : never ) => ( UniqueUnionDeep < ReturnType < U > > )
201+ ? IsNever < keyof U > extends true
202+ // `Parametes` and `ReturnType` results are possible to be object or lambda; both should be passed into `UniqueUnionDeep`.
203+ ? HasMultipleCallSignatures < U > extends true
204+ ? U
205+ : ( ...args : UniqueUnionDeep < Parameters < U > > extends infer A extends any [ ] ? A : never ) => ( UniqueUnionDeep < ReturnType < U > > )
206+ : U
203207 : U ;
208+
204209/**
205210Note: Wrapping this with `Simplify`, `test-d/exact.ts` fails in "Spec: recursive type with union".
206211*/
207- type InternalUniqueUnionDeep < U extends object > = { [ K in keyof U ] : UniqueUnion < RecurseUniqueUnionDeep < U [ K ] > > } ;
212+ type InternalUniqueUnionDeep < U extends object > =
213+ { [ K in keyof U ] : UniqueUnion < RecurseUniqueUnionDeep < U [ K ] > > } ;
208214
209215type Lambda = ( ( ...args : any [ ] ) => any ) ;
210216
Original file line number Diff line number Diff line change @@ -63,6 +63,17 @@ expectType<true>({} as IsEqual<AnyLambda, AnyLambda>);
6363expectType < false > ( { } as IsEqual < AnyLambda , NumberLambda > ) ;
6464expectType < false > ( { } as IsEqual < NumberLambda , AnyLambda > ) ;
6565
66+ // Branded Type
67+ expectType < false > ( { } as IsEqual < 1 & { foo ?: 1 } , 1 > ) ;
68+ expectType < true > ( { } as IsEqual < 1 & { foo ?: 1 } , 1 & { foo ?: 1 } > ) ;
69+ expectType < false > ( { } as IsEqual < { bar : 'a' } & { foo ?: 1 } , { bar : 'a' } > ) ;
70+ expectType < false > ( { } as IsEqual < ( ( value : number ) => void ) & { foo ?: 1 } , ( value : number ) => void > ) ;
71+
72+ // Overload
73+ expectType < false > ( { } as IsEqual < { ( value : 'a' ) : 1 ; ( value : string ) : 1 } , ( value : string ) => 1 > ) ;
74+ expectType < false > ( { } as IsEqual < { ( value : 'a' ) : 1 ; ( value : string ) : 1 ; key : 'value' } , ( value : string ) => 1 > ) ;
75+ expectType < false > ( { } as IsEqual < { ( value : 'a' ) : 1 ; ( value : string ) : 1 ; key : 'value' } , { ( value : string ) : 1 ; key : 'value' } > ) ;
76+
6677// Lambda: Identical Union and Intersection cases.
6778expectType < true > ( { } as IsEqual < SpecificNumericLambda & SpecificNumericLambda , SpecificNumericLambda > ) ; // eslint-disable-line @typescript-eslint/no-duplicate-type-constituents
6879expectType < true > ( { } as IsEqual < SpecificNumericLambda | SpecificNumericLambda , SpecificNumericLambda > ) ; // eslint-disable-line @typescript-eslint/no-duplicate-type-constituents
You can’t perform that action at this time.
0 commit comments