Skip to content

Commit 9e89849

Browse files
committed
Fix printing of record types with optional labels
Fixes #583
1 parent fbafb9d commit 9e89849

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
- Add support for prop completion for JSX V4 https://github.com/rescript-lang/rescript-vscode/pull/579
1818
- Add support for create interface file for JSX V4 https://github.com/rescript-lang/rescript-vscode/pull/580
19-
- Expand one level of type definition on hover. Dig into record/variant body.
19+
- Expand one level of type definition on hover. Dig into record/variant body. https://github.com/rescript-lang/rescript-vscode/pull/584
20+
21+
#### :bug: Bug Fix
22+
23+
- Fix printing of record types with optional labels. https://github.com/rescript-lang/rescript-vscode/pull/584
2024

2125
## v1.6.0
2226

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,5 @@ Completable: Cpath Value[y2].content.""
159159
}]
160160

161161
Hover src/Hover.res 197:4
162-
{"contents": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n```rescript\ntype props<'n, 's> = {n: option<'n>, s: 's}\n```\n\n```rescript\ntype element\n```"}
162+
{"contents": "```rescript\nCompV4.props<int, string> => React.element\n```\n\n```rescript\ntype props<'n, 's> = {?n: 'n, s: 's}\n```\n\n```rescript\ntype element\n```"}
163163

analysis/vendor/compiler-libs-406/printtyp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ and tree_of_constructor cd =
926926
(name, args, Some ret)
927927

928928
and tree_of_label l =
929-
let opt = l.ld_attributes |> List.exists (fun ({txt}, _) -> txt = "optional") in
929+
let opt = l.ld_attributes |> List.exists (fun ({txt}, _) -> txt = "ns.optional") in
930930
let typ = match l.ld_type.desc with
931931
| Tconstr (p, [t1], _) when opt && Path.same p Predef.path_option -> t1
932932
| _ -> l.ld_type in

0 commit comments

Comments
 (0)