- Notifications
You must be signed in to change notification settings - Fork 33.7k
/
Copy pathcommon.d.ts
21 lines (16 loc) · 817 Bytes
/
common.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
exporttypeData={[key: string]: unknown}
exporttypeUnionToIntersection<U>=(
Uextendsany ? (k: U)=>void : never
)extends(k: infer I)=>void
? I
: never
// Conditional returns can enforce identical types.
// See here: https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650
// prettier-ignore
typeEqual<Left,Right>=
(<U>()=>UextendsLeft ? 1 : 0)extends(<U>()=>UextendsRight ? 1 : 0) ? true : false;
exporttypeHasDefined<T>=Equal<T,unknown>extendstrue ? false : true
// If the type T accepts type "any", output type Y, otherwise output type N.
// https://stackoverflow.com/questions/49927523/disallow-call-with-any/49928360#49928360
exporttypeIfAny<T,Y,N>=0extends1&T ? Y : N
exporttypeLooseRequired<T>={[Pinstring&keyofT]: T[P]}