Skip to content

Commit

Permalink
styles types: Set type signature of default export in a way Flow can …
Browse files Browse the repository at this point in the history
…track.

Following Greg's recommendation at
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Flow.20types-first/near/1237936.

This will help move us along toward Flow's new "Types-First" mode;
switching entirely is zulip#4907.
  • Loading branch information
chrisbobbe committed Aug 4, 2021
1 parent 3e98579 commit 7add899
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,21 @@ export function createStyleSheet<+S: ____Styles_Internal>(obj: S): S {
return Object.freeze(obj);
}

export default createStyleSheet({
// By `Object.freeze`, we really mean `createStyleSheet`. But that's too
// much for Flow in types-first mode, and it can't tell the exported
// object's type on a quick skim. But apparently it has no problem if we
// just do an `Object.freeze` directly. So, do that, and get
// `createStyleSheet` to type-check the contents of `styles` separately, in
// a trivial bit of code below.
const styles = Object.freeze({
...composeBoxStyles,
...miscStyles,
...navStyles,
...utilityStyles,
});

// Check the contents of `styles` (see comment above).
// eslint-disable-next-line no-unused-expressions
() => createStyleSheet(styles);

export default styles;

0 comments on commit 7add899

Please sign in to comment.