Skip to content

Only use .flow.js extensions when there is an accompanying entry file#1546

Closed
robhogan wants to merge 1 commit into
mainfrom
pr1545
Closed

Only use .flow.js extensions when there is an accompanying entry file#1546
robhogan wants to merge 1 commit into
mainfrom
pr1545

Conversation

@robhogan

@robhogan robhogan commented Aug 4, 2025

Copy link
Copy Markdown
Contributor

Currently, we have a smattering of *.flow.js files in Metro. These mean either of two things:

  1. Modules that only export Flow types
  2. Modules that are written in Flow, to distinguish them from a colocated plain JS file.

Type 1) doesn't really have any significance and isn't enforced - we still build and publish (usually empty) foo.flow.js files and even accompanying foo.flow.js.flow files, and there's nothing to stop them containing runtime code (indeed, with enums, they do).

The renames all files of type 1) to drop the .flow.

This is a prerequisite for auto-generating TS types for Metro - by establishing and enforcing a convention that foo.js and foo.flow.js are a Babel-registering entry point and an implementation file respectively, we can teach the API generator that foo.flow.js should generate foo.d.ts, and foo.js should be ignored.

Changelog: Internal

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 4, 2025
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@robhogan has imported this pull request. If you are a Meta employee, you can view this in D79566838.

…ile (#1546)

Summary:
Currently, we have a smattering of `*.flow.js` files in Metro. These mean either of two things:
 1) Modules that only export Flow types
 2) Modules that are written in Flow, to distinguish them from a colocated plain JS file.

Type 1) doesn't really have any significance and isn't enforced - we still build and publish (usually empty) `foo.flow.js` files and even accompanying `foo.flow.js.flow` files, and there's nothing to stop them containing runtime code (indeed, with enums, they do).

The renames all files of type 1) to drop the `.flow`.

This is a prerequisite for auto-generating TS types for Metro - by establishing and enforcing a convention that `foo.js` and `foo.flow.js` are a Babel-registering entry point and an implementation file respectively, we can teach the API generator that `foo.flow.js` should generate `foo.d.ts`, and `foo.js` should be ignored.

Changelog: Internal

Pull Request resolved: #1546

Test Plan: - Flow/CI

Differential Revision: D79566838

Pulled By: robhogan
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D79566838

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@robhogan merged this pull request in c575c4e.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants