Skip to content

Instantly share code, notes, and snippets.

@akihisa-shimada
Created December 17, 2021 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akihisa-shimada/7ea4938ae84e5c063cb2df559c425ce3 to your computer and use it in GitHub Desktop.
Save akihisa-shimada/7ea4938ae84e5c063cb2df559c425ce3 to your computer and use it in GitHub Desktop.
const functionA = <T, U>(bool: boolean, param1: T, param2: U): T | U => {
if (bool) return param1;
return param2;
}
const result1 = functionA(true, 1, '文字列');
const result2 = functionA(false, 1, '文字列');
console.log(result1) // 1
console.log(result2) // 文字列
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment