Skip to content

Reuse original env when instantiating type #7231

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

Merged
merged 6 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 12.0.0-alpha.8 (Unreleased)

#### :bug: Bug fix

- Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231

# 12.0.0-alpha.7

#### :bug: Bug fix
Expand Down
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@ After adding a new file to the repository that should go into the npm package -

```sh
make lib # Build compiler and standard library
./bsc myTestFile.res
./cli/bsc myTestFile.res
```

To view the untyped tree of the file run:

```sh
./cli/bsc -dparsetree myTestFile.res
```

To view the typed tree of the file run:

```sh
./cli/bsc -dtypedtree myTestFile.res
```

### Project
Expand Down
6 changes: 6 additions & 0 deletions analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ See main CONTRIBUTING.md's repo structure. Additionally, `examples/` is a conven
dune exec -- rescript-editor-analysis --help
```

Add verbose logging via:

```shell
dune exec -- rescript-editor-analysis debug-dump verbose test
```

## History

This project is based on a fork of [Reason Language Server](https://github.com/jaredly/reason-language-server).
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/TypeUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ let 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
2 changes: 1 addition & 1 deletion tests/analysis_tests/tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions tests/analysis_tests/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> => 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 tests/analysis_tests/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 1 Firebase
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> => 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