type-challenges icon indicating copy to clipboard operation
type-challenges copied to clipboard

25747 - IsNegativeNumber

Open Hfutsora opened this issue 2 years ago • 0 comments

type IsUnion<T, U extends T = T> =
  (T extends any ?
    (U extends T ? false : true)
    : never) extends false ? false : true

type IsNegativeNumber<T extends number> = IsUnion<T> extends true 
  ? never 
  : number extends T 
    ? never 
    : `${T}` extends `-${string}` 
      ? true 
      : false 

IS-UNION

Hfutsora avatar Apr 26 '23 02:04 Hfutsora