@effect/language-service 0.64.1 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -39
- package/cli.js +3438 -1098
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +851 -220
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +895 -245
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +849 -218
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -78,6 +78,8 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
78
78
|
- Warn when using `yield* Effect.fail()` with yieldable error types that can be yielded directly
|
|
79
79
|
- Warn when using `Effect.fail` with the global `Error` type, recommending tagged errors
|
|
80
80
|
- Warn when `Layer.mergeAll` contains layers with interdependencies (where one layer provides a service that another layer in the same call requires)
|
|
81
|
+
- Suggest using `Effect.fn` for functions that return `Effect.gen` for better tracing and concise syntax
|
|
82
|
+
- Suggest removing redundant identifier argument when it equals the tag value in `Schema.TaggedClass`, `Schema.TaggedError`, or `Schema.TaggedRequest`
|
|
81
83
|
|
|
82
84
|
### Completions
|
|
83
85
|
|
|
@@ -133,7 +135,7 @@ Few options can be provided alongside the initialization of the Language Service
|
|
|
133
135
|
},
|
|
134
136
|
"diagnosticsName": true, // controls whether to include the rule name in diagnostic messages (default: true)
|
|
135
137
|
"missingDiagnosticNextLine": "warning", // controls the severity of warnings for unused @effect-diagnostics-next-line comments (default: "warning", allowed values: off,error,warning,message,suggestion)
|
|
136
|
-
"
|
|
138
|
+
"includeSuggestionsInTsc": true, // when enabled with effect-language-service patch enabled, diagnostics with "suggestion" severity will be reported as "message" in TSC with "[suggestion]" prefix; useful to help steer LLM output (default: true)
|
|
137
139
|
"quickinfo": true, // controls Effect quickinfo (default: true)
|
|
138
140
|
"quickinfoEffectParameters": "whenTruncated", // (default: "whenTruncated") controls when to display effect type parameters always,never,whenTruncated
|
|
139
141
|
"quickinfoMaximumLength": -1, // controls how long can be the types in the quickinfo hover (helps with very long type to improve perfs, defaults to -1 for no truncation, can be any number eg. 1000 and TS will try to fit as much as possible in that budget, higher number means more info.)
|
|
@@ -163,11 +165,8 @@ The full list can be found in the [diagnostics](https://github.com/Effect-TS/lan
|
|
|
163
165
|
|
|
164
166
|
TypeScript LSPs are loaded only while editing your files. That means that if you run `tsc` in your project, the plugin won't be loaded and you'll miss out on the Effect diagnostics.
|
|
165
167
|
|
|
166
|
-
We provide two approaches to solve this scenario.
|
|
167
168
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
This option works by modifing directly the source code of the tsc compiler and the typescript library in your project node_modules. This allows to get effect's diagnostics even when noEmit is enabled, for composite and incremental projects as well.
|
|
169
|
+
To solve this we modify directly the source code of the tsc compiler and the typescript library in your project node_modules. This allows to get effect's diagnostics even when noEmit is enabled, for composite and incremental projects as well.
|
|
171
170
|
|
|
172
171
|
After having installed and configured the LSP for editor usage, you can run the following command inside the folder that contains your local project typescript installation:
|
|
173
172
|
|
|
@@ -194,40 +193,6 @@ To make the patch persistent across package installations and updates, we recomm
|
|
|
194
193
|
|
|
195
194
|
so that across updates the patch will be re-applied again.
|
|
196
195
|
|
|
197
|
-
### Option B - Using ts-patch
|
|
198
|
-
|
|
199
|
-
if you use `ts-patch` you can enable the transform as well to get the diagnostics also at compile time.
|
|
200
|
-
Your `tsconfig.json` should look like this:
|
|
201
|
-
|
|
202
|
-
```jsonc
|
|
203
|
-
{
|
|
204
|
-
"compilerOptions": {
|
|
205
|
-
"plugins": [
|
|
206
|
-
{
|
|
207
|
-
"name": "@effect/language-service",
|
|
208
|
-
"transform": "@effect/language-service/transform" // enables diagnostics at compile time when using ts-patch
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
To get diagnostics you need to install `ts-patch` which will make it possible to run `tspc`.
|
|
216
|
-
|
|
217
|
-
Running `tspc` in your project will now also run the plugin and give you the error diagnostics at compile time.
|
|
218
|
-
Effect error diagnostics will be shown only after standard TypeScript diagnostics have been satisfied.
|
|
219
|
-
Beware that setting noEmit will completely skip the effect diagnostics, and projects using incremental builds may encounter some issues.
|
|
220
|
-
|
|
221
|
-
```ts
|
|
222
|
-
$ npx tspc
|
|
223
|
-
index.ts:3:1 - error TS3: Effect must be yielded or assigned to a variable.
|
|
224
|
-
|
|
225
|
-
3 Effect.succeed(1)
|
|
226
|
-
~~~~~~~~~~~~~~~~~
|
|
227
|
-
|
|
228
|
-
Found 1 error in index.ts:3
|
|
229
|
-
```
|
|
230
|
-
|
|
231
196
|
## Effect-Language-Service CLI
|
|
232
197
|
|
|
233
198
|
The effect language service plugin comes with a builtin CLI tool that can be used to perform various utilities, checks and setups. Since it relies on typescript, we recommend to install it locally and run it locally to ensure it loads the same typescript version of your project rather than a global installation that may resolve to use a different TS version from the one of your project.
|
|
@@ -291,6 +256,30 @@ Layers (2)
|
|
|
291
256
|
Complete application layer
|
|
292
257
|
```
|
|
293
258
|
|
|
259
|
+
### `effect-language-service layerinfo`
|
|
260
|
+
This command provides detailed information about a specific exported layer, including what services it provides, what it requires, and a suggested composition order. Use `--file` to specify the file and `--name` to specify the layer name.
|
|
261
|
+
|
|
262
|
+
Example output:
|
|
263
|
+
```
|
|
264
|
+
AppLive
|
|
265
|
+
./src/layers/app.ts:39:14
|
|
266
|
+
Layer<Cache | UserRepository, never, never>
|
|
267
|
+
|
|
268
|
+
Provides (2):
|
|
269
|
+
- Cache
|
|
270
|
+
- UserRepository
|
|
271
|
+
|
|
272
|
+
Suggested Composition:
|
|
273
|
+
UserRepository.Default.pipe(
|
|
274
|
+
Layer.provide(DbConnection.Default),
|
|
275
|
+
Layer.provideMerge(Cache.Default),
|
|
276
|
+
Layer.provide(FileSystem.Default)
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
Tip: Not sure you got your composition right? Just write all layers inside a Layer.mergeAll(...)
|
|
280
|
+
command, and then run the layerinfo command to get the suggested composition order to use.
|
|
281
|
+
```
|
|
282
|
+
|
|
294
283
|
## Configuring diagnostics
|
|
295
284
|
|
|
296
285
|
You can either disable or change the severity of specific diagnostics by using comments in your code.
|