Complete the code to define a conditional type that returns 'string' if T is 'number', otherwise 'boolean'.
type CheckType<T> = T extends number ? [1] : boolean;The conditional type checks if T extends number. If yes, it returns string, otherwise boolean.
Complete the code to create a conditional type that returns 'true' if T is assignable to string, otherwise 'false'.
type IsString<T> = T extends [1] ? true : false;The conditional type checks if T extends string. If yes, it returns true, otherwise false.
Fix the error in the conditional type that should return 'never' if T is 'null', otherwise T.
type NonNull<T> = T extends [1] ? never : T;The conditional type checks if T extends null. If yes, it returns never, otherwise it returns T.
Fill both blanks to create a conditional type that returns 'Array<U>' if T is an array of U, otherwise T.
type WrapArray<T> = T extends [1] ? Array<[2]> : T;
This conditional type uses infer U to extract the element type from the array T. If T is an array, it returns Array<U>, otherwise it returns T.
Fill the two blanks to create a conditional type that returns the type of the property K in T if it exists, otherwise 'never'.
type PropType<T, K extends keyof any> = K extends keyof T ? T[1] : [2];
This conditional type checks if K is a key of T. If yes, it returns the type of property K in T using T[K]. Otherwise, it returns never.