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 where create interface file does not work with V4 #637

Merged
merged 2 commits into from
Nov 25, 2022
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

- Fix file location in Document Symbols response. https://github.com/rescript-lang/rescript-vscode/issues/629

- Fix issue where create interface file would not work with certain JSX V4 components https://github.com/rescript-lang/rescript-vscode/issues/617

## v1.8.2

#### :rocket: New Feature
Expand Down
6 changes: 1 addition & 5 deletions analysis/src/CreateInterface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ let printSignature ~extractor ~signature =
:: Sig_value (makeId (* make *), makeValueDesc)
:: rest
when Ident.name propsId = "props"
&& getComponentTypeV4 makeValueDesc.val_type <> None
&&
match recordRepresentation with
| Record_optional_labels _ -> true
| _ -> labelDecls = [] (* empty record *) ->
&& getComponentTypeV4 makeValueDesc.val_type <> None ->
(* PPX V4 component declaration:
type props = {...}
let v = ...
Expand Down
8 changes: 7 additions & 1 deletion analysis/tests/src/JsxV4.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ let _ = <M4 first="abc" />
let _ = <M4 first="abc" />
// ^hov


module MM = {
@react.component
let make = () => React.null
}

module Other = {
@react.component
let make = (~name) => React.string(name)
}

// ^int
14 changes: 14 additions & 0 deletions analysis/tests/src/expected/JsxV4.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ Completable: Cjsx([M4], f, [first, f])
Hover src/JsxV4.res 14:9
{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<M4.props<string, string, string>>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype M4.props<'first, 'fun, 'second> = {\n first: 'first,\n fun?: 'fun,\n second?: 'second,\n}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22JsxV4.res%22%2C3%2C2%5D)\n\n\n Doc Comment For M4 "}}

Create Interface src/JsxV4.res
module M4: {
@react.component
let make: (~first: string, ~fun: string=?, ~second: string=?) => React.element
}
module MM: {
@react.component
let make: unit => React.element
}
module Other: {
@react.component
let make: (~name: string) => React.element
}