Last active
November 20, 2017 14:50
-
-
Save geon/2e6b5302d06c3ecc5a1a392c83a74b60 to your computer and use it in GitHub Desktop.
This file contains 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
console.log(myFunction()); | |
const myConstant = ""; | |
function myFunction(myArgument: string = myConstant): string { | |
return myArgument; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You would expect myFunction to return a string, since it is typed as such. But it returns undefined.
This comes from the default value
myConstant
not being defined at the point where the function is called. This should either be an error (preferably), or myArgument should be forced to be typed tostring | undefined
(weird).