@effect/language-service 0.35.2 → 0.37.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 CHANGED
@@ -22,6 +22,13 @@ This package implements a TypeScript language service plugin that allows additio
22
22
  3. Ensure that you have installed TypeScript locally in your project and set your editor to use your workspace TypeScript version.
23
23
 
24
24
  - In VSCode you can do this by pressing "F1" and typing "TypeScript: Select TypeScript version". Then select "Use workspace version". If that option does not appear, TypeScript is not installed locally in your node_modules.
25
+ - Not required, but to remember the user to do so, you can update your `.vscode/settings.json`
26
+ ```jsonc
27
+ {
28
+ "typescript.tsdk": "./node_modules/typescript/lib",
29
+ "typescript.enablePromptUseWorkspaceTsdk": true
30
+ }
31
+ ```
25
32
  - In JetBrains you may have to disable the Vue language service, and choose the workspace version of TypeScript in the settings from the dropdown.
26
33
  - In NVim with nvim-vtsls you should refer to [how to enable TypeScript plugins in vtsls](https://github.com/yioneko/vtsls?tab=readme-ov-file#typescript-plugin-not-activated)
27
34
  - In Emacs, additional steps are required to enable LSPs, [step by step instructions can be found here](https://gosha.net/2025/effect-ls-emacs/)
@@ -81,6 +88,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
81
88
  - Toggle between pipe styles `X.pipe(Y)` and `pipe(X, Y)`
82
89
 
83
90
  ### Miscellaneous
91
+ - Renaming a class name, will rename the identifier as well for TaggedError, TaggedClass, etc...
84
92
  - "Go to definition" for RpcClient will resolve to the Rpc definition
85
93
 
86
94
  ## Options
@@ -106,7 +114,8 @@ Few options can be provided alongside the initialization of the Language Service
106
114
  "allowedDuplicatedPackages": [], // list of package names that have effect in peer dependencies and are allowed to be duplicated (default: [])
107
115
  "barrelImportPackages": [], // package names that should be preferred as imported from the top level barrel file (default: [])
108
116
  "namespaceImportPackages": [], // package names that should be preferred as imported with namespace imports e.g. ["effect", "@effect/*"] (default: [])
109
- "topLevelNamedReexports": "ignore" // for namespaceImportPackages, how should top level named re-exports (e.g. {pipe} from "effect") be treated? "ignore" will leave them as is, "follow" will rewrite them to the re-exported module (e.g. {pipe} from "effect/Function")
117
+ "topLevelNamedReexports": "ignore", // for namespaceImportPackages, how should top level named re-exports (e.g. {pipe} from "effect") be treated? "ignore" will leave them as is, "follow" will rewrite them to the re-exported module (e.g. {pipe} from "effect/Function")
118
+ "importAliases": { "Array": "Arr" } // allows to chose some different names for import name aliases (only when not chosing to import the whole module) (default: {})
110
119
  }
111
120
  ]
112
121
  }
@@ -121,7 +130,40 @@ The full list can be found in the [diagnostics](https://github.com/Effect-TS/lan
121
130
 
122
131
  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.
123
132
 
124
- HOWEVER, if you use `ts-patch` you can enable the transform as well to get the diagnostics also at compile time.
133
+ We provide two approaches to solve this scenario.
134
+
135
+ ### Option A - Effect LSP Cli Patch (experimental recommended)
136
+
137
+ 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.
138
+
139
+ 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:
140
+
141
+ `effect-language-service patch`
142
+
143
+ If everything goes smoothly, something along these lines should be printed out:
144
+
145
+ ```
146
+ /node_modules/typescript/lib/typescript.js patched successfully.
147
+ /node_modules/typescript/lib/_tsc.js patched successfully.
148
+ ```
149
+
150
+ Now the CLI has patched the tsc binary and the typescript library to raise effect diagnostics even at build time if the plugin is configured in your tsconfig!
151
+
152
+ As the command output suggests, you may need to delete your tsbuildinfo files or perform a full rebuild in order to re-check previously existing files.
153
+
154
+ To make the patch persistent across package installations and updates, we recommend adding the patch command to your package.json prepare scripts:
155
+
156
+ ```jsonc
157
+ "scripts": {
158
+ "prepare": "effect-language-service patch"
159
+ }
160
+ ```
161
+
162
+ so that across updates the patch will be re-applied again.
163
+
164
+ ### Option B - Using ts-patch
165
+
166
+ if you use `ts-patch` you can enable the transform as well to get the diagnostics also at compile time.
125
167
  Your `tsconfig.json` should look like this:
126
168
 
127
169
  ```jsonc
@@ -141,7 +183,7 @@ To get diagnostics you need to install `ts-patch` which will make it possible to
141
183
 
142
184
  Running `tspc` in your project will now also run the plugin and give you the error diagnostics at compile time.
143
185
  Effect error diagnostics will be shown only after standard TypeScript diagnostics have been satisfied.
144
- Beware that setting noEmit will completely skip the effect diagnostics.
186
+ Beware that setting noEmit will completely skip the effect diagnostics, and projects using incremental builds may encounter some issues.
145
187
 
146
188
  ```ts
147
189
  $ npx tspc