Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created January 18, 2021 05:19
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 hw0k/063093b64c316b0ebe6e26a408c12cc9 to your computer and use it in GitHub Desktop.
Save hw0k/063093b64c316b0ebe6e26a408c12cc9 to your computer and use it in GitHub Desktop.
TN 6
function doSomething(left: string | number, right: string | boolean) {
if (left === right) {
// left와 right가 모두 string으로 추론됨.
console.log(left.toLowerCase());
console.log(right.toLowerCase());
return;
}
// left는 string | number, right는 string | boolean으로 추론됨.
console.log(`${left}`);
console.log(`${right}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment