Generic Type with Constraints 1

Easy
generic constraints

Description:

Create util type that may accept only string or number types and return passed type as it is. For other types TS compiler should throw an error.

For example:

CheckStringOrNumber<string> // expect string CheckStringOrNumber<number> // expect number CheckStringOrNumber<string[]> // ❌ TS traspilation error

Code

Loading...