@effect/language-service 0.64.1 → 0.66.1
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 +30 -39
- package/cli.js +3713 -986
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +1326 -308
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +1370 -333
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +1324 -306
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -73,11 +73,15 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
73
73
|
- Warn when catch callbacks in `Effect.tryPromise`, `Effect.tryMap`, or `Effect.tryMapPromise` return `unknown` or `any` types
|
|
74
74
|
- Warn when catch callbacks in `Effect.tryPromise`, `Effect.try`, `Effect.tryMap`, or `Effect.tryMapPromise` return the global `Error` type instead of typed errors
|
|
75
75
|
- Warn when using `Effect.runSync`, `Effect.runPromise`, `Effect.runFork`, or `Effect.runCallback` inside an Effect
|
|
76
|
+
- Warn when using `Schema.decodeSync`, `Schema.decodeUnknownSync`, `Schema.encodeSync`, or `Schema.encodeUnknownSync` inside Effect generators, suggesting Effect-based alternatives
|
|
77
|
+
- Suggest using Effect Schema for JSON operations instead of `JSON.parse`/`JSON.stringify` inside Effect contexts
|
|
76
78
|
- Warn when using `Schema.Union` with multiple `Schema.Literal` calls that can be simplified to a single `Schema.Literal` call
|
|
77
79
|
- Suggest using `Schema.TaggedStruct` instead of `Schema.Struct` when a `_tag` field with `Schema.Literal` is present to make the tag optional in the constructor
|
|
78
80
|
- Warn when using `yield* Effect.fail()` with yieldable error types that can be yielded directly
|
|
79
81
|
- Warn when using `Effect.fail` with the global `Error` type, recommending tagged errors
|
|
80
82
|
- Warn when `Layer.mergeAll` contains layers with interdependencies (where one layer provides a service that another layer in the same call requires)
|
|
83
|
+
- Suggest using `Effect.fn` for functions that return `Effect.gen` for better tracing and concise syntax
|
|
84
|
+
- Suggest removing redundant identifier argument when it equals the tag value in `Schema.TaggedClass`, `Schema.TaggedError`, or `Schema.TaggedRequest`
|
|
81
85
|
|
|
82
86
|
### Completions
|
|
83
87
|
|
|
@@ -133,7 +137,7 @@ Few options can be provided alongside the initialization of the Language Service
|
|
|
133
137
|
},
|
|
134
138
|
"diagnosticsName": true, // controls whether to include the rule name in diagnostic messages (default: true)
|
|
135
139
|
"missingDiagnosticNextLine": "warning", // controls the severity of warnings for unused @effect-diagnostics-next-line comments (default: "warning", allowed values: off,error,warning,message,suggestion)
|
|
136
|
-
"
|
|
140
|
+
"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
141
|
"quickinfo": true, // controls Effect quickinfo (default: true)
|
|
138
142
|
"quickinfoEffectParameters": "whenTruncated", // (default: "whenTruncated") controls when to display effect type parameters always,never,whenTruncated
|
|
139
143
|
"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 +167,8 @@ The full list can be found in the [diagnostics](https://github.com/Effect-TS/lan
|
|
|
163
167
|
|
|
164
168
|
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
169
|
|
|
166
|
-
We provide two approaches to solve this scenario.
|
|
167
170
|
|
|
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.
|
|
171
|
+
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
172
|
|
|
172
173
|
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
174
|
|
|
@@ -194,40 +195,6 @@ To make the patch persistent across package installations and updates, we recomm
|
|
|
194
195
|
|
|
195
196
|
so that across updates the patch will be re-applied again.
|
|
196
197
|
|
|
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
198
|
## Effect-Language-Service CLI
|
|
232
199
|
|
|
233
200
|
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 +258,30 @@ Layers (2)
|
|
|
291
258
|
Complete application layer
|
|
292
259
|
```
|
|
293
260
|
|
|
261
|
+
### `effect-language-service layerinfo`
|
|
262
|
+
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.
|
|
263
|
+
|
|
264
|
+
Example output:
|
|
265
|
+
```
|
|
266
|
+
AppLive
|
|
267
|
+
./src/layers/app.ts:39:14
|
|
268
|
+
Layer<Cache | UserRepository, never, never>
|
|
269
|
+
|
|
270
|
+
Provides (2):
|
|
271
|
+
- Cache
|
|
272
|
+
- UserRepository
|
|
273
|
+
|
|
274
|
+
Suggested Composition:
|
|
275
|
+
UserRepository.Default.pipe(
|
|
276
|
+
Layer.provide(DbConnection.Default),
|
|
277
|
+
Layer.provideMerge(Cache.Default),
|
|
278
|
+
Layer.provide(FileSystem.Default)
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
Tip: Not sure you got your composition right? Just write all layers inside a Layer.mergeAll(...)
|
|
282
|
+
command, and then run the layerinfo command to get the suggested composition order to use.
|
|
283
|
+
```
|
|
284
|
+
|
|
294
285
|
## Configuring diagnostics
|
|
295
286
|
|
|
296
287
|
You can either disable or change the severity of specific diagnostics by using comments in your code.
|