Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

Commit

Permalink
Flow: use implicit exact object types
Browse files Browse the repository at this point in the history
Flow standard is now to use `{ }` for strict objects and `{ key: value, ... }` for open objects, see: facebook/relay@6fa0b0d and facebook/react-native@00cfb0f

This change should be without any problems as longs as users of our NPM libraries are using Flow with `exact_by_default=true` (which is now pretty standard I'd say).

Here is how object types behave before this change:

```
type A = { x: number }; // already "exact" type but disallowed because it would be confusing to mix different syntaxes
type B = { x: number, ... }; // this is inexact
type C = {| x: number |}; // this is explicitly exact and the only allowed way how to describe type "exactness"
```

Here is how object types behave _after_ this change:

```
type A = { x: number }; // this is the only allowed syntax for "exact" type
type B = { x: number, ... }; // this is still inexact
type C = {| x: number |}; // this is also exact but no longer allowed (so it's not confusing)
```

Some related (non-blocking) issues:

- gajus/eslint-plugin-flowtype#467
- facebook/flow#8612

adeira-source-id: 5f0c905ae627f670804581f78c1b570f3f71a1e6
  • Loading branch information
mrtnzlml authored and adeira-github-bot committed Jun 26, 2021
1 parent 2034035 commit f9d57f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sxTailwind.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import levenshtein from 'fast-levenshtein';

export function suggestUtility(className: string, styles: {| +[string]: any |}): string {
export function suggestUtility(className: string, styles: { +[string]: any }): string {
return Object.keys(styles).sort((first, second) => {
const firstScore = levenshtein.get(className, first);
const secondScore = levenshtein.get(className, second);
Expand Down
12 changes: 6 additions & 6 deletions src/tailwindToSx.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import purgeUnusedStyles from 'tailwindcss/lib/lib/purgeUnusedStyles';
import processPlugins from 'tailwindcss/lib/util/processPlugins';
import corePlugins from 'tailwindcss/lib/corePlugins';

type SxTailwindDefinitions = {|
+keyframes: {| +[string]: any |},
+styles: {| +[string]: any |},
|};
type SxTailwindDefinitions = {
+keyframes: { +[string]: any },
+styles: { +[string]: any },
};

export function generateTailwind(config: {| +[string]: any |}): Promise<SxTailwindDefinitions> {
export function generateTailwind(config: { +[string]: any }): Promise<SxTailwindDefinitions> {
return convert(
` @tailwind base;
@tailwind components;
Expand All @@ -31,7 +31,7 @@ export function generateTailwind(config: {| +[string]: any |}): Promise<SxTailwi

export default async function convert(
css: string,
tailwindConfig: {| +[string]: any |},
tailwindConfig: { +[string]: any },
): Promise<SxTailwindDefinitions> {
const processor = getTailwindProcessor(tailwindConfig);
const postCss = await processor.process(css, { from: '' });
Expand Down

0 comments on commit f9d57f0

Please sign in to comment.