This quiz will test what you have learned about conditional types.
1.
What type is Check equivalent to in the code below?
typeAnimal={
name:string;
legs:number
}
typeCheck=Animalextends{ name:string}?"yes":"no";
2.
We have a requirement to create a utility type called NullableProps that gets all the nullable properties from an object type. How could this be defined?
Copy
typeNullableProps<T>={
[PinkeyofT]:nullextendsT[P]?never:P
}[keyofT];
Copy
typeNullableProps<T>={
[PinkeyofT]:nullextendsT[P]?P:never
}[keyofT];
3.
We have a requirement to create a utility type similar to ReturnType with the improvement of handling asynchronous functions. How could we define this type?
This site uses cookies. Click here to find out moreOkay, thanks
3.
We have a requirement to create a utility type similar to ReturnType with the improvement of handling asynchronous functions. How could we define this type?