I tried leaving out declare from my library definitions and it works just the same (I tried declare type and declare interface, i.e. I tried removing the declare from all those statements and saw no difference).
The documentation is lacking about what it actually does and where to use it. On SO I found someone using declare to define something as global but _within his source code_. He then run into occasional somewhat random problems when it wasn't defined - I ventured the guess that if he defines something as global in the source instead of in a lib. definition the order in which source code files are parsed my matter and that global symbols should only be defined in lib. definitions. However, the documentation had nothing to clarify this issue.
But it seems anything in a library definition is global anyway (at least in my short test)? So what is declare used for anyway, what does it do?
Somebody, Anybody???
Why is a KEY keyword not explained anywhere? It's just "there" in the documentation.
Where did you find KEY keyword?
emphasis on a word by capitalizing it, it is a KEY keyword not just some obscure never used keyword that does not matter anyway
declare keyword is matter for modules, functions and variables as a syntactical anchor for such cases
declare module('lib') {
declare export var a: string;
declare export function (a: string): number;
}
Don't know how it behaves with types and interfaces. Thought it's just for global definitions outside of module declaration. I just never use it.
The question is what I wrote at the top.
I tried leaving out declare from my library definitions and it works just the same (I tried declare type and declare interface, i.e. I tried removing the declare from all those statements and saw no difference).
It is in all the examples but it seems unnecessary.
I would like to know what it actually does.
I tried to remove declare from module and all its statements (type and const) and flow threw parsing error. So declare is necessary.
In your example, okay, nice to know. My question still remains. Nor do we have an explanation of what it actually does.
I've got an interesting case for me. I'm trying to write a handler for my component like
handleClick = ({ key }: { key: string }) => {}
and I'm getting this error by eslint

Then I create
type handleClickKey = {
key: string
}
and try to rewrite my handler
handleClick = ({ key }: handleClickKey)
in this case the same error in the type definition...
But if I write
declare type handleClickKey = {
key: string
}
all right, no eslint errors, no flow errors...
What is declare?
Same for declare export. Is it necessary or not? In the Flow docs reads that declarations without exports are not exposed anywhere but for other declarations in he module declaration:
https://flow.org/en/docs/libdefs/creation/
Anyhow declare export is rarely used for example in flow-typed. The documentation for module and library definitions is not very complete.
Most helpful comment
Same for
declare export. Is it necessary or not? In the Flow docs reads that declarations withoutexportsare not exposed anywhere but for other declarations in he module declaration:https://flow.org/en/docs/libdefs/creation/
Anyhow
declare exportis rarely used for example in flow-typed. The documentation for module and library definitions is not very complete.