Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

flowtype

Cannot assign to ‘current’ because it is a read-only property

March 31, 2024 by Tarik

It’s simply a TypeScript error. Your syntax is problematic: const unblockRef = useRef<() => void | null>(null); This is interpreted as a function that returns either void or null. So, you need to make sure it’s a function or null: const unblockRef = useRef<(() => void) | null>(null);

Categories reactjs Tags flowtype, reactjs, typescript Leave a comment

What does flow {| brace pipe |} syntax do?

January 8, 2024 by Tarik

This is Flowtype’s Exact Object type syntax.

Categories syntax Tags flowtype, syntax Leave a comment

How to correct flow warning: destructuring (Missing annotation)

December 23, 2023 by Tarik

I would write this as type StationType = { code: String, label: String, } function StationDetail({ station } : {station : StationType}) => { const { code, label, } = station; It’s necessary to declare the type of the object parameter that the function accepts.

Categories javascript Tags flowtype, javascript, react-native, reactjs Leave a comment

Flow: Create a flow type by extending another type

December 3, 2023 by Tarik

What you’re looking for is the intersection type. According to the documentation: An intersection type requires a value to be all of the input types. Syntax: Intersection: < type 1 > & < type 2 > … & < type n > The intersection type is intended to extend an existing type and add additional … Read more

Categories javascript Tags casting, flowtype, javascript, type-conversion Leave a comment

flow type question mark before or after param?

November 29, 2023 by Tarik

Basically bar: ?string accepts a string, null or void: foo(“test”); foo(null); foo() While bar?: string Accepts only a string or void: foo(“test”); foo(); As passing null instead of a string is somewhat senseless, theres no real life difference between them.

Categories javascript Tags ecmascript-6, flowtype, javascript Leave a comment

How can Flow be forced to cast a value to another type?

September 17, 2023 by Tarik

Flow doesn’t do direct casting from one type to another, but you can do something like const bar: string = (foo: any); so you cast foo to an any, because any accepts any type of value as an input. Then because the any type also allows you to read all possible types from it, you … Read more

Categories casting Tags casting, flowtype Leave a comment

How to annotate a function with multiple possible call signatures in Flow?

August 10, 2023 by Tarik

The errors you are seeing are a combination of a bug in your code and a bug in Flow. Bug in your code Let’s start by fixing your bug. In the third else statement, you assign the wrong value to } else { name=”someone”; age = args[1]; // <– Should be index 0 } Changing … Read more

Categories javascript Tags flowtype, javascript Leave a comment

Flow (React Native) is giving me errors for using ‘this.state’

August 1, 2023 by Tarik

You need to define a type for the state property in order to use it. class ComponentA extends Component { state: { isExpanded: Boolean }; constructor(props) { super(props); this.state = { isExpanded: false }; } }

Categories reactjs Tags flowtype, react-native, reactjs Leave a comment

Flow (React Native) is giving me errors for using ‘this.state’

August 1, 2023 by Tarik

You need to define a type for the state property in order to use it. class ComponentA extends Component { state: { isExpanded: Boolean }; constructor(props) { super(props); this.state = { isExpanded: false }; } }

Categories reactjs Tags flowtype, react-native, reactjs Leave a comment

Flow type, What does the `+` symbol mean in front a property?

June 13, 2023 by Tarik

The + symbol in front of the property means the property is read-only Reference: https://flow.org/en/docs/types/interfaces/#toc-interface-property-variance-read-only-and-write-only

Categories javascript Tags flowtype, javascript Leave a comment
Older posts
Page1 Page2 Next →

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa