@effect/language-service 0.76.0 → 0.78.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/transform.js CHANGED
@@ -24,7 +24,7 @@ __export(transform_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(transform_exports);
26
26
 
27
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Pipeable.js
27
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Pipeable.js
28
28
  var pipeArguments = (self, args3) => {
29
29
  switch (args3.length) {
30
30
  case 0:
@@ -57,7 +57,7 @@ var pipeArguments = (self, args3) => {
57
57
  }
58
58
  };
59
59
 
60
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Function.js
60
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Function.js
61
61
  var dual = function(arity, body) {
62
62
  if (typeof arity === "function") {
63
63
  return function() {
@@ -105,7 +105,7 @@ function pipe(a, ...args3) {
105
105
  return pipeArguments(a, args3);
106
106
  }
107
107
 
108
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/equal.js
108
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/internal/equal.js
109
109
  var getAllObjectKeys = (obj) => {
110
110
  const keys2 = new Set(Reflect.ownKeys(obj));
111
111
  if (obj.constructor === Object) return keys2;
@@ -128,7 +128,7 @@ var getAllObjectKeys = (obj) => {
128
128
  };
129
129
  var byReferenceInstances = /* @__PURE__ */ new WeakSet();
130
130
 
131
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Predicate.js
131
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Predicate.js
132
132
  function isString(input) {
133
133
  return typeof input === "string";
134
134
  }
@@ -149,7 +149,7 @@ function isObjectKeyword(input) {
149
149
  }
150
150
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObjectKeyword(self) && property in self);
151
151
 
152
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Hash.js
152
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Hash.js
153
153
  var symbol = "~effect/interfaces/Hash";
154
154
  var hash = (self) => {
155
155
  switch (typeof self) {
@@ -268,7 +268,7 @@ function withVisitedTracking(obj, fn2) {
268
268
  return result;
269
269
  }
270
270
 
271
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Equal.js
271
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Equal.js
272
272
  var symbol2 = "~effect/interfaces/Equal";
273
273
  function equals() {
274
274
  if (arguments.length === 1) {
@@ -430,7 +430,10 @@ var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth);
430
430
  var isEqual = (u) => hasProperty(u, symbol2);
431
431
  var asEquivalence = () => equals;
432
432
 
433
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Redactable.js
433
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/internal/array.js
434
+ var isArrayNonEmpty = (self) => self.length > 0;
435
+
436
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Redactable.js
434
437
  var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Inspectable/redactable");
435
438
  var isRedactable = (u) => hasProperty(u, symbolRedactable);
436
439
  function redact(u) {
@@ -449,7 +452,7 @@ var emptyServiceMap = {
449
452
  }
450
453
  };
451
454
 
452
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Formatter.js
455
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Formatter.js
453
456
  function format(input, options) {
454
457
  const space = options?.space ?? 0;
455
458
  const seen = /* @__PURE__ */ new WeakSet();
@@ -528,7 +531,7 @@ function safeToString(input) {
528
531
  }
529
532
  }
530
533
 
531
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Inspectable.js
534
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Inspectable.js
532
535
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
533
536
  var toJson = (input) => {
534
537
  try {
@@ -572,7 +575,7 @@ var Class = class {
572
575
  }
573
576
  };
574
577
 
575
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Utils.js
578
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Utils.js
576
579
  var GenKindTypeId = "~effect/Utils/GenKind";
577
580
  var GenKindImpl = class {
578
581
  value;
@@ -640,7 +643,7 @@ var internalCall = isNotOptimizedAway ? standard[InternalTypeId] : forced[Intern
640
643
  var genConstructor = function* () {
641
644
  }.constructor;
642
645
 
643
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/core.js
646
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/internal/core.js
644
647
  var EffectTypeId = `~effect/Effect`;
645
648
  var ExitTypeId = `~effect/Exit`;
646
649
  var effectVariance = {
@@ -987,7 +990,7 @@ var DoneVoid = {
987
990
  value: void 0
988
991
  };
989
992
 
990
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/option.js
993
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/internal/option.js
991
994
  var TypeId = "~effect/data/Option";
992
995
  var CommonProto = {
993
996
  [TypeId]: {
@@ -1052,7 +1055,7 @@ var some = (value) => {
1052
1055
  return a;
1053
1056
  };
1054
1057
 
1055
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/result.js
1058
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/internal/result.js
1056
1059
  var TypeId2 = "~effect/data/Result";
1057
1060
  var CommonProto2 = {
1058
1061
  [TypeId2]: {
@@ -1123,13 +1126,13 @@ var succeed = (success) => {
1123
1126
  return a;
1124
1127
  };
1125
1128
 
1126
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Order.js
1129
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Order.js
1127
1130
  function make(compare) {
1128
1131
  return (self, that) => self === that ? 0 : compare(self, that);
1129
1132
  }
1130
1133
  var String2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
1131
1134
 
1132
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Option.js
1135
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Option.js
1133
1136
  var none2 = () => none;
1134
1137
  var some2 = some;
1135
1138
  var isNone2 = isNone;
@@ -1139,7 +1142,7 @@ var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : se
1139
1142
  var fromNullishOr = (a) => a == null ? none2() : some2(a);
1140
1143
  var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
1141
1144
 
1142
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Result.js
1145
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Result.js
1143
1146
  var succeed2 = succeed;
1144
1147
  var fail2 = fail;
1145
1148
  var isFailure2 = isFailure;
@@ -1147,18 +1150,7 @@ var isSuccess2 = isSuccess;
1147
1150
  var map = /* @__PURE__ */ dual(2, (self, f) => isSuccess2(self) ? succeed2(f(self.success)) : fail2(self.failure));
1148
1151
  var getOrElse2 = /* @__PURE__ */ dual(2, (self, onFailure) => isFailure2(self) ? onFailure(self.failure) : self.success);
1149
1152
 
1150
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Filter.js
1151
- var apply = (filter2, input, ...args3) => {
1152
- const result = filter2(input, ...args3);
1153
- if (result === true) return succeed2(input);
1154
- if (result === false) return fail2(input);
1155
- return result;
1156
- };
1157
-
1158
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/internal/array.js
1159
- var isArrayNonEmpty = (self) => self.length > 0;
1160
-
1161
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Record.js
1153
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Record.js
1162
1154
  var map2 = /* @__PURE__ */ dual(2, (self, f) => {
1163
1155
  const out = {
1164
1156
  ...self
@@ -1170,7 +1162,7 @@ var map2 = /* @__PURE__ */ dual(2, (self, f) => {
1170
1162
  });
1171
1163
  var keys = (self) => Object.keys(self);
1172
1164
 
1173
- // ../../node_modules/.pnpm/effect@4.0.0-beta.12/node_modules/effect/dist/Array.js
1165
+ // ../../node_modules/.pnpm/effect@4.0.0-beta.27/node_modules/effect/dist/Array.js
1174
1166
  var Array2 = globalThis.Array;
1175
1167
  var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection);
1176
1168
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
@@ -1233,13 +1225,12 @@ var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
1233
1225
  return out;
1234
1226
  });
1235
1227
  var flatten = /* @__PURE__ */ flatMap(identity);
1236
- var filter = /* @__PURE__ */ dual(2, (self, f) => {
1228
+ var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
1237
1229
  const as = fromIterable(self);
1238
1230
  const out = [];
1239
1231
  for (let i = 0; i < as.length; i++) {
1240
- const result = apply(f, as[i], i);
1241
- if (!isFailure2(result)) {
1242
- out.push(result.success);
1232
+ if (predicate(as[i], i)) {
1233
+ out.push(as[i]);
1243
1234
  }
1244
1235
  }
1245
1236
  return out;
@@ -1690,7 +1681,9 @@ function parse(config) {
1690
1681
  keyPatterns: isObject(config) && hasProperty(config, "keyPatterns") && isArray(config.keyPatterns) ? parseKeyPatterns(config.keyPatterns) : defaults.keyPatterns,
1691
1682
  extendedKeyDetection: isObject(config) && hasProperty(config, "extendedKeyDetection") && isBoolean(config.extendedKeyDetection) ? config.extendedKeyDetection : defaults.extendedKeyDetection,
1692
1683
  pipeableMinArgCount: isObject(config) && hasProperty(config, "pipeableMinArgCount") && isNumber(config.pipeableMinArgCount) ? config.pipeableMinArgCount : defaults.pipeableMinArgCount,
1693
- effectFn: isObject(config) && hasProperty(config, "effectFn") && isArray(config.effectFn) && config.effectFn.every(isString) ? config.effectFn.map((_) => _.toLowerCase()) : defaults.effectFn,
1684
+ effectFn: isObject(config) && hasProperty(config, "effectFn") && isArray(config.effectFn) && config.effectFn.every(isString) ? config.effectFn.map(
1685
+ (_) => _.toLowerCase()
1686
+ ) : defaults.effectFn,
1694
1687
  layerGraphFollowDepth: isObject(config) && hasProperty(config, "layerGraphFollowDepth") && isNumber(config.layerGraphFollowDepth) ? config.layerGraphFollowDepth : defaults.layerGraphFollowDepth,
1695
1688
  mermaidProvider: isObject(config) && hasProperty(config, "mermaidProvider") && isString(config.mermaidProvider) ? config.mermaidProvider : defaults.mermaidProvider
1696
1689
  };
@@ -3377,6 +3370,14 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3377
3370
  const layerType = cachedBy(
3378
3371
  fn("TypeParser.layerType")(function* (type, atLocation) {
3379
3372
  yield* pipeableType(type, atLocation);
3373
+ if (supportedEffect() === "v4") {
3374
+ const typeIdSymbol = typeChecker.getPropertyOfType(type, "~effect/Layer");
3375
+ if (typeIdSymbol) {
3376
+ const typeIdType = typeChecker.getTypeOfSymbolAtLocation(typeIdSymbol, atLocation);
3377
+ return yield* layerVarianceStruct(typeIdType, atLocation);
3378
+ }
3379
+ return yield* typeParserIssue("Type is not a layer", type, atLocation);
3380
+ }
3380
3381
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
3381
3382
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration
3382
3383
  );
@@ -3426,6 +3427,34 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
3426
3427
  "TypeParser.effectSubtype",
3427
3428
  (type) => type
3428
3429
  );
3430
+ const effectYieldableType = cachedBy(
3431
+ fn("TypeParser.effectYieldableType")(function* (type, atLocation) {
3432
+ if (supportedEffect() === "v3") {
3433
+ return yield* effectType(type, atLocation);
3434
+ }
3435
+ return yield* firstSuccessOf([
3436
+ effectType(type, atLocation),
3437
+ gen(function* () {
3438
+ const asEffectSymbol = typeChecker.getPropertyOfType(type, "asEffect");
3439
+ if (!asEffectSymbol) {
3440
+ return yield* typeParserIssue("Type has no 'asEffect' property", type, atLocation);
3441
+ }
3442
+ const asEffectType = typeChecker.getTypeOfSymbolAtLocation(asEffectSymbol, atLocation);
3443
+ const asEffectSignatures = typeChecker.getSignaturesOfType(asEffectType, ts.SignatureKind.Call);
3444
+ if (asEffectSignatures.length === 0) {
3445
+ return yield* typeParserIssue("'asEffect' property is not callable", type, atLocation);
3446
+ }
3447
+ return yield* firstSuccessOf(
3448
+ asEffectSignatures.map(
3449
+ (signature) => effectType(typeChecker.getReturnTypeOfSignature(signature), atLocation)
3450
+ )
3451
+ );
3452
+ })
3453
+ ]);
3454
+ }),
3455
+ "TypeParser.effectYieldableType",
3456
+ (type) => type
3457
+ );
3429
3458
  const isEffectContextSourceFile = cachedBy(
3430
3459
  fn("TypeParser.isEffectContextSourceFile")(function* (sourceFile) {
3431
3460
  const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
@@ -4604,6 +4633,73 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4604
4633
  "TypeParser.extendsEffectSqlModelClass",
4605
4634
  (atLocation) => atLocation
4606
4635
  );
4636
+ const isEffectSchemaModelTypeSourceFile = cachedBy(
4637
+ fn("TypeParser.isEffectSchemaModelTypeSourceFile")(function* (sourceFile) {
4638
+ const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
4639
+ if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
4640
+ const classSymbol = typeChecker.tryGetMemberInModuleExports("Class", moduleSymbol);
4641
+ if (!classSymbol) return yield* typeParserIssue("Model's Class type not found", void 0, sourceFile);
4642
+ const generatedSymbol = typeChecker.tryGetMemberInModuleExports("Generated", moduleSymbol);
4643
+ if (!generatedSymbol) {
4644
+ return yield* typeParserIssue("Model's Generated type not found", void 0, sourceFile);
4645
+ }
4646
+ const fieldOptionSymbol = typeChecker.tryGetMemberInModuleExports("FieldOption", moduleSymbol);
4647
+ if (!fieldOptionSymbol) {
4648
+ return yield* typeParserIssue("Model's FieldOption type not found", void 0, sourceFile);
4649
+ }
4650
+ return sourceFile;
4651
+ }),
4652
+ "TypeParser.isEffectSchemaModelTypeSourceFile",
4653
+ (sourceFile) => sourceFile
4654
+ );
4655
+ const isNodeReferenceToEffectSchemaModelModuleApi = (memberName) => cachedBy(
4656
+ fn("TypeParser.isNodeReferenceToEffectSchemaModelModuleApi")(function* (node) {
4657
+ return yield* isNodeReferenceToExportOfPackageModule(
4658
+ node,
4659
+ "effect",
4660
+ isEffectSchemaModelTypeSourceFile,
4661
+ memberName
4662
+ );
4663
+ }),
4664
+ `TypeParser.isNodeReferenceToEffectSchemaModelModuleApi(${memberName})`,
4665
+ (node) => node
4666
+ );
4667
+ const extendsEffectSchemaModelClass = cachedBy(
4668
+ fn("TypeParser.extendsEffectSchemaModelClass")(function* (atLocation) {
4669
+ if (!atLocation.name) {
4670
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
4671
+ }
4672
+ const heritageClauses = atLocation.heritageClauses;
4673
+ if (!heritageClauses) {
4674
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
4675
+ }
4676
+ for (const heritageClause of heritageClauses) {
4677
+ for (const typeX of heritageClause.types) {
4678
+ if (ts.isExpressionWithTypeArguments(typeX)) {
4679
+ const expression = typeX.expression;
4680
+ if (ts.isCallExpression(expression)) {
4681
+ const schemaCall = expression.expression;
4682
+ if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
4683
+ const isEffectSchemaModelModuleApi = yield* pipe(
4684
+ isNodeReferenceToEffectSchemaModelModuleApi("Class")(schemaCall.expression),
4685
+ orUndefined
4686
+ );
4687
+ if (isEffectSchemaModelModuleApi) {
4688
+ return {
4689
+ className: atLocation.name,
4690
+ selfTypeNode: schemaCall.typeArguments[0]
4691
+ };
4692
+ }
4693
+ }
4694
+ }
4695
+ }
4696
+ }
4697
+ }
4698
+ return yield* typeParserIssue("Class does not extend effect's Model.Class", void 0, atLocation);
4699
+ }),
4700
+ "TypeParser.extendsEffectSchemaModelClass",
4701
+ (atLocation) => atLocation
4702
+ );
4607
4703
  const isEffectLayerTypeSourceFile = cachedBy(
4608
4704
  fn("TypeParser.isEffectLayerTypeSourceFile")(function* (sourceFile) {
4609
4705
  const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
@@ -4976,6 +5072,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4976
5072
  isNodeReferenceToEffectDataModuleApi,
4977
5073
  isNodeReferenceToEffectContextModuleApi,
4978
5074
  isNodeReferenceToEffectSqlModelModuleApi,
5075
+ isNodeReferenceToEffectSchemaModelModuleApi,
4979
5076
  isNodeReferenceToEffectLayerModuleApi,
4980
5077
  isNodeReferenceToEffectSchemaParserModuleApi,
4981
5078
  isServiceMapTypeSourceFile,
@@ -4985,6 +5082,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4985
5082
  layerType,
4986
5083
  fiberType,
4987
5084
  effectSubtype,
5085
+ effectYieldableType,
4988
5086
  importedEffectModule,
4989
5087
  effectGen,
4990
5088
  effectFnUntracedGen,
@@ -5013,6 +5111,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
5013
5111
  extendsSchemaTaggedRequest,
5014
5112
  extendsSchemaRequestClass,
5015
5113
  extendsEffectSqlModelClass,
5114
+ extendsEffectSchemaModelClass,
5016
5115
  lazyExpression,
5017
5116
  emptyFunction,
5018
5117
  pipingFlows,
@@ -5303,6 +5402,7 @@ var classSelfMismatch = createDiagnostic({
5303
5402
  )
5304
5403
  ),
5305
5404
  orElse2(() => typeParser.extendsEffectSqlModelClass(node)),
5405
+ orElse2(() => typeParser.extendsEffectSchemaModelClass(node)),
5306
5406
  orElse2(() => void_)
5307
5407
  );
5308
5408
  if (result) {
@@ -5695,16 +5795,16 @@ var effectFnOpportunity = createDiagnostic({
5695
5795
  if (ts.isFunctionDeclaration(node) && node.name) {
5696
5796
  return node.name;
5697
5797
  }
5698
- if (node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {
5798
+ if (node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && node.parent.initializer === node) {
5699
5799
  return node.parent.name;
5700
5800
  }
5701
- if (node.parent && ts.isPropertyAssignment(node.parent)) {
5801
+ if (node.parent && ts.isPropertyAssignment(node.parent) && node.parent.initializer === node) {
5702
5802
  const name = node.parent.name;
5703
5803
  if (ts.isIdentifier(name) || ts.isStringLiteral(name)) {
5704
5804
  return name;
5705
5805
  }
5706
5806
  }
5707
- if (node.parent && ts.isPropertyDeclaration(node.parent)) {
5807
+ if (node.parent && ts.isPropertyDeclaration(node.parent) && node.parent.initializer === node) {
5708
5808
  const name = node.parent.name;
5709
5809
  if (ts.isIdentifier(name)) {
5710
5810
  return name;
@@ -5712,6 +5812,190 @@ var effectFnOpportunity = createDiagnostic({
5712
5812
  }
5713
5813
  return void 0;
5714
5814
  };
5815
+ const hasExportModifier = (node) => {
5816
+ if (!ts.canHaveModifiers(node)) return false;
5817
+ const modifiers = ts.getModifiers(node);
5818
+ return modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
5819
+ };
5820
+ const layerServiceNameFromExpression = (expression) => {
5821
+ if (expression.kind === ts.SyntaxKind.ThisKeyword) {
5822
+ const enclosingClass = ts.findAncestor(
5823
+ expression,
5824
+ (node) => ts.isClassDeclaration(node)
5825
+ );
5826
+ if (enclosingClass?.name) {
5827
+ return ts.idText(enclosingClass.name);
5828
+ }
5829
+ }
5830
+ if (ts.isIdentifier(expression)) return ts.idText(expression);
5831
+ return sourceFile.text.slice(expression.pos, expression.end).trim();
5832
+ };
5833
+ const tryGetLayerApiMethod = (node) => pipe(
5834
+ typeParser.isNodeReferenceToEffectLayerModuleApi("effect")(node),
5835
+ map4(() => "effect"),
5836
+ orElse2(
5837
+ () => pipe(
5838
+ typeParser.isNodeReferenceToEffectLayerModuleApi("succeed")(node),
5839
+ map4(() => "succeed"),
5840
+ orElse2(
5841
+ () => pipe(
5842
+ typeParser.isNodeReferenceToEffectLayerModuleApi("sync")(node),
5843
+ map4(() => "sync"),
5844
+ orElse2(() => succeed3(void 0))
5845
+ )
5846
+ )
5847
+ )
5848
+ )
5849
+ );
5850
+ const verifyLayerMethodAtCall = fn("effectFnOpportunity.verifyLayerMethodAtCall")(
5851
+ function* (callExpression, method, implementationExpression) {
5852
+ const directMethod = yield* tryGetLayerApiMethod(callExpression.expression);
5853
+ if (directMethod === method && callExpression.arguments.length >= 2 && callExpression.arguments[1] === implementationExpression) {
5854
+ return layerServiceNameFromExpression(callExpression.arguments[0]);
5855
+ }
5856
+ if (ts.isCallExpression(callExpression.expression)) {
5857
+ const innerCall = callExpression.expression;
5858
+ const innerMethod = yield* tryGetLayerApiMethod(innerCall.expression);
5859
+ if (innerMethod === method && innerCall.arguments.length >= 1 && callExpression.arguments.length >= 1 && callExpression.arguments[0] === implementationExpression) {
5860
+ return layerServiceNameFromExpression(innerCall.arguments[0]);
5861
+ }
5862
+ }
5863
+ return void 0;
5864
+ }
5865
+ );
5866
+ const tryMatchLayerSucceedInference = fn("effectFnOpportunity.tryMatchLayerSucceedInference")(
5867
+ function* (objectLiteral) {
5868
+ const callExpression = objectLiteral.parent;
5869
+ if (!callExpression || !ts.isCallExpression(callExpression)) return void 0;
5870
+ return yield* verifyLayerMethodAtCall(callExpression, "succeed", objectLiteral);
5871
+ }
5872
+ );
5873
+ const tryMatchLayerSyncInference = fn("effectFnOpportunity.tryMatchLayerSyncInference")(
5874
+ function* (objectLiteral) {
5875
+ const returnStatement = objectLiteral.parent;
5876
+ if (!returnStatement || !ts.isReturnStatement(returnStatement)) return void 0;
5877
+ const functionBody = returnStatement.parent;
5878
+ if (!functionBody || !ts.isBlock(functionBody)) return void 0;
5879
+ const lazyFunction = functionBody.parent;
5880
+ if (!lazyFunction || !ts.isArrowFunction(lazyFunction) && !ts.isFunctionExpression(lazyFunction)) {
5881
+ return void 0;
5882
+ }
5883
+ const callExpression = lazyFunction.parent;
5884
+ if (!callExpression || !ts.isCallExpression(callExpression)) return void 0;
5885
+ return yield* verifyLayerMethodAtCall(callExpression, "sync", lazyFunction);
5886
+ }
5887
+ );
5888
+ const tryMatchLayerEffectInference = fn("effectFnOpportunity.tryMatchLayerEffectInference")(
5889
+ function* (objectLiteral) {
5890
+ const returnStatement = objectLiteral.parent;
5891
+ if (!returnStatement || !ts.isReturnStatement(returnStatement)) return void 0;
5892
+ const generatorBody = returnStatement.parent;
5893
+ if (!generatorBody || !ts.isBlock(generatorBody)) return void 0;
5894
+ const generatorFunction = generatorBody.parent;
5895
+ if (!generatorFunction || !ts.isFunctionExpression(generatorFunction) || !generatorFunction.asteriskToken) {
5896
+ return void 0;
5897
+ }
5898
+ const genCall = generatorFunction.parent;
5899
+ if (!genCall || !ts.isCallExpression(genCall)) return void 0;
5900
+ const parsedEffectGen = yield* option(typeParser.effectGen(genCall));
5901
+ if (parsedEffectGen._tag === "None" || parsedEffectGen.value.generatorFunction !== generatorFunction) {
5902
+ return void 0;
5903
+ }
5904
+ const layerCall = genCall.parent;
5905
+ if (!layerCall || !ts.isCallExpression(layerCall)) return void 0;
5906
+ return yield* verifyLayerMethodAtCall(layerCall, "effect", genCall);
5907
+ }
5908
+ );
5909
+ const tryMatchOfInference = fn("effectFnOpportunity.tryMatchOfInference")(
5910
+ function* (objectLiteral) {
5911
+ const callExpression = objectLiteral.parent;
5912
+ if (!callExpression || !ts.isCallExpression(callExpression)) return void 0;
5913
+ if (callExpression.arguments.length < 1 || callExpression.arguments[0] !== objectLiteral) return void 0;
5914
+ if (!ts.isPropertyAccessExpression(callExpression.expression)) return void 0;
5915
+ if (ts.idText(callExpression.expression.name) !== "of") return void 0;
5916
+ const serviceTagExpression = callExpression.expression.expression;
5917
+ const serviceTagType = typeCheckerUtils.getTypeAtLocation(serviceTagExpression);
5918
+ if (!serviceTagType) return void 0;
5919
+ const isTagLike = yield* pipe(
5920
+ typeParser.contextTag(serviceTagType, serviceTagExpression),
5921
+ orElse2(() => typeParser.serviceType(serviceTagType, serviceTagExpression)),
5922
+ option
5923
+ );
5924
+ if (isTagLike._tag === "None") return void 0;
5925
+ return layerServiceNameFromExpression(serviceTagExpression);
5926
+ }
5927
+ );
5928
+ const tryMatchServiceMapMakeInference = fn("effectFnOpportunity.tryMatchServiceMapMakeInference")(
5929
+ function* (objectLiteral) {
5930
+ const returnStatement = objectLiteral.parent;
5931
+ if (!returnStatement || !ts.isReturnStatement(returnStatement)) return void 0;
5932
+ const generatorBody = returnStatement.parent;
5933
+ if (!generatorBody || !ts.isBlock(generatorBody)) return void 0;
5934
+ const generatorFunction = generatorBody.parent;
5935
+ if (!generatorFunction || !ts.isFunctionExpression(generatorFunction) || !generatorFunction.asteriskToken) {
5936
+ return void 0;
5937
+ }
5938
+ const genCall = generatorFunction.parent;
5939
+ if (!genCall || !ts.isCallExpression(genCall)) return void 0;
5940
+ const parsedEffectGen = yield* option(typeParser.effectGen(genCall));
5941
+ if (parsedEffectGen._tag === "None" || parsedEffectGen.value.generatorFunction !== generatorFunction) {
5942
+ return void 0;
5943
+ }
5944
+ const makeProperty = genCall.parent;
5945
+ if (!makeProperty || !ts.isPropertyAssignment(makeProperty)) return void 0;
5946
+ if (makeProperty.initializer !== genCall) return void 0;
5947
+ if (!ts.isIdentifier(makeProperty.name) || ts.idText(makeProperty.name) !== "make") return void 0;
5948
+ let currentNode = makeProperty.parent;
5949
+ let classDeclaration = void 0;
5950
+ while (currentNode) {
5951
+ if (ts.isClassDeclaration(currentNode)) {
5952
+ classDeclaration = currentNode;
5953
+ break;
5954
+ }
5955
+ currentNode = currentNode.parent;
5956
+ }
5957
+ if (!classDeclaration || !classDeclaration.name) return void 0;
5958
+ const parsedServiceMapService = yield* option(typeParser.extendsServiceMapService(classDeclaration));
5959
+ if (parsedServiceMapService._tag === "None") return void 0;
5960
+ return ts.idText(classDeclaration.name);
5961
+ }
5962
+ );
5963
+ const tryGetLayerInferredTraceName = fn("effectFnOpportunity.tryGetLayerInferredTraceName")(
5964
+ function* (node, suggestedTraceName) {
5965
+ if (!suggestedTraceName) return void 0;
5966
+ if (!(node.parent && ts.isPropertyAssignment(node.parent) && node.parent.initializer === node && node.parent.parent && ts.isObjectLiteralExpression(node.parent.parent))) {
5967
+ return void 0;
5968
+ }
5969
+ const objectLiteral = node.parent.parent;
5970
+ const succeedServiceName = yield* tryMatchLayerSucceedInference(objectLiteral);
5971
+ if (succeedServiceName) return `${succeedServiceName}.${suggestedTraceName}`;
5972
+ const syncServiceName = yield* tryMatchLayerSyncInference(objectLiteral);
5973
+ if (syncServiceName) return `${syncServiceName}.${suggestedTraceName}`;
5974
+ const effectServiceName = yield* tryMatchLayerEffectInference(objectLiteral);
5975
+ if (effectServiceName) return `${effectServiceName}.${suggestedTraceName}`;
5976
+ const ofServiceName = yield* tryMatchOfInference(objectLiteral);
5977
+ if (ofServiceName) return `${ofServiceName}.${suggestedTraceName}`;
5978
+ const serviceMapMakeServiceName = yield* tryMatchServiceMapMakeInference(objectLiteral);
5979
+ return serviceMapMakeServiceName ? `${serviceMapMakeServiceName}.${suggestedTraceName}` : void 0;
5980
+ }
5981
+ );
5982
+ const getInferredTraceName = fn("effectFnOpportunity.getInferredTraceName")(
5983
+ function* (node, suggestedTraceName) {
5984
+ const inferredFromLayer = yield* tryGetLayerInferredTraceName(node, suggestedTraceName);
5985
+ if (inferredFromLayer) return inferredFromLayer;
5986
+ if (ts.isFunctionDeclaration(node) && node.name && hasExportModifier(node)) {
5987
+ return ts.idText(node.name);
5988
+ }
5989
+ if (node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && node.parent.initializer === node) {
5990
+ const variableDeclarationList = node.parent.parent;
5991
+ const variableStatement = variableDeclarationList?.parent;
5992
+ if (variableDeclarationList && ts.isVariableDeclarationList(variableDeclarationList) && variableStatement && ts.isVariableStatement(variableStatement) && hasExportModifier(variableStatement) && (variableDeclarationList.flags & ts.NodeFlags.Const) !== 0) {
5993
+ return ts.idText(node.parent.name);
5994
+ }
5995
+ }
5996
+ return void 0;
5997
+ }
5998
+ );
5715
5999
  const areParametersReferencedIn = (fnNode, nodes) => {
5716
6000
  if (fnNode.parameters.length === 0 || nodes.length === 0) return false;
5717
6001
  const firstParam = fnNode.parameters[0];
@@ -5796,7 +6080,10 @@ var effectFnOpportunity = createDiagnostic({
5796
6080
  );
5797
6081
  };
5798
6082
  const parseEffectFnOpportunityTargetGen = fn("effectFnOpportunity.parseEffectFnOpportunityTarget")(
5799
- function* (node, returnType, traceName, nameIdentifier) {
6083
+ function* (node, returnType, nameIdentifier) {
6084
+ const suggestedTraceName = nameIdentifier ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text : void 0;
6085
+ const inferredTraceName = yield* getInferredTraceName(node, suggestedTraceName);
6086
+ const hasStrictLayerInferredName = inferredTraceName !== void 0 && inferredTraceName !== suggestedTraceName;
5800
6087
  if (yield* isInsideEffectFn(node)) {
5801
6088
  return yield* TypeParserIssue.issue;
5802
6089
  }
@@ -5805,11 +6092,11 @@ var effectFnOpportunity = createDiagnostic({
5805
6092
  const opportunity = yield* pipe(
5806
6093
  tryParseGenOpportunity(node),
5807
6094
  orElse2(() => {
5808
- if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
6095
+ if (ts.isArrowFunction(node) && !ts.isBlock(node.body) && !hasStrictLayerInferredName) {
5809
6096
  return TypeParserIssue.issue;
5810
6097
  }
5811
6098
  const body = ts.isArrowFunction(node) ? node.body : node.body;
5812
- if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
6099
+ if ((!body || !ts.isBlock(body) || body.statements.length <= 5) && !hasStrictLayerInferredName) {
5813
6100
  return TypeParserIssue.issue;
5814
6101
  }
5815
6102
  return succeed3({
@@ -5824,7 +6111,8 @@ var effectFnOpportunity = createDiagnostic({
5824
6111
  node,
5825
6112
  nameIdentifier,
5826
6113
  effectModuleName: opportunity.effectModuleName,
5827
- inferredTraceName: traceName,
6114
+ inferredTraceName,
6115
+ suggestedTraceName,
5828
6116
  explicitTraceExpression: opportunity.explicitTraceExpression,
5829
6117
  pipeArguments: opportunity.pipeArguments,
5830
6118
  generatorFunction: opportunity.generatorFunction,
@@ -5834,27 +6122,26 @@ var effectFnOpportunity = createDiagnostic({
5834
6122
  );
5835
6123
  const parseEffectFnOpportunityTarget = (node) => {
5836
6124
  if (!ts.isFunctionExpression(node) && !ts.isArrowFunction(node) && !ts.isFunctionDeclaration(node)) {
5837
- return TypeParserIssue.issue;
6125
+ return;
5838
6126
  }
5839
6127
  if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) {
5840
- return TypeParserIssue.issue;
6128
+ return;
5841
6129
  }
5842
6130
  if (ts.isFunctionExpression(node) && node.name) {
5843
- return TypeParserIssue.issue;
6131
+ return;
5844
6132
  }
5845
6133
  if (node.type) {
5846
- return TypeParserIssue.issue;
6134
+ return;
5847
6135
  }
5848
6136
  const functionType = typeChecker.getTypeAtLocation(node);
5849
- if (!functionType) return TypeParserIssue.issue;
6137
+ if (!functionType) return;
5850
6138
  const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call);
5851
- if (callSignatures.length !== 1) return TypeParserIssue.issue;
6139
+ if (callSignatures.length !== 1) return;
5852
6140
  const signature = callSignatures[0];
5853
6141
  const returnType = typeChecker.getReturnTypeOfSignature(signature);
5854
6142
  const nameIdentifier = getNameIdentifier(node);
5855
- const traceName = nameIdentifier ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text : void 0;
5856
- if (!traceName) return TypeParserIssue.issue;
5857
- return parseEffectFnOpportunityTargetGen(node, returnType, traceName, nameIdentifier);
6143
+ if (!nameIdentifier) return;
6144
+ return parseEffectFnOpportunityTargetGen(node, returnType, nameIdentifier);
5858
6145
  };
5859
6146
  const getFunctionBodyBlock = (node) => {
5860
6147
  if (ts.isArrowFunction(node)) {
@@ -5928,18 +6215,21 @@ var effectFnOpportunity = createDiagnostic({
5928
6215
  while (nodeToVisit.length > 0) {
5929
6216
  const node = nodeToVisit.shift();
5930
6217
  ts.forEachChild(node, appendNodeToVisit);
5931
- const target = yield* pipe(parseEffectFnOpportunityTarget(node), option);
5932
- if (isNone2(target)) continue;
5933
- if (target.value.hasParamsInPipeArgs) continue;
6218
+ const test = parseEffectFnOpportunityTarget(node);
6219
+ if (!test) continue;
6220
+ const target = yield* orUndefined(test);
6221
+ if (!target) continue;
6222
+ if (target.hasParamsInPipeArgs) continue;
5934
6223
  const {
5935
6224
  effectModuleName,
5936
6225
  explicitTraceExpression,
5937
6226
  inferredTraceName,
5938
6227
  nameIdentifier,
5939
6228
  node: targetNode,
5940
- pipeArguments: pipeArguments2
5941
- } = target.value;
5942
- const innerFunction = target.value.generatorFunction ?? targetNode;
6229
+ pipeArguments: pipeArguments2,
6230
+ suggestedTraceName
6231
+ } = target;
6232
+ const innerFunction = target.generatorFunction ?? targetNode;
5943
6233
  const fixes = [];
5944
6234
  if (pluginOptions.effectFn.includes("span") && explicitTraceExpression) {
5945
6235
  fixes.push({
@@ -5959,7 +6249,7 @@ var effectFnOpportunity = createDiagnostic({
5959
6249
  })
5960
6250
  });
5961
6251
  }
5962
- if (pluginOptions.effectFn.includes("untraced") && target.value.generatorFunction) {
6252
+ if (pluginOptions.effectFn.includes("untraced") && target.generatorFunction) {
5963
6253
  fixes.push({
5964
6254
  fixName: "effectFnOpportunity_toEffectFnUntraced",
5965
6255
  description: "Convert to Effect.fnUntraced",
@@ -5981,22 +6271,41 @@ var effectFnOpportunity = createDiagnostic({
5981
6271
  })
5982
6272
  });
5983
6273
  }
5984
- if (pluginOptions.effectFn.includes("inferred-span") && inferredTraceName && !explicitTraceExpression) {
5985
- fixes.push({
5986
- fixName: "effectFnOpportunity_toEffectFnSpanInferred",
5987
- description: `Convert to Effect.fn("${inferredTraceName}")`,
5988
- apply: gen(function* () {
5989
- const changeTracker = yield* service(ChangeTracker);
5990
- const newNode = createEffectFnNode(
5991
- targetNode,
5992
- innerFunction,
5993
- effectModuleName,
5994
- inferredTraceName,
5995
- pipeArguments2
5996
- );
5997
- changeTracker.replaceNode(sourceFile, targetNode, newNode);
5998
- })
5999
- });
6274
+ if (!explicitTraceExpression) {
6275
+ if (pluginOptions.effectFn.includes("inferred-span") && inferredTraceName) {
6276
+ fixes.push({
6277
+ fixName: "effectFnOpportunity_toEffectFnSpanInferred",
6278
+ description: `Convert to Effect.fn("${inferredTraceName}")`,
6279
+ apply: gen(function* () {
6280
+ const changeTracker = yield* service(ChangeTracker);
6281
+ const newNode = createEffectFnNode(
6282
+ targetNode,
6283
+ innerFunction,
6284
+ effectModuleName,
6285
+ inferredTraceName,
6286
+ pipeArguments2
6287
+ );
6288
+ changeTracker.replaceNode(sourceFile, targetNode, newNode);
6289
+ })
6290
+ });
6291
+ }
6292
+ if (pluginOptions.effectFn.includes("suggested-span") && suggestedTraceName && (!pluginOptions.effectFn.includes("inferred-span") || suggestedTraceName !== inferredTraceName)) {
6293
+ fixes.push({
6294
+ fixName: "effectFnOpportunity_toEffectFnSpanSuggested",
6295
+ description: `Convert to Effect.fn("${suggestedTraceName}")`,
6296
+ apply: gen(function* () {
6297
+ const changeTracker = yield* service(ChangeTracker);
6298
+ const newNode = createEffectFnNode(
6299
+ targetNode,
6300
+ innerFunction,
6301
+ effectModuleName,
6302
+ suggestedTraceName,
6303
+ pipeArguments2
6304
+ );
6305
+ changeTracker.replaceNode(sourceFile, targetNode, newNode);
6306
+ })
6307
+ });
6308
+ }
6000
6309
  }
6001
6310
  if (fixes.length === 0) continue;
6002
6311
  const generateExpectedSignature = () => {
@@ -6009,7 +6318,7 @@ var effectFnOpportunity = createDiagnostic({
6009
6318
  }
6010
6319
  return "_";
6011
6320
  }).join(", ");
6012
- const fnSignature = `function*${typeParamNames}(${paramNames}) { ... }`;
6321
+ const fnSignature = ts.isArrowFunction(innerFunction) ? `${typeParamNames}(${paramNames}) => { ... }` : isGeneratorFunction(innerFunction) ? `function*${typeParamNames}(${paramNames}) { ... }` : `function${typeParamNames}(${paramNames}) { ... }`;
6013
6322
  const pipeArgsForWithSpan = pipeArguments2.slice(0, -1);
6014
6323
  const pipeArgsSuffix = (args3) => args3.length > 0 ? ", ...pipeTransformations" : "";
6015
6324
  switch (firstFix.fixName) {
@@ -6023,6 +6332,8 @@ var effectFnOpportunity = createDiagnostic({
6023
6332
  return `${effectModuleName}.fn(${fnSignature}${pipeArgsSuffix(pipeArguments2)})`;
6024
6333
  case "effectFnOpportunity_toEffectFnSpanInferred":
6025
6334
  return `${effectModuleName}.fn("${inferredTraceName}")(${fnSignature}${pipeArgsSuffix(pipeArguments2)})`;
6335
+ case "effectFnOpportunity_toEffectFnSpanSuggested":
6336
+ return `${effectModuleName}.fn("${suggestedTraceName}")(${fnSignature}${pipeArgsSuffix(pipeArguments2)})`;
6026
6337
  default:
6027
6338
  return `${effectModuleName}.fn(${fnSignature})`;
6028
6339
  }
@@ -6075,6 +6386,70 @@ var effectGenUsesAdapter = createDiagnostic({
6075
6386
  })
6076
6387
  });
6077
6388
 
6389
+ // src/diagnostics/effectInFailure.ts
6390
+ var effectInFailure = createDiagnostic({
6391
+ name: "effectInFailure",
6392
+ code: 49,
6393
+ description: "Warns when an Effect is used inside an Effect failure channel",
6394
+ severity: "warning",
6395
+ apply: fn("effectInFailure.apply")(function* (sourceFile, report) {
6396
+ const ts = yield* service(TypeScriptApi);
6397
+ const typeChecker = yield* service(TypeCheckerApi);
6398
+ const typeParser = yield* service(TypeParser);
6399
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
6400
+ const isStrictEffectType = cachedBy(
6401
+ fn("effectInFailure.isStrictEffectType")(function* (type, atLocation) {
6402
+ yield* typeParser.strictEffectType(type, atLocation);
6403
+ return true;
6404
+ }),
6405
+ "effectInFailure.isStrictEffectType",
6406
+ (type) => type
6407
+ );
6408
+ const visited = /* @__PURE__ */ new WeakSet();
6409
+ const stack = [sourceFile];
6410
+ const shouldSkipBecauseChildMatched = /* @__PURE__ */ new WeakSet();
6411
+ while (stack.length > 0) {
6412
+ const node = stack.pop();
6413
+ if (!visited.has(node)) {
6414
+ visited.add(node);
6415
+ stack.push(node);
6416
+ ts.forEachChild(node, (child) => {
6417
+ stack.push(child);
6418
+ return void 0;
6419
+ });
6420
+ continue;
6421
+ }
6422
+ if (shouldSkipBecauseChildMatched.has(node)) {
6423
+ if (node.parent) shouldSkipBecauseChildMatched.add(node.parent);
6424
+ continue;
6425
+ }
6426
+ const type = typeCheckerUtils.getTypeAtLocation(node);
6427
+ if (!type) continue;
6428
+ const effect = yield* orUndefined(typeParser.strictEffectType(type, node));
6429
+ if (!effect) continue;
6430
+ const failureMembers = typeCheckerUtils.unrollUnionMembers(effect.E);
6431
+ let memberWithEffect = void 0;
6432
+ for (const member of failureMembers) {
6433
+ const isMemberEffect = yield* orUndefined(isStrictEffectType(member, node));
6434
+ if (isMemberEffect) {
6435
+ memberWithEffect = member;
6436
+ break;
6437
+ }
6438
+ }
6439
+ if (!memberWithEffect) continue;
6440
+ const messageText = `The error channel contains an Effect (${typeChecker.typeToString(memberWithEffect)}). Putting Effect computations in the failure channel is not intended; keep only failure types there.`;
6441
+ report({
6442
+ location: node,
6443
+ messageText,
6444
+ fixes: []
6445
+ });
6446
+ if (node.parent) {
6447
+ shouldSkipBecauseChildMatched.add(node.parent);
6448
+ }
6449
+ }
6450
+ })
6451
+ });
6452
+
6078
6453
  // src/diagnostics/effectInVoidSuccess.ts
6079
6454
  var effectInVoidSuccess = createDiagnostic({
6080
6455
  name: "effectInVoidSuccess",
@@ -7443,6 +7818,7 @@ var missingReturnYieldStar = createDiagnostic({
7443
7818
  const ts = yield* service(TypeScriptApi);
7444
7819
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
7445
7820
  const typeParser = yield* service(TypeParser);
7821
+ const tsUtils = yield* service(TypeScriptUtils);
7446
7822
  const nodeToVisit = [];
7447
7823
  const appendNodeToVisit = (node) => {
7448
7824
  nodeToVisit.push(node);
@@ -7452,50 +7828,32 @@ var missingReturnYieldStar = createDiagnostic({
7452
7828
  while (nodeToVisit.length > 0) {
7453
7829
  const node = nodeToVisit.shift();
7454
7830
  ts.forEachChild(node, appendNodeToVisit);
7455
- if (ts.isYieldExpression(node) && node.expression && node.asteriskToken) {
7456
- const type = typeCheckerUtils.getTypeAtLocation(node.expression);
7457
- if (type) {
7458
- const maybeEffect = yield* option(typeParser.effectType(type, node.expression));
7459
- if (isSome2(maybeEffect) && maybeEffect.value.A.flags & ts.TypeFlags.Never) {
7460
- const generatorFunctionOrReturnStatement = ts.findAncestor(
7461
- node,
7462
- (_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isReturnStatement(_) || ts.isThrowStatement(_)
7463
- );
7464
- if (generatorFunctionOrReturnStatement && !ts.isReturnStatement(generatorFunctionOrReturnStatement) && !ts.isThrowStatement(generatorFunctionOrReturnStatement)) {
7465
- if (generatorFunctionOrReturnStatement && generatorFunctionOrReturnStatement.parent) {
7466
- const effectGenNode = generatorFunctionOrReturnStatement.parent;
7467
- const effectGenLike = yield* pipe(
7468
- typeParser.effectGen(effectGenNode),
7469
- orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
7470
- orElse2(() => typeParser.effectFnGen(effectGenNode)),
7471
- option
7472
- );
7473
- if (isSome2(effectGenLike)) {
7474
- const fix = node.expression ? [{
7475
- fixName: "missingReturnYieldStar_fix",
7476
- description: "Add return statement",
7477
- apply: gen(function* () {
7478
- const changeTracker = yield* service(ChangeTracker);
7479
- changeTracker.replaceNode(
7480
- sourceFile,
7481
- node,
7482
- ts.factory.createReturnStatement(
7483
- node
7484
- )
7485
- );
7486
- })
7487
- }] : [];
7488
- report({
7489
- location: node,
7490
- messageText: `It is recommended to use return yield* for Effects that never succeed to signal a definitive exit point for type narrowing and tooling support.`,
7491
- fixes: fix
7492
- });
7493
- }
7494
- }
7495
- }
7496
- }
7497
- }
7498
- }
7831
+ if (!ts.isExpressionStatement(node)) continue;
7832
+ const unwrapped = tsUtils.skipOuterExpressions(node.expression);
7833
+ if (!ts.isYieldExpression(unwrapped) || !unwrapped.expression || !unwrapped.asteriskToken) continue;
7834
+ const type = typeCheckerUtils.getTypeAtLocation(unwrapped.expression);
7835
+ if (!type) continue;
7836
+ const maybeEffect = yield* option(typeParser.effectYieldableType(type, unwrapped.expression));
7837
+ if (!(isSome2(maybeEffect) && maybeEffect.value.A.flags & ts.TypeFlags.Never)) continue;
7838
+ const { effectGen, scopeNode } = yield* typeParser.findEnclosingScopes(node);
7839
+ if (!effectGen || scopeNode && scopeNode !== effectGen.generatorFunction) continue;
7840
+ const fix = [{
7841
+ fixName: "missingReturnYieldStar_fix",
7842
+ description: "Add return statement",
7843
+ apply: gen(function* () {
7844
+ const changeTracker = yield* service(ChangeTracker);
7845
+ changeTracker.replaceNode(
7846
+ sourceFile,
7847
+ node,
7848
+ ts.factory.createReturnStatement(node.expression)
7849
+ );
7850
+ })
7851
+ }];
7852
+ report({
7853
+ location: unwrapped,
7854
+ messageText: `It is recommended to use return yield* for Effects that never succeed to signal a definitive exit point for type narrowing and tooling support.`,
7855
+ fixes: fix
7856
+ });
7499
7857
  }
7500
7858
  })
7501
7859
  });
@@ -7761,6 +8119,761 @@ var nonObjectEffectServiceType = createDiagnostic({
7761
8119
  })
7762
8120
  });
7763
8121
 
8122
+ // src/diagnostics/outdatedApi.db.ts
8123
+ var asUnchanged = {
8124
+ _tag: "Unchanged"
8125
+ };
8126
+ var asRenamedSameBehaviour = (newName) => ({
8127
+ _tag: "RenamedSameBehaviour",
8128
+ newName
8129
+ });
8130
+ var asRenamedAndNeedsOptions = (newName, optionsInstructions) => ({
8131
+ _tag: "RenamedAndNeedsOptions",
8132
+ newName,
8133
+ optionsInstructions
8134
+ });
8135
+ var asRemoved = (alternativePattern) => ({
8136
+ _tag: "Removed",
8137
+ alternativePattern
8138
+ });
8139
+ var effectModuleMigrationDb = {
8140
+ // Common APIs (in both v3 and v4, unchanged)
8141
+ "acquireRelease": asUnchanged,
8142
+ "acquireUseRelease": asUnchanged,
8143
+ "addFinalizer": asUnchanged,
8144
+ "all": asUnchanged,
8145
+ "andThen": asUnchanged,
8146
+ "annotateCurrentSpan": asUnchanged,
8147
+ "annotateLogs": asUnchanged,
8148
+ "annotateSpans": asUnchanged,
8149
+ "as": asUnchanged,
8150
+ "asSome": asUnchanged,
8151
+ "asVoid": asUnchanged,
8152
+ "cached": asUnchanged,
8153
+ "cachedInvalidateWithTTL": asUnchanged,
8154
+ "cachedWithTTL": asUnchanged,
8155
+ "catch": asUnchanged,
8156
+ "catchIf": asUnchanged,
8157
+ "catchTag": asUnchanged,
8158
+ "catchTags": asUnchanged,
8159
+ "clockWith": asUnchanged,
8160
+ "currentParentSpan": asUnchanged,
8161
+ "currentSpan": asUnchanged,
8162
+ "delay": asUnchanged,
8163
+ "die": asUnchanged,
8164
+ "ensuring": asUnchanged,
8165
+ "eventually": asUnchanged,
8166
+ "exit": asUnchanged,
8167
+ "fail": asUnchanged,
8168
+ "failCause": asUnchanged,
8169
+ "failCauseSync": asUnchanged,
8170
+ "failSync": asUnchanged,
8171
+ "fiberId": asUnchanged,
8172
+ "filter": asUnchanged,
8173
+ "filterMap": asUnchanged,
8174
+ "filterOrElse": asUnchanged,
8175
+ "filterOrFail": asUnchanged,
8176
+ "flatMap": asUnchanged,
8177
+ "flatten": asUnchanged,
8178
+ "flip": asUnchanged,
8179
+ "fn": asUnchanged,
8180
+ "fnUntraced": asUnchanged,
8181
+ "forEach": asUnchanged,
8182
+ "forever": asUnchanged,
8183
+ "forkIn": asUnchanged,
8184
+ "forkScoped": asUnchanged,
8185
+ "gen": asUnchanged,
8186
+ "ignore": asUnchanged,
8187
+ "interrupt": asUnchanged,
8188
+ "interruptible": asUnchanged,
8189
+ "interruptibleMask": asUnchanged,
8190
+ "isEffect": asUnchanged,
8191
+ "isFailure": asUnchanged,
8192
+ "isSuccess": asUnchanged,
8193
+ "linkSpans": asUnchanged,
8194
+ "log": asUnchanged,
8195
+ "logDebug": asUnchanged,
8196
+ "logError": asUnchanged,
8197
+ "logFatal": asUnchanged,
8198
+ "logInfo": asUnchanged,
8199
+ "logTrace": asUnchanged,
8200
+ "logWarning": asUnchanged,
8201
+ "logWithLevel": asUnchanged,
8202
+ "makeLatch": asRemoved(
8203
+ "Use Latch.make instead of Effect.makeLatch."
8204
+ ),
8205
+ "makeSemaphore": asRemoved(
8206
+ "Use Semaphore.make instead of Effect.makeSemaphore."
8207
+ ),
8208
+ "makeSpan": asUnchanged,
8209
+ "makeSpanScoped": asUnchanged,
8210
+ "map": asUnchanged,
8211
+ "mapBoth": asUnchanged,
8212
+ "mapError": asUnchanged,
8213
+ "match": asUnchanged,
8214
+ "matchCause": asUnchanged,
8215
+ "matchCauseEffect": asUnchanged,
8216
+ "matchEffect": asUnchanged,
8217
+ "never": asUnchanged,
8218
+ "onError": asUnchanged,
8219
+ "onExit": asUnchanged,
8220
+ "onInterrupt": asUnchanged,
8221
+ "option": asUnchanged,
8222
+ "orDie": asUnchanged,
8223
+ "orElseSucceed": asUnchanged,
8224
+ "promise": asUnchanged,
8225
+ "provide": asUnchanged,
8226
+ "provideService": asUnchanged,
8227
+ "provideServiceEffect": asUnchanged,
8228
+ "race": asUnchanged,
8229
+ "raceAll": asUnchanged,
8230
+ "raceFirst": asUnchanged,
8231
+ "repeat": asUnchanged,
8232
+ "repeatOrElse": asUnchanged,
8233
+ "replicate": asUnchanged,
8234
+ "replicateEffect": asUnchanged,
8235
+ "request": asUnchanged,
8236
+ "retry": asUnchanged,
8237
+ "retryOrElse": asUnchanged,
8238
+ "runCallback": asUnchanged,
8239
+ "runFork": asUnchanged,
8240
+ "runPromise": asUnchanged,
8241
+ "runPromiseExit": asUnchanged,
8242
+ "runSync": asUnchanged,
8243
+ "runSyncExit": asUnchanged,
8244
+ "sandbox": asUnchanged,
8245
+ "schedule": asUnchanged,
8246
+ "scheduleFrom": asUnchanged,
8247
+ "scope": asUnchanged,
8248
+ "scoped": asUnchanged,
8249
+ "scopedWith": asUnchanged,
8250
+ "serviceOption": asUnchanged,
8251
+ "sleep": asUnchanged,
8252
+ "spanAnnotations": asUnchanged,
8253
+ "spanLinks": asUnchanged,
8254
+ "succeed": asUnchanged,
8255
+ "succeedNone": asUnchanged,
8256
+ "succeedSome": asUnchanged,
8257
+ "suspend": asUnchanged,
8258
+ "sync": asUnchanged,
8259
+ "tap": asUnchanged,
8260
+ "tapDefect": asUnchanged,
8261
+ "tapError": asUnchanged,
8262
+ "tapErrorTag": asUnchanged,
8263
+ "timed": asUnchanged,
8264
+ "timeout": asUnchanged,
8265
+ "timeoutOption": asUnchanged,
8266
+ "tracer": asUnchanged,
8267
+ "try": asUnchanged,
8268
+ "tryPromise": asUnchanged,
8269
+ "uninterruptible": asUnchanged,
8270
+ "uninterruptibleMask": asUnchanged,
8271
+ "updateService": asUnchanged,
8272
+ "useSpan": asUnchanged,
8273
+ "void": asUnchanged,
8274
+ "when": asUnchanged,
8275
+ "whileLoop": asUnchanged,
8276
+ "withConcurrency": asUnchanged,
8277
+ "withExecutionPlan": asUnchanged,
8278
+ "withLogSpan": asUnchanged,
8279
+ "withParentSpan": asUnchanged,
8280
+ "withSpan": asUnchanged,
8281
+ "withSpanScoped": asUnchanged,
8282
+ "withTracer": asUnchanged,
8283
+ "withTracerEnabled": asUnchanged,
8284
+ "withTracerTiming": asUnchanged,
8285
+ "yieldNow": asUnchanged,
8286
+ "zip": asUnchanged,
8287
+ "zipWith": asUnchanged,
8288
+ // Renamed APIs (v3 name → v4 name)
8289
+ "catchAll": asRenamedSameBehaviour("catch"),
8290
+ "catchAllCause": asRenamedSameBehaviour("catchCause"),
8291
+ "catchAllDefect": asRenamedSameBehaviour("catchDefect"),
8292
+ "catchSome": asRemoved(
8293
+ "Use Effect.catchIf instead. Note: the API shape changed from returning Option<Effect> to taking a predicate and handler separately."
8294
+ ),
8295
+ "catchSomeCause": asRemoved(
8296
+ "Use Effect.catchCauseIf instead. Note: the API shape changed from returning Option<Effect> to taking a predicate and handler separately."
8297
+ ),
8298
+ "ensureErrorType": asRenamedSameBehaviour("satisfiesErrorType"),
8299
+ "ensureRequirementsType": asRenamedSameBehaviour("satisfiesServicesType"),
8300
+ "ensureSuccessType": asRenamedSameBehaviour("satisfiesSuccessType"),
8301
+ "fork": asRenamedSameBehaviour("forkChild"),
8302
+ "forkDaemon": asRenamedSameBehaviour("forkDetach"),
8303
+ "scopeWith": asRenamedSameBehaviour("scopedWith"),
8304
+ "serviceOptional": asRenamedSameBehaviour("serviceOption"),
8305
+ "tapErrorCause": asRenamedSameBehaviour("tapCause"),
8306
+ // Removed APIs
8307
+ "annotateLogsScoped": asUnchanged,
8308
+ "awaitAllChildren": asUnchanged,
8309
+ "bind": asUnchanged,
8310
+ "bindTo": asUnchanged,
8311
+ "Do": asUnchanged,
8312
+ "let": asUnchanged,
8313
+ "partition": asUnchanged,
8314
+ "validate": asUnchanged,
8315
+ "catchSomeDefect": asRemoved(
8316
+ "Use Effect.catchDefect or Effect.matchCause to handle specific defects."
8317
+ ),
8318
+ "forkAll": asRemoved(
8319
+ "Fork effects individually with Effect.forEach and Effect.forkChild, or use Effect.all with concurrency options."
8320
+ ),
8321
+ "forkWithErrorHandler": asRemoved(
8322
+ "Fork the effect with Effect.forkChild and observe the fiber result via Fiber.join or Fiber.await."
8323
+ ),
8324
+ "Tag": asRemoved(
8325
+ "Use ServiceMap.Service instead of Effect.Tag."
8326
+ ),
8327
+ "Service": asRemoved(
8328
+ "Use ServiceMap.Service instead of Effect.Service."
8329
+ ),
8330
+ "runtime": asRemoved(
8331
+ "Runtime has been removed in Effect v4. Use Effect.services to grab services and then run using Effect.runPromiseWith."
8332
+ ),
8333
+ "bindAll": asRemoved(
8334
+ "Use Effect.gen instead of Effect.bindAll."
8335
+ ),
8336
+ "EffectTypeId": asRemoved(
8337
+ "EffectTypeId has been removed in Effect v4."
8338
+ ),
8339
+ "acquireReleaseInterruptible": asRemoved(
8340
+ "Use Effect.acquireRelease instead."
8341
+ ),
8342
+ "allSuccesses": asRemoved(
8343
+ "Use Effect.all with the { mode: 'either' } option and filter successes."
8344
+ ),
8345
+ "allWith": asRemoved(
8346
+ "Use Effect.all with options instead."
8347
+ ),
8348
+ "allowInterrupt": asRemoved(
8349
+ "Use Effect.yieldNow instead."
8350
+ ),
8351
+ "ap": asRemoved(
8352
+ "Use Effect.map and Effect.flatMap to apply functions instead."
8353
+ ),
8354
+ "asSomeError": asRemoved(
8355
+ "Use Effect.mapError(Option.some) instead."
8356
+ ),
8357
+ "async": asRenamedAndNeedsOptions("callback", "Note: in v4 the callback receives a Scheduler as 'this' context."),
8358
+ "asyncEffect": asRemoved(
8359
+ "Use Effect.suspend combined with Effect.promise instead."
8360
+ ),
8361
+ "blocked": asRemoved(
8362
+ "The request batching API has been reworked in Effect v4."
8363
+ ),
8364
+ "cacheRequestResult": asRemoved(
8365
+ "The request batching API has been reworked in Effect v4."
8366
+ ),
8367
+ "cachedFunction": asRemoved(
8368
+ "Use Effect.cached or implement caching with a Ref instead."
8369
+ ),
8370
+ "cause": asRemoved(
8371
+ "Use Effect.matchCause or Effect.sandbox to access the cause."
8372
+ ),
8373
+ "checkInterruptible": asRemoved(
8374
+ "Interruption checking has been removed in Effect v4."
8375
+ ),
8376
+ "clock": asRemoved(
8377
+ "Use Effect.clockWith instead."
8378
+ ),
8379
+ "configProviderWith": asRemoved(
8380
+ "ConfigProvider access has been reworked in Effect v4."
8381
+ ),
8382
+ "console": asRemoved(
8383
+ "Use Effect.consoleWith or the Console service directly."
8384
+ ),
8385
+ "consoleWith": asRemoved(
8386
+ "Console access has been reworked in Effect v4."
8387
+ ),
8388
+ "context": asRemoved(
8389
+ "Use Effect.context is removed. Access services directly via yield* or Effect.provideService."
8390
+ ),
8391
+ "contextWith": asRemoved(
8392
+ "Use Effect.map with service access instead."
8393
+ ),
8394
+ "contextWithEffect": asRemoved(
8395
+ "Use Effect.flatMap with service access instead."
8396
+ ),
8397
+ "custom": asRemoved(
8398
+ "Use Effect.suspend or Effect.sync to create custom effects."
8399
+ ),
8400
+ "daemonChildren": asRemoved(
8401
+ "Use Effect.forkDetach to fork detached fibers instead."
8402
+ ),
8403
+ "descriptor": asRemoved(
8404
+ "Fiber descriptor access has been removed in Effect v4."
8405
+ ),
8406
+ "descriptorWith": asRemoved(
8407
+ "Fiber descriptor access has been removed in Effect v4."
8408
+ ),
8409
+ "dieMessage": asRemoved(
8410
+ "Use Effect.die(new Error(message)) instead."
8411
+ ),
8412
+ "dieSync": asRemoved(
8413
+ "Use Effect.die with a lazily evaluated value instead."
8414
+ ),
8415
+ "diffFiberRefs": asRemoved(
8416
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8417
+ ),
8418
+ "disconnect": asRemoved(
8419
+ "Fiber disconnect has been removed in Effect v4."
8420
+ ),
8421
+ "dropUntil": asRemoved(
8422
+ "Use Array.dropUntil and Effect.forEach instead."
8423
+ ),
8424
+ "dropWhile": asRemoved(
8425
+ "Use Array.dropWhile and Effect.forEach instead."
8426
+ ),
8427
+ "either": asRenamedAndNeedsOptions(
8428
+ "result",
8429
+ "Note: returns Result.Result<A, E> instead of Either<E, A>. Use the Result module to work with the result."
8430
+ ),
8431
+ "ensuringChild": asRemoved(
8432
+ "Use Effect.onExit to manage child fiber cleanup instead."
8433
+ ),
8434
+ "ensuringChildren": asRemoved(
8435
+ "Use Effect.onExit to manage child fiber cleanup instead."
8436
+ ),
8437
+ "every": asRemoved(
8438
+ "Use Effect.forEach with a predicate check instead."
8439
+ ),
8440
+ "exists": asRemoved(
8441
+ "Use Effect.forEach with a predicate check instead."
8442
+ ),
8443
+ "fiberIdWith": asRemoved(
8444
+ "Use Effect.fiberId instead."
8445
+ ),
8446
+ "filterEffectOrElse": asRemoved(
8447
+ "Use Effect.filterOrElse with an effectful predicate instead."
8448
+ ),
8449
+ "filterEffectOrFail": asRemoved(
8450
+ "Use Effect.filterOrFail with an effectful predicate instead."
8451
+ ),
8452
+ "filterOrDie": asRemoved(
8453
+ "Use Effect.filterOrFail and Effect.orDie instead."
8454
+ ),
8455
+ "filterOrDieMessage": asRemoved(
8456
+ "Use Effect.filterOrFail and Effect.orDie instead."
8457
+ ),
8458
+ "finalizersMask": asRemoved(
8459
+ "Finalizer masking has been removed in Effect v4."
8460
+ ),
8461
+ "findFirst": asUnchanged,
8462
+ "firstSuccessOf": asRemoved(
8463
+ "Use Effect.raceAll instead."
8464
+ ),
8465
+ "flipWith": asRemoved(
8466
+ "Use Effect.flip combined with the desired transformation instead."
8467
+ ),
8468
+ "fromFiber": asRemoved(
8469
+ "Use Fiber.join instead."
8470
+ ),
8471
+ "fromFiberEffect": asRemoved(
8472
+ "Use Effect.flatMap with Fiber.join instead."
8473
+ ),
8474
+ "fromNullable": asRemoved(
8475
+ "Use Effect.suspend with null checks instead."
8476
+ ),
8477
+ "functionWithSpan": asRemoved(
8478
+ "Use Effect.withSpan instead."
8479
+ ),
8480
+ "getFiberRefs": asRemoved(
8481
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8482
+ ),
8483
+ "getRuntimeFlags": asRemoved(
8484
+ "Runtime flags have been removed in Effect v4."
8485
+ ),
8486
+ "head": asRemoved(
8487
+ "Use Array.head and Effect.flatMap instead."
8488
+ ),
8489
+ "if": asRemoved(
8490
+ "Use Effect.when instead of Effect.if."
8491
+ ),
8492
+ "ignoreLogged": asRemoved(
8493
+ "Logging configuration has been reworked in Effect v4."
8494
+ ),
8495
+ "inheritFiberRefs": asRemoved(
8496
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8497
+ ),
8498
+ "interruptWith": asRemoved(
8499
+ "Use Effect.interrupt instead."
8500
+ ),
8501
+ "intoDeferred": asRemoved(
8502
+ "Use Deferred.complete instead."
8503
+ ),
8504
+ "iterate": asRemoved(
8505
+ "Use Effect.whileLoop or recursion with Effect.suspend instead."
8506
+ ),
8507
+ "labelMetrics": asRemoved(
8508
+ "Metric labeling has been reworked in Effect v4."
8509
+ ),
8510
+ "labelMetricsScoped": asRemoved(
8511
+ "Metric labeling has been reworked in Effect v4."
8512
+ ),
8513
+ "liftPredicate": asRemoved(
8514
+ "Use Effect.filterOrFail instead."
8515
+ ),
8516
+ "linkSpanCurrent": asRemoved(
8517
+ "Use Effect.linkSpans instead."
8518
+ ),
8519
+ "locally": asRemoved(
8520
+ "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead."
8521
+ ),
8522
+ "locallyScoped": asRemoved(
8523
+ "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead."
8524
+ ),
8525
+ "locallyScopedWith": asRemoved(
8526
+ "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead."
8527
+ ),
8528
+ "locallyWith": asRemoved(
8529
+ "FiberRef.locally has been removed. Use Effect.provideService with ServiceMap.Reference instead."
8530
+ ),
8531
+ "logAnnotations": asRemoved(
8532
+ "Use Effect.annotateLogs instead."
8533
+ ),
8534
+ "loop": asRemoved(
8535
+ "Use Effect.whileLoop or recursion with Effect.suspend instead."
8536
+ ),
8537
+ "mapAccum": asRemoved(
8538
+ "Use Effect.gen with a mutable accumulator instead."
8539
+ ),
8540
+ "mapErrorCause": asRemoved(
8541
+ "Use Effect.sandbox and Effect.mapError instead."
8542
+ ),
8543
+ "mapInputContext": asRemoved(
8544
+ "Use Effect.provide with a layer instead."
8545
+ ),
8546
+ "merge": asRemoved(
8547
+ "Use Effect.match or Effect.exit instead."
8548
+ ),
8549
+ "mergeAll": asRemoved(
8550
+ "Use Effect.forEach with a mutable accumulator instead."
8551
+ ),
8552
+ "metricLabels": asRemoved(
8553
+ "Metric labeling has been reworked in Effect v4."
8554
+ ),
8555
+ "negate": asRemoved(
8556
+ "Use Effect.map with boolean negation instead."
8557
+ ),
8558
+ "none": asRemoved(
8559
+ "Use Effect.filterOrFail or Effect.option instead."
8560
+ ),
8561
+ "once": asRemoved(
8562
+ "Use Effect.cached instead."
8563
+ ),
8564
+ "optionFromOptional": asRemoved(
8565
+ "Use Effect.option instead."
8566
+ ),
8567
+ "orDieWith": asRemoved(
8568
+ "Use Effect.orDie or Effect.mapError combined with Effect.orDie instead."
8569
+ ),
8570
+ "orElse": asRemoved(
8571
+ "Use Effect.catch or Effect.matchEffect instead."
8572
+ ),
8573
+ "orElseFail": asRemoved(
8574
+ "Use Effect.mapError instead."
8575
+ ),
8576
+ "parallelErrors": asRemoved(
8577
+ "Use Effect.all with concurrency options instead."
8578
+ ),
8579
+ "parallelFinalizers": asRemoved(
8580
+ "Finalizer ordering configuration has been removed in Effect v4."
8581
+ ),
8582
+ "patchFiberRefs": asRemoved(
8583
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8584
+ ),
8585
+ "patchRuntimeFlags": asRemoved(
8586
+ "Runtime flags have been removed in Effect v4."
8587
+ ),
8588
+ "raceWith": asRemoved(
8589
+ "Use Effect.race or Effect.raceFirst instead."
8590
+ ),
8591
+ "random": asRemoved(
8592
+ "Use Effect.randomWith instead."
8593
+ ),
8594
+ "randomWith": asRemoved(
8595
+ "Random access has been reworked in Effect v4."
8596
+ ),
8597
+ "reduce": asRemoved(
8598
+ "Use Effect.forEach with a mutable accumulator or Effect.gen instead."
8599
+ ),
8600
+ "reduceEffect": asRemoved(
8601
+ "Use Effect.forEach with a mutable accumulator or Effect.gen instead."
8602
+ ),
8603
+ "reduceRight": asRemoved(
8604
+ "Use Effect.forEach with a mutable accumulator or Effect.gen instead."
8605
+ ),
8606
+ "reduceWhile": asRemoved(
8607
+ "Use Effect.gen with early return instead."
8608
+ ),
8609
+ "repeatN": asRemoved(
8610
+ "Use Effect.repeat with a schedule instead."
8611
+ ),
8612
+ "runRequestBlock": asRemoved(
8613
+ "The request batching API has been reworked in Effect v4."
8614
+ ),
8615
+ "scheduleForked": asRemoved(
8616
+ "Use Effect.schedule combined with Effect.forkChild instead."
8617
+ ),
8618
+ "sequentialFinalizers": asRemoved(
8619
+ "Finalizer ordering configuration has been removed in Effect v4."
8620
+ ),
8621
+ "serviceConstants": asRemoved(
8622
+ "Service helpers have been removed. Use ServiceMap.Service and yield* to access services."
8623
+ ),
8624
+ "serviceFunction": asRemoved(
8625
+ "Service helpers have been removed. Use ServiceMap.Service and yield* to access services."
8626
+ ),
8627
+ "serviceFunctionEffect": asRemoved(
8628
+ "Service helpers have been removed. Use ServiceMap.Service and yield* to access services."
8629
+ ),
8630
+ "serviceFunctions": asRemoved(
8631
+ "Service helpers have been removed. Use ServiceMap.Service and yield* to access services."
8632
+ ),
8633
+ "serviceMembers": asRemoved(
8634
+ "Service helpers have been removed. Use ServiceMap.Service and yield* to access services."
8635
+ ),
8636
+ "setFiberRefs": asRemoved(
8637
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8638
+ ),
8639
+ "step": asRemoved(
8640
+ "The request batching API has been reworked in Effect v4."
8641
+ ),
8642
+ "summarized": asRemoved(
8643
+ "Use Effect.gen to capture before/after state instead."
8644
+ ),
8645
+ "supervised": asRemoved(
8646
+ "Supervision has been reworked in Effect v4."
8647
+ ),
8648
+ "tagMetrics": asRemoved(
8649
+ "Metric labeling has been reworked in Effect v4."
8650
+ ),
8651
+ "tagMetricsScoped": asRemoved(
8652
+ "Metric labeling has been reworked in Effect v4."
8653
+ ),
8654
+ "takeUntil": asRemoved(
8655
+ "Use Array.takeUntil and Effect.forEach instead."
8656
+ ),
8657
+ "takeWhile": asRemoved(
8658
+ "Use Array.takeWhile and Effect.forEach instead."
8659
+ ),
8660
+ "tapBoth": asRemoved(
8661
+ "Use Effect.tap and Effect.tapError instead."
8662
+ ),
8663
+ "timedWith": asRemoved(
8664
+ "Use Effect.timed instead."
8665
+ ),
8666
+ "timeoutFail": asRemoved(
8667
+ "Use Effect.timeout combined with Effect.catchTag for TimeoutException instead."
8668
+ ),
8669
+ "timeoutFailCause": asRemoved(
8670
+ "Use Effect.timeout combined with Effect.sandbox instead."
8671
+ ),
8672
+ "timeoutTo": asRemoved(
8673
+ "Use Effect.timeoutOption and Effect.map instead."
8674
+ ),
8675
+ "tracerWith": asRemoved(
8676
+ "Use Effect.tracer instead."
8677
+ ),
8678
+ "transplant": asRemoved(
8679
+ "Fiber transplanting has been removed in Effect v4."
8680
+ ),
8681
+ "transposeMapOption": asRemoved(
8682
+ "Use Effect.map with Option operations instead."
8683
+ ),
8684
+ "transposeOption": asRemoved(
8685
+ "Use Effect.option instead."
8686
+ ),
8687
+ "tryMap": asRemoved(
8688
+ "Use Effect.map inside Effect.try instead."
8689
+ ),
8690
+ "tryMapPromise": asRemoved(
8691
+ "Use Effect.tryPromise instead."
8692
+ ),
8693
+ "unless": asRemoved(
8694
+ "Use Effect.when with a negated condition instead."
8695
+ ),
8696
+ "unlessEffect": asRemoved(
8697
+ "Use Effect.when with a negated effectful condition instead."
8698
+ ),
8699
+ "unsafeMakeLatch": asRemoved(
8700
+ "Use Effect.makeLatch instead."
8701
+ ),
8702
+ "unsafeMakeSemaphore": asRemoved(
8703
+ "Use Effect.makeSemaphore instead."
8704
+ ),
8705
+ "unsandbox": asRemoved(
8706
+ "Use Effect.catchCause instead."
8707
+ ),
8708
+ "updateFiberRefs": asRemoved(
8709
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8710
+ ),
8711
+ "using": asRemoved(
8712
+ "Use Effect.scoped instead."
8713
+ ),
8714
+ "validateAll": asRemoved(
8715
+ "Use Effect.all with { mode: 'validate' } instead."
8716
+ ),
8717
+ "validateFirst": asRemoved(
8718
+ "Use Effect.all with { mode: 'validate' } instead."
8719
+ ),
8720
+ "validateWith": asRemoved(
8721
+ "Use Effect.all with { mode: 'validate' } instead."
8722
+ ),
8723
+ "whenEffect": asRemoved(
8724
+ "Use Effect.when with an effectful condition via Effect.flatMap instead."
8725
+ ),
8726
+ "whenFiberRef": asRemoved(
8727
+ "FiberRef has been replaced by ServiceMap.Reference in Effect v4."
8728
+ ),
8729
+ "whenLogLevel": asRemoved(
8730
+ "Log level checking has been reworked in Effect v4."
8731
+ ),
8732
+ "whenRef": asRemoved(
8733
+ "Use Ref.get and Effect.when instead."
8734
+ ),
8735
+ "withClock": asRemoved(
8736
+ "Clock configuration has been reworked in Effect v4."
8737
+ ),
8738
+ "withClockScoped": asRemoved(
8739
+ "Clock configuration has been reworked in Effect v4."
8740
+ ),
8741
+ "withConfigProvider": asRemoved(
8742
+ "ConfigProvider configuration has been reworked in Effect v4."
8743
+ ),
8744
+ "withConfigProviderScoped": asRemoved(
8745
+ "ConfigProvider configuration has been reworked in Effect v4."
8746
+ ),
8747
+ "withConsole": asRemoved(
8748
+ "Console configuration has been reworked in Effect v4."
8749
+ ),
8750
+ "withConsoleScoped": asRemoved(
8751
+ "Console configuration has been reworked in Effect v4."
8752
+ ),
8753
+ "withEarlyRelease": asRemoved(
8754
+ "Use Effect.scoped with manual resource management instead."
8755
+ ),
8756
+ "withFiberRuntime": asRenamedAndNeedsOptions(
8757
+ "withFiber",
8758
+ "Note: in v4, only the Fiber is provided (not the full FiberRuntime with status). The callback receives (fiber: Fiber<unknown, unknown>) instead of (fiber: FiberRuntime<A, E>, status: FiberStatus)."
8759
+ ),
8760
+ "withMaxOpsBeforeYield": asRemoved(
8761
+ "Use ServiceMap.Reference for MaxOpsBeforeYield configuration instead."
8762
+ ),
8763
+ "withMetric": asRemoved(
8764
+ "Metric configuration has been reworked in Effect v4."
8765
+ ),
8766
+ "withRandom": asRemoved(
8767
+ "Random configuration has been reworked in Effect v4."
8768
+ ),
8769
+ "withRandomFixed": asRemoved(
8770
+ "Random configuration has been reworked in Effect v4."
8771
+ ),
8772
+ "withRandomScoped": asRemoved(
8773
+ "Random configuration has been reworked in Effect v4."
8774
+ ),
8775
+ "withRequestBatching": asRemoved(
8776
+ "Request batching configuration has been reworked in Effect v4."
8777
+ ),
8778
+ "withRequestCache": asRemoved(
8779
+ "Request caching configuration has been reworked in Effect v4."
8780
+ ),
8781
+ "withRequestCaching": asRemoved(
8782
+ "Request caching configuration has been reworked in Effect v4."
8783
+ ),
8784
+ "withRuntimeFlagsPatch": asRemoved(
8785
+ "Runtime flags have been removed in Effect v4."
8786
+ ),
8787
+ "withRuntimeFlagsPatchScoped": asRemoved(
8788
+ "Runtime flags have been removed in Effect v4."
8789
+ ),
8790
+ "withScheduler": asRemoved(
8791
+ "Use ServiceMap.Reference for Scheduler configuration instead."
8792
+ ),
8793
+ "withSchedulingPriority": asRemoved(
8794
+ "Scheduling priority configuration has been removed in Effect v4."
8795
+ ),
8796
+ "withTracerScoped": asRemoved(
8797
+ "Use Effect.withTracer instead."
8798
+ ),
8799
+ "withUnhandledErrorLogLevel": asRemoved(
8800
+ "Use ServiceMap.Reference for UnhandledLogLevel configuration instead."
8801
+ ),
8802
+ "zipLeft": asRemoved(
8803
+ "Use Effect.tap instead of Effect.zipLeft."
8804
+ ),
8805
+ "zipRight": asRemoved(
8806
+ "Use Effect.andThen instead of Effect.zipRight."
8807
+ )
8808
+ };
8809
+
8810
+ // src/diagnostics/outdatedApi.ts
8811
+ var outdatedApi = createDiagnostic({
8812
+ name: "outdatedApi",
8813
+ code: 48,
8814
+ description: "Detects usage of APIs that have been removed or renamed in Effect v4",
8815
+ severity: "warning",
8816
+ apply: fn("outdatedApi.apply")(function* (sourceFile, report) {
8817
+ const typeParser = yield* service(TypeParser);
8818
+ const ts = yield* service(TypeScriptApi);
8819
+ const typeChecker = yield* service(TypeCheckerApi);
8820
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
8821
+ if (typeParser.supportedEffect() === "v3") return;
8822
+ let hasReported = false;
8823
+ function reportMigration(propertyAccess, propertyName, _migration) {
8824
+ hasReported = true;
8825
+ report({
8826
+ location: propertyAccess.name,
8827
+ messageText: `${propertyName} is an Effect v3 API, but the project is using Effect v4.`,
8828
+ fixes: []
8829
+ });
8830
+ }
8831
+ const checkPropertyAccessMigration = (propertyAccess, checkRightNode, migrationDb) => {
8832
+ if (!ts.isPropertyAccessExpression(propertyAccess)) return;
8833
+ const identifier2 = propertyAccess.name;
8834
+ if (!ts.isIdentifier(identifier2)) return;
8835
+ const identifierName = ts.idText(identifier2);
8836
+ const migration = migrationDb[identifierName];
8837
+ if (!migration) return;
8838
+ if (migration._tag === "Unchanged") return;
8839
+ const targetType = typeCheckerUtils.getTypeAtLocation(propertyAccess.expression);
8840
+ if (!targetType) return;
8841
+ const targetPropertySymbol = typeChecker.getPropertyOfType(targetType, identifierName);
8842
+ if (targetPropertySymbol) return;
8843
+ return pipe(
8844
+ checkRightNode(propertyAccess.expression),
8845
+ map4(() => reportMigration(propertyAccess, identifierName, migration)),
8846
+ ignore
8847
+ );
8848
+ };
8849
+ const nodeToVisit = [];
8850
+ const appendNodeToVisit = (node) => {
8851
+ nodeToVisit.push(node);
8852
+ return void 0;
8853
+ };
8854
+ ts.forEachChild(sourceFile, appendNodeToVisit);
8855
+ while (nodeToVisit.length > 0) {
8856
+ const node = nodeToVisit.shift();
8857
+ ts.forEachChild(node, appendNodeToVisit);
8858
+ const checkEffectMigration = checkPropertyAccessMigration(
8859
+ node,
8860
+ typeParser.importedEffectModule,
8861
+ effectModuleMigrationDb
8862
+ );
8863
+ if (checkEffectMigration) {
8864
+ yield* ignore(checkEffectMigration);
8865
+ }
8866
+ }
8867
+ if (hasReported) {
8868
+ report({
8869
+ location: { pos: 0, end: 0 },
8870
+ messageText: "This project targets Effect v4, but is using Effect v3 APIs. To find the correct API to use, clone and consult the github.com/effect-ts/effect-smol repository for the corresponding v4 replacement.",
8871
+ fixes: []
8872
+ });
8873
+ }
8874
+ })
8875
+ });
8876
+
7764
8877
  // src/refactors/writeTagClassAccessors.ts
7765
8878
  var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, service2, className, atLocation, involvedMembers) {
7766
8879
  const ts = yield* service(TypeScriptApi);
@@ -10200,6 +11313,7 @@ var unsupportedServiceAccessors = createDiagnostic({
10200
11313
 
10201
11314
  // src/diagnostics.ts
10202
11315
  var diagnostics = [
11316
+ outdatedApi,
10203
11317
  anyUnknownInErrorContext,
10204
11318
  instanceOfSchema,
10205
11319
  catchAllToMapError,
@@ -10212,6 +11326,7 @@ var diagnostics = [
10212
11326
  missingEffectServiceDependency,
10213
11327
  missingLayerContext,
10214
11328
  floatingEffect,
11329
+ effectInFailure,
10215
11330
  missingStarInYieldEffectGen,
10216
11331
  unnecessaryEffectGen,
10217
11332
  unnecessaryFailYieldableError,