Browse Source

chore: add explaination about the utility type IfAny<T, Y, N> (#5862) [ci skip]

Dongcai Huang 4 năm trước cách đây
mục cha
commit
109453f2ba
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      packages/shared/src/typeUtils.ts

+ 3 - 0
packages/shared/src/typeUtils.ts

@@ -7,4 +7,7 @@ export type UnionToIntersection<U> = (
 // make keys required but keep undefined values
 // make keys required but keep undefined values
 export type LooseRequired<T> = { [P in string & keyof T]: T[P] }
 export type LooseRequired<T> = { [P in string & keyof T]: T[P] }
 
 
+
+// If the the type T accepts type "any", output type Y, otherwise output type N.
+// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
 export type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N
 export type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N