Photo by Aksonsat Uanthoeng from Pexels

What we’re building in 2020

Andrew Pardoe
Mar 9 · 4 min read

Our plan for 2020 covers three areas:

  • Improve the capabilities and responsiveness of our VS Code editing and browsing experience
  • Make our type system more simple, expressive, and correct
  • Reduce our peak memory usage while holding the line on recheck performance

VS Code editing and browsing

Flow provides a language server to provide rich editing and code browsing features such as in-editor diagnostics (type errors), autocomplete and “go to definition”. While our focus is on providing a best-in-class experience in VS Code, any editor that uses LSP can take advantage of Flow’s language server.

In 2020 we’ll focus on two kinds of investments in our editing and browsing experience. First, we’ll continue to improve the reliability and responsiveness of our IDE features. Second, we’ll add support for some top-requested IntelliSense features.

The Flow language server doesn’t always respond immediately because it needs to initialize when first starting up, and sometimes needs to restart after events like large rebases. Most language features require that the Flow server be running continuously while you edit code. Where possible, we’ll convert our edit and browse requests to make them possible to complete without requiring the server. We’ll also continue to reduce the situations where the Flow server needs to restart itself.

A second set of investments come from adding support for the top-requested IntelliSense features: parameter info, quick info, and quick fixes.

  • Parameter info includes signature help — the number and types of parameters expected — displayed as you type the function call. We’ll also show documentation about the parameter extracted from JSDoc comments in the code.
  • Quick info shows the declaration when you hover over an identifier in your code. Flow already shows function signatures. We’ll improve the formatting for quick info and add documentation comments similar to parameter info.
  • We’ve just added our first quick fix feature — a “Did You Mean?” that suggests corrections to your code as you type. For example, if you write foo.bar on an object foo that doesn’t have a field named bar but does have a field named baz, the quick fix will apply that suggestion. We're also investigating adding Flow error suppressions and automatic generation of static import statements.

Enhanced type system

We believe that a thoughtfully designed type system that is simple, expressive, and correct can provide a better experience for developers.

  • Simple: can developers predict how Flow would behave on their code?
  • Expressive: can developers do what they need to do without being blocked by Flow?
  • Correct: can developers rely on Flow to help them avoid common costly mistakes?

Here are some of the changes we’ll introduce this year to help us create a better type system for JavaScript.

  • Use of this in functions and methods often leads to unchecked code, because it can be implicitly typed as any. Using any is unsafe and prevents Flow from reporting errors. Implementing typing for this will allow Flow to check code that uses this.
  • Unsealed object types are used to model empty object literals and properties on functions. Unsealed objects allow new properties to be written at any time. They’re useful for scenarios like enabling object initialization across multiple statements. But Flow doesn’t check reads from unsealed objects with no matching writes. We’ll work on addressing this unsoundness, by carefully tracking common initialization patterns.
  • Many of Flow’s utility types, such as $ObjMap and $PropertyType, don't reflect the semantics of the corresponding runtime operations. We'll create first-class designs for those types.
  • Flow error suppressions are very coarse. Adding a $FlowFixMe above a line of code to suppress one kind of error actually suppresses all errors introduced by that code, potentially masking future errors. We're designing error codes that will allow you to suppress specific errors without hiding another error on the same line of code. And we'll move suppressions to the primary position of an error, preventing a suppression attached to a definition from hiding errors where that definition is used.
  • Generic types and functions currently have unpredictable behavior, with generic type parameters able to escape their scope and calls to generic functions able to accumulate new bounds far away from the call-site. We are designing new behavior for generics, including more reliable detection of errors in generic functions, a test to prevent escaped type parameters, and a check to ensure function calls are properly constrained.

Performance improvements

The Flow team delivered massive performance improvements last year, such as reducing our recheck times by 70%. We’ve heard overwhelming positive feedback from Facebook developers about our performance improvements. We aim to hold the line on performance, even as our JavaScript codebases grow. We’re also working to reduce the Flow’s memory usage in all situations.

In closing

In 2020, the Flow team will deliver a developer experience that is on par with industry-wide standards of reliability, feature completeness, and delight. As part of this developer experience, we’ll continue to improve on fundamentals: memory usage and reliability. We’ll deliver the most-requested IDE edit and browse features. And we’ll enhance Flow’s type system to make it easier for developers to write safe, correct code.

We’ll keep in touch with you on this blog, on GitHub, and in our Flowtype Discord channel.

Flow

The official publication for the Flow static type checker for JavaScript. Code faster. Code smarter. Code confidently.

Andrew Pardoe

Written by

Flow

Flow

The official publication for the Flow static type checker for JavaScript. Code faster. Code smarter. Code confidently.

More From Medium

More from Flow

More on Flow from Flow

More on Flow from Flow

Improvements to Flow in 2019

Andrew Pardoe
Feb 19 · 4 min read

200

More on Flow from Flow

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade