If I have the process.browser variable in my code how can I annotate it?
You can declare the process
variable:
// @flow
declare var process: { browser: number }
const foo = process.browser * 3
Here is a sample of it in action: https://flow.org/try/#0PTAEAEDMBsHsHcBQiAmBTAxtAhgJzaAG56gAOusGaAztQFygDeoARhfNWrgwHYCuAWxZdQAX2QZYPagBdQkWLFABeMhSq0AdGwSdcoAFSgAzIiA
In this example the global variable is declared locally in the file that consumes it, however it might be more ideal to declare this globally via a library definition. Going this route, it will automatically be defined for every file.
For example, add the following to <PROJECT_ROOT>/flow-typed/process.js
and you should be set. You may need to restart the Flow server.
declare var process: { browser: number }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With