Skip to content

Commit

Permalink
Reuse original env when instantiating type (#1067)
Browse files Browse the repository at this point in the history
* Reuse original env when instantiating type

* Add changelog entry
  • Loading branch information
nojaf authored Jan 6, 2025
1 parent ddc23b0 commit 6604f4b
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

- Fix bug where type args stopped working in some completions when passed through inline records. https://github.com/rescript-lang/rescript-vscode/pull/1064
- 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
- Fix bug where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript-vscode/pull/1067

## 1.60.0

Expand Down
2 changes: 1 addition & 1 deletion analysis/src/TypeUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ let rec extractFunctionTypeWithEnv ~env ~package typ =
| Tconstr (path, typeArgs, _) -> (
match References.digConstructor ~env ~package path with
| Some
( env,
( _env,
{
item = {decl = {type_manifest = Some t1; type_params = typeParams}};
} ) ->
Expand Down
33 changes: 33 additions & 0 deletions analysis/tests/src/Firebase.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Firebase = {
module Firestore = {
type firestore

type documentReference<'documentdata> = {
id: string,
path: string,
}

type documentSnapshot<'documentdata> = {
id: string,
ref: documentReference<'documentdata>,
}

@module("firebase/firestore") @variadic
external doc: (firestore, string, array<string>) => documentReference<'documentdata> = "doc"

@module("firebase/firestore")
external getDoc: documentReference<'documentdata> => Js.Promise.t<
documentSnapshot<'documentdata>,
> = "getDoc"
}
}

module Sample = {
open Firebase

external store: Firestore.firestore = "store"

let ref = store->Firestore.doc("some_id", [])
// ref.
// ^com
}
41 changes: 41 additions & 0 deletions analysis/tests/src/expected/Firebase.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Complete src/Firebase.res 30:9
posCursor:[30:9] posNoWhite:[30:8] Found expr:[30:5->30:9]
Pexp_field [30:5->30:8] _:[32:0->30:9]
Completable: Cpath Value[ref].""
Raw opens: 1 Firebase.place holder
Package opens Pervasives.JsxModules.place holder
Resolved opens 2 pervasives Firebase.res
ContextPath Value[ref].""
ContextPath Value[ref]
Path ref
ContextPath Value[ref]->
ContextPath Value[ref]
Path ref
CPPipe pathFromEnv:Firebase.Firestore found:true
Path Firebase.Firestore.
[{
"label": "id",
"kind": 5,
"tags": [],
"detail": "string",
"documentation": {"kind": "markdown", "value": "```rescript\nid: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
}, {
"label": "path",
"kind": 5,
"tags": [],
"detail": "string",
"documentation": {"kind": "markdown", "value": "```rescript\npath: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
}, {
"label": "->Firestore.getDoc",
"kind": 12,
"tags": [],
"detail": "documentReference<\n 'documentdata,\n> => Js.Promise.t<documentSnapshot<'documentdata>>",
"documentation": null,
"sortText": "getDoc",
"insertText": "->Firestore.getDoc",
"additionalTextEdits": [{
"range": {"start": {"line": 30, "character": 8}, "end": {"line": 30, "character": 9}},
"newText": ""
}]
}]

0 comments on commit 6604f4b

Please sign in to comment.