@effect/language-service 0.33.1 → 0.34.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
@@ -53,6 +53,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
53
53
  - Detect unnecessary pipe chains like `X.pipe(Y).pipe(Z)`
54
54
  - Warn when using `Effect.Service` with `accessors: true` but methods have generics or multiple signatures
55
55
  - Warn on missing service dependencies in `Effect.Service` declarations
56
+ - Warn when schema classes override the default constructor behavior
56
57
 
57
58
  ### Completions
58
59
 
@@ -137,8 +138,9 @@ Your `tsconfig.json` should look like this:
137
138
  To get diagnostics you need to install `ts-patch` which will make it possible to run `tspc`.
138
139
 
139
140
  Running `tspc` in your project will now also run the plugin and give you the error diagnostics at compile time.
140
- Effect error diagnostics will be shown only after standard TypeScript diagnostics have been satisfied.
141
- Beware that setting noEmit will completely skip the effect diagnostics.
141
+ Effect diagnostics in watch mode with noEmit enabled are not supported by ts-patch unfortunately.
142
+
143
+ If you use incremental builds, after enabling ts-patch, a full rebuild may be necessary to invalidate the previous diagnostics cache.
142
144
 
143
145
  ```ts
144
146
  $ npx tspc
package/cli.js CHANGED
@@ -31969,6 +31969,68 @@ var outdatedEffectCodegen = createDiagnostic({
31969
31969
  })
31970
31970
  });
31971
31971
 
31972
+ // src/diagnostics/overriddenSchemaConstructor.ts
31973
+ var overriddenSchemaConstructor = createDiagnostic({
31974
+ name: "overriddenSchemaConstructor",
31975
+ code: 30,
31976
+ severity: "error",
31977
+ apply: fn("overriddenSchemaConstructor.apply")(function* (sourceFile, report) {
31978
+ const ts2 = yield* service2(TypeScriptApi);
31979
+ const typeParser = yield* service2(TypeParser);
31980
+ const typeChecker = yield* service2(TypeCheckerApi);
31981
+ const nodeToVisit = [];
31982
+ const appendNodeToVisit = (node) => {
31983
+ nodeToVisit.push(node);
31984
+ return void 0;
31985
+ };
31986
+ ts2.forEachChild(sourceFile, appendNodeToVisit);
31987
+ while (nodeToVisit.length > 0) {
31988
+ const node = nodeToVisit.shift();
31989
+ if (ts2.isClassDeclaration(node) && node.heritageClauses) {
31990
+ let extendsSchema = false;
31991
+ for (const heritageClause of node.heritageClauses) {
31992
+ if (heritageClause.token === ts2.SyntaxKind.ExtendsKeyword) {
31993
+ for (const type2 of heritageClause.types) {
31994
+ const typeAtLocation = typeChecker.getTypeAtLocation(type2.expression);
31995
+ const isSchema2 = yield* pipe(
31996
+ typeParser.effectSchemaType(typeAtLocation, type2.expression),
31997
+ map33(() => true),
31998
+ orElse14(() => succeed17(false))
31999
+ );
32000
+ if (isSchema2) {
32001
+ extendsSchema = true;
32002
+ break;
32003
+ }
32004
+ }
32005
+ }
32006
+ if (extendsSchema) break;
32007
+ }
32008
+ if (extendsSchema) {
32009
+ const members = node.members;
32010
+ for (const member of members) {
32011
+ if (ts2.isConstructorDeclaration(member)) {
32012
+ report({
32013
+ location: member,
32014
+ messageText: "Classes extending Schema must not override the constructor",
32015
+ fixes: [{
32016
+ fixName: "overriddenSchemaConstructor_fix",
32017
+ description: "Remove the constructor override",
32018
+ apply: gen3(function* () {
32019
+ const changeTracker = yield* service2(ChangeTracker);
32020
+ changeTracker.delete(sourceFile, member);
32021
+ })
32022
+ }]
32023
+ });
32024
+ break;
32025
+ }
32026
+ }
32027
+ }
32028
+ }
32029
+ ts2.forEachChild(node, appendNodeToVisit);
32030
+ }
32031
+ })
32032
+ });
32033
+
31972
32034
  // src/diagnostics/returnEffectInGen.ts
31973
32035
  var returnEffectInGen = createDiagnostic({
31974
32036
  name: "returnEffectInGen",
@@ -32487,6 +32549,7 @@ var diagnostics = [
32487
32549
  strictBooleanExpressions,
32488
32550
  multipleEffectProvide,
32489
32551
  outdatedEffectCodegen,
32552
+ overriddenSchemaConstructor,
32490
32553
  unsupportedServiceAccessors
32491
32554
  ];
32492
32555