Created
July 7, 2019 12:56
-
-
Save Bannerets/57fda44a56167bdeca87dcc94af787c4 to your computer and use it in GitHub Desktop.
$Flow$ModuleRef
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
[ignore] | |
[include] | |
[libs] | |
[lints] | |
[options] | |
module.system=haste | |
module.system.haste.module_ref_prefix=m# | |
[strict] |
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
// @flow | |
declare export var str1: 'str1' | |
export function sayHi(name: string) { | |
console.log('hi, ' + name) | |
} |
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
// @flow | |
declare export var str2: 'str2' |
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
// @flow | |
export function sayHi(name: string) { | |
console.log('hello, ' + name) | |
} |
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
// @flow | |
declare function requireMany<T>(T) | |
: $TupleMap<T, <M>($Flow$ModuleRef<M>) => M> | |
const t = requireMany(['m#./a', 'm#./b']) | |
const a = t[0] // {| +sayHi: (name: string) => void, +str1: "str1" |} | |
const b = t[1] // {| +str2: "str2" |} | |
// --- | |
interface HiModule { | |
+sayHi: string => void | |
} | |
declare function requireHi<M: HiModule>($Flow$ModuleRef<M>): M | |
// or: | |
// declare function requireHi<M: { sayHi: string => void, ... }>($Flow$ModuleRef<M>): M | |
const h1 = requireHi('m#./a') // ok | |
const h2 = requireHi('m#./b') // error | |
const h3 = requireHi('m#./c') // ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment