Created
April 26, 2019 16:10
-
-
Save m93a/fe5310d3c3088faaf775ad2ada763d45 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
let validPattern = await fetch('something something'); | |
type validString = string : (s) => s.includes(validPattern); | |
// error, the value of validPattern is not known at compile time | |
let validPattern = 'cool'; | |
type validString = string : (s) => s.includes(validPattern); | |
// this should be perfectly valid, huh? | |
let isValidPattern = (s: string) => s.includes('cool'); | |
type validString = string: (s) => isValidPattern(s); | |
// you don't want to write the code twice for runtime and compile time, | |
// so this should work, right? | |
let isValidPattern = (s: string) => { | |
let pattern: validString = 'cool'; | |
return s.includes(pattern); | |
} | |
type validString = string: (s) => isValidPattern(s); | |
// so now you have to run isValidPattern in order to compile isValidPattern? | |
// this is a nightmare! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment