Repository navigation
Label dictionary keys in @stylexjs/stylex Flow types - #2017
Open
SamChou19815 wants to merge 1 commit into
Open
SamChou19815 wants to merge 1 commit into
SamChou19815 wants to merge 1 commit into
Conversation
## 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
|
@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. |
There was a problem hiding this comment.
🟢 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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 changed / motivation ?
Flow's
experimental.require_dictionary_key_labeloption requires every dictionary key to be labeled, as TypeScript does:This labels the 44 unlabeled keys in
@stylexjs/stylex's Flow types (StyleXTypes.js,StyleXUtils.jsandstylex.js) askey, the labelStyleXTypes.d.tsalready 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-checkwith Flow 0.338.0, using a copy of.flowconfigupdated for 0.338 with the option turned on: the 44missing-dictionary-key-labelerrors 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 inyarn.lock) passes on the changed files.Pre-flight checklist
Contribution Guidelines