Type Alias: If<Value, TrueResult, FalseResult>
If<
Value,TrueResult,FalseResult> =Valueextendstrue?TrueResult:Valueextendsfalse?FalseResult:TrueResult|FalseResult
Defined in: types.ts:258
A type utility that allows branching of types depending on the Value parameter.
Type Parameters
| Type Parameter | 
|---|
| Valueextendsboolean | 
| TrueResult | 
| FalseResult | 
Example
declare function get<const GetValues extends boolean = false>(
  getValues?: GetValues
): If<GetValues, string, string[]>;
const a = get(true);
//    ^? string
const b = get(false);
//    ^? string[]
declare const someBoolean: boolean;
const c = get(someBoolean);
//    ^? string | string[]