From: Dongcai Huang Date: Thu, 12 May 2022 01:39:06 +0000 (+0800) Subject: chore: add explaination about the utility type IfAny (#5862) [ci skip] X-Git-Tag: v3.2.34-beta.1~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=109453f2baa0716806c82f328dce8c4459f8c7d7;p=thirdparty%2Fvuejs%2Fcore.git chore: add explaination about the utility type IfAny (#5862) [ci skip] --- diff --git a/packages/shared/src/typeUtils.ts b/packages/shared/src/typeUtils.ts index 8caba54c6c..8a56abaa2c 100644 --- a/packages/shared/src/typeUtils.ts +++ b/packages/shared/src/typeUtils.ts @@ -7,4 +7,7 @@ export type UnionToIntersection = ( // make keys required but keep undefined values export type LooseRequired = { [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 = 0 extends (1 & T) ? Y : N