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

Flow error when passing props to function

I have defined the following flow types: /* @flow */ type PropsA = {| name: string, lastName: string, |}; type PropsB = {| email: string, |}; type PropsC = {| text: string, phone: string, address: string, |}; type ComponentAType…
0
votes
1 answer

How to correctly type an Apollo Client instance in Flow?

I'm unsure what the correct type of a new ApolloClient is and I can't use any. Would it be best to create an interface for the ApolloClient instance? If so, what would the interface look like since there are so many different options? This is what…
Noob
  • 82
  • 9
0
votes
1 answer

flow.js createSlice access generic key

Trying to write a declaration for redux toolkit's createSlice. Having trouble creating a declaration that takes in an object that reads one of it's own keys with a function that returns one of the objects keys. Have tried the following which gives…
LittleBro
  • 41
  • 5
0
votes
1 answer

Pass flow type to react component

I have a component that uses another component from an external project. How I can generate flow type in the external component without duplicate types? For example: import {ExternalComponent} from '@npm-component/another-component'; type…
Liudmyla
  • 1
  • 2
0
votes
1 answer

How to correctly type render props in Flow?

I can't figure out how to correctly type a Wrapper and Counter component when using render props. I've tried the following but it just leads to more errors: App.js // @flow const App = (): React.Node => { return (
Noob
  • 82
  • 9
0
votes
1 answer

wrap children for react component which has children restricted to certain types

I have a component that I restricted to have certain types of children using flow types. However, now I have several situations where it is convenient to wrap those components in other component that just returns one of the valid components but with…
Danielo515
  • 2,933
  • 2
  • 19
  • 43
0
votes
1 answer

How to get a more specific type from "object type" in flow?

Well consider the following code: class base { field: T; } type SpecificTy = {| val: number, field: string, |} class subclass extends base {} This gives the following error: `T` [1] is…
paul23
  • 7,226
  • 9
  • 44
  • 108
0
votes
1 answer

Flow type refine mixed to function

I'm using koa which has middleware props typed as mixed, so I'm trying to do something along the lines of the following below but I'm getting an error that Cannot call `ctx.render` because mixed [1] is not a…
Brianzchen
  • 629
  • 1
  • 15
0
votes
1 answer

Typing a function with an interface of type in flowjs?

I have had quite a few look at the flow documentation, with some question still in mind. I have write a constructor named Track ;with my best attempt to type annotate it still not fully understanding it. Here is the code: javascript //@flow "use…
0
votes
1 answer

Property nullity check doesn't work on iteration

In the code below, the ab.bv check doesn't work to iterate over ab.bv. It works, however, to access elements of ab.bv. Has the if (ab.bv) check not checked for nullity of ab.bv? type B = {| bv: ?B[], |} const c: B => void = n => {} let ab: B…
Pedro Sobota
  • 1,100
  • 1
  • 9
  • 14
0
votes
1 answer

Testing type of union variable without verifying properties

I'm trying to check for the type of the value of a variable of union type. /* @flow */ type A = { a: number, b: number } type B = { c: string } const fun1: (A | B) => void = (x) => { if (x.a) { x.a x.b // Doesn't work } if…
Pedro Sobota
  • 1,100
  • 1
  • 9
  • 14
0
votes
0 answers

Flow server undesired restarts

Running yarn flow in iTerm2 (macOS 11, zsh) starts the server up normally. Once it finishes the initial check, running yarn flow again is lightning fast, as expected. However, if I then kickoff the githook in our codebase which simply runs yarn -s…
0
votes
1 answer

signature-verification-failure in Interface on Arrow function in Flow

I recently updated a project using Flow to version 0.138.0. After the update, it's the first time I'm stumbling upon similar errors like this: Cannot build a typed interface for this module. You should annotate the exports of this module with…
Alacho
  • 21
  • 6
0
votes
1 answer

Can ActionCreators and Actions be mixed with Redux?

My experience is mostly with React Hooks & Context, where Actions & Reducers are defined. The Actions are then imported into a React component and called via a Dispatch function. On a new project, I must use React Hooks & Redux. Here I'm using…
0
votes
1 answer

Use react "runtime": "automatic" with flow

{ "presets": [ "@babel/preset-env", ["@babel/preset-react", { "runtime": "automatic" }], "@babel/preset-flow" ] } Above you can see my .bablerc file , I try to setup oportunity create components…
Andrey Radkevich
  • 1,127
  • 1
  • 9
  • 23
1 2 3
99
100