Created
March 6, 2021 11:27
-
-
Save donavon/232aaaa1d3889eadcb306690d4936ca3 to your computer and use it in GitHub Desktop.
TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const someFunction = (arg: string | string[]) => { | |
if (Array.isArray(arg)) { | |
return arg.map<string>(someFunction); | |
} | |
return arg.toUpperCase(); | |
}; | |
const x = someFunction('a'); // should be type string | |
const arr = someFunction(['a']); // should be type string[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment