question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do Flow types actually work?

See original GitHub issue

I’ve been struggling getting Flow to type check my code, which heavily uses Preact, and as I was trying to introduce more types, I started running into more and more issues where I wasn’t able to type my components and HOCs. I dug a bit deeper into the subject and I believe that the types Preact package provides are simply wrong and aren’t used as expected.

I’ve set up a little example which shows what I mean: https://github.com/smirnowld/flow-preact-issues It’s a simple component rendering another component that requires props. If I render that component without passing any props, Flow doesn’t detect any problems. At the same time, similar React example correctly errors out as Flow is able to resolve component types whereas I think Preact types are defaulted to any (essentially skipping type checking altogether).

I’ve looked at TypeScript definitions for Preact and they seem to be much better than Flow libdefs. Has anyone had much luck getting their Preact components to be correctly typed and checked?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ngyikpcommented, Oct 3, 2018

Seems like you’re hitting https://github.com/facebook/flow/issues/5469 and https://github.com/facebook/flow/issues/4657

Workarounds:

  1. Remove @jsx h from your scripts, put it on a Babel config instead:
presets: [
	[
		'@babel/preset-react',
		{
			pragma: 'h',
		},
	],
	'@babel/preset-flow',
],
  1. Create a new folder called flow-typed next to .flowconfig, and create a new file called react.js:
// @flow

// https://github.com/facebook/flow/issues/4657#issuecomment-323602289
declare var React: $Exports<'react'>;
1reaction
marvinhagemeistercommented, Aug 12, 2019

We removed support for flowtypes in master as they were somewhat broken and we don’t have experience with flow in the core team. On top of that we didn’t receive any PRs to fix those, so we made the decision to remove them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flow under the hood: how does it really work - Kt. Academy
In this article, I would like to give you a deep understanding of how Flow works. We will start with a very simple...
Read more >
Power Automate Flow Types And When To Use Them
In this blog, we go through the similarities and differences between the Power Automate flow types, and we determine when to use each...
Read more >
Flow: How To Use Different Type of Flows
Explanation of different flow types, their launch method, their specialty, and their use cases. - Salesforce Flowsome!
Read more >
Types-First | Flow
It improves error reliability. Inferred types often become complicated, and may lead to errors being reported in downstream files, far away from their...
Read more >
Power Automate Flow Types Explained - YouTube
PowerAutomateIn this introductory video I explain all of the different types of flows you can create in Power Automate and where you might ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found