Complete the code to define a conditional type that checks if T is a string.
type IsString<T> = T extends [1] ? true : false;The conditional type checks if T extends string. If yes, it returns true, otherwise false.
Complete the code to prevent distributive behavior by wrapping T in a tuple.
type NonDistributive<T> = [T] extends [[1]] ? true : false;T in a tuple, causing distributive behavior.Wrapping T in a tuple [T] stops TypeScript from distributing the conditional type over unions.
Fix the error in the conditional type to avoid distribution over union types.
type FixDistribution<T> = [T] extends [1] ? true : false;string directly, which causes distribution.Using [string] inside the extends clause wraps the type in a tuple, preventing distribution.
Fill both blanks to create a non-distributive conditional type that checks if T is assignable to U.
type IsAssignable<T, U> = [T] extends [[1]] ? [2] : false;
T in a tuple.T instead of true in the true branch.This type checks if T is assignable to U without distribution by wrapping T in a tuple. If yes, it returns true, else false.
Fill all three blanks to create a non-distributive conditional type that returns the type if it extends U, else never.
type FilterType<T, U> = [T] extends [[1]] ? [2] : [3];
unknown instead of never in the false branch.T in a tuple.This type filters T by checking if it extends U without distribution. If yes, it returns T, else never.