@effect/language-service 0.13.0 → 0.14.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
@@ -26,6 +26,38 @@ This package implements a TypeScript language service plugin that allows additio
26
26
 
27
27
  And you're done! You'll now be able to use a set of refactor and diagnostics that targets Effect!
28
28
 
29
+ ## Enable diagnostics at compile time
30
+
31
+ TypeScript LSP 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.
32
+
33
+ HOWEVER, if you use `ts-patch` you can enable the transform as well to get the diagnostics also at compile time.
34
+ Your `tsconfig.json` should look like this:
35
+
36
+ ```json
37
+ {
38
+ "compilerOptions": {
39
+ "plugins": [
40
+ {
41
+ "name": "@effect/language-service",
42
+ "transform": "@effect/language-service/transform" // enables diagnostics at compile time when using ts-patch
43
+ }
44
+ ]
45
+ }
46
+ }
47
+ ```
48
+
49
+ Running `tspc` in your project will now also run the plugin and give you the diagnostics at compile time.
50
+
51
+ ```ts
52
+ $ npm tspc
53
+ index.ts:3:1 - error TS3: Effect must be yielded or assigned to a variable.
54
+
55
+ 3 Effect.succeed(1)
56
+ ~~~~~~~~~~~~~~~~~
57
+
58
+ Found 1 error in index.ts:3 
59
+ ```
60
+
29
61
  ## Options
30
62
 
31
63
  Few options can be provided alongside the initialization of the Language Service Plugin.
package/index.js CHANGED
@@ -1444,6 +1444,14 @@ function createRefactor(definition) {
1444
1444
  function createDiagnostic(definition) {
1445
1445
  return definition;
1446
1446
  }
1447
+ function parsePluginOptions(config) {
1448
+ return {
1449
+ diagnostics: config && "diagnostics" in config && typeof config.diagnostics === "boolean" ? config.diagnostics : true,
1450
+ quickinfo: config && "quickinfo" in config && typeof config.quickinfo === "boolean" ? config.quickinfo : true,
1451
+ completions: config && "completions" in config && typeof config.completions === "boolean" ? config.completions : true,
1452
+ multipleEffectCheck: config && "multipleEffectCheck" in config && typeof config.multipleEffectCheck === "boolean" ? config.multipleEffectCheck : true
1453
+ };
1454
+ }
1447
1455
  function createCompletion(definition) {
1448
1456
  return definition;
1449
1457
  }
@@ -3609,12 +3617,7 @@ var refactors = [
3609
3617
  var init = (modules) => {
3610
3618
  function create(info) {
3611
3619
  const languageService = info.languageService;
3612
- const pluginOptions = {
3613
- diagnostics: info.config && "diagnostics" in info.config && typeof info.config.diagnostics === "boolean" ? info.config.diagnostics : true,
3614
- quickinfo: info.config && "quickinfo" in info.config && typeof info.config.quickinfo === "boolean" ? info.config.quickinfo : true,
3615
- completions: info.config && "completions" in info.config && typeof info.config.completions === "boolean" ? info.config.completions : true,
3616
- multipleEffectCheck: info.config && "multipleEffectCheck" in info.config && typeof info.config.multipleEffectCheck === "boolean" ? info.config.multipleEffectCheck : true
3617
- };
3620
+ const pluginOptions = parsePluginOptions(info.config);
3618
3621
  const diagnosticsErrorCodes = diagnostics.map((diagnostic) => diagnostic.code);
3619
3622
  try {
3620
3623
  ;