Questions tagged [flowtype]

Flow is a static type checker, designed to find type errors in JavaScript programs, created by Facebook.

What is Flow?

Flow is a static type checker, designed to find type errors in JavaScript programs.

The goal of Flow is to find errors in JavaScript code with little programmer effort. Flow relies heavily on type inference to find type errors even when the program has not been annotated - it precisely tracks the types of variables as they flow through the program.

At the same time, Flow is a gradual type system. Any parts of your program that are dynamic in nature can easily bypass the type checker, so you can mix statically typed code with dynamic code.

Flow also supports a highly expressive type language. Flow types can express much more fine-grained distinctions than traditional type systems. For example, Flow helps you catch errors involving null, unlike most type systems.

2301 questions
0
votes
1 answer

How to fix this red underline when using Flow in WebStorm in React project?

I tried to describe the problem with screenshots. In addition, JSHint here doesn't seem to play any role. There is an ESLint config has been set up, so all the code is edited according to ESLint. But anyway I don't know how this underline can be…
jakhando
  • 37
  • 4
0
votes
2 answers

Does Flow work with any JavaScript framework?

Not looking for any recommendations, just an objective assessment if any JavaScript framework can be type-checked with Flow in the current state. With Flow decreasing in popularity compared to TypeScript, framework declaration files tend to be…
Olle Härstedt
  • 3,348
  • 1
  • 18
  • 46
0
votes
1 answer

how to check if a click event occurred within or outside a specific element

I'm listening to click bubbled events on window and I want to check if the click occurred within a a specific element in order to dispatch (or not) an action. The inerestinc part of my component is the following one: const…
Bertuz
  • 2,058
  • 2
  • 21
  • 37
0
votes
1 answer

Flow is giving SyntaxError on imports

Here's my code: // @flow import { EntityModel } from '@http-utils/hateoas'; I compile it: babel src/ -d dist/ Then I run it, but I get a runtime error: $ node dist/http-utils-hateoas-example.js import { EntityModel } from '@http-utils/hateoas'; …
Naresh
  • 18,757
  • 25
  • 99
  • 162
0
votes
0 answers

FlowType: Combine builder functions for exact object types

I have a collection of types I wish to build which are extending from a base type. The use case is creating the props for a bunch of React components which have some props in common but different optional props. It's desirable to keep the prop types…
ioseph
  • 1,813
  • 17
  • 22
0
votes
0 answers

Flow | Separate namespace for types and variables

Does Flow maintain a separate namespace for types and variables? In TypeScript, I leverage this feature to connect helper functions to interfaces. But this is not working in Flow: // @flow interface Person { firstName: string; lastName:…
Naresh
  • 18,757
  • 25
  • 99
  • 162
0
votes
0 answers

copy non js, non flow files in destination directory

I am using flow in my project. When I did npx flow-remove-types --help I can see the following in the output, -a, --all Transform all files, not just those with a @flow comment But when I run npx flow-remove-types --out-dir lib/ src/ --all I am…
BhaskerYadav
  • 529
  • 3
  • 20
0
votes
1 answer

Is it possible to make a type safe Vue app without transpilation?

Vue can be used without transpilation (no build step), but can it also be made type safe? That is, checked with TypeScript (or possibly Flow)?
Olle Härstedt
  • 3,348
  • 1
  • 18
  • 46
0
votes
1 answer

React - How to assign flow type to an exported module?

I have a file like this: // @flow type Options = { active?: string, name?: string, }; exports.myObject = process.env.NODE_ENV === 'dev' ? { active: 'some string', name: 'some string', } : {} How can I assign a type/interface to myObject ?…
Afsanefda
  • 2,141
  • 1
  • 26
  • 50
0
votes
1 answer

Unable to resolve [signature-verification-failure] and [incompatible-call] errors in Flow

I have a file Foo.js: // @flow export const Foo = (( x: number, y: number ) => { class Foo { bar1: number; bar2: number; constructor(x: number, y: number) { this.bar1 = x; …
jlewkovich
  • 2,627
  • 2
  • 34
  • 45
0
votes
1 answer

How do I add a function to the prototype chain on a primitive type in Flow?

Case in point: Adding a new split function to the string type. Can't find anything in the docs. I'm using vanilla JS and would like to declare a new type string which adds my new split function. Something like type mystring = string + function ....…
Olle Härstedt
  • 3,348
  • 1
  • 18
  • 46
0
votes
0 answers

Flow error: Cannot call dispatch with object bound to action

Cannot call explicitConnect with object literal bound to connectOptions because ThunkAction [1] is incompatible with undefined [2] in the return value of property mapDispatchToProps.updatePreviewSelection. Can anyone help me my thunkAction is not…
0
votes
0 answers

Flow error: Cannot reference type `updatePreviewSelection` [1] from a value position

I am having an error in my yarn flow console. I am a bit confused about what it actually telling me to do? I am a bit confused about why my reference can not find value in the position. Cannot reference type updatePreviewSelection 1 from a value…
bombom
  • 85
  • 10
0
votes
1 answer

Is it possible to dynamically set flow type of a function in an object to the type of one of its properties?

Consider a config of type: type Config = { props: any, isEnabled?: (args: { custom: string, props: any }) => boolean, }; I want to use this Config type such that any changes to it will apply to all its subtypes. I am able to do this as: type…
0
votes
1 answer

Can I use JSDoc annotations with Flow to enforce typing on a per-file basis?

What I want is to Flow to understand JSDoc syntax, without any transpiling. Example: // @flow /** * @param {string} str * @return {string} */ function foo(str) { return str + str; } foo(1); // Flow shows error And then using flow…
Olle Härstedt
  • 3,348
  • 1
  • 18
  • 46
1 2 3
99
100