-
Notifications
You must be signed in to change notification settings - Fork 12.8k
LanguageServices.getDocumentHighlights does not find references within JSX #4175
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
I assume FindAllRefs and GoToDefinition also doesn't work. Will need to test this. |
Note: I edited In trying to debug this, I found that |
presume this also happens for variable references from within JSX. |
The updated sample still works fine in Sublime Text. The posted code using the LS directly gets |
@RyanCavanaugh Is there any trick to finding references in a .tsx file in Sublime? For some reason I can't get it to work. Also, in your above screenshot, the first onChange shouldn't be marked as a reference, should it? |
You'll need to manually set the Syntax for .tsx files to TypeScript. Then all the regular TS features should work. The Sublime plugin finds references the same way the VS plugin does -- using the compiler language service. |
Maybe we're using the wrong feature in the language service to get references? Is I think @jkillian is right -- the |
This is correct, and the behavior is also correct. In the "Find References" pane, it's string-based underlining. Here, I did "Find References" on the attribute name and found two references (the usage in the element, and the definition on the .d.ts file). It reports two references even though there are four things underlined. Conversely, if I Find References on the class method, it reports the correct three references (modified the code slightly from above to show this more clearly). Again, the underlining is string-based and doesn't reflect the actual references. |
The code in the OP doesn't work because @RyanCavanaugh Care to see how this code does in Sublime? Specifically import * as React from "react";
export class FooComponent extends React.Component<{}, {}}> {
public render() {
return (
<div onClick={() => this.onClick()}>
{this.state.bar.map((s) => <span>{s}</span>)}
<BazComponent someProp={123} anotherProp={456} />
</div>
);
}
private onClick() {
console.info("click");
}
}
export function buildFooComponent(): JSX.Element {
let bar: string = "test";
return <FooComponent fooProp={ bar } />;
} |
#4406 should fix a broad class of issues here. Anyone care to try the latest |
@RyanCavanaugh this appears to have fixed the bug mentioned in my previous comment, thanks! |
Using
v1.6.0-dev.20150805
.For the following code,
LanguageServices.getDocumentHighlights
reports only 1 highlight span foronChange
, where it should really report 2:test.tsx
You can reproduce this error with the sample code from #3688 (copied below):
The text was updated successfully, but these errors were encountered: