You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installed and configured Flow, a static type checker for JavaScript, in the NodeBB project. Flow enables gradual type checking by adding type annotations to individual files via the // @flow pragma.
Why?
NodeBB currently has no static type checking — only ESLint for code style/quality. Flow catches type-related bugs (wrong argument types, null dereferences, missing properties) at development time before they reach production. It integrates into the existing JavaScript codebase without requiring a migration to TypeScript.
How?
Added configuration files and an install script for Flow and its Babel integration:
No runtime overhead — types are stripped by Babel before execution
Works with existing ESLint — runs separately, no config conflicts
Cons
False positives at untyped boundaries — Flow-checked files importing from untyped files may produce false positives, requiring // $FlowFixMe suppressions until more of the codebase is annotated.
Manual setup — since package.json is gitignored, teammates must run install-flow.sh after cloning
Babel build step — requires npm run build to strip types before Node.js can run annotated files
Overall Assessment
Flow is a good fit for gradual type safety in an existing JavaScript project like NodeBB. It doesn't require rewriting files or changing the build pipeline — you opt in per file. The main tradeoff is ecosystem support: TypeScript has broader community adoption and tooling. However, Flow's opt-in model means it can be added to a large codebase like NodeBB without disrupting existing workflows. The GLIBC version pinning is a minor inconvenience specific to our devcontainer environment.
Anything Else?
After pulling branch, run the install script:
bash install-flow.sh
This installs all required NPM packages. Then you can use:
npx flow status # Run type checker
npm run build # Strip Flow types via Babel (src/ → lib/)
What is the name and high-level description of what the tool does? Flow is a static type checker for JavaScript developed by Meta. It analyzes your code for type errors without running it — you add type annotations (e.g., function add(a: number, b: number): number) and Flow verifies that types are used correctly across your codebase. It uses a // @flow pragma so you can opt in file-by-file.
Is the tool used for static or dynamic analysis?
Static analysis. Flow analyzes source code at development time without executing it. Types are stripped out by Babel before the code runs in production.
What types of problems does this particular tool catch?
Type mismatches (passing a string where a number is expected)
Null/undefined dereferences (accessing a property on a potentially null value)
Missing object properties
Incorrect function argument counts or types
Incompatible return types
Cross-file type contract violations
What types of customization are possible or necessary?
.flowconfig is required — configures which directories to check/ignore, module resolution, and strictness options. We configured it to only check src/ and ignore node_modules, vendor, test, etc. and could also check the directory containing our plugin code: nodebb-plugin-topic-type.
.babelrc is required — configures @babel/preset-flow so Babel can strip type annotations for Node.js to run the code.
flow-bin version had to be pinned to 0.241.0 due to GLIBC compatibility in our devcontainer.
Per-file opt-in via // @flow — you choose which files to type-check.
// $FlowFixMe comments can suppress specific errors where needed.
Over time, you can enable stricter lint rules in .flowconfig under [lints] (e.g., unclear-type=error to ban use of any).
How can/should this tool be integrated into a development process?
Run npx flow status during development or in CI alongside npm run lint and npm run test. Flow and ESLint serve different purposes (types vs style) so they run separately. Developers add // @flow to files they want checked and annotate functions/variables with types. Before shipping, npm run build strips the types via Babel. A combined check script like npm run lint && npx flow status could be added to CI.
Are there many false positives? False negatives? True positive reports about things you don't care about?
False positives: Low in fully annotated files. However, when a Flow-checked file imports from an untyped file, Flow treats those imports as any, which can cause false positives at the boundary. These require // $FlowFixMe suppressions until more files are annotated.
False negatives: Possible in files without // @flow — Flow skips them entirely. Also, imports typed as any from untyped files won't be checked, so bugs can slip through at those boundaries.
True positives you don't care about: Minimal. Since adoption is opt-in per file, you only see errors in files you chose to check. You won't get noise from legacy code you haven't modified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Installed and configured Flow, a static type checker for JavaScript, in the NodeBB project. Flow enables gradual type checking by adding type annotations to individual files via the
// @flowpragma.Why?
NodeBB currently has no static type checking — only ESLint for code style/quality. Flow catches type-related bugs (wrong argument types, null dereferences, missing properties) at development time before they reach production. It integrates into the existing JavaScript codebase without requiring a migration to TypeScript.
How?
Added configuration files and an install script for Flow and its Babel integration:
.flowconfig— Flow configuration targetingsrc/, ignoringnode_modules,vendor,build,lib,test,public.babelrc— Babel preset to strip Flow type annotations for Node.js runtimeinstall-flow.sh— Install script for people who clone the repository to use flow.Installation Evidence
See changed files in this PR's commits. Key NPM packages installed:
flow-bin@0.241.0— Flow binary (pinned for GLIBC 2.36 compatibility in devcontainers)@babel/cli,@babel/core,@babel/preset-flow— Babel toolchain to strip Flow typesbabel-plugin-syntax-hermes-parser— Hermes parser for BabelSince
package.jsonis gitignored in this repo,install-flow.shdocuments the exact packages and versions.Artifacts of Running the Tool
See attached screenshot showing:
npx flow version— confirms Flow 0.241.0 installednpx flow status— "No errors!"npm run build— Babel successfully compiles all source filesPros
// @flow, so no upfront cost to annotate the entire codebaseCons
// $FlowFixMesuppressions until more of the codebase is annotated.package.jsonis gitignored, teammates must runinstall-flow.shafter cloningnpm run buildto strip types before Node.js can run annotated filesOverall Assessment
Flow is a good fit for gradual type safety in an existing JavaScript project like NodeBB. It doesn't require rewriting files or changing the build pipeline — you opt in per file. The main tradeoff is ecosystem support: TypeScript has broader community adoption and tooling. However, Flow's opt-in model means it can be added to a large codebase like NodeBB without disrupting existing workflows. The GLIBC version pinning is a minor inconvenience specific to our devcontainer environment.
Anything Else?
After pulling branch, run the install script:
This installs all required NPM packages. Then you can use: