DEV Community

Discussion on: Function flexibility considered harmful

Collapse
 
joeytwiddle profile image
Paul "Joey" Clark • Edited

The type assertion example can be made safer with this signature:

function add<T extends string | number>(a: T, b: T) {
Enter fullscreen mode Exit fullscreen mode

Anyway, I agree with you that isUserAdult is the simplest way to solve this. :-)