You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/manual/v12.0.0/editor-plugins.mdx
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,17 @@ let x = [1, 2, 3]->
196
196
- ArrayExtra.myOtherArrayFn
197
197
```
198
198
199
+
**Note**: generic types like `promise.t` and `result.t` do not need any additional types in the `rescript.json`:
200
+
201
+
```json
202
+
"editor": {
203
+
"autocomplete": {
204
+
"promise": ["PromiseExt"],
205
+
"result": ["ResultExt"]
206
+
}
207
+
}
208
+
```
209
+
199
210
##### Enhancing completion for non-builtin types
200
211
201
212
Now, let's look at an example of when you have a non-builtin type that you don't have control over.
@@ -221,3 +232,35 @@ Let's configure this using the `editor.autocomplete` config in `rescript.json`:
221
232
```
222
233
223
234
Now, when using pipes on anything of type `Fastify.t`, we'll also get completions from our custom `FastifyExtra`.
235
+
236
+
##### Enhancing completion for non-builtin types with namespaces
237
+
238
+
When a project uses a namespace, this affects the internal representation of type names used in the `autocomplete` configuration.
239
+
240
+
Consider the [geolocation](https://rescript-lang.github.io/experimental-rescript-webapi/apidocs/geolocation-api/#geolocation) type from the [Experimental WebAPI bindings](https://rescript-lang.github.io/experimental-rescript-webapi/).
241
+
This project specifies in its `rescript.json`:
242
+
243
+
```json
244
+
{
245
+
"name": "@rescript/webapi",
246
+
"namespace": "WebAPI"
247
+
}
248
+
```
249
+
250
+
This makes the `geolocation` type internally represented as `GeolocationAPI-WebAPI.geolocation`, where:
251
+
252
+
-`GeolocationAPI` is the module name
253
+
-`WebAPI` is the namespace
254
+
-`geolocation` is the type name
255
+
256
+
**Important**: You must use this internal representation when configuring autocomplete for namespaced types:
0 commit comments