Skip to content

Label dictionary keys in @stylexjs/stylex Flow types - #2017

Open
SamChou19815 wants to merge 1 commit into
meta:mainfrom
SamChou19815:flow-label-dictionary-keys
Open

SamChou19815 wants to merge 1 commit into
meta:mainfrom
SamChou19815:flow-label-dictionary-keys

Conversation

@SamChou19815

Copy link
Copy Markdown
Contributor

What changed / motivation ?

Flow's experimental.require_dictionary_key_label option requires every dictionary key to be labeled, as TypeScript does:

type T = { [string]: number }; // error
type T = { [key: string]: number }; // ok

This labels the 44 unlabeled keys in @stylexjs/stylex's Flow types (StyleXTypes.js, StyleXUtils.js and stylex.js) as key, the label StyleXTypes.d.ts already uses. Labels don't affect type checking. Prettier rewrapped the lines that grew past the print width.

Meta's internal copy of these files is turning the option on, so the labels need to land here too, or the next upgrade drops them.

Linked PR/Issues

None.

Additional Context

  • flow full-check with Flow 0.338.0, using a copy of .flowconfig updated for 0.338 with the option turned on: the 44 missing-dictionary-key-label errors in these three files are gone, and no other errors change.
  • prettier --check (3.5.3 with prettier-plugin-hermes-parser 0.36.1, the versions in yarn.lock) passes on the changed files.

Pre-flight checklist

## What changed / motivation ?

Flow's `experimental.require_dictionary_key_label` option requires every dictionary key to be labeled, as TypeScript does:

```js
type T = { [string]: number }; // error
type T = { [key: string]: number }; // ok
```

This labels the 44 unlabeled keys in `@stylexjs/stylex`'s Flow types (`StyleXTypes.js`, `StyleXUtils.js` and `stylex.js`) as `key`, the label `StyleXTypes.d.ts` already uses. Labels don't affect type checking. Prettier rewrapped the lines that grew past the print width.

Meta's internal copy of these files is turning the option on, so the labels need to land here too, or the next upgrade drops them.

## Linked PR/Issues

None.

## Additional Context

- `flow full-check` with Flow 0.338.0, using a copy of `.flowconfig` updated for 0.338 with the option turned on: the 44 `missing-dictionary-key-label` errors in these three files are gone, and no other errors change.
- `prettier --check` (3.5.3 with prettier-plugin-hermes-parser 0.36.1, the versions in `yarn.lock`) passes on the changed files.

## Pre-flight checklist

- [x] I have read the contributing guidelines
      [Contribution Guidelines](https://github.com/facebook/stylex/blob/main/.github/CONTRIBUTING.md)
- [x] Performed a self-review of my code
Copilot AI balanced review requested due to automatic review settings November 7, 2026 17:18
@vercel

vercel Bot commented Nov 7, 2026

Copy link
Copy Markdown

@SamChou19815 is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@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 Nov 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The Flow dictionary-key labeling changes have no active review issues.

No open issues 🎉

What changed in this PR

Updates @stylexjs/stylex Flow types to support experimental.require_dictionary_key_label, keeping the public source compatible with the stricter internal configuration without changing type-checking semantics or runtime behavior.

Changes:

  • Labels 44 dictionary keys as key, matching the existing TypeScript convention.
  • Rewraps affected type declarations to preserve formatting.
File Description
packages/​@stylexjs/​stylex/​src/​types/​StyleXUtils.js Labels the dictionary key in ValueWithDefault.
packages/​@stylexjs/​stylex/​src/​types/​StyleXTypes.js Labels dictionary keys throughout shared Flow types and constraints.
packages/​@stylexjs/​stylex/​src/​stylex.js Labels dictionary keys in API annotations and the IStyleX interface.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants