Complete the code to define a generic type that returns string if the type is number, otherwise boolean.
type CheckType<T> = T extends [1] ? string : boolean;string instead of number in the condition.The conditional type checks if T extends number. If yes, it returns string, else boolean.
Complete the code to create a conditional type that returns T if it extends string, otherwise returns never.
type FilterString<T> = T extends [1] ? T : never;number or other types instead of string.This conditional type returns T only if it extends string. Otherwise, it returns never, which means no valid type.
Fix the error in the conditional type that should return Array<T> if T extends string, else T.
type WrapInArray<T> = T extends [1] ? Array<T> : T;number or other types in the extends clause.The conditional type checks if T extends string. If yes, it wraps T in an array, else returns T as is.
Fill the blank to create a conditional type that returns Promise<T> if T extends string, otherwise returns T.
type AsyncType<T> = T [1] string ? Promise<T> : T;== or extends= which are invalid in this context.The correct syntax for conditional types uses extends to check if T is a subtype of string.
Fill all three blanks to define a conditional type that returns string if T extends number, returns boolean if T extends string, otherwise returns never.
type MultiCheck<T> = T [1] number ? string : T [2] string ? boolean : [3];
implements instead of extends.any instead of never as fallback.This nested conditional type checks if T extends number, then returns string. Otherwise, it checks if T extends string, then returns boolean. If neither, it returns never.