Skip to content

Instantly share code, notes, and snippets.

@m93a
Created April 26, 2019 16:10
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 m93a/fe5310d3c3088faaf775ad2ada763d45 to your computer and use it in GitHub Desktop.
Save m93a/fe5310d3c3088faaf775ad2ada763d45 to your computer and use it in GitHub Desktop.
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