Skip to content

Commit 6604f4b

Browse files
authored
Reuse original env when instantiating type (#1067)
* Reuse original env when instantiating type * Add changelog entry
1 parent ddc23b0 commit 6604f4b

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
- Fix bug where type args stopped working in some completions when passed through inline records. https://github.com/rescript-lang/rescript-vscode/pull/1064
2222
- Fix bug where objects weren't actually iterated on, making completions inside of them not work. https://github.com/rescript-lang/rescript-vscode/pull/1065
23+
- Fix bug where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript-vscode/pull/1067
2324

2425
## 1.60.0
2526

analysis/src/TypeUtils.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ let rec extractFunctionTypeWithEnv ~env ~package typ =
275275
| Tconstr (path, typeArgs, _) -> (
276276
match References.digConstructor ~env ~package path with
277277
| Some
278-
( env,
278+
( _env,
279279
{
280280
item = {decl = {type_manifest = Some t1; type_params = typeParams}};
281281
} ) ->

analysis/tests/src/Firebase.res

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Firebase = {
2+
module Firestore = {
3+
type firestore
4+
5+
type documentReference<'documentdata> = {
6+
id: string,
7+
path: string,
8+
}
9+
10+
type documentSnapshot<'documentdata> = {
11+
id: string,
12+
ref: documentReference<'documentdata>,
13+
}
14+
15+
@module("firebase/firestore") @variadic
16+
external doc: (firestore, string, array<string>) => documentReference<'documentdata> = "doc"
17+
18+
@module("firebase/firestore")
19+
external getDoc: documentReference<'documentdata> => Js.Promise.t<
20+
documentSnapshot<'documentdata>,
21+
> = "getDoc"
22+
}
23+
}
24+
25+
module Sample = {
26+
open Firebase
27+
28+
external store: Firestore.firestore = "store"
29+
30+
let ref = store->Firestore.doc("some_id", [])
31+
// ref.
32+
// ^com
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Complete src/Firebase.res 30:9
2+
posCursor:[30:9] posNoWhite:[30:8] Found expr:[30:5->30:9]
3+
Pexp_field [30:5->30:8] _:[32:0->30:9]
4+
Completable: Cpath Value[ref].""
5+
Raw opens: 1 Firebase.place holder
6+
Package opens Pervasives.JsxModules.place holder
7+
Resolved opens 2 pervasives Firebase.res
8+
ContextPath Value[ref].""
9+
ContextPath Value[ref]
10+
Path ref
11+
ContextPath Value[ref]->
12+
ContextPath Value[ref]
13+
Path ref
14+
CPPipe pathFromEnv:Firebase.Firestore found:true
15+
Path Firebase.Firestore.
16+
[{
17+
"label": "id",
18+
"kind": 5,
19+
"tags": [],
20+
"detail": "string",
21+
"documentation": {"kind": "markdown", "value": "```rescript\nid: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
22+
}, {
23+
"label": "path",
24+
"kind": 5,
25+
"tags": [],
26+
"detail": "string",
27+
"documentation": {"kind": "markdown", "value": "```rescript\npath: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
28+
}, {
29+
"label": "->Firestore.getDoc",
30+
"kind": 12,
31+
"tags": [],
32+
"detail": "documentReference<\n 'documentdata,\n> => Js.Promise.t<documentSnapshot<'documentdata>>",
33+
"documentation": null,
34+
"sortText": "getDoc",
35+
"insertText": "->Firestore.getDoc",
36+
"additionalTextEdits": [{
37+
"range": {"start": {"line": 30, "character": 8}, "end": {"line": 30, "character": 9}},
38+
"newText": ""
39+
}]
40+
}]
41+

0 commit comments

Comments
 (0)