[ANN] VSCode extension 1.12.0 released

We’re glad to announce that 1.12.0 of the VSCode extension is released and available as of now. This version is the culmination of an intense period of building out the editor tooling with new capabilities, primarily around autocomplete. We’ll list all of the significant new features below and take you on a tour of how they work.

While this release brings quite a few new features and capabilities, it’s also paving the way for some exciting work and improvements we’ll share with you in the near future.

The full changelog is available here: rescript-vscode/CHANGELOG.md at master · rescript-lang/rescript-vscode · GitHub

New autocomplete capabilites

Exhaustive switch statements

exhaustive-switch-2

Variables that are booleans/options/variants/polyvariants now get an extra completion item named exhaustive switch. Selecting that completion item inserts an exhaustive switch statement for all the cases of the variable.

Completion in patterns of switches

pattern-completion

Autocomplete inside the pattern of a switch. Please note that you need to manually trigger completion (ctrl + space in VSCode) inside the pattern, it won’t trigger automatically. We’re considering adding | as a completion trigger, so this would trigger automatically when switching. Feedback welcome.

A lot of these completions work without saving, but occasionally you’ll need to save and compile for the compiler to give us the information we need.

let destructure completion

let-destructure-completion
Completion of field names when destructuring records.

Lowercase JSX tag completion

jsx-html-tag-completion
Autocomplete for lowercase JSX tags (HTML tags).

Completion for JSX prop values

expr-completion
Get type based completion for component props in JSX. Should work for all hand written components, and for lowercase components (e.g. <div />) if you’re using JSX v4.

Completion for function arguments

fn-argument-completion
Completion for the value of function arguments. This should work for labelled and unlabelled arguments, together with piping, etc.

Function snippet completion

Related to the above, arguments that take functions will produce a function snippet matching the expected function signature. Example in the context of a JSX event handler:
function-templates

React.element fn completion in JSX

react-element
Figures out if you’re in a JSX context (either inside of a make component function, or inside of actual JSX) and adds completion for React.{int/string/array}. These are used a lot when you work with JSX, so this is an attempt to improve the ergonomics of working with JSX.

Improved signature help

Signature help is currently an experimental feature that you need to activate through settings to use. However, we intend to release this as a stable feature soon.

We’ve also done a bit of polishing work on signature help, like cleaning up the output, improved precision in what arguments are highlighted (and when), and fixed a few bugs.

Wrapping up

Thank you for using the VSCode extension. As usual, report any issues you experience to the bug tracker.

21 Likes

awesome work, thanks a lot for this huge effort @zth!

4 Likes

Absolutely, this is huge. Thanks a ton!

3 Likes

I’m confused. I tried typing let x = Option.getWithDefault( and see no autocomplete suggestions as I finish typing the open paren and try to fill in the function parameters. Should this work?

Thanks @zth We are lucky to enjoy your hard work =)
Wondering if you have any thoughts about the interaction of extended completions with CoPilot etc? Will any of these features be subsumed at some point?

1 Like

What do you think it should suggest? All the optional values in the scope?

It work the other way: if you type let y = x->, and x is an option, the extension starts suggesting the functions from Belt.Option.

1 Like

I read “Completion for function arguments” and assumed it would show me something like this…

I run into this problem all the time. I get autocomplete after typing Option but then after I pick a specific function and the cursor is ready to type the first parameter I can’t remember what I’m supposed to type. So I pick up the mouse and move it back over the function name, or delete everything and start again so I can see the signature again. Maybe there is a better way to see the function signature again after you start filling it in but I don’t know how.

Here is what happens in TypeScript. This works great since the current parameter is highlighted so you know what to type.

This is called “signature help”, and you can activate it in the settings dialogue (it’s currently marked as an experimental feature). Looks like this:

2 Likes

Thank you!

Unfortunately I don’t know anything substantial about CoPilot etc, but it has crossed my mind more than once that ReScript should be a good language for “AI” driven code completion, due to the type system, relative simplicity etc. Would be interesting to explore what that could mean for ReScript.

2 Likes

Thanks this is exactly what I need. I just tried it and like it.

1 Like

The support for ReScript should be done on their side.

Since I upgraded I noticed that the unused warnings are not showing up anymore.

my bsconfig

 "warnings": {
    "number": "-44-102",
    "error": "+5"
  },

Sometimes I see the warning but it disappears when I do any other code change.

Please file an issue with a reproducible example on the bug tracker.

1 Like

I haven’t been able to know which variables make it happen. It just happens all the time since I upgraded.
I will file a bug when I figure how to reproduce.
I use monorepo… maybe that has something to do :thinking: