Created
February 25, 2017 13:23
-
-
Save rchaser53/2f52dc8ef540e4521184fda0cfd4cc86 to your computer and use it in GitHub Desktop.
continueとreturnでのunion typeの挙動
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
// for文内のcontinueはNG | |
const abc = (arg: (string | number)[]) => { | |
for (let i=0;i<arg.length;i++) { | |
if (typeof arg[i] === 'string') continue; | |
const abc: number = arg[i]; | |
} | |
} | |
// if文のearly returnはOK | |
const abc2 = (arg: (string | number)[]) => { | |
if (typeof arg[0] === 'string') return; | |
const abc: number = arg[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment