Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse original env when instantiating type #1067

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": ""
}]
}]

Loading