Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this support proptypes? #3

Open
aikeru opened this issue Sep 8, 2016 · 1 comment
Open

Does this support proptypes? #3

aikeru opened this issue Sep 8, 2016 · 1 comment

Comments

@aikeru
Copy link

aikeru commented Sep 8, 2016

I tried a simple example and it didn't seem to work.
It would be really nice if this had basic support for completion of proptype names...

@jacksonrayhamilton
Copy link
Owner

JSX is actually separate from React; JSX is a language extension to ECMAScript, whereas React is a UI API. JSX provides a JSXAttribute node, which is commonly compiled to one "prop" in a React API call.

This distinction dictates how concerns should be separated between a plugin providing JSX support and one providing React support. This plugin would need to make it possible to obtain completions for a JSXAttribute name, and possibly a JSXAttribute value. A plugin like tern-react would then provide the list of PropTypes, and maybe potential values and types, based on the React API's offerings.

(I should note that, ideally, tern-react would only provide React-related functionality. But actually, right now, tern-react also offers JSX support. I've talked with the author about separating the concerns of our plugins, but it doesn't seem like he's gotten around to it yet.)

This issue might be effectively gated by lack of loose parsing support, see #1. In the case for PropType names, because JSX supports "boolean attributes," we could offer completion in the following case, because the syntax tree is still valid:

Desired completion is "babyBoo".
Text is <Foo b></Foo>, cursor is after "b".

But in the following cases, the syntax tree is invalid, so completion is less likely to work:

Text is <Foo b=></Foo>, cursor is after "b". (We want to complete the JSXAttribute name.)
Text is <Foo babyBoo=></Foo>, cursor is after "=". (We want to complete the JSXAttribute value.)

Thankfully, the first case seems like the most important one, so we could probably get by well without loose parsing.

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

No branches or pull requests

2 participants