rescript-vscode
rescript-vscode copied to clipboard
Feature request: Autocomplete variants as function parameters
(Somewhat related to #120 which is about autocompletion of variants in the case of pattern matching.)
There is another common situation where it would be nice to have autocompletion for variants:
Say I have a variant
type action =
| A
| B
| C
and a dispatch
function with signature action => unit
.
Now if I type dispatch(
, it is known that the parameter is of type action and it would be great if A
, B
and C
could be autosuggested.
This looks very specific: assume there's a single unlabeled argument of type variant. Then try to autocomplete. Feels like we need a more general proposal for this.
I just wanted to give a simple example for a common use case. Yes, it can be generalized in various ways, e.g. to multiple arguments, labelled arguments, uncurried invocation etc.
It also can be generalized to other situations where we know that a variant type is expected, e.g.
let action: action =
It also can be generalized to functions with a record parameter, e.g.
type user = {
firstName: string,
lastName: string,
}
let fullName = ({firstName, lastName}) => firstName ++ " " ++ lastName
fullName(
This sort of things generally works very well in TypeScript:
![Bildschirmfoto 2021-04-30 um 07 42 26](https://user-images.githubusercontent.com/591384/116653551-b78bbe80-a987-11eb-8df6-7ae1efd6248a.png)
![Bildschirmfoto 2021-04-30 um 07 42 42](https://user-images.githubusercontent.com/591384/116653559-bb1f4580-a987-11eb-990e-c788c5be4218.png)
Fixed in https://github.com/rescript-lang/rescript-vscode/pull/665