Declare a global which may or may not be present
Open
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to do something like `declare var foo? : string` such that `foo` is either a string, or doesn't exist at all as a global variable.
I can do `declare var foo : string | void` but that only gets me half way there; `console.log(foo)` will still typecheck. What I want is force the code to have to do a `typeof` check before using the variable, to make sure it exists.
Is there any way to declare a global that might not exist, in flow?
Contributor guide
Assessment
This issue has not been assessed yet.