Skip to content

Commit

Permalink
fix: remove empty object check
Browse files Browse the repository at this point in the history
This is likely to workaround a bug in TS whice does not apply any more
  • Loading branch information
unional committed Oct 22, 2023
1 parent 6fa80ce commit d957b78
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions type-plus/ts/predicates/CanAssign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ import type { IsEmptyObject } from './IsEmptyObject.js'
* If you want to make sure all branches are assignable,
* use `StrictCanAssign<A, B>`.
*/
export type CanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true
? Record<string, unknown> extends B
? Then
: Else
: boolean extends A
export type CanAssign<A, B, Then = true, Else = false> = boolean extends A
? boolean extends B
? Then
: Else
? Then
: Else
: A extends B
? Then
: Else
Expand All @@ -49,12 +45,12 @@ export type CanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extend
*/
export type StrictCanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true
? Record<string, unknown> extends B
? Then
: Else
? Then
: Else
: boolean extends A
? boolean extends B
? Then
: Else
? Then
: Else
: [A] extends [B]
? Then
: Else
Expand Down

0 comments on commit d957b78

Please sign in to comment.