Search Terms
type guards ternary
Suggestion
Support to use dser-defined type guards with ternary operator
Use Cases
More complex type guards function
Examples
function checkAnimal(animal: Animal)
: animal is Cat ? 'Cat'
: animal is Dog ? 'Dog'
: animal is Animal
{
// ...
}
let value: any;
let checkResult = checkAnimal(animal);
if(checkResult === 'Cat'){
// value is Cat now
}
else if(checkResult === 'Dog'){
// value is Dog now
}
else if(checkResult){
// value is other Animal
}
else{
// value is not Animal
}
Checklist
My suggestion meets these guidelines:
Search Terms
type guards ternarySuggestion
Support to use dser-defined type guards with ternary operator
Use Cases
More complex type guards function
Examples
Checklist
My suggestion meets these guidelines: