Flow version: 0.145.0
I expect running flow check should evaluate the project's types
What I get: Global flow errors that are coming from outside the project? Specifically from /private/tmp/flow or /tmp/flow/
Here's an example of the Errors I'm getting:
Error ----------------------------------------------------- /private/tmp/flow/flowlib_1f5c80229e26e8fa_502/dom.js:988:17
Cannot use Node as a type because it is an any-typed value. Type Node properly, so it is no longer any-typed, to use it
as an annotation. [value-as-type]
985| head: HTMLHeadElement | null;
986| images: HTMLCollection<HTMLImageElement>;
987| implementation: DOMImplementation;
988| importNode<T: Node>(importedNode: T, deep: boolean): T;
989| inputEncoding: string;
990| lastModified: string;
991| links: HTMLCollection<HTMLLinkElement>;
I confirmed it is flow that builds this directory and the type declarations as when I removed /private/tmp/flow and I reran flow check that directory and the declarations were regenerated.
Thanks for any help or guidance on this issue.
Theses are the builtin type definitions from https://github.com/facebook/flow/tree/master/lib.
They are written to disk so that you can view them when an error occurs.
I had a similar problem with another builtin global type. Turned out I had a conflicting declare type in my own global type definition files.
If you look at the files that are included as [libs] in your flowconfig, do you by any chance have something like
declare var Node: any
in any of those files, including flow-typed and any custom type definition files that you might have? I can repro OP's error if I add a libdef file like that to a project. The type conflicts with builtin types and creates errors in there.
@noppa Thanks for the reply. This does seem to be the right direction in solving this problem. However I checked my flow-type declarations and none declared the type Node or Element? I also had no [libs] declarations. I also checked the entire source for those type declarations and did not find them. This is a react app and I do see Element and Node types imported from React but when I look at node_modules/react I don't find type declarations. I also ran npx flow-typed update but the problem is still persisting.
Most helpful comment
I had a similar problem with another builtin global type. Turned out I had a conflicting
declare typein my own global type definition files.If you look at the files that are included as
[libs]in your flowconfig, do you by any chance have something likein any of those files, including flow-typed and any custom type definition files that you might have? I can repro OP's error if I add a libdef file like that to a project. The type conflicts with builtin types and creates errors in there.