Skip to content

Conversation

@jpdriver
Copy link
Contributor

@jpdriver jpdriver commented Mar 8, 2020

The Issue

When code like the below is parsed into an AST, an Identifier (like active here) is treated as though it were a string (vs. a bool) by our current type checks.

const active = true;

const Component = () => (
  <TouchableOpacity accessibilityState={{ selected: active }} />
);

Investigation

After asking around some of the other Formidable devs, we collectively concluded that almost all type-checking should be delegated to either Flow or TypeScript.

However, there are still cases where we can reliably detect incorrect usage (even without a static type checker being used).

Conclusion

This PR attempts to provide a balanced approach, whereby the library still functions the same way in all cases except for when an Identifier is encountered.

In these cases, this library will allow any value as valid -- but separate static type checkers should report any misuse.

@jpdriver jpdriver merged commit 8afae35 into master Mar 8, 2020
@jpdriver jpdriver deleted the jp-ignore-Identifiers branch March 8, 2020 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

accessibilityState doesn't recognise boolean value in variable

2 participants