-
Notifications
You must be signed in to change notification settings - Fork 12.8k
JSX and Salsa: Intellisense for ReactComponents does not work #7000
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
Comments
Did you install the corresponding .d.ts files?
|
Does it work in this simple hello world example: var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
}
});
ReactDOM.render(
<CommentBox />,
document.getElementById('content')
); |
From @nwehrle on February 10, 2016 12:13 You are right, I forgot to install the .d.ts file for the screenshot (but I tried before). It does not offer the React-Component as the best option in your minimal example: |
I see in your screenshot that you are using ES7 bind operator which is not yet supported by TypeScript which powers Salsa. As a consequence you get syntax errors and red squiggles which can make Intellisense fail. In the second screenshot you are correct that the React-Component could be proposed first, but the React-Component is proposed so Intellisense is working but the sorting isn't optimal. Moving over to TypeScript as an FYI. |
I've discussed this internally before with @RyanCavanaugh . The challenge is with things like stateless functional components, any function really could be a valid React element, not just those types which derive from React classes/components. I assume the identifier you require is in the list and starts filtering down when you type? Arguably we could do a better job of filtering out things like interface names from the list, but that is a general issue with the global identifier list, and orthogonal to React. Assigning to Ryan to see if he has any further input, else I believe this is by design. |
|
I'm new to TypeScript so please excuse me if this is silly. I do get IntelliSense for React via typings if I try accessing typings statically or inside the Is this rather an issue with the |
There are two issues going on here:
|
This issue is tracking item 2 above, i.e. showing appropriate error message. |
@mhegazy As I mentioned in my last comment, auto-complete on For this to work, though, like I posted over on microsoft/vscode#2898 (comment) I have had to change the |
This sounds like the same issue as #7076 . I'm looking into that. |
I have a fix out for the ES6-style imports, and confirmed it works in this scenario. See #7249 (comment) |
I'm running into a similar issue, but I'm not sure if it is the same as what has been discussed here. Most of the comments here appear to be with intellisense in a code block. My issue is that my react components are not showing up in the intellisense only for JSX blocks. Once I create the JSX element, the intellisense works for the attributes on the JSX element, just not for the initial creation of the element. Hopefully these screenshots provide some insight into what I'm speaking of. |
@patsissons what version of VSCode / TypeScript are you using? |
this issue is fixed in #7326. so should be available in the nightly builds (see https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Nightly%20Builds.md#visual-studio-code) or in the next release. |
I believe all the issues discussed above are either fixed or explained, with the exception of @mhegazy 's comment that the error message should be improved when trying to use a default import that doesn't exist (and without @mhegazy, did you have any thoughts on how this should behave? This is for JavaScript, so it may well be that you have no definitions for the imported module, and that is not an error. Seems that if: a) There is a definition we can use for the imported module, and b) That definition does not contain a Even then, this is a little weird, as this is still a 'type system' error on a JavaScript file, and users may not be aware of the "synthetic default" and how different module systems interact with it. |
From @nwehrle on February 10, 2016 11:52
Salsa is enabled:

But intellisense fails to offer proper React Elements:
System:
OSX 10.11.2
vscode 0.10.8
db71ac615ddf9f33b133ff2536f5d33a77d4774e
jsconfig.json:
User settings:
Partial eslintrc:
Copied from original issue: microsoft/vscode#2886
The text was updated successfully, but these errors were encountered: