Skip to content

Commit 7afcdcd

Browse files
committed
Fix issue in JSX autocomplete when the component is declared external.
Fixes #307.
1 parent fd11bf4 commit 7afcdcd

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## master
2-
2+
- Fix issue in JSX autocomplete when the component is declared external.
33
- Fix jump-to-definition for uncurried calls.
44
- Fix issue where values for autocomplete were pulled from implementations instead of interfaces.
55

analysis/src/NewCompletions.ml

+13
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,19 @@ let processCompletable ~findItems ~full ~package ~rawOpens
914914
_,
915915
_ ) ->
916916
getFields tObj
917+
| Tconstr
918+
( path,
919+
[
920+
{
921+
desc =
922+
( Tconstr (* Js.t *) (_, [{desc = Tobject (tObj, _)}], _)
923+
| Tobject (tObj, _) );
924+
};
925+
_;
926+
],
927+
_ )
928+
when Path.name path = "React.componentLike" ->
929+
getFields tObj
917930
| _ -> []
918931
in
919932
typ |> getLabels

analysis/tests/src/Jsx.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ module Ext = {
4949
external make: (~align: string=?) => React.element = "Typography"
5050
}
5151

52-
let extMake = Ext.make
52+
let _extMake = Ext.make
5353

5454
//^com <Ext al

analysis/tests/src/expected/Jsx.res.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,17 @@ Definition tests/src/Jsx.res 43:11
182182
{"uri": "Component.res", "range": {"start": {"line": 1, "character": 4}, "end": {"line": 1, "character": 8}}}
183183

184184
Complete tests/src/Jsx.res 52:2
185-
[]
185+
[{
186+
"label": "align",
187+
"kind": 4,
188+
"tags": [],
189+
"detail": "option<string>",
190+
"documentation": null
191+
}, {
192+
"label": "key",
193+
"kind": 4,
194+
"tags": [],
195+
"detail": "string",
196+
"documentation": null
197+
}]
186198

0 commit comments

Comments
 (0)