From cc777fb5991444dfab9d8ab4a9c5d7e5c75689e2 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 29 Oct 2021 18:30:52 +0200 Subject: [PATCH 1/2] Example failure of jsx completion when the component is declared external. See https://github.com/rescript-lang/rescript-vscode/issues/307 --- analysis/tests/src/Jsx.res | 11 ++++++++++- analysis/tests/src/expected/Jsx.res.txt | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/analysis/tests/src/Jsx.res b/analysis/tests/src/Jsx.res index 849777079..c1fbdc204 100644 --- a/analysis/tests/src/Jsx.res +++ b/analysis/tests/src/Jsx.res @@ -42,4 +42,13 @@ let y = 44 //^com -// ^def \ No newline at end of file +// ^def + +module Ext = { + @react.component @module("@material-ui/core") + external make: (~align: string=?) => React.element = "Typography" +} + +let extMake = Ext.make + +//^com Date: Mon, 1 Nov 2021 14:30:02 +0100 Subject: [PATCH 2/2] Fix issue in JSX autocomplete when the component is declared external. Fixes https://github.com/rescript-lang/rescript-vscode/issues/307. --- CHANGELOG.md | 2 +- analysis/src/NewCompletions.ml | 13 +++++++++++++ analysis/tests/src/Jsx.res | 2 +- analysis/tests/src/expected/Jsx.res.txt | 14 +++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c35222f1..e54de7c53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/analysis/src/NewCompletions.ml b/analysis/src/NewCompletions.ml index a8f384750..cdfc9e542 100644 --- a/analysis/src/NewCompletions.ml +++ b/analysis/src/NewCompletions.ml @@ -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 diff --git a/analysis/tests/src/Jsx.res b/analysis/tests/src/Jsx.res index c1fbdc204..4fbfd5a33 100644 --- a/analysis/tests/src/Jsx.res +++ b/analysis/tests/src/Jsx.res @@ -49,6 +49,6 @@ module Ext = { external make: (~align: string=?) => React.element = "Typography" } -let extMake = Ext.make +let _extMake = Ext.make //^com ", + "documentation": null + }, { + "label": "key", + "kind": 4, + "tags": [], + "detail": "string", + "documentation": null + }]