Skip to content

Please include index.js.flow in the npm package #51885

@buschco

Description

@buschco

Description

There are still people using react-native with flow and at some point the types went to any in my project. Today I figured out adding the index.js.flow file (https://github.com/facebook/react-native/blob/v0.79.3/packages/react-native/index.js.flow) manually to the react-native node module the typings worked again.

Am I missing something?

Steps to reproduce

  1. Setup a react-native project with flow (or clone https://github.com/buschco/react-native-flow + cd ReproducerApp && npm i)

  2. import {Alert} from 'react-native' -> Alert has type any

  3. add index.js.flow File (https://github.com/facebook/react-native/blob/v0.79.3/packages/react-native/index.js.flow) to node_modules/react-native/index.js.flow -> Alert no longer any

React Native Version

0.79.3

Affected Platforms

Build - MacOS

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: macOS 15.5
  CPU: (14) arm64 Apple M4 Pro
  Memory: 412.52 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.5
    path: ~/.nvm/versions/node/v18.20.5/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v18.20.5/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v18.20.5/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/colin/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12550806
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.3
    path: /Users/colin/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 3.3.6
    path: /Users/colin/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.3
    wanted: 0.79.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

yarn flow type-at-pos alert.js 2 10
yarn run v1.22.22
$ /<...>/node_modules/.bin/flow type-at-pos test.js 2 10
any (implicit)

MANDATORY Reproducer

https://github.com/react-native-community/reproducer-react-native (the reproducer is not typed in flow)

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FlowNeeds: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions