Skip to content

Fix package .js.flow type discovery#307

Open
landeqiming666 wants to merge 1 commit into
gajus:masterfrom
landeqiming666:fix-js-flow-package-resolution
Open

Fix package .js.flow type discovery#307
landeqiming666 wants to merge 1 commit into
gajus:masterfrom
landeqiming666:fix-js-flow-package-resolution

Conversation

@landeqiming666

@landeqiming666 landeqiming666 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • Prefer .js.flow files over stripped JavaScript siblings when discovering Flow definition files.
  • Register package-root node_modules/<package>/index.js.flow exports as an implicit module when the file does not already declare one.
  • Add an end-to-end CLI regression for a package that ships index.js plus index.js.flow.

Why

Fixes #27. Flow resolves index.js.flow before index.js for packages that ship copied Flow sources, but the flow-runtime definition output path did not model that package entrypoint. This meant imported package types could be missing even though Flow itself could see them.

This differs from #288, which only discovers .js.flow files and tests an already explicit declare module fixture. The new regression creates a temporary package with stripped JS plus typed .js.flow, then verifies import type {ExternalUser} from "fixture-package" emits a t.module("fixture-package", ...) definition. It also differs from #297, which focuses on module.name_mapper.extension remapping rather than package .js.flow entrypoint resolution.

Validation

  • GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=url.https://github.com/.insteadOf GIT_CONFIG_VALUE_0=git://github.com/ npx yarn@1 install --frozen-lockfile --ignore-engines --ignore-scripts
  • npx yarn@1 workspace flow-runtime build-cjs
  • npx yarn@1 workspace flow-config-parser build
  • npx yarn@1 workspace babel-plugin-flow-runtime build
  • npx yarn@1 workspace flow-runtime-cli test -- src/__tests__/jsFlowPackageDefinitions.test.js
  • npx yarn@1 workspace flow-runtime-cli test -- src/__tests__/generateDefinitions.test.js
  • npx yarn@1 workspace flow-runtime-cli test
  • npx yarn@1 workspace flow-runtime-cli build
  • git diff --check

Note: a full install without --ignore-scripts is blocked locally by the old node-sass / node-gyp@3.8.0 toolchain requiring python / python2 on Node v25.8.1. The package-level CLI tests and build above pass after building the required workspaces.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@landeqiming666

Copy link
Copy Markdown
Author

Hi, a brief follow-up on this PR. It remains clean and mergeable. The focused tests cover package-root node_modules//index.js.flow discovery and implicit module registration. Happy to adjust the resolution behavior or fixtures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Types not resolving to .js.flow files

1 participant