February 2019
Beginner
694 pages
18h 4m
English
When defining a conditional type, we can also use distributive syntax to return one of a number of types. As an example of this, consider the following function definition:
function compareTwoValues(
input : string | number | Date,
compareTo : string | number | Date ) {
}
Here, we have defined a function named compareTwoValues that has two parameters, input and compareTo. Both the input and the compareTo parameters can accept either a string or a number or a Date type. But what if we wanted to apply the following rules:
Read now
Unlock full access