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

Fix issue in JSX autocomplete when the component is declared external. #308

Merged
merged 2 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## master

- Fix issue in JSX autocomplete when the component is declared external.
- Fix jump-to-definition for uncurried calls.
- Fix issue where values for autocomplete were pulled from implementations instead of interfaces.

Expand Down
13 changes: 13 additions & 0 deletions analysis/src/NewCompletions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,19 @@ let processCompletable ~findItems ~full ~package ~rawOpens
_,
_ ) ->
getFields tObj
| Tconstr
( path,
[
{
desc =
( Tconstr (* Js.t *) (_, [{desc = Tobject (tObj, _)}], _)
| Tobject (tObj, _) );
};
_;
],
_ )
when Path.name path = "React.componentLike" ->
getFields tObj
| _ -> []
in
typ |> getLabels
Expand Down
11 changes: 10 additions & 1 deletion analysis/tests/src/Jsx.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,13 @@ let y = 44
//^com <M prop=%bs.raw("1") k

let _ = <Component />
// ^def
// ^def

module Ext = {
@react.component @module("@material-ui/core")
external make: (~align: string=?) => React.element = "Typography"
}

let _extMake = Ext.make

//^com <Ext al
15 changes: 15 additions & 0 deletions analysis/tests/src/expected/Jsx.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,18 @@ Complete tests/src/Jsx.res 40:2
Definition tests/src/Jsx.res 43:11
{"uri": "Component.res", "range": {"start": {"line": 1, "character": 4}, "end": {"line": 1, "character": 8}}}

Complete tests/src/Jsx.res 52:2
[{
"label": "align",
"kind": 4,
"tags": [],
"detail": "option<string>",
"documentation": null
}, {
"label": "key",
"kind": 4,
"tags": [],
"detail": "string",
"documentation": null
}]