# VOCaml: add and remove type annotations in VS Code

**URL:** https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618
**Category:** Ecosystem
**Tags:** announce, vscode
**Created:** [March 8, 2023, 5:47pm UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618 "2023-03-08T17:47:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)
#### Post date: [March 8, 2023, 5:47pm UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/1 "2023-03-08T17:47:09Z")

</div>

Hi!

I’m happy to announce [a VS Code extension VOCaml](https://marketplace.visualstudio.com/items?itemName=lukstafi.vocaml) ([GitHub release](https://github.com/lukstafi/vocaml/releases/tag/1.0.0)) where I’ll be putting my OCaml coding helpers. Currently, it has three commands:

- _VOCaml: Add Type Annotations_ inserts type annotations around let bindings.
- _VOCaml: Remove Type Annotations_ removes type annotations from let bindings.
- _VOCaml: Visit File from Current Line_ triggers a _Quick Open_ dialog populated with a file and line number retrieved from the line at cursor position.

VOCaml is a companion to [`ppx_minidebug`](https://github.com/lukstafi/ppx_minidebug), but it can be used for its own merits. It has some limitations, report issues if you try it!

Thanks,  
Lukasz

---

<div class="post-metadata">

### Author: ![Khady](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/khady/32/469_2.png) [@Khady](https://discuss.ocaml.org/u/Khady)
#### Post date: [March 9, 2023, 2:56am UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/2 "2023-03-09T02:56:58Z")

</div>

ocamllsp has a code action to do type annotation. I believe that using it could simplify your code a little bit.

---

<div class="post-metadata">

### Author: ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)
#### Post date: [March 9, 2023, 5:19am UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/3 "2023-03-09T05:19:21Z")

</div>

Ah it has both actions “Type annotate” and upcoming “Remove type annotation”! I wasn’t aware. I could maybe retire this extension. Except, it enhances the functionality for selections – it annotates multiple let-bindings at once. The code action treats a selection as indicating the expression to annotate.

Thank you!

---

<div class="post-metadata">

### Author: ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)
#### Post date: [March 9, 2023, 8:05am UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/4 "2023-03-09T08:05:15Z")

</div>

The code action `Type annotate` also does not type-annotate function bindings in a nice way, so there’s still raison d’etre for VOCaml…

---

<div class="post-metadata">

### Author: ![3Rafal](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/3rafal/32/4262_2.png) [@3Rafal](https://discuss.ocaml.org/u/3Rafal)
#### Post date: [March 17, 2023, 11:03am UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/5 "2023-03-17T11:03:08Z")

</div>

Hi @lukstafi,  
I have take a look into your solution, which is related to my current work.  
I’ve been working on improving type annotations in ocaml-lsp. The problem with functions is actually a bit harder then I expected, so for now it will probably be disabled. You can find the discussion and explanation here:

> <https://github.com/ocaml/ocaml-lsp/issues/801>
>
> We shouldn't produce syntactically incorrect code, e.g., 
> 
> \<img width="449" al…t="image" src="https://user-images.githubusercontent.com/16353531/180753196-a4461ef9-1716-42b1-a5a7-beebae2985a5.png"\>

Best,  
Rafal

---

<div class="post-metadata">

### Author: ![lukstafi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lukstafi/32/3442_2.png) [@lukstafi](https://discuss.ocaml.org/u/lukstafi)
#### Post date: [March 21, 2023, 12:20pm UTC](https://discuss.ocaml.org/t/vocaml-add-and-remove-type-annotations-in-vs-code/11618/6 "2023-03-21T12:20:56Z")

</div>

A new version of [VOCaml – 1.1.1](https://github.com/lukstafi/vocaml/releases/tag/1.1.1) is out ([Marketplace](https://marketplace.visualstudio.com/items?itemName=lukstafi.vocaml)). Multiline types work now, also labeled arguments (and optional without defaults), unit value pattern.
